[R] comparing regression slopes
Spencer Graves
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:
>
>
>
>>Dear List,
>>
>>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:
>>http://www.mail-archive.com/r-help@stat.math.ethz.ch/msg06666.html
>>
>>The code was:
>>
>> > df1 <- data.frame(x=1:10, y=1:10+rnorm(10)) #3observations in
>>original code
>> > 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)
>>[1] 0.9510506
>>
>>However when I use rlm instead of lm I get NA for df.residual.
>> > fit1 <- rlm(y~x, df1)
>> > fit1$df.residual
>>[1] NA
>>
>>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[2]
>>[1] 8
>>
>>Is this o.k.?
>>
>>Help greatly appreciated.
>>
>>Best,
>>Nathan Weisz
>>
>>______________________________________________
>>R-help at stat.math.ethz.ch mailing list
>>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>>
>>
>>
>>
>
>
>
More information about the R-help
mailing list