Re: [R-sig-phylo] fitDiscrete question - super large likelihood and AIC values

2016-09-10 Thread Lei Yang
Hi, Liam,

Thank you for your suggestions. I tried fitMk in phytools and ace in ape.
Below is what I got.


> fit.phytools<-fitMk(tree,bathy2,model="ER",pi="equal")
> fit.phytools
Object of class "fitMk".

Fitted (or set) value of Q:
  1shallow 2bathypelagic
1shallow   NaN   NaN
2bathypelagic  NaN   NaN

Fitted (or set) value of pi:
 1shallow 2bathypelagic
  0.5   0.5

Log-likelihood: -1e+50


> fit.ape<-ace(bathy2,tree,type="discrete",model="ER")
Error in matexpo(Q * EL[i]) : NA/NaN/Inf in foreign function call (arg 1)
In addition: Warning message:
In ace(bathy2, tree, type = "discrete", model = "ER") :
  model fit suspicious: gradients apparently non-finite


Best wishes, Lei



On Sat, Sep 10, 2016 at 4:22 PM, Liam J. Revell  wrote:

> Hi Lei.
>
> Looks like an error. The likelihood is actually a very *small* number as
> the log-likelihood is a very *large* negative number. Similarly, the fitted
> transition rates are very small - near zero.
>
> Have you tried to fit the same model using ace in the ape package or fitMk
> in phytools? (These are not totally independent implementations, actually,
> as fitMk borrows some of its code from ace, but nonetheless.) These
> functions should usually result in almost the same fitted model and
> likelihood values as fitDiscrete, but make slightly different assumptions
> about the root state: http://blog.phytools.org/2015/
> 09/the-difference-between-different.html. You can also fit an Mk model
> using diversitree or phangorn. (Look for details on my blog.)
>
> All the best, Liam
>
> Liam J. Revell, Associate Professor of Biology
> University of Massachusetts Boston
> web: http://faculty.umb.edu/liam.revell/
> email: liam.rev...@umb.edu
> blog: http://blog.phytools.org
>
>
> On 9/10/2016 2:00 PM, Lei Yang wrote:
>
>> Dear All,
>>
>> I am learning to use fitDiscrete in geiger recently. Results on several
>> discrete characters look normal except for the following one. Can someone
>> please tell me why the values of log-likelihood, AIC, and AICc are so
>> large? Thanks a lot.
>>
>>
>> ER<-fitDiscrete(tree, aabb, model="ER")
>>>
>>
>> ARD<-fitDiscrete(tree, aabb, model="ARD")
>>>
>>
>> ER
>>>
>>
>> GEIGER-fitted comparative model of discrete data
>>
>>  fitted Q matrix:
>>
>>aa  bb
>>
>> aa  -5.915287  5.915287
>>
>> bb   5.915287 -5.915287
>>
>>
>>  model summary:
>>
>> log-likelihood =
>> -6973312221251036165947450327545502362648241
>> 750950346848435554075534196338404706251868027512415973882408
>> 182135734368278484639385041047239877871023591066789981811181
>> 813306167128854888448.00
>>
>> AIC =
>> 13946624442502072331894900655091004725296483
>> 501900693696871108151068392676809412503736055024831947764816
>> 364271468736556969278770082094479755742047182133579963622363
>> 626612334257709776896.00
>>
>> AICc =
>> 13946624442502072331894900655091004725296483
>> 501900693696871108151068392676809412503736055024831947764816
>> 364271468736556969278770082094479755742047182133579963622363
>> 626612334257709776896.00
>>
>> free parameters = 1
>>
>>
>> Convergence diagnostics:
>>
>> optimization iterations = 100
>>
>> failed iterations = 0
>>
>> frequency of best fit = 1.00
>>
>>
>>  object summary:
>>
>> 'lik' -- likelihood function
>>
>> 'bnd' -- bounds for likelihood search
>>
>> 'res' -- optimization iteration summary
>>
>> 'opt' -- maximum likelihood parameter estimates
>>
>> ARD
>>>
>>
>> GEIGER-fitted comparative model of discrete data
>>
>>  fitted Q matrix:
>>
>> aabb
>>
>> aa  -3.629411e-149  3.629411e-149
>>
>> bb  3.629411e-149  -3.629411e-149
>>
>>
>>  model summary:
>>
>> log-likelihood =
>> -6973312221251036165947450327545502362648241
>> 750950346848435554075534196338404706251868027512415973882408
>> 182135734368278484639385041047239877871023591066789981811181
>> 813306167128854888448.00
>>
>> AIC =
>> 13946624442502072331894900655091004725296483
>> 501900693696871108151068392676809412503736055024831947764816
>> 364271468736556969278770082094479755742047182133579963622363
>> 626612334257709776896.00
>>
>> AICc =
>> 13946624442502072331894900655091004725296483
>> 501900693696871108151068392676809412503736055024831947764816
>> 364271468736556969278770082094479755742047182133579963622363
>> 626612334257709776896.00
>>
>> free parameters = 2
>>
>>
>> Convergence diagnostics:
>>
>> optimization iterations = 100
>>
>> failed iterations = 0
>>
>> frequency of best fit = 1.00
>>
>>
>>  object summary:
>>
>> 'lik' -- likelihood function
>>
>> 'bnd' -- bounds for likelihood search
>>
>> 'res' -- optimization iteration summary
>>
>> 'opt' -- maximum likelihood parameter estimates
>>
>> ER$opt$aicc
>>>
>>
>> [1] 2e+200
>>
>> ARD$opt$aicc
>>>
>>
>> [1] 

