Generating list of rsquared_adj regression values for variating i with loop

Alexander Hempfing alexander.hempfing at googlemail.com
Wed Apr 18 13:19:35 EDT 2018


Dear all, 

I am wondering if someone could please help me with an issue I am currently trying to solve:

I have a "static" code which looks as follows:

tsd_res_fra_08 =res_fra_08['D_Cummulative'][100]
tsd_res_fra_09 =res_fra_09['D_Cummulative'][100]
tsd_res_fra_10 =res_fra_10['D_Cummulative'][100]
tsd_res_fra_11 =res_fra_11['D_Cummulative'][100]
tsd_res_fra_12 =res_fra_12['D_Cummulative'][100]
tsd_res_fra_13 =res_fra_13['D_Cummulative'][100]
tsd_res_fra_14 =res_fra_14['D_Cummulative'][100]
tsd_res_fra_15 =res_fra_15['D_Cummulative'][100]
reg_list_fra = list([tsd_res_fra_08,tsd_res_fra_09,tsd_res_fra_10,tsd_res_fra_11,tsd_res_fra_12,tsd_res_fra_13,tsd_res_fra_14,tsd_res_fra_15])

fra_gdp = fra_gdpseries.tolist()

import statsmodels.api as sm
X = reg_list_fra
y = fra_gdp 
X = sm.add_constant(X)
model = sm.OLS(y, X).fit()
predictions = model.predict(X)
model.rsquared_adj

Now I would like to generate a "dynamic" code by replacing 100 in the top eight rows to i and let it run from 1 to 1000, thereby running the regression below for every i and save its rsquared_adjvalue in a new list, which contains the rsquared_adj values for i=1, i=2,... i=1000. y stays "static" the whole time.

Can someone please help me here?



More information about the Python-list mailing list