Re: [R-sig-phylo] Non Parametric PGLS

2015-06-17 Thread Simon Blomberg
Hi Sérgio. Liam is right. But we do expect the normalised residuals to be approximately Normal. You can calculate the normalised residuals by pre-multiplying the raw residuals by the inverse of the Cholesky decomposition of the phylogenetic variance-covariance matrix, and then dividing by the

Re: [R-sig-phylo] Missing States in ML Reconstruction of Discrete Ancestral States (phytools, ape)

2015-06-17 Thread Liam J. Revell
Hi David. The diagonal of Q is defined such that row sum (or sometimes the column sum) is zero. This is the case for any transition rate matrix of a continuous time Markov chain & is required so that matrix exponentiation of Q*t give the matrix P[i,j] in which i,j gives the probability of goi

Re: [R-sig-phylo] Missing States in ML Reconstruction of Discrete Ancestral States (phytools, ape)

2015-06-17 Thread David Bapst
Liam- Yes, that works! I apparently confused the sort of model matrix needed by rTraitDisc with the sort needed by ace. Here's a full working example, for future posterity: # library(ape) library(phytools) data(bird.orders) #make a matrix for a 4 step trait model<-matrix(c(0,1,

Re: [R-sig-phylo] Missing States in ML Reconstruction of Discrete Ancestral States (phytools, ape)

2015-06-17 Thread Liam J. Revell
Hi David. I think the problem may be that you're specifying the model matrix incorrectly. The model matrix is an integer matrix in which each number is a different rate type and the diagonal is zeroes. So, for instance, for a single-rate ordered model with four states you would do: model<-

Re: [R-sig-phylo] Missing States in ML Reconstruction of Discrete Ancestral States (phytools, ape)

2015-06-17 Thread Brian O'Meara
corHMM should be able to do this as long as the states are defined in the transition matrix (rate.mat.maker() to start, then modify). BioGeoBEARS could do this (since it has to for biogeography: not all combos of ancestral areas are observed at the tips), and one of its models might be equivalent t

Re: [R-sig-phylo] Missing States in ML Reconstruction of Discrete Ancestral States (phytools, ape)

2015-06-17 Thread David Bapst
Liam, Ah, I see, rerootingMethod(), unlike ace, will accept a matrix representation of discrete trait values. However, it doesn't appear that one can define a model matrix still? Outside of molecular data, the missing state issue is often for ordered data, hence the need to define a model matrix.

Re: [R-sig-phylo] Missing States in ML Reconstruction of Discrete Ancestral States (phytools, ape)

2015-06-17 Thread Liam J. Revell
Hi David. Actually, if I understand correctly, this does work in phytools. I suspect it can be set up in phangorn as well - Klaus can probably explain how. So, if I understand correctly, you want to get marginal ancestral states for a character that can assume, say, states "A", "C", "G", & "

[R-sig-phylo] Missing States in ML Reconstruction of Discrete Ancestral States (phytools, ape)

2015-06-17 Thread David Bapst
Hello all, (I'm a troublemaker today.) Sometimes, in ordered discrete data, there are states we know might exist as intermediary between observed states but aren't observed themselves. I suppose this is probably common for meristic data. At least to me, it seems like it should be possible to reco

Re: [R-sig-phylo] Non Parametric PGLS

2015-06-17 Thread Liam J. Revell
Hi Sérgio. It might be worth pointing out that we do not expect that the residuals from a phylogenetic regression to be normal. I described this with respect to the phylogenetic ANOVA on my blog (http://blog.phytools.org/2013/02/a-comment-on-distribution-of-residuals.html), but this applies e

Re: [R-sig-phylo] Non Parametric PGLS

2015-06-17 Thread Daniel Fulop
Sergio, You can fit a non-Gaussian phylo regression with MCMCglmm. HTH, Dan. > On Jun 17, 2015, at 9:40 AM, Sergio Ferreira Cardoso > wrote: > > Hello all, > > I'm having a problem with a Multiple Regression PGLS analysis that I'm > performing. The residuals are not normal and it's dif

[R-sig-phylo] Non Parametric PGLS

2015-06-17 Thread Sergio Ferreira Cardoso
Hello all, I'm having a problem with a Multiple Regression PGLS analysis that I'm performing. The residuals are not normal and it's difficult to bring them to normality. In these cases, are there any alternatives to the linear model? I know that for non-phylogenetic analyses other models exist, bu

[R-sig-phylo] collapse.singles() can be confused by node numbering (Was: Bug in reorder.phylo() (related to cleaning phylo objects))

2015-06-17 Thread David Bapst
Hello all, Following up on discussion from Monday, I've been trying to figure out how the tree I shared broke ape's rules for 'phylo' objects. It turns out, it doesn't, really (other than having single nodes), at least not as defined by checkValidPhylo or as described in the formatTree PDF. #