[R] comparing regression slopes
spencer.graves at pdf.com
Fri Jun 11 12:14:48 CEST 2004
Fortunately, you don't have to accept "no" for an answer: You can
dream up something that you think is sensible, simulate scenarios you
want to detect plus scenarios with no difference, and find out what your
procedure produces, the distributions of your sample statistics, etc.,
e.g., as described by Venables and Ripley (2000) S Programming
(Springer) to obtain confidence intervals for normal probability plots.
R has many functions for pseudo-random number generation as well as
packages for bootstrapping. Only a few hours ago, I checked a
theoretical computation using pseudo-random numbers.
hope this helps. spencer graves
Prof Brian Ripley wrote:
>It's not OK. Treat the results from rlm as having infinite df since the
>theory is asymptotic (use pnorm not pt), and don't expect anything useful
>in samples as small as 10 cases (30+, preferably 100+ would be OK).
>On Fri, 11 Jun 2004, Nathan Weisz wrote:
>>I used rlm to calculate two regression models for two data sets (rlm
>>due to two outlying values in one of the data sets). Now I want to
>>compare the two regression slopes. I came across some R-code of Spencer
>>Graves in reply to a similar problem:
>>The code was:
>> > df1 <- data.frame(x=1:10, y=1:10+rnorm(10)) #3observations in
>> > df2 <- data.frame(x=1:10, y=1:10+rnorm(10))
>> > fit1 <- lm(y~x, df1)
>> > s1 <- summary(fit1)$coefficients
>> > fit2 <- lm(y~x, df2)
>> > s2 <- summary(fit2)$coefficients
>> > db <- (s2[2,1]-s1[2,1])
>> > sd <- sqrt(s2[2,2]^2+s1[2,2]^2)
>> > df <- (fit1$df.residual+fit2$df.residual)
>> > td <- db/sd
>> > 2*pt(-abs(td), df)
>>However when I use rlm instead of lm I get NA for df.residual.
>> > fit1 <- rlm(y~x, df1)
>> > fit1$df.residual
>>Does this mean that I can not apply the code for values gained by rlm?
>>In the example above I continued by taking the df from:
>> > summary(fit1)$df
>>Is this o.k.?
>>Help greatly appreciated.
>>R-help at stat.math.ethz.ch mailing list
>>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
More information about the R-help