ProbitResults.t_test()

statsmodels.discrete.discrete_model.ProbitResults.t_test

ProbitResults.t_test(r_matrix, cov_p=None, scale=None, use_t=None)

Compute a t-test for a each 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. It is assumed that the linear combination is equal to zero.
  • 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). If q is given, can be either a scalar or a length p row vector.

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.

use_t : bool, optional

If use_t is None, then the default of the model is used. If use_t is True, then the p-values are based on the t distribution. If use_t is False, then the p-values are based on the normal distribution.

Returns:

res : ContrastResults instance

The results for the test are attributes of this results instance. The available results have the same elements as the parameter table in summary().

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

>>> from statsmodels.formula.api import ols
>>> 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)
doc_statsmodels
2017-01-18 16:14:29
Comments
Leave a Comment

Please login to continue.