View source: R/complexModels.R
opt.GRW.shift | R Documentation |
Fit random walk model with shift(s) in generating parameters
opt.GRW.shift(y, ng = 2, minb = 7, model = 1, pool = TRUE, silent = FALSE)
y |
a |
ng |
number of segments in the sequence |
minb |
minimum number of populations in each segment |
model |
numeric, specifies exact evolutionary model; see Details |
pool |
if TRUE, sample variances are substituted with their pooled estimate |
silent |
logical, if TRUE, progress updates are suppressed |
Fits a model in which a sequence is divided into two or more segments and
trait evolution proceeds as a general random walk, with each segment (potentially)
getting its own generating parameters (mstep
, vstep
).
This function tests for shifts after each population, subject to the
constraint that the number of populations in each segment is always >= minb
. The
shiftpoint yielding the highest log-likelihood is returned as the solution, along with
the log-likelihoods (all.logl
of all tested shift points (GG
).
Different variants of the model can be specified by the model
argument:
model = 1:
mstep
is separate across segments; vstep
is shared
model = 2:
mstep
is shared across segments; vstep
is separate
model = 3:
mstep
is set to zero (unbiased random walk); vstep
is separate across segments
model = 4:
mstep
and vstep
are both separate across segments
a paleoTSfit
object
sim.GRW.shift
x <- sim.GRW.shift(ns = c(15,15), ms = c(0, 1), vs = c(0.1,0.1))
w.sep <- opt.GRW.shift(x, ng = 2, model = 4)
w.sameVs <- opt.GRW.shift(x, ng = 2, model = 1)
compareModels(w.sep, w.sameVs)
plot(x)
abline(v = x$tt[16], lwd = 3) # actual shift point
abline(v = x$tt[w.sameVs$par["shift1"]], lty = 3, col = "red", lwd = 2) # inferred shift point
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.