简体   繁体   中英

Abline for gls won't plot

I am attempting to plot the model below with a regression line, and I can generate a plot but none of the abline commands I have tried (also below) seem to work. R will appear to be happy and not output any error messages with the first abline command I try, but no line will appear on the plot. I've tried adding the abline function into the plot code itself too but this hasn't worked either. Any help would be appreciated.

model2<-gls(transformedlongevity~transformedproportion, data=independencedata, 
            correlation=corPagel(1,trimtree))
summary(model2)
plot(model2, xlab= "Transformed Value of Proportion of Life Spent Under Parental Care (Years)", 
     ylab="Transformed Value of Maximum Life Span (Years)", 
     main= "Time Spent Under Parental Care Relative 
     to Longevity of Passerine Species")


abline(gls(transformedproportion~transformedlongevity, independencedata), untf=T)
abline(a=0, b=coef(model2)) 
abline(coef(model2)) 

Please include the package used in your post. So if your gls comes from nlme then the plot you are seeing is for residuals, not predicted values. Using an example set from nlme:

library(nlme)
fm1 <- gls(follicles ~ Time, Ovary,
            correlation = corAR1(form = ~ 1 | Mare))
plot(fm1)

在此处输入图像描述

So a fitted line doesn't make sense here. You most likely want to do:

plot(Ovary$Time,Ovary$follicles)
abline(fm1,col="blue")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM