Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Newbie question: how to generate dataframe and use multiple regression
#1
Hello:
I have some code, which is not finished yet:
from scipy.stats import linregress

x0 = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
y = [2,3,4,5,6,7,8,9,10,11]

def genList1(x, n, offset):
    list1 = []
    if (n + offset) <= len(x):
       list1 = x[offset:(offset + n)]
    return(list1)

x1 = genList1(x0, 10, 5)
x2 = genList1(x0, 10, 4)
x3 = genList1(x0, 10, 3)
x4 = genList1(x0, 10, 2)
x5 = genList1(x0, 10, 1)
I have one original list X0 with 15 items, and another list y with 10 items.
I would like to generate other 5 lists with 10 items each, the way how to generate each list is in function: genList1.
Now, I want to know how I can use the 6 lists to generate a dataframe or whatever is required to do
Multiple Regression using Statsmodels or whatever python packages.
The corresponding R linear model expression is:
fit <- lm(y ~ x1 + x2 + x3 + x4 + x5, data=dataframe1)
And I want to print coefficients for each variable (x1, x2, x3, x4, x5)
How I can do this in python?
Thanks,
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Python & Dataframe basic question georgialtr 0 271 Apr-06-2020, 03:59 PM
Last Post: georgialtr
Question Dividing a single column of dataframe into multiple columns based on char length darpInd 2 290 Mar-14-2020, 09:19 AM
Last Post: scidam
  newbie: loop, modify dataframe cells expat_th 5 369 Mar-03-2020, 09:05 PM
Last Post: jefsummers
  Simple pandas dataframe question popohoma 1 836 Jan-03-2019, 05:00 PM
Last Post: ashlardev
  Newbie question to return only the index of a dataframe zydjohn 0 890 Jan-22-2018, 03:40 PM
Last Post: zydjohn
  Question for dataframe to replace INF value zydjohn 0 3,471 Jan-15-2018, 10:00 PM
Last Post: zydjohn
  very simple dataframe question really_this_dumb 0 799 Jan-02-2018, 11:30 AM
Last Post: really_this_dumb
  Newbie question how to find the coefficient for each variable zydjohn 10 4,687 Dec-14-2017, 05:01 PM
Last Post: j.crater
  Newbie question on how to use pandas.rolling_mean zydjohn 5 9,218 Dec-09-2017, 08:42 PM
Last Post: j.crater
  Newbie question for using map, lambda zydjohn 2 1,339 Dec-09-2017, 07:18 PM
Last Post: zydjohn

Forum Jump:


Users browsing this thread: 1 Guest(s)