RLMResults.t()

126 views
Skip to first unread message

dieterv77

unread,
Jan 18, 2011, 11:32:34 AM1/18/11
to pystatsmodels
Hi, I had a (hopefully) quick question about what i should expect from
the t() method for an RLMResults object.
I was expecting the return value to match the ratio of the params and
bse attributes, i.e. the ratios of the coefficients and their
standard errors, but i'm not finding this to be the case. Is my
expectation incorrect (a distinct possibility)?

Here's what i'm running:

data = sm.datasets.stackloss.data.load()
data.exog = sm.add_constant(data.exog)

model = sm.RLM(data.endog, data.exog)

result = model.fit(maxiter=250)

print result.params
print result.bse
print result.t()
print result.params/result.bse


Here's the output (with comments added)
result.params: [ 0.82938433 0.92606597 -0.12784672 -41.02649835]
result.bse: [ 0.11100521 0.30293016 0.12864961 9.79189854]
result.t(): [ 12.76825596 5.22418482 -1.69824461 -7.16006021]
result.params/result.bse: [ 7.47158002 3.05702792 -0.9937591
-4.18984104]

Thanks for much for this excellent package, btw.

regards
Dieter

Skipper Seabold

unread,
Jan 18, 2011, 12:07:07 PM1/18/11
to pystat...@googlegroups.com
On Tue, Jan 18, 2011 at 11:32 AM, dieterv77 <diet...@gmail.com> wrote:
> Hi, I had a (hopefully) quick question about what i should expect from
> the t() method for an RLMResults object.
> I was expecting the return value to match the ratio of the params and
> bse attributes, i.e. the ratios of the coefficients and their
> standard errors, but i'm not finding this to be the case.  Is my
> expectation incorrect (a distinct possibility)?
>

I think you might have found a bug (or at least some incomplete code).
I will need to check a reference. The reason is that the bse differ
is that they're taken from the robust covariance matrix; whereas, the
t() method uses the scaled covariance matrix.

> Here's what i'm running:
>
> data = sm.datasets.stackloss.data.load()
> data.exog = sm.add_constant(data.exog)
>
> model = sm.RLM(data.endog, data.exog)
>
> result = model.fit(maxiter=250)
>
> print result.params
> print result.bse
> print result.t()
> print result.params/result.bse
>
>
> Here's the output (with comments added)
> result.params:  [  0.82938433   0.92606597  -0.12784672 -41.02649835]
> result.bse: [ 0.11100521  0.30293016  0.12864961  9.79189854]
> result.t(): [ 12.76825596   5.22418482  -1.69824461  -7.16006021]
> result.params/result.bse: [ 7.47158002  3.05702792 -0.9937591
> -4.18984104]
>

np.sqrt(np.diag(results.bcov_scaled))
array([ 0.11100521, 0.30293016, 0.12864961, 9.79189854])

# bse used for t comes from cov_params
bse = np.sqrt(np.diag(results.cov_params(scale=results.scale)))

results.params/bse
array([ 12.76825596, 5.22418482, -1.69824461, -7.16006021])


> Thanks for much for this excellent package, btw.

Thanks for the feedback.

Skipper

>
> regards
> Dieter
>
>

Reply all
Reply to author
Forward
0 new messages