Hello Colleagues,
I require some help in debugging a Stata code. I know where the error is but I am not sure how to fix it. The error is coming from how I am handling ch_hpi, neg_ch_hpi and int_hpi_ch.
I want to do the following:
I want to forecast loan default.
I have the "CA2016" dataset where the dependent variable is default and the control variables are fico, fico_680, fico_720, fico_760, int_fico680, int_fico720, int_fico760, orig7, orig8, purchase, retail, ch_hpi, neg_ch_hpi, int_hpi_ch, ltv, ltv_dummy, int_ltv, CA, NY, CO, WA, TX, FL, and the intercept.
First, I estimate a logit model using the dependent and control variables.
There are about 1723 observations in this dataset.
I need to save the coefficients from this model to be used later in the session.
In the "sim_ch_hpi_vh" dataset, I have a date variable that goes from Oct 2022 to Sept 2042 and variables Sim1 to Sim100. This dataset has 240 rows and 101 columns.
First, I want to take the first observation from the "CA2016" dataset and forecast default using the saved coefficients estimated earlier. The data points for the corresponding coefficients are already there in the first observation. However, the only variables that will change are ch_hpi, neg_ch_hpi (this is an indicator variable if ch_hpi is negative), and int_hpi_ch (it is the interaction of neg_ch_hpi and ch_hpi). The ch_hpi values will come from the Sim1 to Sim100 variables in the "sim_ch_hpi_vh" dataset.
I want to take the first row from "sim_ch_hpi_vh" and use Sim1 to Sim100 as ch_hpi, and then calculate neg_ch_hpi and int_hpi_ch based on ch_hpi, and forecast default.
I should get 240 rows and 100 columns of default forecasts for the first observation from the CA2016 dataset.
I need to repeat this for 1723 observations in the CA2016 dataset.
However, for each observation in the CA2016 dataset, I only want to keep the 37th, 97th, 157th, 229th, and 240th rows.
In my final dataset, I want to keep the observation ID from the CA2016 dataset, row numbers from "sim_ch_hpi_vh," and the default values corresponding to Sim1 to Sim100. So the final dataset will have 1723*5 rows and 102 columns.
I hope this is not too confusing. I have attached the code. I am facing difficulty in changing the values of ch_hpi, neg_ch_hpi, and int_hpi_ch. The error is "local not found."
Your help is appreciated.
My code is attached.
Thank you.
Sagarika
I require some help in debugging a Stata code. I know where the error is but I am not sure how to fix it. The error is coming from how I am handling ch_hpi, neg_ch_hpi and int_hpi_ch.
I want to do the following:
I want to forecast loan default.
I have the "CA2016" dataset where the dependent variable is default and the control variables are fico, fico_680, fico_720, fico_760, int_fico680, int_fico720, int_fico760, orig7, orig8, purchase, retail, ch_hpi, neg_ch_hpi, int_hpi_ch, ltv, ltv_dummy, int_ltv, CA, NY, CO, WA, TX, FL, and the intercept.
First, I estimate a logit model using the dependent and control variables.
There are about 1723 observations in this dataset.
I need to save the coefficients from this model to be used later in the session.
In the "sim_ch_hpi_vh" dataset, I have a date variable that goes from Oct 2022 to Sept 2042 and variables Sim1 to Sim100. This dataset has 240 rows and 101 columns.
First, I want to take the first observation from the "CA2016" dataset and forecast default using the saved coefficients estimated earlier. The data points for the corresponding coefficients are already there in the first observation. However, the only variables that will change are ch_hpi, neg_ch_hpi (this is an indicator variable if ch_hpi is negative), and int_hpi_ch (it is the interaction of neg_ch_hpi and ch_hpi). The ch_hpi values will come from the Sim1 to Sim100 variables in the "sim_ch_hpi_vh" dataset.
I want to take the first row from "sim_ch_hpi_vh" and use Sim1 to Sim100 as ch_hpi, and then calculate neg_ch_hpi and int_hpi_ch based on ch_hpi, and forecast default.
I should get 240 rows and 100 columns of default forecasts for the first observation from the CA2016 dataset.
I need to repeat this for 1723 observations in the CA2016 dataset.
However, for each observation in the CA2016 dataset, I only want to keep the 37th, 97th, 157th, 229th, and 240th rows.
In my final dataset, I want to keep the observation ID from the CA2016 dataset, row numbers from "sim_ch_hpi_vh," and the default values corresponding to Sim1 to Sim100. So the final dataset will have 1723*5 rows and 102 columns.
I hope this is not too confusing. I have attached the code. I am facing difficulty in changing the values of ch_hpi, neg_ch_hpi, and int_hpi_ch. The error is "local not found."
Your help is appreciated.
My code is attached.
Thank you.
Sagarika
Comment