Dear Edwin, Your first approach is correct. Since confidence intervals strongly related to one-sample tests, you can use one-sample t-test if you want p-values. Someone may suggest built-in function for this, but you can calculate it easily without such function.
Here is an example: # creating data, the intercept is zero, the slope is 1.2 x<-seq(0,100) y<-rnorm(length(x),mean=1.2*x,sd=15) # plotting the data plot(x,y) abline(0,1) # fitting linear equation m<-lm(y~x) summary(m) # for test we need the slope and its standard error # we can get both from the summary sm<-summary(m) sm$coefficients (slope<-sm$coefficients[2,1]) (se.slope<-sm$coefficients[2,2]) # the last steps: calculating t-value and probability of type I error (t.value<-(slope-1)/se.slope) 1-pt(t.value,df=length(x)-2) Best regards, Zoltan 2013.06.12. 13:46 keltezéssel, Pos, E.T. írta: > Dear all, > > I'm having trouble with something that I presume is foolishly easy. > > I have a linear model with a slope slightly higher than the slope of y=x. Now > I wish to test if the slope of this lm is actually significantly different > from the slope of y=x (i.e. 1) > > One option to do this obviously is testing whether 1 falls within the 95% > confidence interval of the original lm. I've done this and it gives me an > indication but I would like a hard p-value for testing this significance. The > problem I run into is that I don't know how to test for the significance of > this difference between the slope of my lm and the line y=x. > > Thus far: > > Method #1 > > data1.y = "some data" > data1.x = "some more data" > data1 = lm(data1.y~data1.x) > abline(data1, col = "red", lwd = 2) #draw a line through the regression > abline(a = 0, b = 1) # which gives me the line for x=y but > this doesn't work for ANOVA but is nicely ilustrative > > #Check the 95% confidence interval > confint(data1) > > Method #2 > > # I used offset because I found that on the mailinglist in the archives but > I'm not sure why this would indicate the difference is significant from the > slope y=x? Any suggestions? > data1.y = "some data" > data1.x = "some more data" > data1 = lm(data1.y~data1.x) > data1.offset = lm(data1.y~data1.x+offset(data1.x)) > summary(data1.offset) #then check if the slope is significantly different > from 1 > > But I'm not convinced that method number 2 gives me the correct answer. Any > idea's here? > > Thanks a lot, > > Edwin. > > > [[alternative HTML version deleted]] > > > > _______________________________________________ > R-sig-ecology mailing list > R-sig-ecology@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-ecology -- Botta-Dukát Zoltán -------------------------------- Ökológiai és Botanikai Intézet Magyar Tudományos Akadémia Ökológiai Kutatóközpont -------------------------------- 2163. Vácrátót, Alkotmány u. 2-4. tel: +36 28 360122/157 fax: +36 28 360110 botta-dukat.zol...@okologia.mta.hu www.okologia.mta.hu Zoltán BOTTA-Dukát -------------------------------- Institute of Ecology and Botany Hungarian Academy of Sciences Centre for Ecological Research -------------------------------- H-2163 Vácrátót, Alkomány u. 2-4. HUNGARY Phone: +36 28 360122/157 Fax..: +36 28 360110 botta-dukat.zol...@okologia.mta.hu www.okologia.mta.hu [[alternative HTML version deleted]]
_______________________________________________ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology