traitecoevo / modeladequacy

The purpose of this project is to develop an approach to evaluate the fit of continuous trait evolution models and to apply this approach to angiosperm functional trait data.
7 stars 2 forks source link

caper with multiple rescaling #60

Closed mwpennell closed 10 years ago

mwpennell commented 10 years ago

so looking at the caper interface, it is possible to estimate any combination of parameters (lambda, delta, kappa) for the pgls, but i am not sure how to handle this (or whether it is even valid) when rescaling for model adequacy, as the order seems to matter

library(geiger) library(caper) set.seed(1) phy <- sim.bdtree(stop="taxa") d1 <- sim.char(phy, 1, model="BM")[,,] d2 <- sim.char(phy, 1, model="BM")[,,]

traits <- cbind.data.frame(d1, d2, phy$tip.label) colnames(traits)[3] <- "species" cd <- comparative.data(phy, traits, species)

now fit the model with both kappa and delta

fit <- pgls(d1~d2, data=cd, kappa="ML", delta="ML")

ignoring s2, rescale the tree first by delta, then kappa

delta.phy <- rescale(phy, model="delta", delta=fit$param["delta"]) dk.phy <- rescale(delta.phy, model="kappa", kappa=fit$param["kappa"])

now rescale by kappa, then by delta

kappa.phy <- rescale(phy, model="kappa", kappa=fit$param["kappa"]) kd.phy <- rescale(kappa.phy, model="delta", delta=fit$param["delta"])

these are not equivalent

kd.phy$edge.length == dk.phy$edge.length

richfitz commented 10 years ago

One option is just to detect that someone has done this and throw an error. Does fitting multiple rescaling parameters make any sense?

mwpennell commented 10 years ago

I don't think it makes any sense at all but caper does not check for this. writing caper parsing fxns now and am just throwing error if more than one model is used.