我正在努力如何將個人和組趨勢線添加到我的圖中。 (R和使用ggplot2)。R:將組和單個多項式趨勢線添加到GMM圖中
這裏是我使用的代碼:
MensHG.fm2=lmer(HGNewtons~Temperature+QuadTemp+Run+(1|Subject),MenstrualData) #model
plot.hg<-data.frame([email protected],fitted.re=fitted(MensHG.fm2))
g1<-ggplot(plot.hg,aes(x=Temperature,y=HGNewtons))+geom_point()
g2<-g1+facet_wrap(~Subject, nrow=6)+ylab(bquote('HG MVF (N)'))+xlab(bquote('Hand ' ~T[sk] ~(degree*C)))
g3<-g2+geom_smooth(method="glm", formula=y~ploy(x,2), se=FALSE) #This gives me my individual trendlines
現在我希望把趨勢線的數據的G1部分(即整體趨勢)到我的每一個個別地塊的 - 什麼是最好的方法來做到這一點?我可以看到的趨勢,如果我使用的代碼:只要我做的小麪包裝
g5=g1+geom_smooth(method="glm", formula=y~poly(x,2), se=FALSE)
但是這個趨勢線disspears(我得到的輸出G3相同)
它不會出現通過使用來解決這個問題:G4 < -g3 + geom_smooth(數據= MensHG.fm2)
的[如何放置在GGPLOT2對象的每個方面相同的流暢?(HTTPS可能重複: //stackoverflow.com/questions/6673074/how-do-i-place-an-identical-smooth-on-each-face-of-a-ggplot2-object) – aosmith
代替'geom_smooth',使用'geom_line(aes (Temperature,fitted.re))'來生成連接所有擬合值的線。 – Brian