Re: [R-sig-phylo] fitDiscrete question - super large likelihood and AIC values

2016-09-10 Thread Liam J. Revell

Hi Lei.

Looks like an error. The likelihood is actually a very *small* number as 
the log-likelihood is a very *large* negative number. Similarly, the 
fitted transition rates are very small - near zero.


Have you tried to fit the same model using ace in the ape package or 
fitMk in phytools? (These are not totally independent implementations, 
actually, as fitMk borrows some of its code from ace, but nonetheless.) 
These functions should usually result in almost the same fitted model 
and likelihood values as fitDiscrete, but make slightly different 
assumptions about the root state: 
http://blog.phytools.org/2015/09/the-difference-between-different.html. 
You can also fit an Mk model using diversitree or phangorn. (Look for 
details on my blog.)


All the best, Liam

Liam J. Revell, Associate Professor of Biology
University of Massachusetts Boston
web: http://faculty.umb.edu/liam.revell/
email: liam.rev...@umb.edu
blog: http://blog.phytools.org

On 9/10/2016 2:00 PM, Lei Yang wrote:

Dear All,

I am learning to use fitDiscrete in geiger recently. Results on several
discrete characters look normal except for the following one. Can someone
please tell me why the values of log-likelihood, AIC, and AICc are so
large? Thanks a lot.



ER<-fitDiscrete(tree, aabb, model="ER")



ARD<-fitDiscrete(tree, aabb, model="ARD")



ER


GEIGER-fitted comparative model of discrete data

 fitted Q matrix:

   aa  bb

aa  -5.915287  5.915287

bb   5.915287 -5.915287


 model summary:

log-likelihood =
-6973312221251036165947450327545502362648241750950346848435554075534196338404706251868027512415973882408182135734368278484639385041047239877871023591066789981811181813306167128854888448.00

AIC =
13946624442502072331894900655091004725296483501900693696871108151068392676809412503736055024831947764816364271468736556969278770082094479755742047182133579963622363626612334257709776896.00

AICc =
13946624442502072331894900655091004725296483501900693696871108151068392676809412503736055024831947764816364271468736556969278770082094479755742047182133579963622363626612334257709776896.00

free parameters = 1


Convergence diagnostics:

optimization iterations = 100

failed iterations = 0

frequency of best fit = 1.00


 object summary:

'lik' -- likelihood function

'bnd' -- bounds for likelihood search

'res' -- optimization iteration summary

'opt' -- maximum likelihood parameter estimates


ARD


GEIGER-fitted comparative model of discrete data

 fitted Q matrix:

aabb

aa  -3.629411e-149  3.629411e-149

bb  3.629411e-149  -3.629411e-149


 model summary:

log-likelihood =
-6973312221251036165947450327545502362648241750950346848435554075534196338404706251868027512415973882408182135734368278484639385041047239877871023591066789981811181813306167128854888448.00

AIC =
13946624442502072331894900655091004725296483501900693696871108151068392676809412503736055024831947764816364271468736556969278770082094479755742047182133579963622363626612334257709776896.00

AICc =
13946624442502072331894900655091004725296483501900693696871108151068392676809412503736055024831947764816364271468736556969278770082094479755742047182133579963622363626612334257709776896.00

free parameters = 2


Convergence diagnostics:

optimization iterations = 100

failed iterations = 0

frequency of best fit = 1.00


 object summary:

'lik' -- likelihood function

'bnd' -- bounds for likelihood search

'res' -- optimization iteration summary

'opt' -- maximum likelihood parameter estimates


ER$opt$aicc


[1] 2e+200


ARD$opt$aicc


[1] 2e+200



Sincerely, Lei

[[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/