def set_base_liab_summary(self, numOfLoB): if self.stress_testing: self.liab_summary['stress'] = Corp.summary_liab_analytics( self.liability['stress'], numOfLoB) # always generate liab_summary['base'], which is needed in new IR BSCR self.liab_summary['base'] = Corp.summary_liab_analytics( self.liability['base'], numOfLoB)
def run_TP(self, numOfLoB, Proj_Year): if self.stress_testing: if self.actual_estimate == 'Actual': self.liability['stress'] = Corp.run_TP( self.liability['stress'], self.BSCR, self.RM, numOfLoB, Proj_Year) elif self.actual_estimate == 'Estimate': self.liability['stress'] = Corp.run_TP( self.liability['stress'], self.BSCR, self.RM, numOfLoB, Proj_Year, curveType="Treasury", valDate=self.liab_base_date, EBS_Calc_Date=self.eval_date) if not self.stress_testing: if self.actual_estimate == 'Actual': self.liability['base'] = Corp.run_TP(self.liability['base'], self.BSCR, self.RM, numOfLoB, Proj_Year) elif self.actual_estimate == 'Estimate': self.liability['dashboard'] = Corp.run_TP( self.liability['dashboard'], self.BSCR, self.RM, numOfLoB, Proj_Year, curveType="Treasury", valDate=self.liab_base_date, EBS_Calc_Date=self.eval_date)
def run_dashboard_liab_value(self, valDate, EBS_Calc_Date, curveType, numOfLoB, market_factor, liab_spread_beta=0.65, KRD_Term=IAL_App.KRD_Term, irCurve_USD=0, irCurve_GBP=0, gbp_rate=0, Scen=0): if self.stress_testing: if self.actual_estimate == 'Actual': self.liability['stress'] = copy.deepcopy( self.liability['base']) for idx in range(1, numOfLoB + 1, 1): self.liability['stress'][idx].cashflow = self.liability[ 'stress'][idx].cashflow[0] self.liability['stress'][idx].OAS_alts = self.liability[ 'stress'][idx].OAS self.liability['stress'] = Corp.Run_Liab_DashBoard( valDate, EBS_Calc_Date, curveType, numOfLoB, self.liability['stress'], market_factor, liab_spread_beta=liab_spread_beta, KRD_Term=KRD_Term, irCurve_USD=irCurve_USD, irCurve_GBP=irCurve_GBP, gbp_rate=gbp_rate, Scen=Scen) self.liability['stress'][34].PV_BE += UI.ALBA_adj * ( self.actual_estimate == 'Actual' ) # under 'Estimate', ALBA_adj is added in run_TP. elif not self.stress_testing: self.liability['dashboard'] = Corp.Run_Liab_DashBoard( valDate, EBS_Calc_Date, curveType, numOfLoB, self.liability['base'], market_factor, liab_spread_beta=liab_spread_beta, KRD_Term=KRD_Term, irCurve_USD=irCurve_USD, irCurve_GBP=irCurve_GBP, gbp_rate=gbp_rate)
def BSCR_PC_Risk_Forecast_RM( reserve_risk_method, proj_date, val_date_base, nested_proj_dates, liab_val_base, liab_summary_base, curveType, numOfLoB, gbp_rate, base_irCurve_USD=0, base_irCurve_GBP=0, market_factor=[], liab_spread_beta=0.65, KRD_Term=IAL_App.KRD_Term, OpRiskCharge=BSCR_Config.BSCR_Charge['OpRiskCharge'], coc=BSCR_Config.RM_Cost_of_Capital): Reserve_Risk_current = {} Reserve_Risk_new = {} Reserve_CoC_current = {} Reserve_CoC_new = {} for t, each_date in enumerate(nested_proj_dates): Nested_Proj_LOB = Corp.Run_Liab_DashBoard(val_date_base, each_date, curveType, numOfLoB, liab_val_base, market_factor, liab_spread_beta, KRD_Term, base_irCurve_USD, base_irCurve_GBP, gbp_rate) PC_Risk_calc = BSCR_PC_Reserve_Risk_Charge(Nested_Proj_LOB, method=reserve_risk_method) Reserve_Risk_current.update({each_date: PC_Risk_calc['BSCR_Current']}) Reserve_Risk_new.update({each_date: PC_Risk_calc['BSCR_New']}) if t == 0: Reserve_CoC_current.update({each_date: 0}) Reserve_CoC_new.update({each_date: 0}) else: prev_date = nested_proj_dates[t - 1] Reserve_CoC_current.update({ each_date: Reserve_Risk_current[prev_date] * (1 + OpRiskCharge) * coc }) Reserve_CoC_new.update({ each_date: Reserve_Risk_new[prev_date] * (1 + OpRiskCharge) * coc }) BSCR_PC_Risk_Forecast_RM = { 'BSCR_Current': Reserve_Risk_current, 'BSCR_New': Reserve_Risk_new, 'PC_CoC_Current': Reserve_CoC_current, 'PC_CoC_New': Reserve_CoC_new } return BSCR_PC_Risk_Forecast_RM
def run_BSCR_dashboard(self, Regime): if self.stress_testing: self.BSCR_Dashboard = Corp.run_BSCR_dashboard( self.BSCR_Dashboard, self.BSCR, self.EBS, self.liab_summary['stress'], self.liab_summary['stress'], self.actual_estimate, Regime) elif not self.stress_testing: if self.actual_estimate == 'Estimate': self.BSCR_Dashboard = Corp.run_BSCR_dashboard( self.BSCR_Dashboard, self.BSCR, self.EBS, self.liab_summary['base'], self.liab_summary['dashboard'], self.actual_estimate, Regime) elif self.actual_estimate == 'Actual': ### Vincent 07/18/2019 - Step 2 self.BSCR_Dashboard = Corp.run_BSCR_dashboard( self.BSCR_Dashboard, self.BSCR, self.EBS, self.liab_summary['base'], self.liab_summary['base'], self.actual_estimate, Regime)
def run_projection_liab_value(self, valDate, EBS_Calc_Date, curveType, numOfLoB, market_factor, liab_spread_beta, KRD_Term, irCurve_USD, irCurve_GBP, gbp_rate, eval_date): self.liability[EBS_Calc_Date] = Corp.Run_Liab_DashBoard( valDate, EBS_Calc_Date, curveType, numOfLoB, self.liability['base'], market_factor, liab_spread_beta, KRD_Term, irCurve_USD, irCurve_GBP, gbp_rate, eval_date)
def run_RiskMargin(self, valDate, Proj_Year, Regime, BMA_curve_dir, Scen): self.RM = Corp.run_RM(self.BSCR, valDate, Proj_Year, Regime, BMA_curve_dir, self.eval_date, Scen=Scen)
def set_base_liab_value(self, base_irCurve_USD, base_irCurve_GBP): self._liab_val_base = Corp.Set_Liab_Base( valDate=self._val_date, curveType=self._input_liab_val_base['curve_type'], curr_GBP=self._input_liab_val_base['base_GBP'], numOfLoB=self._input_liab_val_base['numOfLoB'], liabAnalytics=self._liab_val_base, rating=self._input_liab_val_base['liab_benchmark'], irCurve_USD=base_irCurve_USD, irCurve_GBP=base_irCurve_GBP)
def run_dashboard_stress_liab_value(self, valDate, EBS_Calc_Date, curveType, numOfLoB, Scen_market_factor, stress_scen, M_Stress_Scen, liab_spread_beta=0.65): self.liability[stress_scen] = Corp.Run_Stress_Liab_DashBoard( valDate, EBS_Calc_Date, curveType, numOfLoB, self.liability['base'], Scen_market_factor, stress_scen, M_Stress_Scen, liab_spread_beta)
def set_base_projection(self): self._proj_cash_flows = Corp.get_liab_cashflow( actual_estimate=self._actual_estimate, valDate=self._val_date, CF_Database=self._input_proj_cash_flows['CF_Database'], CF_TableName=self._input_proj_cash_flows['CF_TableName'], Step1_Database=self._input_proj_cash_flows['Step1_Database'], PVBE_TableName=self._input_proj_cash_flows['PVBE_TableName'], bindingScen=self._input_proj_cash_flows['projScen'], numOfLoB=self._input_proj_cash_flows['numOfLoB'], Proj_Year=self._input_proj_cash_flows['Proj_Year'], work_dir=self._input_proj_cash_flows['work_dir'], freq=self._input_proj_cash_flows['cash_flow_freq'])
def run_EBS(self, Scen, EBS_asset_Input, AssetAdjustment, market_factor=[]): ### Vincent 07/17/2019 - Step 2 EBS if self.stress_testing == 'Step_3': self.EBS = Corp.run_EBS(self.liab_base_date, self.eval_date, self.EBS, Scen, self.liab_summary['base'], EBS_asset_Input, AssetAdjustment, self.SFS, market_factor) elif self.stress_testing: if self.actual_estimate == 'Estimate': self.EBS = Corp.run_EBS(self.liab_base_date, self.eval_date, self.EBS, Scen, self.liab_summary['stress'], self.asset_holding, AssetAdjustment, self.SFS, market_factor) elif self.actual_estimate == 'Actual': self.EBS = Corp.run_EBS(self.liab_base_date, self.eval_date, self.EBS, Scen, self.liab_summary['stress'], EBS_asset_Input, AssetAdjustment, self.SFS, market_factor) elif not self.stress_testing: if self.actual_estimate == 'Estimate': self.EBS = Corp.run_EBS(self.liab_base_date, self.eval_date, self.EBS, Scen, self.liab_summary['dashboard'], self.asset_holding, AssetAdjustment, self.SFS, market_factor) elif self.actual_estimate == 'Actual': self.EBS = Corp.run_EBS(self.liab_base_date, self.eval_date, self.EBS, Scen, self.liab_summary['base'], EBS_asset_Input, AssetAdjustment, self.SFS, market_factor) self.Run_Iteration += 1
def run_PVBE(self, valDate, numOfLoB, Proj_Year, bindingScen, BMA_curve_dir, Step1_Database, Disc_rate_TableName, base_GBP, Stress_testing, base_scen=0): self.liability['base'] = Corp.run_EBS_PVBE( self.liability['base'], valDate, numOfLoB, Proj_Year, bindingScen, BMA_curve_dir, Step1_Database, Disc_rate_TableName, base_GBP, Stress_testing, base_scen)
def set_base_cash_flow(self, valDate, CF_Database, CF_TableName, Step1_Database, PVBE_TableName, bindingScen, numOfLoB, Proj_Year, work_dir, freq, Scen): ### Vincent 07/02/2019 self.liability['base'] = Corp.get_liab_cashflow(self.actual_estimate, valDate, CF_Database, CF_TableName, Step1_Database, PVBE_TableName, bindingScen, numOfLoB, Proj_Year, work_dir, freq, Scen=Scen)
def set_base_liab_value(self, valDate, curveType, curr_GBP, numOfLoB, rating="BBB", irCurve_USD=0, irCurve_GBP=0): self.liability['base'] = Corp.Set_Liab_Base(valDate, curveType, curr_GBP, numOfLoB, self.liability['base'], rating, irCurve_USD=irCurve_USD, irCurve_GBP=irCurve_GBP)
def set_liab_GAAP_base(self): Corp.Set_Liab_GAAP_Base(self._val_date, self._run_control.GAAP_Reserve, self._liab_val_base)
print('End Projection') print('Total time: %.2fs' % (time.time() - startT)) #%% #test_results['test'] = cfo_work finProj = cfo_work.fin_proj[1]['Forecast'] #%%Output results #Kyle: this will take very long time to run write_results = False if write_results: Corp.exportBase(cfo_work, 'EBS_IS_test.xlsx', file_dir, 'EBS_IS', lobs=['Agg', 'GI', 'LT'], output_all_LOBs=1, output_type='xlsx') Corp.exportBase(cfo_work, 'EBS_test.xlsx', file_dir, 'EBS', lobs=['Agg', 'GI', 'LT'], output_all_LOBs=1, output_type='xlsx') Corp.exportBase(cfo_work, 'BSCR_test.xlsx', file_dir, 'BSCR_Dashboard', lobs=['Agg', 'GI', 'LT'],
def update_runControl(run_control): ''' One Run_Control file for each valuation period Always has a function update_runControl ''' ### Hard-coded inputs from I_Control run_control.time0_LTIC = 97633492 run_control.surplus_life_0 = 1498468068.62392 run_control.surplus_PC_0 = 1541220172.25324 run_control.I_SFSLiqSurplus = 1809687680.14178 run_control.GAAP_Reserve_method = 'Roll-forward' #### 'Product_Level" or 'Roll-forward' ### Update assumptions as needed ##### # Load ModCo Asset Projection BSCR_mapping = run_control.modco_BSCR_mapping BSCR_charge = BSCR_Config.BSCR_Asset_Risk_Charge_v1 run_control.asset_proj_modco = Corp.get_asset_category_proj( run_control._val_date, 'alm', freq=run_control._freq) run_control.asset_proj_modco['MV_Dur'] = run_control.asset_proj_modco[ 'MV'] * run_control.asset_proj_modco['Dur'] run_control.asset_proj_modco[ 'FI_Alts'] = run_control.asset_proj_modco.apply( lambda x: 'Alts' if x['asset_class'] == 'Alts' else 'FI', axis=1) run_control.asset_proj_modco['risk_charge_factor'] \ = run_control.asset_proj_modco.apply(lambda \ x: BSCR_calc.proj_BSCR_asset_risk_charge(BSCR_mapping[x['asset_class']], BMA_asset_risk_charge = BSCR_charge), axis=1) run_control.asset_proj_modco[ 'asset_risk_charge'] = run_control.asset_proj_modco[ 'MV'] * run_control.asset_proj_modco['risk_charge_factor'] run_control.asset_proj_modco_agg = run_control.asset_proj_modco.groupby( ['val_date', 'rowNo', 'proj_time', 'FI_Alts']).sum().reset_index() run_control.asset_proj_modco_agg['Dur'] = run_control.asset_proj_modco_agg[ 'MV_Dur'] / run_control.asset_proj_modco_agg['MV'] run_control.asset_proj_modco_agg[ 'risk_charge_factor'] = run_control.asset_proj_modco_agg[ 'asset_risk_charge'] / run_control.asset_proj_modco_agg['MV'] run_control.asset_proj_modco_agg.fillna(0, inplace=True) # Dividend Schedule run_control.proj_schedule[1]['dividend_schedule'] = 'Y' run_control.proj_schedule[1]['dividend_schedule_amt'] = 500000000 run_control.proj_schedule[2]['dividend_schedule'] = 'Y' run_control.proj_schedule[2]['dividend_schedule_amt'] = 1000000000 run_control.proj_schedule[3]['dividend_schedule'] = 'Y' run_control.proj_schedule[3]['dividend_schedule_amt'] = 1000000000 # LOC SFS Limit SFS_limit = [ 0.25, 0.248285375, 0.252029898, 0.285955276, 0.38330347, 0.441096663, 0.460419183, 0.470052356, 0.462474131, 0.448079715, 0.42905067, 0.401161493, 0.374517694, 0.354974144, 0.312988995, 0.298355834, 0.301492895, 0.294050736, 0.284305953, 0.274386361, 0.264800284, 0.257449286, 0.253203818, 0.248658944, 0.240894683, 0.235788524, 0.224783331, 0.218340687, 0.214482419, 0.209553337, 0.208785641, 0.211190424, 0.210920573, 0.216687659, 0.222172075, 0.227580018, 0.232088173, 0.236832925, 0.241751243, 0.245726161, 0.248599255, 0.248058163, 0.246790226, 0.24740993, 0.247595613, 0.247582842, 0.244536254, 0.254065247, 0.246678196, 0.242226328, 0.25, 0.242866482, 0.244004135, 0.301949013, 0.244575476, 0.244081956, 0.243021021, 0.250817216, 0.252697673, 0.200005319, 0.200005319, 0.200005319, 0.200005319, 0.200005319, 0.200005319, 0.200005319, 0.200005319, 0.200005319, 0.200005319, 0.200005319, 0.200005319, 0.200005319, 0.200005319, 0.200005319, 0.200006653, 0.200011781, 0.2, 0.2, 0.2, 0.2 ] for i in range(min(len(run_control._dates), len(SFS_limit))): run_control.proj_schedule[i]['LOC_SFS_Limit'] = SFS_limit[i] # Initial and Ultimate Spread run_control.initial_spread = { 'Term': [1, 2, 3, 5, 7, 10, 20, 30], 'AAA': [0.0016, 0.0028, 0.0035, 0.0037, 0.0042, 0.0054, 0.0069, 0.0084], 'AA': [0.0019, 0.0034, 0.0042, 0.0048, 0.0055, 0.007, 0.0085, 0.0099], 'A': [0.0023, 0.0042, 0.0052, 0.0062, 0.0095, 0.0109, 0.0105, 0.0127], 'BBB': [0.0044, 0.0082, 0.0092, 0.0114, 0.0156, 0.0162, 0.0161, 0.0183], 'BB': [0.012, 0.0162, 0.0193, 0.0234, 0.0267, 0.0306, 0.0337, 0.0368], 'B': [0.0183, 0.0237, 0.0277, 0.0331, 0.0373, 0.0421, 0.046, 0.0499], 'CCC': [0.0546, 0.0579, 0.0602, 0.0631, 0.0655, 0.0684, 0.0705, 0.0726] } run_control.ultimate_spread = { 'Term': [1, 2, 3, 5, 7, 10, 20, 30], 'AAA': [0.0049, 0.0053, 0.0058, 0.0065, 0.0066, 0.0062, 0.0065, 0.008], 'AA': [0.0053, 0.0059, 0.0066, 0.0076, 0.0081, 0.0081, 0.0091, 0.0107], 'A': [0.0073, 0.0081, 0.009, 0.0106, 0.0114, 0.0117, 0.0134, 0.0154], 'BBB': [0.0123, 0.0136, 0.0149, 0.0173, 0.0187, 0.0196, 0.0219, 0.0238], 'BB': [0.0295, 0.0311, 0.0328, 0.0357, 0.0375, 0.0386, 0.0407, 0.0421], 'B': [0.0492, 0.0569, 0.059, 0.0626, 0.0647, 0.0661, 0.068, 0.0681], 'CCC': [0.1221, 0.1255, 0.1269, 0.1288, 0.1287, 0.1263, 0.1196, 0.1129] }
# irCurve_USD_eval = IAL_App.load_BMA_Std_Curves(valDate, "USD", EBS_Calc_Date) irCurve_USD_eval = IAL_App.createAkitZeroCurve( EBS_Calc_Date, curveType, "USD") irCurve_GBP_eval = IAL_App.load_BMA_Std_Curves( valDate, "GBP", EBS_Calc_Date) # Calculate PVBE projection for t, each_date in enumerate(nested_proj_dates): work_EBS_DB.run_projection_liab_value( valDate, each_date, curveType, numOfLoB, market_factor_c, liab_spread_beta, IAL_App.KRD_Term, irCurve_USD_eval, irCurve_GBP_eval, base_GBP, EBS_Calc_Date) Corp.projection_summary( work_EBS_DB.liability, nested_proj_dates ) # Load EBS_PVBE projection (PVBE_net) into work_EBS_DB.liability['dashboard'] # D_Est = work_EBS_DB.liability['dashboard'] # Calculate BSCR @ reval_date work_EBS_DB.run_estimate_BSCR(numOfLoB, Proj_Year, Regime, PC_method, concentration_Dir, AssetRiskCharge) # D1_Est = work_EBS_DB.BSCR # Calculate RM @ reval_date work_EBS_DB.run_RiskMargin(valDate, Proj_Year, Regime, BMA_curve_dir, Scen) # D2_Est = work_EBS_DB.RM # Calculate TP @ reval_date
def set_sfs(self, SFS_File): self.SFS = Corp.set_SFS_BS(self.SFS, SFS_File)
def export_LiabAnalytics(work_liab_analytics, outFileName, work_dir, valDate, EBS_Calc_Date, csv_file): Corp.exportLobAnalytics(work_liab_analytics, outFileName, work_dir, valDate, EBS_Calc_Date, csv_file)
def run_liab_dashboard_GAAP_disc(self, t, current_date): Corp.Run_Liab_DashBoard_GAAP_Disc(t, current_date, self.liability['dashboard'], self.liability['base'])
def set_dashboard_liab_summary(self, numOfLoB): self.liab_summary['dashboard'] = Corp.summary_liab_analytics( self.liability['dashboard'], numOfLoB)
def set_base_liab_summary(self): self._liab_summary_base = Corp.summary_liab_analytics( self._liab_val_base, self._input_liab_val_base['numOfLoB'])
def set_base_BSCR(self, Step1_Database, BSCRRisk_agg_TableName, BSCRRisk_LR_TableName, BSCRRisk_PC_TableName, Regime): self.BSCR_Base = Corp.Set_BSCR_Base(self.BSCR_Base, Step1_Database, BSCRRisk_agg_TableName, BSCRRisk_LR_TableName, BSCRRisk_PC_TableName, Regime)
def BSCR_LT_Ins_Risk_Forecast_RM( proj_date, val_date_base, nested_proj_dates, liab_val_base, liab_summary_base, curveType, numOfLoB, gbp_rate, base_irCurve_USD=0, base_irCurve_GBP=0, market_factor=[], liab_spread_beta=0.65, KRD_Term=IAL_App.KRD_Term, OpRiskCharge=BSCR_Config.BSCR_Charge['OpRiskCharge'], coc=BSCR_Config.RM_Cost_of_Capital): LT_Ins_Risk_current = {} LT_Ins_Risk_new = {} LT_Ins_Risk_CoC_current = {} LT_Ins_Risk_CoC_new = {} Start_BSCR = {'LT_Longevity_Risk': {}} for t, each_date in enumerate(nested_proj_dates): Nested_Proj_LOB = Corp.Run_Liab_DashBoard(val_date_base, each_date, curveType, numOfLoB, liab_val_base, market_factor, liab_spread_beta, KRD_Term, base_irCurve_USD, base_irCurve_GBP, gbp_rate) each_BSCR = Corp_Class.BSCR_Analytics("Agg") # PC_Risk_calc = BSCR_PC_Reserve_Risk_Charge(Nested_Proj_LOB, method = reserve_risk_method) ## LT Mortality Risk LT_Mort_calc = BSCR_Mortality_Risk_Charge(Nested_Proj_LOB, t) LT_Longevity_calc = BSCR_Longevity_Risk_Charge( Nested_Proj_LOB, t, nested_proj_dates[0], each_date, Start_BSCR['LT_Longevity_Risk']) if t == 0: Start_BSCR['LT_Longevity_Risk'] = LT_Longevity_calc LT_Morbidity_calc = BSCR_Morbidity_Risk_Charge(Nested_Proj_LOB, t) LT_Other_Ins_calc = BSCR_Other_Ins_Risk_Charge(Nested_Proj_LOB) LT_Stop_Loss_calc = BSCR_Stoploss_Risk_Charge(Nested_Proj_LOB) LT_Riders_calc = BSCR_Riders_Risk_Charge(Nested_Proj_LOB) LT_VA_calc = BSCR_VA_Risk_Charge(Nested_Proj_LOB) each_BSCR.Mortality_Risk = LT_Mort_calc['Total']['Mort_Risk'] each_BSCR.StopLoss_Risk = LT_Stop_Loss_calc['Total']['StopLoss_Risk'] each_BSCR.Riders_Risk = LT_Riders_calc['Total']['Riders_Risk'] each_BSCR.Morbidity_Risk = LT_Morbidity_calc['Total']['Morbidity_Risk'] each_BSCR.Longevity_Risk = LT_Longevity_calc['Total']['Longevity_Risk'] each_BSCR.VA_Guarantee_Risk = LT_VA_calc['Total']['VA_Risk'] each_BSCR.OtherInsurance_Risk = LT_Other_Ins_calc['Total'][ 'Other_Ins_Risk'] LT_Agg_calc = BSCR_LT_Ins_Risk_Aggregate(each_BSCR) LT_Ins_Risk_current.update({each_date: LT_Agg_calc['BSCR_Current']}) LT_Ins_Risk_new.update({each_date: LT_Agg_calc['BSCR_New']}) if t == 0: LT_Ins_Risk_CoC_current.update({each_date: 0}) LT_Ins_Risk_CoC_new.update({each_date: 0}) else: prev_date = nested_proj_dates[t - 1] LT_Ins_Risk_CoC_current.update({ each_date: LT_Ins_Risk_current[prev_date] * (1 + OpRiskCharge) * coc }) LT_Ins_Risk_CoC_new.update({ each_date: LT_Ins_Risk_new[prev_date] * (1 + OpRiskCharge) * coc }) BSCR_LT_Risk_Forecast_RM = { 'BSCR_Current': LT_Ins_Risk_current, 'BSCR_New': LT_Ins_Risk_new, 'LT_CoC_Current': LT_Ins_Risk_CoC_current, 'LT_CoC_New': LT_Ins_Risk_CoC_new } return BSCR_LT_Risk_Forecast_RM