Source code for policy_modules.premium_parameters

#!/usr/bin/env python
from utility_modules.get_parameters import get_params
import numpy as np


[docs]class PremiumParams(): def __init__(self, policy_dict): prem_gid = policy_dict['prem_ratio'] admin_gid = policy_dict['admin_loading'] prem_equ = policy_dict['prem_equiv'] self.prem_df = get_params(prem_gid) self.admin_df = get_params(admin_gid) self.eq_df = get_params(prem_equ) ### administrative loading, depending on firm size
[docs] def admin_load(self, f_size): # idx stores the row number idx = (self.admin_df.min_firm_size < f_size).sum() - 1 return self.admin_df.loading[idx]
[docs] def prem_ratio(self, premiums): av = premiums[['av_value']].values max_thresh = np.matrix(self.prem_df['max_av']).T ones_mtx = np.ones([self.prem_df.shape[0], av.shape[0]]) max_mtx = np.multiply(max_thresh, ones_mtx).T idx = (av >= max_mtx).sum(axis=1) idx = np.array(idx.T)[0] rtn_df = self.prem_df[['self', 'sp', 'ch', 'fam']].iloc[idx] rtn_df['plan_id'] = premiums['plan_id'].values return rtn_df
### Converting other premiums to the ratio of self premiums ### for the purpose of aggregating all the people?
[docs] def reference_prem(self, premium): my_ratio = self.prem_ratio(premium) # ones_mtx = np.ones([max_av.shape[0], input_av.shape[0]]) # print "ones_mtx:" # print ones_mtx # max_mtx = np.multiply(max_av, ones_mtx) # max_mtx = max_mtx.T # print "max_mtx" # print max_mtx # input_mtx = np.multiply(np.matrix(input_av).T, ones_mtx.T) ##print "input_mtx" #print input_mtx #idx_mtx = (input_mtx >= max_mtx).sum(axis = 1) #print "idx_mtx is" #print idx_mtx #return (np.array(self.eq_df.alpha.values[idx_mtx]).T)[0] return my_ratio