1

Not sure where this belongs so asking this in crossvalidated also. I am running the following regression: from patsy import dmatrices import statsmodels.api as sm

y, X = dmatrices('M ~ I(4.8*(Q**0.8)) ', data=DF, return_type='dataframe')
res = sm.OLS(y, X).fit()

Now I need to test the joint hypothesis that intercept=0 and beta=1. I tried doing this:

hyp='Intercept = 0, 4.8*(Q**0.8) = 1'
t=res.f_test(hyp)

but got the following error:

PatsyError: unrecognized token in constraint
    Intercept = 0, 4.8*(Q**0.8) = 1

I also tried

hyp='Intercept = 0, I(4.8*(Q**0.8)) = 1'

but got

PatsyError: unrecognized token in constraint
    Intercept = 0, I(4.8*(Q**0.8)) = 1

what is the correct way to go about this?

dayum
  • 1,073
  • 15
  • 31
  • 1
    I think you need to check what parameter names patsy created for `4.8*(Q**0.8)`, e.g. by looking at the `summary()`, and use that in the constraint. – Josef Feb 03 '17 at 17:41
  • No, that doesn't work. If you want to use formulas in the hypothesis tests, then you need to use the formula interface instead of providing only y and X. With only y and X, there is no information inside OLS about how they were created. The parameter names should be just generic `const, x1, x2, ..` or whatever column names are available in the DataFrame. – Josef Feb 03 '17 at 17:53
  • `hyp = "Intercept=0, I(4.8 * (Q ** 0.8))=1"` works for me. Note the spacing as used in `X.columns` – Josef Feb 03 '17 at 18:12

0 Answers0