Functions to find maximum likelihood solutions to general random walk (`opt.GRW`

), unbiased random walk `opt.URW`

, and stasis models `opt.Stasis`

.

1 2 3 4 | ```
opt.GRW(y, pool = TRUE, cl = list(fnscale = -1), meth = "L-BFGS-B", hess = FALSE)
opt.URW(y, pool = TRUE, cl = list(fnscale=-1), meth = "L-BFGS-B", hess = FALSE)
opt.Stasis(y, pool = TRUE, cl = list(fnscale=-1), meth = "L-BFGS-B", hess = FALSE)
opt.StrictStasis(y, pool = TRUE, cl = list(fnscale=-1), meth = "L-BFGS-B", hess = FALSE)
``` |

`y` |
a |

`cl` |
control list, passed to function |

`pool` |
logical indicating whether to pool variances across samples |

`meth` |
optimization method, passed to function |

`hess` |
logical, indicating whether to calculate standard errors from the Hessian matrix |

These functions numerically search a log-likelihood surface for its optimum–they are a convenient wrapper to `optim`

. Arguments `meth`

, `cl`

, and `hess`

are passed to `optim`

; see that function's help for details. These are included to allow sophisticated users greater control over the optimization; the defaults seem to work well for most, but not all sequences. For `meth="L-BFGS-B"`

, some parameters are constrained to be non-negative, which is useful paramters which cannot truly be negative, such as `vstep`

(random walk) and `omega`

(stasis model).

Initial estimates to start the optimization come from analytical solutions based on assuming equal sampling error across samples and evenly spaced samples in time (functions `mle.GRW`

, `mle.URW`

and `mle.Stasis`

).

A `paleoTSfit`

object.

Standard errors computed from the Hessian matrix are reasonably accurate for `mstep`

and `theta`

, but not as useful for the vstep and omega because of the asymmetry of the log-likelihood surfaces.

Gene Hunt

Hunt, G. 2006. Fitting and comparing models of phyletic evolution: random walks and beyond. *Paleobiology* ** 32**:578–601.

Hunt, G., M. J. Hopkins, and S. L. Lidgard 2015. Simple versus complex models of trait evolution and stasis as a response to environmental change. *PNAS* ** 112**:4885–4890.

`logL.GRW`

, `fit3models`

, `fitMult`

, `sim.GRW`

, `as.paleoTSfit`

1 2 3 4 5 6 7 8 9 10 | ```
## generate data for a directional sequence
y <- sim.GRW(ns=30, ms=1, vs=1)
plot(y)
m.rw<- opt.GRW(y)
m.rwu<- opt.URW(y)
m.sta<- opt.Stasis(y)
m.ss<- opt.StrictStasis(y)
## print log-likelihoods; easier to use function fit4models()
compareModels(m.rw, m.rwu, m.sta, m.ss)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.