I am using statsmodels.api for some simple OLS regression... And somehow every time I ran my script it got stuck at model.fit
and I couldn't figure out why.
Here is a snippet of my code:
import statsmodels.api as sm
merged
is a pandas data frame as regressors and memoscore is a pandas data frame of one variable as my dependent variable. The following worked smoothly and instantly:
model = sm.OLS(np.array(memoscore), np.array(sm.add_constant(merged)))
results = model.fit()
Then I took the log of memoscore
, the following still worked instantly:
memoscore_ln = np.log(memoscore)
model = sm.OLS(np.array(memoscore_ln), np.array(sm.add_constant(merged))
But it got stuck here forever:
results = model.fit()
Could anyone kindly suggest reason why and/or how to get around that? Thank you so much in advance!
I exported my data to R and ran the same OLS using memoscore
and logged memoscore
as the dependent variable, it worked like a charm. Still don't know what's wrong with statsmodels
, but at least I learnt R is the go-to software for such easy regression tasks.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.