0

the title already defined my problem so let me start by giving an example:

import statsmodels.formula.api as smf
import numpy as np
import pandas as pd

data = pd.DataFrame( {'x1' : np.arange(1,10) , 'x2' : np.random.normal(scale=2,size=9) , 'x3' : np.random.sample(size=9) , 'y' : np.arange(10,20) } )
result = smf.ols(formula = 'y ~ x_1 x_2 x_3' ,data=data).fit()

Using this example, it doesn't matter if the numbers work out, how do I for instance test if b_1 and b_2 are equal assuming they are the respective partial regression coefficients for x_1 and x_2?

Thank for any help.

crabnebul
  • 124
  • 1
  • 7

1 Answers1

0

You can use the t_test method in the result object for that.

data = pd.DataFrame({'x1' : np.arange(1,10) , 'x2' :np.random.normal(scale=2,size=9) , 'x3' : np.random.sample(size=9) , 'y' : np.arange(11,20)} )
result = smf.ols(formula = 'y ~ x1 + x2 + x3' ,data=data).fit()

After your piece of code, you need to add:

# You need to define the hypothesis to be tested
hypothesis = 'x1 = x2'
t_test = result.t_test(hypothesis)
print(t_test)