Generating list of rsquared_adj regression values for variating i with loop - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Generating list of rsquared_adj regression values for variating i with loop (/thread-9609.html) |
Generating list of rsquared_adj regression values for variating i with loop - hpg - Apr-18-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_adjNow 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? RE: Generating list of rsquared_adj regression values for variating i with loop - nilamo - Apr-18-2018 Have you tried indenting all of that, and adding for i in range(1, 1001): to the top?
|