Logo

statsmodels.discrete.discrete_model.MultinomialResults.t_test

MultinomialResults.t_test(r_matrix, q_matrix=None, cov_p=None, scale=None)

Compute a t-test for a joint linear hypothesis of the form Rb = q

Parameters:

r_matrix : array-like, str, tuple

  • array : If an array is given, a p x k 2d array or length k 1d array specifying the linear restrictions.
  • str : The full hypotheses to test can be given as a string. See the examples.
  • tuple : A tuple of arrays in the form (R, q), since q_matrix is deprecated.

q_matrix : array-like or scalar, optional

This is deprecated. See r_matrix and the examples for more information on new usage. Can be either a scalar or a length p row vector. If omitted and r_matrix is an array, q_matrix is assumed to be a conformable array of zeros.

cov_p : array-like, optional

An alternative estimate for the parameter covariance matrix. If None is given, self.normalized_cov_params is used.

scale : float, optional

An optional scale to use. Default is the scale specified by the model fit.

See also

tvalues
individual t statistics
f_test
for F tests

patsy.DesignInfo.linear_constraint

Examples

>>> import numpy as np
>>> import statsmodels.api as sm
>>> data = sm.datasets.longley.load()
>>> data.exog = sm.add_constant(data.exog)
>>> results = sm.OLS(data.endog, data.exog).fit()
>>> r = np.zeros_like(results.params)
>>> r[5:] = [1,-1]
>>> print r
[ 0.  0.  0.  0.  0.  1. -1.]

r tests that the coefficients on the 5th and 6th independent variable are the same.

>>>T_Test = results.t_test(r) >>>print T_test <T contrast: effect=-1829.2025687192481, sd=455.39079425193762, t=-4.0167754636411717, p=0.0015163772380899498, df_denom=9> >>> T_test.effect -1829.2025687192481 >>> T_test.sd 455.39079425193762 >>> T_test.tvalue -4.0167754636411717 >>> T_test.pvalue 0.0015163772380899498

Alternatively, you can specify the hypothesis tests using a string

>>> dta = sm.datasets.longley.load_pandas().data
>>> formula = 'TOTEMP ~ GNPDEFL + GNP + UNEMP + ARMED + POP + YEAR'
>>> results = ols(formula, dta).fit()
>>> hypotheses = 'GNPDEFL = GNP, UNEMP = 2, YEAR/1829 = 1'
>>> t_test = results.t_test(hypotheses)
>>> print t_test

Previous topic

statsmodels.discrete.discrete_model.MultinomialResults.summary2

Next topic

statsmodels.discrete.discrete_model.MultinomialResults.tvalues

This Page