[R] split and rlm

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Oct 11 16:54:18 CEST 2004


On Mon, 11 Oct 2004, Stuart Luppescu wrote:

> Hello, I'm trying to do a little rlm of some data that looks like this:
> 
> UNIT    COHORT     perdo     adjodds
>  1010      96      0.39890    1.06894
>  1010      97      0.48113    1.57500
>  1010      98      0.36328    1.21498
>  1010      99      0.44391    1.38608
> 
> It works fine like this: rlm(perdo ~ COHORT, psi=psisquare)
> But the problem is that I have about 100 UNITs, and I want to do a
> separate rlm for each one. I tried to use split and lapply but it didn't
> work at all. Is this possible?
> 
> In addition, I'm trying to extract the t statistic for the slope
> coefficient and the degrees of freedom so I can put them into dt() to
> get the p-value. I can get the t from coef(summary(u))[2,3] (where u is
> my rlm object), but u$df.residual gives me NULL. Also, the help for
> summary.lm says it returns coefficients, which contains a 4x4 matrix
> including the p-values, but when I do summary(u)$coefficients I get:
> 
>  summary(u)$coefficients
>                                        Value Std. Error    t value
> (Intercept)                      0.151756859 3.00972988 0.05042209
> drops$COHORT[drops$UNIT == unit] 0.002769108 0.03086700 0.08971097
> 
> Any help with this, and on getting the degrees of freedom or the p-value
> would be much appreciated. 

0) Do use extractor function like coef() and df.residual().

1) for the 100 fits try using the default interface, not the formula one.

2) df.residual is not a relevant concept, and the coefficients are not 
t-distributed.  Where did you read that it had?

You can try a normal approximation, but beware it may be rough.  If you
look up MASS4 (the book this software supports) you will see better ideas
illustrated.

3) I get in ?summary.rlm

coefficients: A matrix with three columns, containing the coefficients,
          their standard errors and the corresponding t statistic.

What has summary.lm got to do with rlm fits?

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list