phylopars.lm: Rphylopars regression

View source: R/phylopars_update.R

phylopars.lmR Documentation

Rphylopars regression

Description

Performs phylogenetic regression.

Usage

phylopars.lm(formula, trait_data, tree, model = "BM", pheno_error,
phylo_correlated = TRUE, pheno_correlated = TRUE, REML = TRUE,
full_alpha = TRUE, phylocov_start, phenocov_start, model_par_start,
phylocov_fixed, phenocov_fixed, model_par_fixed, skip_optim = FALSE,
skip_EM = FALSE, EM_Fels_limit = 1000, repeat_optim_limit = 1,
EM_missing_limit = 50,repeat_optim_tol = 0.01, model_par_evals = 10,
max_delta = 10000, EM_verbose = FALSE,optim_verbose = FALSE, npd = FALSE,
nested_optim = FALSE, usezscores = TRUE, phenocov_list = list(),
ret_args = FALSE, ret_level = 1, get_cov_CIs = FALSE)

Arguments

formula

Model formula – e.g. Y~X1+X2

trait_data

A data frame with the first column labeled "species" (with species names matching tips on the phylogeny) and one column per trait. Each row corresponds to a single observation, and multiple observations for species are allowed. Missing data should be represented with NA.

tree

An object of class phylo

model

Model of evolution. Default is "BM". Alternative evolutionary models include "mvOU" (for the multivariate Ornstein-Uhlenbeck), or univariate tree transformations: "OU" "lambda", "kappa", "delta", "EB", "star".

pheno_error

If TRUE (default, unless <=1 observation per species is provided), parameters are estimated assuming within-species variation.

phylo_correlated

If TRUE (default), parameters are estimated assuming traits are correlated.

pheno_correlated

If TRUE (default), parameters are estimated assuming within-species observations traits are correlated.

REML

If TRUE (default), the algorithm will return REML estimates. If FALSE, maximum likelihood estimates will be returned.

full_alpha

Only applicable for the multivariate OU (model="mvOU"). If TRUE (default), a fully parametrized alpha matrix is fit. If FALSE, a diagonal alpha matrix is fit.

phylocov_start

Optional starting value for phylogenetic trait variance-covariance matrix. Must be of dimension n_traits by n_traits.

phenocov_start

Optional starting value for phenotypic trait variance-covariance matrix. Must be of dimension n_traits by n_traits.

model_par_start

Optional starting parameters for the evolutionary model. For model="mvOU", must be of dimension n_traits by n_traits. Otherwise, must be a single value.

phylocov_fixed

Optional fixed value for phylogenetic trait variance-covariance matrix. Must be of dimension n_traits by n_traits.

phenocov_fixed

Optional starting value for phenotypic trait variance-covariance matrix. Must be of dimension n_traits by n_traits.

model_par_fixed

Optional fixed parameter for the evolutionary model. For model="mvOU", must be of dimension n_traits by n_traits. Otherwise, must be a single value.

skip_optim

Whether to skip BFGS optimization (not recommended unless all parameters are fixed).

skip_EM

Whether to skip Expectation-Maximiation prior to generating starting parameters for BFGS optimization (not recommended unless providing fixed parameters).

EM_Fels_limit

Whether to skip Expectation-Maximiation prior to generating starting parameters for BFGS optimization (not recommended unless providing fixed parameters).

repeat_optim_limit

The number of times to repeat numerical optimization (default is 1).

EM_missing_limit

Maximum number of iterations for EM.

repeat_optim_tol

Maximum tolerance for repeated numerical optimization (only relevant if repeat_optim_limit>1).

model_par_evals

Number of times to evaluate univariate tree transformation models along the range of possible parameter values. Used to generate informed starting values for alternative evolutionary models if nested_optim=TRUE.

max_delta

Maximum allowed difference between the log-likelihood for EM-generated starting parameters and new parameters tried under numerical optimization. Extremely large deltas are likely to be numerical artifiacts. Prevents artificial convergence.

EM_verbose

Whether to print the log-likelihood during Expectation-Maximization.

optim_verbose

Whether to print log-likelihooods during numerical optimization.

npd

Whether to find the nearest positive-definite matrix for all covariance matrices during numerical optimization (slow – only set to TRUE if converging to singular matrices).

nested_optim

Only relevant if fitting a univariate alternative evolutionary model. Tries multiple tree transformation parameter values along the range of possible values to make informed starting parameters. Slower than the default (nested_optim=FALSE), in which all parameters are estimated simultaneously.

usezscores

Whether or not ot use centered and standardized data during numerical optimization (recommended).

phenocov_list

An optional named list of species-specific within-species covariance matrices to be held fixed, as in Ives et al (2007). This option forces pheno_error and pheno_correlated to be FALSE, and uses mean species values instead of raw data. Raw variance should be divided by the number of observations per species (i.e., squared standard errors). See Ives et al (2007) for more details.

ret_args

For internal use only.

ret_level

For internal use only.

get_cov_CIs

Whether to return 95-percent confidence intervals of covariance parameters (default=FALSE).

Value

A fitted phylopars.lm object.

Examples

  # simulate data
  sim_data <- simtraits(ntaxa = 15,ntraits = 4)

  phylopars.lm(V4~V1+V2+V3,trait_data=sim_data$trait_data,tree=sim_data$tree)

ericgoolsby/Rphylopars documentation built on May 15, 2022, 8:24 p.m.