Python Forum
Newbie question: how to generate dataframe and use multiple regression
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,
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Creating a Dataframe from Zenodo zip file with multiple CSVs about Spotify man0s 0 1,326 Apr-26-2022, 01:45 PM
Last Post: man0s
  Statsmodels Multiple Regression Syntax Error Burger 2 2,750 Jul-13-2021, 03:04 AM
Last Post: Burger
  Automating to generate multiple arrays Robotguy 1 1,783 Nov-05-2020, 08:14 AM
Last Post: Gribouillis
  Python & Dataframe basic question georgialtr 0 3,834 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 2,419 Mar-14-2020, 09:19 AM
Last Post: scidam
  newbie: loop, modify dataframe cells expat_th 5 3,631 Mar-03-2020, 09:05 PM
Last Post: jefsummers
  Simple pandas dataframe question popohoma 1 3,497 Jan-03-2019, 05:00 PM
Last Post: ashlardev
  Newbie question to return only the index of a dataframe zydjohn 0 2,522 Jan-22-2018, 03:40 PM
Last Post: zydjohn
  Question for dataframe to replace INF value zydjohn 0 5,120 Jan-15-2018, 10:00 PM
Last Post: zydjohn
  very simple dataframe question really_this_dumb 0 2,158 Jan-02-2018, 11:30 AM
Last Post: really_this_dumb

Forum Jump:

User Panel Messages

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