2013-06-13 Rich FitzJohn * For current changes, see github page. 2012-03-26 Rich FitzJohn * R/model-mkn-multitrait.R, R/model-musse-multitrait.R: restore 'pars.only' argument to multitrait function, as this is useful for priors. 2012-03-25 Rich FitzJohn * R/check.R: Negative branch length check was being skipped. * R/diversitree-branches.R: More safety checking for ultrametric trees, in preparation of allowing eventual non-ultrametric trees for more models. * R/model-bm-direct.R: Clarify branches calculations. * R/plot-alt-extra.R: add drop=TRUE to prevent de-dataframing. * R/profiles-plot.R: More automation (legends, argument names, and opacity). 2012-03-23 Rich FitzJohn * R/check.R: typo in check.scalar(), more informative error in check.loaded.symbol(). * R/cvodes.R: function 'cvodes.headers()' to generate appropriate headers for using cvodes-based integrators. * R/deSolve.R: Function arguments were transposed! Plus pure-R ode generation. * R/diversitree-branches.R: Support for pure-R odes (replacing make.branches.lsoda and all.branches.lsoda). Simplify argument list for dt.tips.grouped(). * R/model-bd-ode.R, R/model-mkn-ode.R, R/model-musse-multitrait.R: use new dt.tips.grouped(). 2012-03-22 Rich FitzJohn * Too many files to list: huge rewrite of most behind the scenes stuff. New VCV based OU calculations. 2012-03-15 Rich FitzJohn * R/asr-musse.R: Updates so that time-varying musse models are possible. * R/check.R: Fix handling of clade.trees in bd models. * R/model-bd-ode.R: Reorder error checking * R/model-bd.R: Give up on special yule model ML treatment * R/model-musse-t.R: Improve logic around parameter checking -- avoid checking constant parameters twice, check time varying ones. * R/sim-character.R: Unfortunately, this was broken on release. Fixed now. * Updates so that diversitree compiles and passes check on CRAN. 2012-03-13 Rich FitzJohn * R/model-bd*.R: Combined ode and Nee BD calculations. * DESCRIPTION: Bump to 0.9-1, add mention of Classe and BiSSE-ness * NAMESPACE: More imports * R/check.R: check.control.continuous, for checking vcv/direct switch for BM methods. * R/diversitree-branches.R: whitespace? * R/model-bisseness-unresolved.R: Added unresolved clade support for BiSSE-ness (from Sally Otto) * R/model-bisseness.R: Changes to allow unresolved clades, and other minor tweaks. * R/model-bm.R: switch to 'control' based method switching. * R/model-classe.R: Added * R/model-geosse-split.R: Updated to work with new split functions. * R/model-geosse.R: A ton of little updates to work better with new support functions. * R/model-ou.R: Added control argument, though it does nothing. * R/plot-alt-extra.R: New trait.plot() function. * R/plot-alt-util.R: New unexported "filled.arcs" function. * R/plot-alt.: Minor tweaks. * R/simulate-musse.R: Simulation support for musse.multitrait trees. * R/util.R: uniform prior was incorrect (but not in a way that would affect calculations). * man/make.bisseness.Rd: New documentation. * man/make.bm.Rd: Updated to reflect control change. * man/make.classe.Rd: New documentation * man/make.geosse.Rd: Substantial updates * man/simulate.Rd: Updates for tree.musse.multitrait * man/trait.plot.Rd: New documentation * src/bucexp.c: Remove print statements * src/classe-eqs.c: New * src/cvodes/*: Remapped printf -> Rprintf * src/geosse-eqs.c: Small tidy up * src/nuexp.f: BiSSE-ness unresolved clade calculations. 2012-02-23 Rich FitzJohn * DESCRIPTION: Bump to 0.8-4 * NAMESPACE: Updated to add bisseness * R/mcmc.R: Additional argument checking. * R/mle.R: Hardened version of anova.fit.mle that attempts to check that models are truely nested. * R/model-bd.R: find.mle.yule now returns class "fit.mle.bd" so that it is clear that it can be compared against a bd fit. * R/model-bisseness.R: Added skeleton for "unresolved" branches function to clear up code. * R/simulation.R: Added "bisseness" to list of possible tree types that can be simulated. * man/find.mle.Rd: Documented additional restrictions on model comparison. * man/make.bisse.Rd: Updated returned function definition. * man/mcmc.Rd: Documented save.every/save.file arguments. * man/simulate.Rd: Documented addition of bisseness simulator. 2012-02-22 Rich FitzJohn * R/model-bisseness.R: Added the "BiSSE-ness" model from Karen and Sally. 2012-02-13 Rich FitzJohn * DESCRIPTION: Bump R dependency up, and add support for current deSolve. * R/combine.R: First import of experimental likelihood combining functions. * R/diversitree-branches.R: Simplify treatment of root node. * R/mcmc.R: Simplify mcmc function exit, and add support for saving progress to a csv file during a run. * R/model-bm-vcv.R: Fix treatment of NULL/0 meserr. * R/plot-alt-extra.R: Fix treatment of stored angles. * R/plot-alt.R: Cosmetics 2012-01-05 Rich FitzJohn * DESCRIPTION: Bump to 0.8-3 * NAMESPACE: New exports for mkn.ode, mkn.multitrait, ou, geosse.split, sim.character, and others. * R/asr-mkn.R: Adjust to the changes to mkn backends. * R/check.R: BM parameter checking, split control checking. * R/constrain.R: Constrained functions now handle additional arguments. * R/diversitree-branches-C.R: Fixed bug in cache translation for some models (was failing to run previously). * R/model-bisse-split.R: Abstract checking. * R/model-bm-direct.R: New direct BM likelihood calculation (from bbm). * R/model-bm-vcv.R: Previous BM calculation * R/model-bm.R: Now make.bm() has method argument to switch between direct and vcv. * R/model-geosse-split.R: Started adding (still unchecked). * R/model-mkn-exp.R: Prevous mkn version (matrix exponentiation) * R/model-mkn-multitrait.R: Multitrait version of the Mk model, done as for MuSSE. * R/model-mkn-ode.R: New ODE-based Mkn integrator, useful for high k. * R/model-mkn.R: Allows switching between ode and exp version. * R/model-mkn-ode.R: ODE based branch-by-branch version of the Mk model. This is needed for very large trait space where it is much more efficient to compute exp(Qt).v without storing Pij=exp(Qt) directly. * R/model-mkn.R: Allow switching backends. * R/model-musse-multitrait.R: Change mcmc defaults * R/model-musse-split.R: Abstract checking * R/model-ou.R: Branch-by-branch calculation of OU, from bbm. * R/model-quasse-common.R: Bring up to date with BM changes. * R/model-quasse-{fftC,fftR,mol}.R: Bunchn of changes to handling of badly behaved branches -- now split branches into parts if integration fails. * R/model-quasse-split.R: Now does caching branches so that only some parts of the variables may need recomputing. Will be particularly useful during MCMC and ML searches with large models. * R/plot-alt.R: Fix x/y coordinates for fan plots. * R/sim-character.R: Character simulation code. * R/simulate-musse.R: Fixed bug that caused error when empty tree was generated. * R/split.R: Changes to allow caching branches. * R/util.R: Uniform prior, and default setting function (modifies a function's formals). * man/*: Documentation updates. * src/cvodes.c: Fixed compilation-preventing bug (reported by Jos Kafer). * src/mkn-eqs.c: Required support for the ODE based Mkn model. 2011-11-03 Rich FitzJohn * R/constrain.R: Allow variables used as constraints (on the RHS) to be themselves constrained (on the LHS). 2011-10-13 Rich FitzJohn * DESCRIPTION: bump to 0.8-1 * NAMESPACE: New asr methods declared * R/asr-bisse-split.R, asr-musse-split.R: New asr methods * R/asr-bisse.R: Minor clarification in code * R/asr.R, R/model-bd-ode.R, R/model-bisse.R, R/model-geosse.R, R/model-musse.R, R/t.R, R/td.R: branches() now takes 'index' argument. Added. * R/check.R: sampling.f check was incorrect. * R/diversitree-branches.R: Added index argument to branches, and other cleanup. * R/model-bd-split.R: Cleanup * R/model-bd-t.R: unresolved and sampling.f arguments were transposed when checking, disabling sampling.f != 1. (reported by Dan Rabosky). * R/model-bisse-split.R, R/model-musse-split.R, R/model-quasse-split.R: Reworked; should be more reliable now. * R/model-quasse-common.R: Now allows different diffusion parameters. * R/model-quasse-fftC.R: Simpify away an old optimisation. * R/model-quasse.R: Minor tidyup. * R/plot-alt-extra.R, R/plot-alt-util.R: Pass additional arguments of group.label.tip.rad() to radial.text() to text() * R/split.R: Totally reworked. * R/util.R: Updated to work with deSolve 1.10-3 * configure.ac: Revert to controllable strict gcc checking (off again by default). * man/*: Assorted documentation updates. 2011-07-11 Rich FitzJohn * DESCRIPTION: bump to 0.7-6 * NAMESPACE: New "musse.multitrait" exports (see below) * R/check.R: There was an error in checking states when strict=FALSE (values were never checked to see if they were valid, as was advertised). check.unresolved.bd added (taken from make.bd, and used by make.bd.split). * R/diversitree-branches.R: Individual tip conditions added for make.branches.matrix. dt.tips.ordered() rewritten. * R/history.R: Minor tweaks * R/model-bd-split.R: Use with unresolved clades was totally broken (but failed to even run, so no harm done). * R/model-bd.R: Minor tweaks while tidying up model-bd-split.R * R/model-musse-multitrait.R: Alternative reparametrisation of MuSSE when the multistate character is really combinations of binary traits. * R/simulation.R: Simulation code was returning events in incorrect order. * man/*: minor documentation changes * src/cvodes_asr_marginal.c,mkn.c,mkn.h: Tweaks to compile under windows. 2011-06-03 Rich FitzJohn * DESCRIPTION: bump to 0.7-4 * R/asr-bisse.R: General cleanup and remove obsolete options. * R/asr-mkn.R: Cleanup, especially parameter handling and actual simulation. * R/asr-musse.R: General cleanup and remove obsolete options. Simpler parameter handling. * R/asr.R: Reimplimented asr on constrained models. General tidy up. * R/check.R: New BiSSE/MuSSE parameter checking that will end up applied to more functions over time. * R/constrain.R: Tidy up * R/diversitree-branches-C.R: Moved do.marginal.asr.C into asr.R. * R/diversitree-branches.R: Substantial simplification to all.branches.matrix(). Removed cleanup(). * R/model-bisse-split.R: Tidy to parallel model-musse-split.R * R/model-mkn.R: Cleanup, especially parameter handling. * Other files: General cleanup 2011-06-01 Rich FitzJohn * Many files: reworked internals to use matrices rather than lists where possible to simplify the ASR code. Slight efficiency gain, too. 2011-05-31 Rich FitzJohn * R/asr-mkn.R: Faster joint and stochastic reconstructions through the new C code; (still optional) * R/asr.R: Faster joint reconstructions through the new C code; (still optional) * R/diversitree-branches.R: Prepping for big change * R/mcmc.R: Additional ... arguments being passed to prior with poor effects. * R/model-mkn.R: No longer ever return lists as intermediate output. * R/util.R: Temporary fix for older R versions 2011-05-12 Rich FitzJohn * DESCRIPTION: Bump to 0.7-2 * NAMESPACE: Actually export the make.asr.marginal functions * R/asr-bisse.R, R/asr-musse.R: Tidy up, and enable CVODES to be used for the ASR. * R/check.R;R/cvodes.R: check to see if we have CVODES support before trying to use it. * R/diversitree-branches-C.R: Expose toC.int(). New do asr.marginal.C(), for doing faster ASR. * configure.ac: Changes to detect CVODES presence. * configure.win: Disable CVODES. * src/cvodes*: Check to see if CVODES enabled (WITH_CVODES) * src/cvodes/cvodes_lapack.c: Minor fix to align with R's Lapack * src/sundials_config.h: Disable unused sections * src/.../sundials_lapack.h: Remove F77 cludging and use R's Lapack 2011-05-11 Rich FitzJohn * DESCRIPTION: Bump version number to 0.7-1, and require deSolve >= 1.7. * NAMESPACE: New make.asr.* functions around the different asr functions (more changes to ASR code coming soon) * README;cvodes-notes.txt: Information about CVODES * configure.ac;configure.win;cleanup: Copy/delete CVODES files when building and cleaning up. Strict GCC checks now enabled whenever configure detects GCC is being used. * R/asr-bisse.R;R/asr-mkn.R;R/asr-musse.R: More flexible root treatment now possible. * R/asr.R: New make.asr.* functions around the different asr functions (more changes to ASR code coming soon). Switch internal data from list to matrix. * R/check.R: New check.control.ode() function for testing the ODE tuning parameters. check.scalar() for checking things are length 1. * R/cvodes.R;R/diversitree-branches-C.R: Support for the new CVODES integrator. * R/diversitree-branches.R: ROOT.EQUI was only using the stationary frequency of state 0 (thanks to Gregory Imholte for reporting). New function make.ode.branches(), which is the preferred way of making branches functions. Allows switching between the deSolve and CVODES integrators. * R/model-bd-*.R;R/model-bisse*;R/model-geosse.R;R/model-musse*: New CVODES integrator and branches interface added. * R/t.R: make.ode.branches.t() is the new preferred way of making time-dependent branches functions. * R/util.R: Massive cleanup of the make.ode function. Will not fail when using unknown deSolve, but will fall back on safe version with a warning. Support for deSolve < 1.7 removed, and support for deSolve 1.10 confirmed. * inst/include: CVODES header files that are needed for making CVODES based models. * man/*: Documentation updates. * src/Makevars.in;src/Makevars.win: New include flags needed for CVODES * src/bd-eqs.c;src/bisse-eqs.c;src/geosse-eqs.c;src/musse-eqs.c: Support for CVODES models added. * src/cvodes: Almost entirely unmodified CVODES package. * src/cvodes_*: Wrapper around CVODES. 2011-04-20 Rich FitzJohn * NAMESPACE: new ROOT.MAX constant for maximising the root state probability * R/check.R: Simple support for multistate/polymorphic tip states. Slightly improved "almost-integer" checking. * R/mle.R: Additional arguments not being passed through to hessian calculations. * R/model-bisse-split.R: Work around corner case. * R/model-bm.R: Check on parameter length. Don't require an ultrametric tree. Measurement error handling was slightly off. * R/model-musse.R: Simple support for multistate/polymorphic tip states. * man/constants.Rd: Added ROOT.MAX * man/make.quasse.Rd: Update correct likelihood numbers. Disable fftR run, as it is far too slow. 2011-03-17 Rich FitzJohn * data/geosse.R: Remove save=TRUE argument from require() (defunct in R 2.13). 2011-03-14 Rich FitzJohn * DESCRIPTION: Version bump to 0.6-4 2011-03-11 Rich FitzJohn * NAMESPACE: Added start of mkn-with-derivatives. * R/check.R: Check for negative branch lengths in trees. * R/diversitree-branches.R: Better treatment of root when one lambda value is zero (*Will change calculations*) * R/model-{bd-ode,bd-t,bisse-split,bisse-t,bisse-td,bisse, geosse,musse-split,musse,musse-t,musse-td,musse}.R (and associated documentation): Replaced safe=FALSE argument with control list that also allows controlling precision of integration and quality of results. * R/mcmc-hmc.R: Hamiltonian (Hybrid) Monte Carlo sampler. Not yet wired up to work with mcmc(). * R/model-linear-deriv.R, man/make.mkn.deriv.Rd, src/linear-deriv.{c,h}: Preliminary code for mkn-with-derivatives * src/util-complex.{c,h}, src/util-linalg.c, src/util-matrix.{c,h}: Utilities for mkn-with-derivatives. 2011-02-18 Rich FitzJohn * R/mcmc.R: Removed check.par() from mcmc(). Changed order of arguments for mcmc.lowerzero() to avoid an odd argument matching bug. * R/mle-mixed.R: Extra effort for QuaSSE models. * R/model-quasse-split.R: Standardise attribute names * R/util.R: Added count.eval(), added interval=0 support to big.brother() * man/asr-bisse.Rd, man/asr-mkn.Rd: Fixed examples 2011-01-26 Rich FitzJohn * DESCRIPTION: Bumped to 0.6-3 * R/asr-musse.R: Added marginal ASR for MuSSE models * R/model-geosse.R: Improved starting point function from Emma. * R/model-musse.R, R/model-mkn.R: Support for models with >9 states (preventing duplicated argument names). * R/util.R: deSolve 1.9 OK * configure.win, src/Makevars.win, src/config.h.win: Hopefully fixed windows build. 2010-10-25 Rich FitzJohn * R/check.R: No longer check node labels by default (duplicates are not a problem for non-split methods). * R/model-quasse-mol.R, R/model-quasse-common.R, R/model-quasse.R: Methods-of-lines integration now works, albeit slowly. * R/util.R: deSolve 1.8.1 OK * cleanup: added * configure.win, src/Makevars.win: Hopefully build on windows (untested). 2010-10-21 Rich FitzJohn * many: Added GeoSSE to the package. 2010-10-20 Rich FitzJohn * many: Added QuaSSE to the package, including the configure build system. 2010-10-14 Rich FitzJohn * NAMESPACE: new exports from below * R/model-bd-ode.R: New ODE based version of the BD model; this is really here for completeness and testing against the ODE based BD extensions. * R/model-bd-split.R: Removed find.mle method; inherits bd method now. * R/model-bd-t.R, R/model-bisse-t.R, R/model-musse-t.R: New time-dependent models, where parameters are arbitrary functions of time. * R/model-bisse.R: Avoid warning when making bisse likelihood function when all tips represent unresolved clades (thanks: Hanno Schaefer for finding bug). Internal C function names have standardised now. * R/t.R: Support functions for time-dependent models. * man/make.bd.R: Documentation for make.bd.ode() * man/make.bd.split.R: Improve example * man/make.bd.t.Rd, man/make.bisse.td.Rd, man/make/musse.td.Rd, man/time.Rd: Add new time-varying functions to the help. * man/mcmc.Rd: Small improvements in the help. * src/bd-eqs.c: New file for ODE based BD model * src/bisse-eqs.c: Standardised function names, and abstracted derivative calculation from plain BiSSE, added time-dependent derivative calculation. * src/mkn.c: Moved matrix multiplication code into util.c * src/musse.c: Abstracted plain MuSSE calculation, removed matrix multiplication, added time-dependent derivative calculation. * src/util.{ch}: Utility matrix multiplication helpers. 2010-09-23 Rich FitzJohn * NAMESPACE: new exports from below * R/check.R: Improved logic of states checking for clade trees. * R/clade.tree.R: make.unresolved() -> make.unresolved.bisse(), plus similar function for bd models. Fixed an old bug, for where clade trees do not include clades for *every* tip. * R/mcmc.R: Added mcmc.lowerzero(), which is just passes through to mcmc.default() with lower=0. This is used as the mcmc method for all the likelihood models. * R/model-bd-split.R: bd.split models now inherit from "bd". * R/model-bd.R: Allow clade trees when making bd models. 2010-09-22 Rich FitzJohn * DESCRIPTION: Bumped version number to 0.5-3, which will be released soon. Also updated the description, and added "Suggests" dependencies on multicore and tgp. * NAMESPACE: New exports for the musse.split, musse.td models, and generic mcmc. * R/check.R: New check.par.length() for doing simple recycling. Simplified check.sampling.f() to use this. Added check.sampling.f.split(), check.bounds(), check.par.multipart(). * R/diversitree-branches.R: More defensive node depth/height calculations when building cache. * R/mcmc.R, R/mcmc-norm.R, R/mcmc-slice.R: New generic mcmc function. Default method allows different MCMC samplers. Slice sampling removed (added to R/mcmc-slice.R), and demonstration univariate Gaussian sampler added. In mcmc(), 'lower', 'upper', and 'w' can be passed in as scalars now. * R/mle-tgp.R: New find.mle interface to the tgp statistical optimiser (currently experimental and unadvertised). * R/mle.R: Added support for tgp (see above). Simplified things with new R/check.R support. * R/model-bisse-split.R: BiSSE/split functions now inherit from 'bisse'. argnames.bisse.split() simplified. find.mle.bisse.split() no longer required. * R/model-bisse-td.R: Added 'safe' argument to make.bisse.td(). Changed argument order. Use check.par.multpart() to tidy likelihood function. Simplify argnames.bisse.td(). Remved find.mle.bisse.td(). * R/model-bisse.R: Switched 'safe' and 'strict' arguments for consistency (should affect few users, as these should not really be used positionally). * R/model-musse-split.R, R/model-musse-td.R: Added new models. * R/model-musse.R: Added 'safe' argument. Other minor changes. * R/split.R: split.t can now be a scalar if '0' or 'Inf'. * R/util.R: Added support for deSolve version 1.8. Added make.prior.ExpBeta() (unadvertised, unexported), which gives an alternative parametrisation of bisse models. Other support functions added. * man/make.bd.split.Rd, man/make.bisse.td.Rd, man/make.musse.split.Rd, man/make.musse.td.Rd: new documentation files * man/mcmc.Rd: Substantial rewrite to reflect new MCMC approach. * man/make.bisse.Rd, man/make.musse.Rd: Minor cleanups 2010-08-12 Rich FitzJohn * DESCRIPTION: Bumped version number to 0.5-2 * R/model-bd-split.R: make.bd.split has new default for split.t, copying MEDUSA's default behaviour. * R/split.R: Fixed bug in negative branch check. * src/bucexp.f, src/dmexpv.f, src/dsexpv.f, src/dsexpvi.f, src/hyperg.f: Tidied code to remove compiler warnings. 2010-08-06 Rich FitzJohn * R/model-bd-split.R: Fixed local naming error (phy->tree). * man/argnames.Rd: Example was broken with strict character checking. * man/make.bisse.Rd: Document strict character checking. 2010-07-27 Rich FitzJohn * NAMESPACE, R/model-bd-split.R: New bd.split model * R/split.R: Improved handling of times around splits. * R/split-recycle.R: Removed. 2010-07-20 Rich FitzJohn * R/model-bisse-split.R, R/split.R: Removed the recycling code. * NAMESPACE: New exports for the BiSSE/td model. * R/check.R: Strengthened state checking. * R/diversitree-branches.R: Renamed xxsse.ll -> ll.xxsse * R/model-bisse-split.R: Now includes parameter recycling. * R/model-bisse-td.R: New model * R/model-bisse.R, R/model-musse.R: Strict state checking, other minor changes. * R/split.R, R/split-recycle.R: Bulk of the parameter recycling code. * R/td.R: New time dependent code 2010-06-23 Rich FitzJohn * R/diversitree-branches.R: Many changes to all.branches to remove handling of unresolved clades, and to move the internal data structures to be lists (rather than matrices). New function dt.tips.ordered for helping make initial conditions in the format we now expect. * R/mcmc.R: MCMC now returns samples if run to completion (oops) * R/model-bisse-split.R: Now makes its own branches.aux(), changes to unresolved clade handling, new list structure, and using the generic all.branches.split in R/split.R * R/model-bisse.R: Changed handling of unresolved clades, given above changes. Changed initial condition format. * R/model-mkn-legacy.R: Removed as I doubt that it is accurate at all now. * R/model-mkn.R: Removed unresolved clades, updated to list structure. * R/model-musse.R: Removed unresolved clades, updated to list structure, new initial conditions. * R/split.R: New generic all.branches.split() and make.cache.split() functions. * R/util.R: matrix.to.list() - convert matrix rows to list elements. * R/check.R: Moved check.unresolved into R/model-bisse.R * R/asr.R, R/asr-bisse.R, R/asr-mkn.R: Changed handling of unresolved clades, given above changes. R/asr.R is also updated to the new list data structures. * man/*.Rd: Sundry documentation changes. * R/model-mkn-legacy.R: check in before removal. 2010-06-14 Rich FitzJohn * R/constrain.R: Better constraining of constrained functions. * R/history.R: Fix plot.history to better return an ape-compatible state. * R/mcmc.R: MCMC now allows interrupt part-way through a chain, and returns all completed points so far. * R/make.bisse.split.R: Tweaks to fix argument handling. * R/model-bisse.R: subplex is now the default ML search algorithm. * R/make-bm.R: Clean up pre-diversitree code. * R/model-musse.R: subplex is now the default ML search algorithm. Better checking to make sure that expected states are present. * R/profiles-plot.R: Work around for extremely thin CIs * R/simulation.R: musse trees available to 'trees()'. * R/split.R: Catch an edge case of root node type. * R/util.R: mrca.tipset() now accepts character vector of tip names. * man/constrain.Rd: Updated to reflect constraining constrained functions being allowed. * man/make.bisse.Rd: Removed prior argument from returned function description. * man/make.bisse.split.Rd: New help file. * man/make.bm.R: New help file * man/make.musse.Rd: Added starting.point.musse(), clarified example. * man/mcmc.Rd: MCMC interrupt documentation, new prior requirements. * man/simulate.Rd: Added Musse abilities. 2010-05-31 Rich FitzJohn * NAMESPACE: Added functions for the changes included in this changeset. * DESCRIPTION: bumped version number to 0.5-1, as this version will have quite a few new features. * R/clade-tree.R: New function clades.from.classification(), that builds a clade tree by using a higher-level classification of tips. Renamed polytomies.to.clades() -> clades.from.polytomies() for consistency. * R/clade-tree-plot.R: Removed - now uses alternative plotting in R/plot-alt.R. Methods for control have been added to R/clade-tree.R. * R/history.R: Minor changes to cope with changes to the alternative plotting interface. * R/mcmc.R: Changes to move the prior control within MCMC. * R/mle.R: Added box constraints for subplex (not done "properly", but through disallowing any value outside of the constraints). * R/model-bd.R: Moved to new checking functions in R/check.R, using the "prior" argument to bd likelihood functions is now an error. * R/model-bisse.R: nt.extra was not being passed through correctly. Moved to new checking functions, and added error for use of "prior" argument to likelihood function. * R/model-bm.R: Added to the package * R/model-mkn-legacy.R: Added error for use of "prior" argument to likelihood function. * R/model-mkn.R: Moved to new checking functions, and added error for use of "prior" argument to likelihood function. * R/model-musse.R: Added to the package. * R/plot-alt.R, R/plot-alt-util.R, R/plot-alt-extra.R: Completely reworked. Now works for type="fan". * R/simulate-musse.R: Added to the package * R/split.R, R/model-bisse-split.R: Functions for partitioned, MEDUSA-style, calculations, including the BiSSE method. * R/util.R: New functions boxconstrain(), descendants(), mrca.tipset(), and branching.heights() (none are exported). * src/musse-eqs.c: Added to the package * man/make.bd.Rd: Fixed typo in example * man/make.clade.tree.Rd: Added documentation for clades.from.classification(), though this is preliminary, and no examples are given. * man/make.musse.Rd: Added * man/tree.musse.Rd: Added 2010-03-25 Rich FitzJohn * DESCRIPTION: bumped version number (did I miss checking in 0.4-5?) * R/asr-mkn.R: Pass additional arguments through to underlying likelihood calculations. * R/model-bd.R: Some warnings for the Yule function with sampling and unresolved clades. Fixed a couple of bugs (e.g., use of phy rather than tree leading to unbound variables). Check parameter number and give a nice error if the wrong number are given. Corrected formula for bd likelihood under sampking where survival is not conditioned on. * R/profiles-plot.R: Overhaul that should perform much better on distributions whose density does not tend to zero as x->infty. Also now the shading lines up properly with the confidence intervals. * man/make.bd.Rd, man/make.bisse.Rd: Documentation improvements. 2010-03-02 Rich FitzJohn * R/model-bd.R: Fix for lambda=mu (not pretty, but should work in the short term). * R/mle.R: Reverted previous change (gives error when starting point invalid) as the handling of '...' needs fixing. * R/model-bd.R: Added support for sampled trees and trees with unresolved clades. * R/model-bisse.R: Minor logical tweaks in make.cache checking code. * R/simulate-bd.R: Don't create final species when making a tree with fixed number of species (simulate to n+1 and trim the final species). * man/make.bisse.Rd: More examples, showing that BiSSE reduces to Mk2 and the birth-death model under certain conditions. This is also shown for the case of sampled trees and unresolved clades, and acts as a good test case that everything is working correctly. * src/bucexp.f: Likelihoods were incorrectly calculated for clades with no known states. 2010-02-23 Rich FitzJohn * R/asr*.R: Finished fix of the asr code. * R/constrain.R: More informative error message when parameters of wrong length. * R/mle.R: find.mle gives error when starting point invalid. * R/model-bisse.R, R/model-mkn.R: Give informative error message when given invalid tree object (e.g. NULL) and likelihood calculations give informative message when given wrong length parameters. * R/zzz.R: no longer needed - removed. * DESCRIPTION: Depend on at least deSolve 1.5, so that correct behaviour can be guaranteed. * R/asr*.R: Half way through a fix of the asr code, particulary for root states. * R/diversitree-branches.R: root.xxsse() now takes root.p argument, computed through the new function root.p.xxssse(). This allows reuse of that function elsewhere. Changes to xxsse.ll to reflect this. * R/model-bd.R: Added extra check in the bd likelihood (mu/lambda where both were zero causing a to be NaN). Fixed handling of prior (was ignored before!). * R/model-bisse.R: Fixed initial conditions (should not avoid multiplying by lambda at the root (e.g. cases where lambda_i is zero for some i); this now happens at the root (within root.xxsse). * R/model-mkn.R: Changed root handling to follow bisse (separating calculation of the root probabilities from the root calculation). Added the Mk2 equilibrium frequency for root calculations. * R/simulate-bisse.R: make.tree.bisse.C.core now has verbose argument. Fixed crash where rates of character evolution were fast relative to speciation; the history matrix could overflow. This fix requires tracking the number of history entries. * R/util.R: make.ode: Updated to deal with deSolve-1.7 (new elag argument). * man/asr-mkn.Rd, man/make.bd.Rd, man/make.mkn.Rd: Minor changes * src/simulate-bisse.c: Changes to simulate_bisse() (and corresponding changes in wrapper code) to deal with the history overflow bug. 2010-02-02 Rich FitzJohn * DESCRIPTION: Bumped version number to 0.4-4 * R/asr-mkn.R: Fixed bug in use of make.history() (relied on a 'phy' object in .GlobalEnv) * R/history.R: Check on trees is optional (required for above bug fix) * R/make.mkn.R: Change default of make.mkn's use.mk2 argument to FALSE so that results are numerically more consistent, if a little slower. * R/simulate-bisse.R: Swap bisse.stationary.freq -> stationary.freq.bisse * R/simulation.R: prune() throwing error on single species trees; now gives up. * man/asr-bisse.Rd, man/asr-mn.Rd, man/make.mkn.Rd, man/asr.Rd: minor documentation fixes/improvements. 2010-01-28 Rich FitzJohn * man/asr-bisse.Rd: Added BiSSE/Mk2 equivalency section to help page. 2010-01-27 Rich FitzJohn * NAMESPACE: Updated to reflect changes below * R/asr-bisse.R: Added marginal ASR under BiSSE to diversitree. * R/asr-mkn.R: Marginal ASR under Mk2/Mkn now works again, plus various changes and bug fixes. Works as it should now. * R/asr.R: do.asr.marginal no longer runs all.branches(), and expects this passed in. This helps with the mk2 code. Margnal asr now takes correct node numbers (I think). * R/diversitree-branches.R (make.prior.exponential): Normalise the exponential prior, for use with computing Bayes factors, etc., following suggestion from Emma Goldberg. * R/history.R: Wimp out from summarising multiple histories. * R/model-mkn-legacy.R: Tidy out some commented out code, and adding old asr.marginal.mkn.old function. * R/model-mkn.R: New versions of the mk2 & mkn asr functions that use the new mk2/mkn likelihood functions (forgot to add yesterday). * R/plot-alt.R: plot functions pass ... through to plot() * man/asr-bisse.Rd: New documentation * man/asr-mkn.Rd: New documentation 2010-01-26 Rich FitzJohn * R/asr.R: New asr generics * R/asr-mkn.R: New versions of the mk2 & mkn asr functions that use the new mk2/mkn likelihood functions (see below). * R/mcmc.R: Check that 'w' is correct length. * R/model-bisse.R: Add check for largest unresolved clade (200 spp), preventing possible crash. * R/model-mkn-legacy.R: Old Mk2 code that uses all.branches(); preserved for the next version or so. * R/model-mkn.R: New Mk2/Mkn model that is about 20-50 times faster than the old version (does all branches at once). * man/make.mkn.R: Small fix to reflect new version * src/mkn.c: C code required for new mkn/mk2 code. 2010-01-21 Rich FitzJohn * R/clade-tree.R: Was totally broken due to overloading of "ancestors2" function. Also fixed bug when there is exactly one polytomy and replaced drop.tip and drop.tip.fixed. * R/diversitree-branches.R (make.cache): Return "edge" and "edge.length" as part of the cache object. * R/model-bisse.R: Bug in branches.unresolved.bisse due to missing drop=FALSE fixed. Also suppress warnings when finding a BiSSE starting point, as these are not interesting. 2010-01-19 Rich FitzJohn * DESCRIPTION: updated to version 0.4-3 * R/constrain.R: Now allows "extra" variables to be specified, allowing constraint against dummy parameters. New "update" method for removing constraints (adding constraints will come soon). constrained functions now have attribute "func" containing the original unconstrained function. * R/diversitree-branches.R: New check for appropriate length for root.p. * R/mcmc.R: Better handling of fail values. * R/mle.R: coef.fit.mle for constrained models can now return coefficients for the underlying full model (with full=TRUE). * R/model-bd.R: New starting.point.bd function * R/model-bisse.R: starting.point.bisse uses starting.point.bd * R/util.R: protect() now takes a default value for failure. 2010-01-14 Rich FitzJohn * DESCRIPTION: Now depends on subplex * NAMESPACE: export new methods for fit.mle objects (coef and extractAIC), plus constants ROOT.* * R/clade-tree-plot.R: Fixed (was broken after importing plot2.R). Now uses node.depth and node.depth.edgelength from plot2.R, but uses different version of node.height that allows for the number of taxa represented at a tip to affect spacing. * R/constrain.R (constrain): now allows 'formulae' object including a list of constraints. * R/mcmc.R: Removed partially-implemented options for functions that do not return proper log-likelihoods. * R/mle.R: Optional supression of warnings when guessing a constrained starting position. New extractAIC.fit.mle method. Option for (mostly unchecked) sequential likelihood ratio tests for sequentially nested models. * R/model-bd.R (make.yule): Cannot (yet) use a prior with the Yule model: warning added. * R/model-bisse.R (starting.point.bisse): Improved to start the search from a yule model first, removing the need to include a starting point. * R/model-mkn.R: make.mkn() was broken (did not pass k through to make.cache.mkn()). argnames.mkn() now takes optional 'k' argument for generating argument names manually (may change in future). * R/profiles-plot.R (profiles.plot): Number of breaks in a plot now tunable in argument. * R/util.R (make.ode): Now compatible with deSolve-1.6. * man/make.bisse.Rd: typo * man/simulate.Rd: small clarifications. 2010-01-05 Rich FitzJohn * R/simulate-bisse.R (make.tree.bisse): Fixed creation of empty history objects. * R/history.R (plot.history.coords): Fixed plotting history objects where nothing happened. * R/simulation.R (prune.hist): Fix for history plotting where changes occur along a branch leading to the reconstructed root when the branch is erased by extinction. * R/mle.R: Moved do.mle.search around to make file easier to navigate. New coef.fit.mle method for extracting parameters from ML fits. * R/model-bd.R: Renamed bd.ll -> ll.bd for consistency with other functions. * R/model-bisse.R: Reordered arguments of ll.bisse to match those of ll.xxsse. 2010-01-04 Rich FitzJohn * R/model-bisse.R (branches.unresolved.bisse): Switch log-compensation to the sum of variables (rather than minimum of variables) to avoid a crash on Linux (stack smashing) and an excessive number of warnings on other platforms. * R/model-bisse.R (make.branches.bisse): make.ode for the branch integration is now done during make.bisse. Added new "safe" argument to make.bisse that selects how this should be done. Eventually all lsoda based likelihood functions will get a "safe" argument. * man/make.bisse.Rd: Added "safe" argument. * R/zzz.R: Removed .onLoad function; no longer needed with make.ode moved inside of make.bisse. * R/util.R (make.ode): Updated make.ode to work with deSolve version 1.6 (two new additional arguments). The "safe" version now returns same data format as the unsafe version. * R/model-mkn.R (argnames.mk2): Fixed logic around argument names for mk2 and two-state mkn (latter now returns q12, q21) * R/simulate-bd.R (tree.yule): New Yule tree simulation function that uses the existing tree.bd with mu = 0. Required changes also to R/simulation.R and man/simulation.Rd. * R/mle.R, R/mcmc.R and all likeihood functions: Shifted protect() from within every likelihood functions into the new mle interface and MCMC functions directly. This removes significant code duplication, simplifies creation of new likelihood functions, and means we can always depend on fail.value existing. * R/model-bd.R (find.mle.yule): Added support for Yule models. These are nice as the ML parameters are findable analytically. 2009-12-21 Rich FitzJohn * Too many little changes to list * R/plot-alt.R: New plotting functions, partially duplicating ape's plot function to allow stochastic character map type plots to be drawn. I am attempting to retain as much compatibility with ape as possible and only using these commands within high-level plots. * R/history.R: Functions for storing and plotting phylogenetic histories. The simulation code now stores exactly when changes occured and can plot the full character history. * R/find.mle.R: Continuing to revamp the find.mle code. Different back ends now abstracted (though new ones cannot be added without recompiling the package). Further changes coming though. * R/model-mkn.R: Uses the general log-compensation feature now. * R/util.R: New function discretize, which is useful for binning continuous characters into discrete characters (possibly for making colour codes). Probably will change soon. * man/plot.history.Rd: Documentation for histories 2009-12-02 Rich FitzJohn * R/simulation.R (tree.bisse): Fix to tree simulation code to store node states. This requires fix to ape's drop.tip function. 2009-12-01 Rich FitzJohn * R/util.R (invert): New function invert for returning the inverse of the log-likelihood. * R/model-bd.R: Simple birth-death process estimation. This does not yet allow for sampling fractions or unresolved clades, but these will be added soon. MLE routines are also included. * R/model-mkn.R: Simple Mk2/Mk-n discrete character evolution. This directly duplicates the 'ace' function in ape, but should allow some additional flexibility. * R/find.mle.R (find.mle.bisse): Removed default 'lower' specificiation as this was causing more confusion than helping anybody. Using fail.value will get around more problems, including invalid models because of invalid lower/upper. This may cause some problems where a hard lower bound is preferred to get exact solutions. 2009-11-30 Rich FitzJohn * R/mcmc.R (mcmc): Added checking that the initial position has positive probability. Also added 'verbose' flag to make MCMC searches quieter. * R/model-bisse.R (branches.bisse): Recursive algorithm to reduce the probability of numerical underflow along unlikely branches. This will overflow the stack sometimes though. * General: rewrite of the calculation functions to allow new models to be more easily developed. This may cause a slight slowdown, unfortunately. 2009-10-22 Rich FitzJohn * R/util.R (protect): Switch from trySilent to try(..., silent=TRUE) in anticipation of R 2.10's deprecation of trySilent. * R/util.R (make.ode): Fixed bug that caused integration to fail with deSolve version 1.5 (added 'flist' parameter). 2009-10-14 Rich FitzJohn * New formula-based constraint interface (through function constrain()) * Subplex available to do ML searches * Standard error estimates on ML estimates