[R] split and rlm
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Mon Oct 11 17:17:41 CEST 2004
Stuart Luppescu <s-luppescu at uchicago.edu> writes:
> 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?
How about by()?
> 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
pt(), I would hope....
> 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.
As Brian usually puts it: This is support software for a book. You
might want to read it...
Looking at the code, it seems to explicitly set the residual DF to NA,
which - along with the absense of p values - usually suggests that the
author(s) do not trust them and I think I can see why. Apparently the
lm() methods which get invoked through inheritance have ways of
sticking the residual DF back in, but that doesn't make them any more
sensible. If you must, have a look inside print.summary.lm and see
where "rdf" comes from, but I'd suspect that you're just as well off
by using the normal approximation.
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list