[SciPy-User] statsmodels - rlm

Skipper Seabold jsseabold at gmail.com
Thu Jul 14 12:50:58 EDT 2011


On Tue, Jul 12, 2011 at 6:27 AM, Jeff Reback <jreback at yahoo.com> wrote:
> Hi,
>
> Is their a way to recover the final Results class in a robust estimation?
>
> see below - I can clearly replicate the WLS regression and get a Results
> class with the correct results;
> is their a reference in the RLMResults class (that points to the
> wls_results) that I am missing?
>
> thanks,
>
> Jeff
>
> # using v2 of statsmodels
> import numpy as np
> import scikits.statsmodels as sm
>
> #delivery time(minutes)
> endog = np.array([16.68, 11.50, 12.03, 14.88, 13.75, 18.11, 8.00, 17.83,
>                   79.24, 21.50, 40.33, 21.00, 13.50, 19.75, 24.00, 29.00,
> 15.35, 19.00,
>                   9.50, 35.10, 17.90, 52.32, 18.75, 19.83, 10.75])
>
> #number of cases, distance (Feet)
> exog = np.array([[7, 3, 3, 4, 6, 7, 2, 7, 30, 5, 16, 10, 4, 6, 9, 10, 6, 7,
> 3, 17, 10, 26, 9, 8, 4],
>                  [560, 220, 340, 80, 150, 330, 110, 210, 1460, 605, 688,
> 215, 255, 462, 448, 776, 200, 132, 36, 770, 140, 810, 450, 635,150]])
> exog = exog.T
> exog = sm.add_constant(exog)
> rlm  = sm.RLM(endog, exog).fit()
> print "RLM params -> %s, r2 -> %s" % (rlm.params,
> getattr(rlm,'rsquared',None))
> wls  = sm.WLS(endog, exog, weights = rlm.weights).fit()
> print "WLS params -> %s, r2 -> %s" % (wls.params, wls.rsquared)
>

For posterity, answered here.

https://groups.google.com/group/pystatsmodels/browse_thread/thread/ab999ff6ab32c5e0

Skipper



More information about the SciPy-User mailing list