Robust Linear Models

Robust Linear Models Link to Notebook GitHub In [1]: from __future__ import print_function import numpy as np import statsmodels.api as sm import matplotlib.pyplot as plt from statsmodels.sandbox.regression.predstd import wls_prediction_std Estimation Load data: In [2]: data = sm.datasets.stackloss.load() data.exog = sm.add_constant(data.exog) Huber's T norm with the (default) median absolute deviation scaling In [3]: huber_t = sm.RLM(data.endog, data.e

Robust Linear Models

Robust Linear Models Robust linear models with support for the M-estimators listed under Norms. See Module Reference for commands and arguments. Examples # Load modules and data import statsmodels.api as sm data = sm.datasets.stackloss.load() data.exog = sm.add_constant(data.exog) # Fit model and print summary rlm_model = sm.RLM(data.endog, data.exog, M=sm.robust.norms.HuberT()) rlm_results = rlm_model.fit() print rlm_results.params Detailed examples can be found here: Robust Linear Models

RLMResults.wald_test()

statsmodels.robust.robust_linear_model.RLMResults.wald_test RLMResults.wald_test(r_matrix, cov_p=None, scale=1.0, invcov=None, use_f=None) Compute a Wald-test for a joint linear hypothesis. Parameters: r_matrix : array-like, str, or tuple array : An r x k array where r is the number of restrictions to test and k is the number of regressors. 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 tup

RLMResults.t_test()

statsmodels.robust.robust_linear_model.RLMResults.t_test RLMResults.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 a

RLMResults.summary2()

statsmodels.robust.robust_linear_model.RLMResults.summary2 RLMResults.summary2(xname=None, yname=None, title=None, alpha=0.05, float_format='%.4f') [source] Experimental summary function for regression results Parameters: xname : List of strings of length equal to the number of parameters Names of the independent variables (optional) yname : string Name of the dependent variable (optional) title : string, optional Title for the top table. If not None, then this replaces the default tit

RLMResults.summary()

statsmodels.robust.robust_linear_model.RLMResults.summary RLMResults.summary(yname=None, xname=None, title=0, alpha=0.05, return_fmt='text') [source] This is for testing the new summary setup

RLMResults.save()

statsmodels.robust.robust_linear_model.RLMResults.save RLMResults.save(fname, remove_data=False) save a pickle of this instance Parameters: fname : string or filehandle fname can be a string to a file path or filename, or a filehandle. remove_data : bool If False (default), then the instance is pickled without changes. If True, then all arrays with length nobs are set to None before pickling. See the remove_data method. In some cases not all arrays will be set to None. Notes If remove_

RLMResults.remove_data()

statsmodels.robust.robust_linear_model.RLMResults.remove_data RLMResults.remove_data() [source] remove data arrays, all nobs arrays from result and model This reduces the size of the instance, so it can be pickled with less memory. Currently tested for use with predict from an unpickled results and model instance. Warning Since data and some intermediate results have been removed calculating new statistics that require them will raise exceptions. The exception will occur the first time an a

RLMResults.predict()

statsmodels.robust.robust_linear_model.RLMResults.predict RLMResults.predict(exog=None, transform=True, *args, **kwargs) Call self.model.predict with self.params as the first argument. Parameters: exog : array-like, optional The values for which you want to predict. transform : bool, optional If the model was fit via a formula, do you want to pass exog through the formula. Default is True. E.g., if you fit a model y ~ log(x1) + log(x2), and transform is True, then you can pass a data str

RLMResults.normalized_cov_params()

statsmodels.robust.robust_linear_model.RLMResults.normalized_cov_params RLMResults.normalized_cov_params()