Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

random effect of clade for species in a phylo tree #47

Open
Jigyasa3 opened this issue Jan 12, 2020 · 1 comment
Open

random effect of clade for species in a phylo tree #47

Jigyasa3 opened this issue Jan 12, 2020 · 1 comment

Comments

@Jigyasa3
Copy link

Hey!

I am following the simulated examples from https://leanpub.com/correlateddata/read#leanpub-auto-trait-by-environment-interactions.
I was wondering if it is possible to examine the random effects of clade of each species (as a factor).

I tried with the simulated example in section 4.6 of the above link, but I keep getting the following error-

#simulated data-
#Simulate the data-
nspp <- 20

Simulate a phylogenetic tree

phy <- compute.brlen(rtree(n = nspp), method = "Grafen", power = 1)
sd.env <- 1
env1 <- rnorm(nspp, sd=sd.env)
env2 <- rnorm(nspp, sd=sd.env)
lineage<-rep(c("s1","s2","s3","s4"),times=5)
sd.trait <- 1
trait1 <- rTraitCont(phy, model = "BM", sigma = sd.trait)
trait2 <- rTraitCont(phy, model = "BM", sigma = sd.trait)

d2<-data.frame(sp=phy$tip.label,trait1=trait1,env1=env1)
d2$Y <- b0 + b1*d2$trait1 + b2*trait2 + c1*d2$env1 + c2*env2 + f11*d2$trait1*d2$env1 + f21*trait2*d2$env1
d2$lineage<-as.factor(lineage)

d2%>%head()
sp trait1 env1 Y lineage
t7 t7 0.1155387 0.3428021 0.41741713 s1
t4 t4 -0.0228887 -0.2150611 0.05225095 s2
t8 t8 -0.4770557 0.5494478 0.43393900 s3
t9 t9 -1.1772624 0.2776693 -0.43220921 s4
t13 t13 -0.4740025 0.4773304 -0.23581239 s1
t14 t14 -1.2359375 -0.3810483 -1.48079339 s2

#model-
mod.f <- communityPGLMM(Y ~ 1 + (1|sp__)+(lineage|sp__)+ (env1|sp__), tree=phy, data=d2)

#error-
Error in pglmm_gaussian_internal_cpp(par = s, X, Y, Zt, St, nested, REML, :
Evaluation error: objective in x0 returns NA.
In addition: There were 41 warnings (use warnings() to see them)

My aim to examine the effect of each clade of species on a trait of interest. Any suggestions?

@daijiang
Copy link
Owner

daijiang commented Jun 4, 2020

Sorry for the late response. Can you paste the whole example?
Also, try mod.f <- pglmm_compare(Y ~ 1 + (1|sp__)+(lineage|sp__)+ (env1|sp__), data=d2, phy = phy).
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants