[R-sig-ME] Hadfield et al 2014 co-evolution analysis

jigyasa arora @ror@j|gy@@@1992 @end|ng |rom gm@||@com
Sat Jan 4 10:58:48 CET 2020


Hey!

I want to reproduce Hadfield *et al* (2014) analysis in-
https://datadryad.org/stash/dataset/doi:10.5061/dryad.jf3tj. The
data-analysis from the paper is-
https://datadryad.org/stash/dataset/doi:10.5061/dryad.jf3tj

In the Analysis.R file in the data-analysis link, Hadfield *et al* created
an "*ndat"* dataframe which contains host and parasite counts. When I run
the original codes for MCMC run as it is (as shown below), I get the
following error-

##########################
##### MCMC Count Data ####
##########################
#distribution of counts is assumed to be overdispersed zero-truncated
Poisson

>priorC=list(R=list(V=1, nu=0))
>priorC$G<-lapply(1:9, function(x){list(V=1, nu=1, alpha.mu=0,
alpha.V=1000)})
>names(priorC$G)<-paste("G", 1:9, sep="")

>mC.MCMCa<-MCMCglmm(counts~log(no.hosts.sampled)+log(no.parasites.sampled),
random=~Region+Parasite.species+Host.species+Parasite.species.ide+Host.species.ide+Host.Parasite+Host.Parasite.ide+Host.Parasite.ide2+Host.Parasite.ide3,
family="ztpoisson", data=ndat, ginverse=list(Host.species=hostA,
Host.Parasite=host.parasiteA, Host.Parasite.ide2=host.parasiteAS,
Host.Parasite.ide3=host.parasiteSA), prior=priorC, nitt=1000000, thin=400,
burnin=200000)

Error-
Error in MCMCglmm(counts ~ log(no.hosts.sampled) +
log(no.parasites.sampled),  :
  Zero-truncated Poisson data must be positive integers

If I remove 0 values in "counts" columns from the "ndat" dataframe, then I
will have to change the prior itself according to the new error-

>library(tidyr)
>ndat_cleaned<-ndat %>% filter(counts>0)
>mC.MCMCai<-MCMCglmm(counts~1,
random=~Parasite.species+Host.species+Parasite.species.ide+Host.species.ide+Host.Parasite+Host.Parasite.ide+Host.Parasite.ide2+Host.Parasite.ide3,
family="ztpoisson", data=ndat_cleaned, ginverse=list(Host.species=hostA,
Host.Parasite=host.parasiteA, Host.Parasite.ide2=host.parasiteAS,
Host.Parasite.ide3=host.parasiteSA), prior=priorC, nitt=1000000, thin=400,
burnin=200000)

Error-
Error in MCMCglmm(counts ~ 1, random = ~Parasite.species + Host.species +
 :
  prior$G has the wrong number of structures

How do I make it work?
I want to ultimately check the effect of each of the random effects
separately on the "counts" variable to compare the effect of host
phylogeny, parasite phylogeny, and host-parasite coevolution. Would I need
to change the priors each time?

Thanks!
Jigyasa Arora

	[[alternative HTML version deleted]]



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