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

two versions of OU in phylolm #12

Open
richfitz opened this issue Apr 8, 2014 · 2 comments
Open

two versions of OU in phylolm #12

richfitz opened this issue Apr 8, 2014 · 2 comments

Comments

@richfitz
Copy link
Collaborator

richfitz commented Apr 8, 2014

Issue by mwpennell from Tuesday Dec 10, 2013 at 19:48 GMT
Originally opened as traitecoevo/modeladequacy#63


this is a very low priority at the moment but there are two different options for OU models in phylolm -- depending on whether one want to assume stationarity or not. i am just going to ignore the difference for now and rescale them in the same way. just wanted to put the issue on record

@richfitz richfitz added this to the Paper 2: PGLS models milestone Apr 8, 2014
@richfitz
Copy link
Collaborator Author

richfitz commented Apr 8, 2014

Comment by richfitz from Wednesday Dec 18, 2013 at 02:31 GMT


This should be simlar to the with.optimum=TRUE / with.optimum=FALSE models made by diversitree::make.ou. It's possible that the with optimum scaling could be tricky to get right.

@richfitz
Copy link
Collaborator Author

richfitz commented Apr 8, 2014

Comment by richfitz from Wednesday Dec 18, 2013 at 02:39 GMT


Actually, looking further into this, phylom.R contains:

        if (model=="OUrandomRoot") {
            alpha = value
            edge.length = numeric(N)
            distFromRoot <-  exp(-2*alpha*times)
            externalEdge <- des<=n
            for (i in 1:N) {
                d1 = distFromRoot[which(names(times)==anc[i])]
                if (externalEdge[i]) {d2 = exp(-2*alpha*D[des[i]])} else d2 = distFromRoot[which(names(times)==des[i])]
                edge.length[i] = d2 - d1
                }
            root.edge = min(distFromRoot)
            }

        ### OUfixedRoot model   
        if (model=="OUfixedRoot") {
            alpha = value
            edge.length = numeric(N)
            distFromRoot <-  exp(-2*alpha*times)*(1 - exp(-2*alpha*(Tmax-times)))
            externalEdge <- des<=n
            for (i in 1:N) {
                d1 = distFromRoot[which(names(times)  == anc[i])]
                if (externalEdge[i]) {d2 = exp(-2*alpha*D[des[i]])*(1-exp(-2*alpha*(Tmax-D[des[i]])))}
                    else d2 = distFromRoot[which(names(times)==des[i])]
                edge.length[i] = d2 - d1
                }
            root.edge = min(distFromRoot)
            }

which look to be equivalent to different root treatments only. The relevant lines are

# random, fixed:
distFromRoot <-  exp(-2*alpha*times)
distFromRoot <-  exp(-2*alpha*times)*(1 - exp(-2*alpha*(Tmax-times)))

# external edge: random, fixed:
exp(-2*alpha*D[des[i]])
exp(-2*alpha*D[des[i]])*(1-exp(-2*alpha*(Tmax-D[des[i]])))

# internal edge: random, fixed
distFromRoot[which(names(times)==des[i])]
distFromRoot[which(names(times)==des[i])]

which are not so different. I'm not sure I see how these relate to the root treatment actually.

I agree that this is not a priority. We could probably use the transf.branch.lengths function to do the hard work creating a unit tree anyway, without having to pick apart the models.

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

1 participant