Re: [R-sig-phylo] Error in diversitree with MuSSE models

2014-04-05 Thread Rich FitzJohn
Hi Kevin,

Guessing here at possible solutions:

Have a close look at:

start[-c(1,2,3,5,6,7,9,10,11,12,13,14,15,16,17,18,19)]

You may have negative or NA values in there.

You could try running find.mle with lower=0, but that should not be
needed.  I suspect that you got the error while the find.mle function
was evaluating the starting point.  If that's the case try:

lik.allcon(start[-c(1,2,3,5,6,7,9,10,11,12,13,14,15,16,17,18,19)])

(or more readably:

x.init - start[-c(1,2,3,5,6,7,9,10,11,12,13,14,15,16,17,18,19)])
lik.allcon(x.init)

to check that you get the same error.  If you do, then something is up
with the constrained function.  Check that after typing 'constrain'
you see

environment: namespace:diversitree

not

 environment: namespace:geiger

otherwise, load diversitree after geiger, or upgrade to the current
geiger which solves a number of incompatibilities with diversitree.

FWIW, I don't normally recommend constraining like that: I usually
constrain all rates onto a single rate, e.g.

..., lambda2 ~ lambda1, lambda3 ~ lambda1, lambda4 ~ lambda1, ...

but you should get an error from constrain() if it can't resolve your
constraints.

If all that fails, can you post a minimal working example (data and
script that generates the error) perhaps as a gist and I can have a
further poke about.

Cheers,
Rich


On 3 April 2014 00:23, Arbuckle, Kevin k.arbuc...@liverpool.ac.uk wrote:
 Hi Nick, it's running (or trying to) on diversitree v0.9-7



 Kev





 
 From: Nicholas Crouch [ncro...@uic.edu]
 Sent: 01 April 2014 17:01
 To: Arbuckle, Kevin
 Subject: Re: [R-sig-phylo] Error in diversitree with MuSSE models


 Kev,

 What version of diversitree are you running?

 Nick

 On Apr 1, 2014 10:50 AM, Arbuckle, Kevin 
 k.arbuc...@liverpool.ac.ukmailto:k.arbuc...@liverpool.ac.uk wrote:
 Hi,

 I am trying to run a set of MuSSE models in diversitree but getting error 
 messages that I can't seem to figure out (fortunately the models are only an 
 adjunct to my main premise, not particularly vital). The trait has 4 levels 
 and the full model works fine, with the following code:-

 lik-make.musse(contree,col,k=4,sampling.f=0.33)
 start-starting.point.musse(contree,k=4)
 fit-find.mle(lik,start)

 However, when I then try and run a fully constrained model (with only a 
 single speciation rate, extinction rate, and transition rate) with the 
 following code:-

 lik.allcon-constrain(lik,lambda1~lambda2,lambda2~lambda3,lambda3~lambda4,mu1~mu2,mu2~mu3,mu3~mu4,q12~q13,q13~q14,q14~q21,q21~q23,q23~q24,q24~q31,q31~q32,q32~q34,q34~q41,q41~q42,q42~q43)
 fit.allcon-find.mle(lik.allcon,start[-c(1,2,3,5,6,7,9,10,11,12,13,14,15,16,17,18,19)])

 I get the following error message:-

 Error in check.pars.nonnegative(pars, k * (k + 1)) :
   Parameters must be non-negative and finite

 I don't quite understand why or how to fix this. I have previously run BiSSE 
 models (including with constraints) on the same dataset (just with different 
 coding of some levels which made the trait binary) and had no problems. After 
 looking through the diversitree manual I have tried specifying/changing the 
 fail.value and method arguments in find.mle, but I get exactly the same 
 message. Any help or ideas would be greatly appreciated. I presume it is 
 something introduced via the constraints since the full model runs fine, but 
 other than that I am none the wiser.

 Thanks,

 Kev


 [[alternative HTML version deleted]]

 ___
 R-sig-phylo mailing list - 
 R-sig-phylo@r-project.orgmailto:R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

 [[alternative HTML version deleted]]

 ___
 R-sig-phylo mailing list - R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] Error in diversitree with MuSSE models (Arbuckle, Kevin)

2014-04-03 Thread Daniel Caetano
Hi Kev,

Your constrain looks fine but I think you should double check your index 
for the 'find.mle' function in this line:
fit.allcon - 
find.mle(lik.allcon,start[-c(1,2,3,5,6,7,9,10,11,12,13,14,15,16,17,18,19)])

'start' is a vector with a number of elements equal to the number of 
parameters in your full model. To find the MLE of your constrained 
likelihood function you need to point to the free parameters in 'start'.

Try this, check if start has only lambda1,mu1,q12:

fit.allcon - find.mle(lik.allcon,start[c(1,6,12)])

Good luck

*Daniel Caetano Silva*
Ph.D. Student
Harmon Lab
http://caetanods.weebly.com/
http://www.webpages.uidaho.edu/~lukeh/
University of Idaho - Department of Biological Sciences
Moscow, Idaho 83844-3051 USA

On 04/03/2014 03:00 AM, r-sig-phylo-requ...@r-project.org wrote:
 Send R-sig-phylo mailing list submissions to
   r-sig-phylo@r-project.org

 To subscribe or unsubscribe via the World Wide Web, visit
   https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 or, via email, send a message with subject or body 'help' to
   r-sig-phylo-requ...@r-project.org

 You can reach the person managing the list at
   r-sig-phylo-ow...@r-project.org

 When replying, please edit your Subject line so it is more specific
 than Re: Contents of R-sig-phylo digest...


 Today's Topics:

 1. Re: Error in diversitree with MuSSE models (Arbuckle, Kevin)


 --

 Message: 1
 Date: Wed, 2 Apr 2014 13:23:44 +
 From: Arbuckle, Kevin k.arbuc...@liverpool.ac.uk
 To: Nicholas Crouch ncro...@uic.edu
 Cc: r-sig-phylo@r-project.org r-sig-phylo@r-project.org
 Subject: Re: [R-sig-phylo] Error in diversitree with MuSSE models
 Message-ID:
   eb15200a53ef104a85d6d8e071cc0edcb2131...@bhexmbx2.livad.liv.ac.uk
 Content-Type: text/plain

 Hi Nick, it's running (or trying to) on diversitree v0.9-7



 Kev





 
 From: Nicholas Crouch [ncro...@uic.edu]
 Sent: 01 April 2014 17:01
 To: Arbuckle, Kevin
 Subject: Re: [R-sig-phylo] Error in diversitree with MuSSE models


 Kev,

 What version of diversitree are you running?

 Nick

 On Apr 1, 2014 10:50 AM, Arbuckle, Kevin 
 k.arbuc...@liverpool.ac.ukmailto:k.arbuc...@liverpool.ac.uk wrote:
 Hi,

 I am trying to run a set of MuSSE models in diversitree but getting error 
 messages that I can't seem to figure out (fortunately the models are only an 
 adjunct to my main premise, not particularly vital). The trait has 4 levels 
 and the full model works fine, with the following code:-

 lik-make.musse(contree,col,k=4,sampling.f=0.33)
 start-starting.point.musse(contree,k=4)
 fit-find.mle(lik,start)

 However, when I then try and run a fully constrained model (with only a 
 single speciation rate, extinction rate, and transition rate) with the 
 following code:-

 lik.allcon-constrain(lik,lambda1~lambda2,lambda2~lambda3,lambda3~lambda4,mu1~mu2,mu2~mu3,mu3~mu4,q12~q13,q13~q14,q14~q21,q21~q23,q23~q24,q24~q31,q31~q32,q32~q34,q34~q41,q41~q42,q42~q43)
 fit.allcon-find.mle(lik.allcon,start[-c(1,2,3,5,6,7,9,10,11,12,13,14,15,16,17,18,19)])

 I get the following error message:-

 Error in check.pars.nonnegative(pars, k * (k + 1)) :
Parameters must be non-negative and finite

 I don't quite understand why or how to fix this. I have previously run BiSSE 
 models (including with constraints) on the same dataset (just with different 
 coding of some levels which made the trait binary) and had no problems. After 
 looking through the diversitree manual I have tried specifying/changing the 
 fail.value and method arguments in find.mle, but I get exactly the same 
 message. Any help or ideas would be greatly appreciated. I presume it is 
 something introduced via the constraints since the full model runs fine, but 
 other than that I am none the wiser.

 Thanks,

 Kev


  [[alternative HTML version deleted]]

 ___
 R-sig-phylo mailing list - 
 R-sig-phylo@r-project.orgmailto:R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

   [[alternative HTML version deleted]]



 --

 ___
 R-sig-phylo mailing list
 R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


 End of R-sig-phylo Digest, Vol 75, Issue 3
 **



[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] Error in diversitree with MuSSE models

2014-04-02 Thread Arbuckle, Kevin
Hi Nick, it's running (or trying to) on diversitree v0.9-7



Kev






From: Nicholas Crouch [ncro...@uic.edu]
Sent: 01 April 2014 17:01
To: Arbuckle, Kevin
Subject: Re: [R-sig-phylo] Error in diversitree with MuSSE models


Kev,

What version of diversitree are you running?

Nick

On Apr 1, 2014 10:50 AM, Arbuckle, Kevin 
k.arbuc...@liverpool.ac.ukmailto:k.arbuc...@liverpool.ac.uk wrote:
Hi,

I am trying to run a set of MuSSE models in diversitree but getting error 
messages that I can't seem to figure out (fortunately the models are only an 
adjunct to my main premise, not particularly vital). The trait has 4 levels and 
the full model works fine, with the following code:-

lik-make.musse(contree,col,k=4,sampling.f=0.33)
start-starting.point.musse(contree,k=4)
fit-find.mle(lik,start)

However, when I then try and run a fully constrained model (with only a single 
speciation rate, extinction rate, and transition rate) with the following code:-

lik.allcon-constrain(lik,lambda1~lambda2,lambda2~lambda3,lambda3~lambda4,mu1~mu2,mu2~mu3,mu3~mu4,q12~q13,q13~q14,q14~q21,q21~q23,q23~q24,q24~q31,q31~q32,q32~q34,q34~q41,q41~q42,q42~q43)
fit.allcon-find.mle(lik.allcon,start[-c(1,2,3,5,6,7,9,10,11,12,13,14,15,16,17,18,19)])

I get the following error message:-

Error in check.pars.nonnegative(pars, k * (k + 1)) :
  Parameters must be non-negative and finite

I don't quite understand why or how to fix this. I have previously run BiSSE 
models (including with constraints) on the same dataset (just with different 
coding of some levels which made the trait binary) and had no problems. After 
looking through the diversitree manual I have tried specifying/changing the 
fail.value and method arguments in find.mle, but I get exactly the same 
message. Any help or ideas would be greatly appreciated. I presume it is 
something introduced via the constraints since the full model runs fine, but 
other than that I am none the wiser.

Thanks,

Kev


[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - 
R-sig-phylo@r-project.orgmailto:R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/