Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Generating list of rsquared_adj regression values for variating i with loop
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)
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?
Have you tried indenting all of that, and adding for i in range(1, 1001): to the top?
Gribouillis likes this post

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  access dictionary with keys from another and write values to list redminote4dd 6 226 Jun-03-2020, 05:20 PM
Last Post: DeaD_EyE
  Grabbing comma separed values from SQLite and putting them in a list PythonNPC 8 366 Apr-10-2020, 02:39 PM
Last Post: buran
  Randomly assign values in List 1 to a value in List 2 Seneca260 7 862 Dec-16-2019, 12:57 PM
Last Post: BamBi25
  How do I name a list while generating numbers on the fly? Pleiades 6 442 Dec-03-2019, 05:47 PM
Last Post: jefsummers
  How do I map a list of values to specified colors? larkypython 4 435 Nov-05-2019, 09:22 AM
Last Post: larkypython
  For loop prints strane values? colt 2 374 Sep-22-2019, 02:01 AM
Last Post: ichabod801
  Get all values of for loop with an index BollerwagenIng 2 505 Aug-09-2019, 07:58 AM
Last Post: BollerwagenIng
  Why does this list of lists end up with the same values alehak 2 594 Jul-18-2019, 12:34 PM
Last Post: perfringo
  How to create a list with all values being zero 357mag 4 492 Jul-14-2019, 03:43 PM
Last Post: ThomasL
  Remove \n from list of values within a pandas columns klllmmm 2 2,461 Jun-24-2019, 05:16 AM
Last Post: klllmmm

Forum Jump:

Users browsing this thread: 1 Guest(s)