首页 > 解决方案 > 用于 gls 的 Abline 不会绘图

问题描述

我试图用回归线绘制下面的模型,我可以生成一个图,但我尝试过的 abline 命令(也在下面)似乎都不起作用。R 似乎很高兴,并且不会使用我尝试的第一个 abline 命令输出任何错误消息,但绘图上不会出现任何线条。我也尝试将 abline 函数添加到绘图代码本身中,但这也没有奏效。任何帮助,将不胜感激。

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)) 

标签: r

解决方案


请包括您的帖子中使用的包裹。因此,如果您gls来自nlme那么您看到的图是残差,而不是预测值。使用来自 nlme 的示例集:

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

在此处输入图像描述

所以拟合线在这里没有意义。你很可能想要做:

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

推荐阅读