I\'m not sure why I\'m getting slightly different results for a simple OLS, depending on whether I go through panda\'s experimental rpy interface to do the regression in
Looks like Python does not add an intercept by default to your expression, whereas R does when you use the formula interface..
This means you did fit two different models. Try
lm( y ~ x - 1, data)
in R to exclude the intercept, or in your case and with somewhat more standard notation
lm(num_rx ~ ridageyr - 1, data=demoq)
Note that you can still use ols
from statsmodels.formula.api
:
from statsmodels.formula.api import ols
results = ols('num_rx ~ ridageyr', demoq).fit()
results.summary()
I think it uses patsy
in the backend to translate the formula expression, and intercept is added automatically.