class statsmodels.regression.linear_model.OLS(endog, exog=None, missing='none', hasconst=None, **kwargs)
[source]
A simple ordinary least squares model.
Parameters: |
|
---|
weights
scalar – Has an attribute weights = array(1.0) due to inheritance from WLS.
See also
>>> import numpy as np >>> >>> import statsmodels.api as sm >>> >>> Y = [1,3,4,5,2,3,4] >>> X = range(1,8) >>> X = sm.add_constant(X) >>> >>> model = sm.OLS(Y,X) >>> results = model.fit() >>> results.params array([ 2.14285714, 0.25 ]) >>> results.tvalues array([ 1.87867287, 0.98019606]) >>> print(results.t_test([1, 0])) <T test: effect=array([ 2.14285714]), sd=array([[ 1.14062282]]), t=array([[ 1.87867287]]), p=array([[ 0.05953974]]), df_denom=5> >>> print(results.f_test(np.identity(2))) <F test: F=array([[ 19.46078431]]), p=[[ 0.00437251]], df_denom=5, df_num=2>
No constant is added by the model unless you are using formulas.
fit ([method, cov_type, cov_kwds, use_t]) | Full fit of the model. |
fit_regularized ([method, alpha, L1_wt, …]) | Return a regularized fit to a linear regression model. |
from_formula (formula, data[, subset, drop_cols]) | Create a Model from a formula and dataframe. |
get_distribution (params, scale[, exog, …]) | Returns a random number generator for the predictive distribution. |
hessian (params[, scale]) | Evaluate the Hessian function at a given point. |
hessian_factor (params[, scale, observed]) | Weights for calculating Hessian |
information (params) | Fisher information matrix of model |
initialize () | Initialize (possibly re-initialize) a Model instance. |
loglike (params[, scale]) | The likelihood function for the OLS model. |
predict (params[, exog]) | Return linear predicted values from a design matrix. |
score (params[, scale]) | Evaluate the score function at a given point. |
whiten (Y) | OLS model whitener does nothing: returns Y. |
df_model | The model degree of freedom, defined as the rank of the regressor matrix minus 1 if a constant is included. |
df_resid | The residual degree of freedom, defined as the number of observations minus the rank of the regressor matrix. |
endog_names | Names of endogenous variables |
exog_names | Names of exogenous variables |
© 2009–2012 Statsmodels Developers
© 2006–2008 Scipy Developers
© 2006 Jonathan E. Taylor
Licensed under the 3-clause BSD License.
http://www.statsmodels.org/stable/generated/statsmodels.regression.linear_model.OLS.html