1

我想发布一个由 nlme 生成的 augPred 图,所以它需要看起来更好一点(评论者说)。我想重新排列面板并更改标题。我曾尝试使用我为 lattice 找到的信息,但不知何故它在 nlme 中不起作用。例如,我尝试过使用index.cond. 它确实对面板重新排序,但不是按照我指定的顺序。

这是原始图:

数字

以及我一直在尝试使用此数据集数据的代码,您将需要此函数SSbgf

library(nlme)
grow<-read.table("cobsgddv8.txt", header=T)

grow10<-subset(grow, grow$year == "2010")
grow10$EU<- with(grow10, factor(ground):factor(plot))
grow10G<-groupedData(mass ~ gdd | EU, data=grow10)

fit.beta.10 <- nlsList(mass ~ SSbgf(gdd, w.max, t.e, t.m), data = grow10G)
plot(intervals(fit.beta.10), layout = c(3,1))
fit.nlme.10<-nlme(fit.beta.10, random=pdDiag(w.max ~1))

fit.nlme3.10<-update(fit.nlme.10, random = list(w.max + t.m + t.e ~ 1))

plot(augPred(fit.nlme3.10), layout = c(4,6), xlab="", ylab="", ylim=c(-200,2700), 
index.cond=list(c(3,8,4,7,2,5,6,1,9,12,10,11,24,21,22,23,20,18,19,17,13,14,15,16))) 

#Order I am looking for
c("Above:12", "Above:21", "Above:35", "Above:43", "Above:15", "Above:23", "Above:32", 
"Above:41", "Above:13", "Above:24", "Above:31", "Above:46","Below:12", "Below:21", 
"Below:35", "Below:43", "Below:15", "Below:23", "Below:32", "Below:41",     "Below:13", 
"Below:24", "Below:31", "Below:46")))

#Panel titles I want 
c("M", "M", "M", "M", "FP", "FP", "FP", "FP", "P", "P", "P", "P","M", "M", "M", "M",
 "FP", "FP", "FP", "FP", "P", "P", "P", "P")
4

1 回答 1

0

我认为更改面板顺序的最简单方法是更改​​绘图调用之外的因素的顺序。

dat22 = augPred(fit.nlme3.10)
dat22$.groups = factor(dat22$.groups, 
                   levels = c("Above:12", "Above:21", "Above:35", "Above:43", "Above:15", 
                         "Above:23", "Above:32", "Above:41", "Above:13", "Above:24", 
                         "Above:31", "Above:46", "Below:12", "Below:21", "Below:35", 
                         "Below:43", "Below:15", "Below:23", "Below:32", "Below:41", 
                         "Below:13", "Below:24", "Below:31", "Below:46"))
plot(dat22, layout = c(4,6), xlab="", ylab="", ylim=c(-200,2700))

要更改每个片段中的标题,您可以设置factor.levelsusing strip.custom

plot(dat22, layout = c(4,6), xlab="", ylab="", ylim=c(-200,2700), 
    strip = strip.custom(factor.levels = c("M", "M", "M", "M", "FP", "FP", "FP", "FP", "P", "P", 
                                    "P", "P","M", "M", "M", "M", "FP", "FP", "FP", "FP", "P", 
                                    "P", "P", "P")))

不过,这会替换原来的名称,我不确定您是想增加名称还是完全更改它们。

于 2013-09-17T19:12:56.973 回答