runOptim: Calling optim a number of times

Description Usage Arguments Value

Description

Calling optim a number of times

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
RunOptim(
  X,
  tree,
  model,
  SE,
  metaI,
  positiveValueGuard,
  parLower,
  parUpper,
  matParInit,
  control = NULL,
  doParallel = FALSE,
  verbose = TRUE
)

Arguments

X

a k x N numerical matrix with possible NA and NaN entries. For i=1,..., N, the column i of X contains the measured trait values for species i (the tip with integer identifier equal to i in tree). Missing values can be either not-available (NA) or not existing (NaN). These two values are treated differently when calculating likelihoods (see PCMPresentCoordinates).

tree

a phylo object with N tips.

model

an S3 object specifying both, the model type (class, e.g. "OU") as well as the concrete model parameter values at which the likelihood is to be calculated (see also Details).

SE

a k x N matrix specifying the standard error for each measurement in X. Alternatively, a k x k x N cube specifying an upper triangular k x k factor of the variance covariance matrix for the measurement error for each tip i=1, ..., N. When SE is a matrix, the k x k measurement error variance matrix for a tip i is calculated as VE[, , i] <- diag(SE[, i] * SE[, i], nrow = k). When SE is a cube, the way how the measurement variance matrix for a tip i is calculated depends on the runtime option PCMBase.Transpose.Sigma_x as follows:

if getOption("PCMBase.Transpose.Sigma_x", FALSE) == FALSE (default):

VE[, , i] <- SE[, , i] %*% t(SE[, , i])

if getOption("PCMBase.Transpose.Sigma_x", FALSE) == TRUE:

VE[, , i] <- t(SE[, , i]) %*% SE[, , i]

Note that the above behavior is consistent with the treatment of the model parameters Sigma_x, Sigmae_x and Sigmaj_x, which are also specified as upper triangular factors. Default: matrix(0.0, PCMNumTraits(model), PCMTreeNumTips(tree)).

metaI

a list returned from a call to PCMInfo(X, tree, model, SE), containing meta-data such as N, M and k. Alternatively, this can be a character string naming a function or a function object that returns such a list, e.g. the functionPCMInfo or the function PCMInfoCpp from the PCMBaseCpp package.

positiveValueGuard

a real number (not necessarily positive) used during the fit as a threshold for highly positive but likely incorrect log-likelihood values. This argument is set to Inf by default and should be used only as a last escape. The recommended way to of preventing such numerical errors is by setting more stringent values for the runtime options PCMBase.Threshold.EV and PCMBase.Threshold.SV (see PCMOptions).

parLower, parUpper

numeric vectors of equal length p: the number of parameters of the function lik;

matParInit

a numeric matrix of p columns.

control

a list passed to optim().

doParallel

logical indicating if optim calls should be executed in parallel using the foreach() %dopar% {} construct. Default: FALSE.

verbose

logical indicating whether informative messages should be printed on the console during the run.

Value

a named list


venelin/PCMFit documentation built on June 7, 2021, 12:14 p.m.