[R-sig-ME] Repeated Measures in MCMCglmm model
Tricia Markle
markl033 at umn.edu
Thu Dec 18 06:41:58 CET 2014
Hello,
I am hoping to find someone familiar with the R code for taking repeated
measures into account in a MCMCglmm model. I have put together a working
code (see below) based on a couple of examples that I found (adding “ID” as
a random term), but remain unsure if it is the best approach.
My study is investigating whether wide-ranging species of salamander have a
greater degree of plasticity in oxygen consumption (i.e. metabolic rate) at
different acclimation temperatures than narrow-ranging species. The same
individuals were tested at each of three acclimation temperatures (6, 14,
and 22C). Each acclimation temperature had 3 separate respirometry tests to
measure oxygen consumption (5, 15, and 25C) for a total of 9 tests per
individual.
*R script:*
library(MCMCglmm)
dataset<-read.csv(file="RData.csv", head=TRUE)
dataset$Range<-as.factor(dataset$Range)
str(dataset)
#Phylogeny Component
tree<-read.tree("Plethodontidae_comb61_PL.phy")
species<-c("D._carolinensis_KHK103", "D._fuscus_KHK142",
"D._imitator_KHK05", "D._ochrophaeus_WKS05", "D._ocoee_B_KHK62",
"D._orestes_KHK129", "D._monticola_A", "D._santeetlah_11775",
"P_cinereus", "P_cylindraceus", "P_glutinosus", "P_hubrichti",
"P_montanus", "P_punctatus", "P_richmondi", "P_teyahalee", "P_virginia",
"P_wehrlei")
pruned.tree<-drop.tip(tree,tree$tip.label[-match(species,
tree$tip.label)])# Prune tree to just include species of interest
sptree<-makeNodeLabel(pruned.tree, method="number", prefix="node") #rename
nodes to be unique
plot(sptree, show.node.label=TRUE)
treeAinv<-inverseA(sptree)$Ainv
#For Repeated Measures
dataset$ID<-dataset$animal
head(dataset)
p.var<-var(dataset$LVO2, na.rm=TRUE)
#Prior
prior<-list(G=list(G1=list(V=1, n=0.002), G2=list(V=1, n=0.002)),
R=list(V=1, n=0.002))
#Model 1 with Range Size
model1<-MCMCglmm(LVO2~1+Acclm+Temp+LMass+Sex+Range+Acclm*Temp*Range,
random=~animal+ID, data=dataset, ginverse=list(species=treeAinv),
nodes="ALL", prior=prior, nitt=300000, burnin=25000, thin = 1000,
verbose=FALSE)
*Sincerely, *
*Tricia Markle*
*PhD Candidate, **University of Minnesota*
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list