Skip to contents

Function to find maximum likelihood solutions for multivariate Unbiased Random Walk models fitted to two different segments of a multivariate evolutionary sequence (time-series).

Usage

fit.multivariate.URW.shift(
  yy,
  minb = 10,
  hess = FALSE,
  pool = TRUE,
  shift.point = NULL,
  method = "L-BFGS-B",
  trace = FALSE,
  iterations = NULL,
  iter.sd = NULL
)

Arguments

yy

a multivariate evoTS object.

minb

the minimum number of samples within a segment to consider.

hess

logical, indicating whether to calculate standard errors from the Hessian matrix.

pool

indicating whether to pool variances across samples

shift.point

the sample in the time series that represents the first sample in the second segment.

method

optimization method, passed to function optim. Default is "L-BFGS-B".

trace

logical, indicating whether information on the progress of the optimization is printed.

iterations

the number of times the optimization method is run from different starting points. Default is NULL, meaning the optimization is run once.

iter.sd

defines the standard deviation of the Gaussian distribution from which starting values for the optimization routine is run. Default is 1.

Value

First part of the output reports the log-likelihood of the model and its AICc score. The second part of the output is the maximum log-likelihood model parameters (ancestral.values, R). The last part of the output gives information about the number of parameters in the model (K), number of samples in the data (n) and number of times the optimization routine was run (iter).

Details

The function searches - using an optimization routine - for the maximum-likelihood solution for a multivariate Unbiased Random Walk model ti two non-overlapping segments in the time series.

The argument 'method' is passed to the 'optim' function and is included for the convenience of users to better control the optimization routine. The the default method (L-BFGS-B) seems to work for most evolutionary sequences.

Initial estimates to start the optimization come from maximum-likelihood estimates of the univariate Unbiased Random Walk model (from the paleoTS package) fitted to each time-series separately.

It is good practice to repeat any numerical optimization procedure from different starting points. This is especially important for complex models as the log-likelihood surface might contain more than one peak. The number of iterations is controlled by the argument 'iterations'. The function will report the model parameters from the iteration with the highest log-likelihood.

Note

The models have been implemented to be compatible with the joint parameterization routine in the package paleoTS. The optimization is therefore fit using the actual sample values, with the autocorrelation among samples accounted for in the log-likelihood function. The joint distribution of sample means is multivariate normal, with means and variance-covariances determined by evolutionary parameters and sampling errors.

References

Revell, L. J. & Harmon, L. Testing quantitative genetic hypotheses about the evolutionary rate matrix for continuous characters. Evolutionary Ecology Research 10, 311–331 (2008).

Author

Kjetil Lysne Voje

Examples

## Generate an evoTS object by simulating a multivariate dataset
x <- sim.multi.URW(60)

## Fit two multivariate Unbiased Random Walk models to separate parts of the time-series.
fit.multivariate.URW.shift(x, shift.point = 31)
#> $converge
#> [1] "Model converged successfully"
#> 
#> $modelName
#> [1] "Multivariate model: Random walk with two R matrices (with non-zero off-diagonal elements)"
#> 
#> $logL
#> [1] 89.8037
#> 
#> $AICc
#> [1] -158.0074
#> 
#> $ancestral.values
#> [1] 0.05102420 0.04434417
#> 
#> $SE.anc
#> [1] NA
#> 
#> $R
#> $R$R.1
#>           [,1]      [,2]
#> [1,] 0.2379648 0.1837261
#> [2,] 0.1837261 0.1418499
#> 
#> $R$R.2
#>             [,1]        [,2]
#> [1,]  0.28130795 -0.07484496
#> [2,] -0.07484496  0.77110392
#> 
#> 
#> $SE.R
#> [1] NA
#> 
#> $shift.point
#> [1] 31
#> 
#> $method
#> [1] "Joint"
#> 
#> $K
#> [1] 9
#> 
#> $n
#> [1] 60
#> 
#> $iter
#> [1] NA
#> 
#> attr(,"class")
#> [1] "evoTSmvFit"