BLUP

From RAJ INFO
Revision as of 09:07, 6 August 2013 by Raj (talk | contribs) (Created page with "Category:R ==r-BLUP== # computation of BLUP's, using seedling dry weight data as example library(lme4) d <- read.table('SeedlingDryWeight2.txt',as.is=T, header=T) # ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Category:R

r-BLUP

  1. computation of BLUP's, using seedling dry weight data as example

library(lme4)

d <- read.table('SeedlingDryWeight2.txt',as.is=T, header=T)

  1. create factors

d$g <- as.factor(d$Genotype) d$t <- as.factor(d$Tray) d$s <- as.factor(d$Seedling)

  1. fit the mixed effects model model

temp <- lmer(SeedlingWeight~g+(1|t),data=d)

  1. BLUPs

blup <- ranef(temp)

  1. look at ranef() output to see its structure

str(blup)

  1. there are options to ranef(drop=T) to simplify structure of output
  1. compare BLUP to genotype averages

gmean <- tapply(d$SeedlingWeight,d$t,mean)

plot(gmean,blup$t$'(Intercept)')

  1. BLUPs + fixed effects
  2. there is no predict() for an lmer object
  3. these are the equivalents

betau <- coef(temp)

  1. values are beta + u for each row

trayX <- cbind(rep(1,8), rep(c(0,1),c(4,4)))

  1. model.matrix with one row per tray

pred.tray <- apply(betau$t*trayX,1,sum)

plot(gmean, pred.tray)