calc_loglike_for_optim: Take model parameters and the data and calculate the...

Description Usage Arguments Value Note Author(s) References See Also Examples

View source: R/BioGeoBEARS_univ_model_v1.R

Description

This function is an input to optim or optimx, the ML estimation routines.

Usage

1
2
3
4
5
6
  calc_loglike_for_optim(params, BioGeoBEARS_run_object,
    phy, tip_condlikes_of_data_on_each_state,
    print_optim = TRUE, areas_list = areas_list,
    states_list = states_list, force_sparse = force_sparse,
    cluster_already_open = cluster_already_open,
    return_what = "loglike", calc_ancprobs = FALSE)

Arguments

params

A vector of parameters for optimization.

BioGeoBEARS_run_object

Object containing the run parameters and the model.

phy

An ape tree object

tip_condlikes_of_data_on_each_state

A numeric matrix with rows representing tips, and columns representing states/geographic ranges. The cells give the likelihood of the observation data under the assumption that the tip has that state; typically this means that the known geographic range gets a '1' and all other states get a 0.

force_sparse

Should sparse matrix exponentiation be used?

print_optim

If TRUE (default), print the optimization steps as ML estimation progresses.

areas_list

A list of the desired area names/abbreviations/letters (?).

states_list

A list of the possible states/geographic ranges, in 0-based index form.

cluster_already_open

If the user wants to distribute the matrix exponentiation calculations from all the branches across a number of processors/nodes on a cluster, specify the cluster here. E.g. cluster_already_open = makeCluster(rep("localhost",num_cores_to_use), type = "SOCK"). Note: this will work on most platforms, including Macs running R from command line, but will NOT work on Macs running the R GUI R.app, because parallel processing functions like MakeCluster from e.g. library(parallel) for some reason crash R.app. The program runs a check for R.app and will just run on 1 node if found.

return_what

What should be returned to the user? Options are "loglike" (the log-likelihood of the data under the tree, model, and model parameters), "nodelikes" (the scaled conditional likelihoods at the nodes), "rootprobs" (the relative probability of the geographic ranges/states at the root), or "all" (all of the above in a list). Typically the user will only want to return "loglike" while doing ML optimization, but then return "all" once the ML parameter values have been found.

calc_ancprobs

Just use this function once, return the anc probs of states.

Value

ttl_loglike The log-likelihood of the data under the input model and parameters.

Note

Go BEARS!

Author(s)

Nicholas J. Matzke matzke@berkeley.edu

References

http://phylo.wikidot.com/matzke-2013-international-biogeography-society-poster

Matzke_2012_IBS

See Also

prune_states_list

Examples

1
test=1

Example output

Loading required package: rexpokit
Loading required package: SparseM

Attaching package: 'SparseM'

The following object is masked from 'package:base':

    backsolve

Loading required package: Rcpp
Loading required package: cladoRcpp
Loading required package: ape
Loading required package: phylobase

Attaching package: 'phylobase'

The following object is masked from 'package:ape':

    edges

BioGeoBEARS documentation built on May 29, 2017, 8:36 p.m.