Posts

Showing posts with the label regression

'Series' object is not callable Error / Statsmodels illegal variable name

Image
Clash Royale CLAN TAG #URR8PPP 'Series' object is not callable Error / Statsmodels illegal variable name Update: You can download my dataset here. I am running a simple OLS regression with statsmodels and pandas dataframe as following: import statsmodels.formula.api as sm import pandas as pd df=pd.read_csv("exp.csv") #df is a dataframe that I have containing many variable names such as AAPL, SPY, INF, etc. for column in df: result=sm.ols(formula="SPY"+" ~ "+column, data=df).fit() However, one of the column name in df is INF . I guess maybe INF is a reserved word for pasty, the code gives me the following error: INF INF Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/ap248/.local/easybuild/software/2017/Core/miniconda2/4.3.27/lib/python2.7/site-packages/statsmodels/base/model.py", line 155, in from_formula missing=missing) File "/home/ap248/.local/easybuild/softw...

mgcv_1.8-24: “fREML” or “REML” method of bam() gives wrong explained deviance

mgcv_1.8-24: “fREML” or “REML” method of bam() gives wrong explained deviance Fitting the same model with bam using methods "fREML" and "REML" gave me close results, but the deviance explained is rather different as returned by summary.gam . bam summary.gam With "fREML" the quantity is ~3.5% (not good) while with "REML" it is ~50% (not that bad). How can it be possible? Which one is correct? Unfortunately, I cannot provide a simple reproducible example. ####################################### ## method = "fREML", discrete = TRUE ## ####################################### Family: binomial Link function: logit Formula: ObsOrRand ~ s(Var1, k = 3) + s(RandomVar, bs = "re") Parametric coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) -5.0026 0.2199 -22.75 <2e-16 Approximate significance of smooth terms: edf Ref.df Chi.sq p-value s(Var1) 1.00 1.001 17.54 2.82e-0...