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


Possibly Related Threads…
Thread Author Replies Views Last Post
  Copying the order of another list with identical values gohanhango 7 1,060 Nov-29-2023, 09:17 PM
Last Post: Pedroski55
  Search Excel File with a list of values huzzug 4 1,147 Nov-03-2023, 05:35 PM
Last Post: huzzug
  Loop through values and compare edroche3rd 6 627 Oct-18-2023, 04:04 PM
Last Post: edroche3rd
  Comparing List values to get indexes Edward_ 7 1,082 Jun-09-2023, 04:57 PM
Last Post: deanhystad
  Loop through json file and reset values [SOLVED] AlphaInc 2 1,960 Apr-06-2023, 11:15 AM
Last Post: AlphaInc
  Adding values with reduce() function from the list of tuples kinimod 10 2,512 Jan-24-2023, 08:22 AM
Last Post: perfringo
  user input values into list of lists tauros73 3 1,023 Dec-29-2022, 05:54 PM
Last Post: deanhystad
  Creating a loop with dynamic variables instead of hardcoded values FugaziRocks 3 1,430 Jul-27-2022, 08:50 PM
Last Post: rob101
  How do loop over curl and 'put' different values in API call? onenessboy 0 1,196 Jun-05-2022, 05:24 AM
Last Post: onenessboy
  Loop through values in dictrionary and find the same as in previous row Paqqno 5 1,839 Mar-27-2022, 07:58 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020