[R-sig-ME] Repeated Measures in MCMCglmm model
Jarrod Hadfield
j.hadfield at ed.ac.uk
Fri Dec 26 07:36:16 CET 2014
Hi Tricia,
How do you define plasticity, as the slope of the regression of oxygen
consumption on temperature, acclimation temperature or some aspect of
both?
If it was temperature I would fit the random effect term
us(1+temp):species which allows different species to have different
levels of plasticity which is phylogentically correlated. However,
with 18 (?) species it is going to be hard to get precise estimates of
how variable plasticity is across different species.
Its not clear whether you have multiple individuals per species? If
there is only one individual per species then us(1+temp):ID models
between-species variation in plasticity not determined by phylogeny
and any between individual (within-species) variation in plasticity.
If you have multiple individuals per species then you could separate
these two effects.
Also, does your code work? You have associated the A inverse with
species but then fitted animal in your random model - you should have
species in the random model rather than animal.
Cheers,
Jarrod
Quoting Tricia Markle <markl033 at umn.edu> on Wed, 17 Dec 2014 23:41:58 -0600:
> 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]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
More information about the R-sig-mixed-models
mailing list