Dear useRs,

I am working on a series of field experiments (159 in total) carried out in 
different years in several locations. The cultivars in each experiment are not 
always the same, in fact they change over 
time. I would like to get the fitted values and MSE of the individual fits from 
the following lmList object, so I can use them to fit a mixed model using the 
fitted values and weight each environment 
with (number of reps/MSE)/Average MSE.

library(nlme)
yield.list <- lmList(yield ~ as.factor(rep) + id | yearloc, data = df1, 
na.action = na.omit)

then I do

yield.fitted <- fitted(yield.list)
yield.fitted
     Akron1999      Akron1999      Akron1999      Akron1999      Akron1999 
      45.06508       61.29841       63.73175       61.16508       63.53175 
     Akron1999      Akron1999      Akron1999      Akron1999      Akron1999 
      64.63175       53.09841       60.66508       70.36508       57.19841 
     Akron1999      Akron1999      Akron1999      Akron1999      Akron1999 
      55.33175       60.79841       54.79841       56.46508       64.99841 
     Akron1999      Akron1999      Akron1999      Akron1999      Akron1999 
      57.56508       58.59841       57.86508       56.43175       51.79841 

The label of each value is the "yearloc", I also need to know their "id". Is 
there a way to ad this info?

I have not figured out how to obtain individual mean square errors from an 
lmList object. However, I can do it with:

res <- as.data.frame(matrix(NA, ncol = 3, nrow = 
length(levels(yieldh$yearloc)), dimnames = list(NULL, c("yearloc", "MSE", 
"rep"))))
for (i in 1:length(levels(yieldh$yearloc))) {
  dta <- subset(yieldh,yieldh$yearloc==levels(yieldh$yearloc)[i], drop = T)
  x <- anova(lm(yield ~ factor(rep) + id, data = dta, na.actio = 
na.omit))$"Mean Sq"[3]
  res[i,] <- c(levels(yieldh$yearloc)[i],x, length(levels(dta$rep)))
}

Can anybody give me directions to solve this?

Thanks,
Marc


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to