[R-sig-ME] Repeated Measures in MCMCglmm model

Tricia Markle markl033 at umn.edu
Mon Dec 29 06:53:53 CET 2014


Hi Jarrod,

Thank you for the reply. We are defining plasticity as the difference in
slope for oxygen consumption on temperature at different acclimations. So
essentially asking if wide-ranging species have a greater change in slope
between acclimation temperatures than narrow-ranging species. Since there
are three acclimation temps, one thought is to break it up and look at the
difference in slope between acclimation at 15C vs. 22C and then 15C vs. 6C
(so that 15C is somewhat of a reference point).

I like the idea of allowing different species to have different levels of
plasticity, but agree that for 19 species it's going to be hard to
interpret the results. I also have the species broken into 2 groups based
on range size  (large vs. small) and since this gets at the heart of what
I'd like to test perhaps it is the best way to go for now?

I do have multiple individuals per species (and each individual is tested
at each acclimation temp). If I break the data into 2 groups based on range
size, would the random term then be us(1+temp):Range? Since the same
individuals are used in multiple trials would I need to also include ID
somewhere?

The code did work despite the odd script with A inverse associated with
species (I was basing it on an example that I found). I tried some of your
random effect suggestions and now I get the error message  "prior$G has the
wrong number of structures".

Here is my code as it stands now (I would also love your thoughts on the
phylogeny component and if the code for that looks right):

library(MCMCglmm)
dataset<-read.csv(file="RespDataID.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

prior<-list(G=list(G1=list(V=1, n=0.002), R=list(V=1, n=0.002))

#Model 1  with Range Size - Small (1) versus Large (2)
model1<-MCMCglmm(LVO2~1+Acclm+Temp+LMass+Sex+Range+Acclm*Temp*Range,
random=~us(1+Temp):species, data=dataset, family="gaussian",
ginverse=list(species=treeAinv), nodes="ALL", prior=prior, nitt=300000,
burnin=25000, thin = 1000, verbose=FALSE)

summary(model1)

best,
Tricia


On Thu, Dec 25, 2014 at 10:36 PM, Jarrod Hadfield <j.hadfield at ed.ac.uk>
wrote:

> 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.
>
>
>

	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list