Hi ?????,
my approach would be to use the estimated variance of the slope
estimator. For your regression models m1 and m2 you can enter
vcov(m1)
vcov(m2)
to get the variance-covariance matrix of m1 and m2. Then, assuming that
the slope estimator is normal, you compute the p-value for slope_theo
with respect to this normal distribution.
On Fri, 2011-03-18 at 10:04 +0300, ????? ???????? wrote:
> Hi all,
> I need to test the significnce of difference between slopes of two
regression lines and regression line with theoretical line. I try to use
Slope.test function from emu package,
> but an error occured...
>
> library(emu)
> d1<-data.frame(P1=c(1,2,3,5,7,8,9,13,14,15),
> P2=c(1,2,5,8,11,13,15,15,18,24),
> R=c(2,7,8,9,16,21,27,31,33,36)) # First data set
> m1<-lm(R~P1+P2+P1*P2,data=d1) # Regr. model
>
> d2<-data.frame(P1=c(1,5,4,7,9,1,12,4,4,5),
> P2=c(1,2,0,7,4,1,2,0,7,0),
> R=c(3,12,15,15,9,7,4,5,6,1)) # Second data set
> m2<-lm(R~P1+P2+P1*P2,data=d2) # Regr. model
>
> Slope.test(data.frame(fitted(m1),d1$R),data.frame(fitted(m2),d2$R))
#Doesn't work...
>
> Is it correct to use t-test in this situation and how to compute df for
it? My solution is:
>
> s1<-coefficients(summary(lm(fitted(m1)~d1$R)))[2,1] #Slopes of regr.line
> s2<-coefficients(summary(lm(fitted(m2)~d2$R)))[2,1]
> se1<-coefficients(summary(lm(fitted(m1)~d1$R)))[2,2] #SE of slopes
> se2<-coefficients(summary(lm(fitted(m2)~d1$R)))[2,2]
> df1<-df.residual(lm(fitted(m1)~d1$R)) #D. of f.
> df2<-df.residual(lm(fitted(m2)~d1$R))
>
>
kk<-function(se1,se2,df1,df2){(se1^2+se2^2)^2/(se1^4/(df1-1)+se2^4/(df2-1))}
#D. of f. for Welsch test
> tt<-function(s1,s2,se1,se2){(s1-s2)/sqrt(se1^2+se2^2)}
>
pp<-function(s1,s2,se1,se2,df1,df2){2*pt(-abs(tt(s1,s2,se1,se2)),df=kk(se1,se2,df1,df2))}
>
> pp(s1,s2,se1,se2,df1,df2) # p-value
>
> ## Theoretical line
>
> s3<-0.75
> se3<-0
> df3<-0
>
> pp(s1,s3,se1,se3,df1,df3) # p-value
> pp(s2,s3,se2,se3,df2,df3) # p-value
>
>
> Thanks,
> A.M.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Daniel Kaschek
Physikalisches Institut, Freiburg
Hermann-Herder-Str. 3
79104 Freiburg
Office: Westbau, 02020
Phone: +49-761-203-8531
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part
URL:
<https://stat.ethz.ch/pipermail/r-help/attachments/20110318/93251112/attachment.bin>