2021年3月24日星期三

lm in R vs statsmodels.api OLS in Python

I get completely different results with the same datasets in R and Python. I cannot understand why it happens.

R:

library(RcppCNPy)  d <- npyLoad("/home/vvkovalchuk/bin/src/python/asks1.npy")  datas = npyLoad('/home/vvkovalchuk/bin/src/python/bids2.npy')    m <- lm(d ~ datas)  summary(m)  

Python:

import time  import numpy  import statsmodels.api as sm  from math import log    Y = numpy.load('./asks1.npy', allow_pickle=True)  X = numpy.load('./bids2.npy', allow_pickle=True)    X3 = sm.add_constant(X)  res_ols = sm.OLS(Y, X3).fit()    print(res_ols.params)  

What am I doing wrong?

https://stackoverflow.com/questions/66791621/lm-in-r-vs-statsmodels-api-ols-in-python March 25, 2021 at 09:05AM

没有评论:

发表评论