Description Usage Arguments Details Value Examples
View source: R/estimate_shift.r
Estimation and helper functions for nls fit of migration model
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
T |
time |
X |
x coordinate |
Y |
y coordinate |
n.clust |
the number of ranges to estimate. Two is relatively easy and robust, and three works fairly will (with good initial guesses). More can be prohibitively slow. |
p.m0 |
initial parameter guesses - a named vector with (e.g.) elements x1, x2, y1, y2, t1, dt.
It helps if this is close - the output of |
dt0 |
initial guess for duration of migration |
method |
one of 'ar' or 'like' (case insenstive), whether or not to use the AR equivalence method (faster, needs regular data - with some tolerance for gaps) or Likelihood method, which is slower but robust for irregular data. |
CI |
whether or not to estimate confidence intervals |
nboot |
number of bootstraps |
model |
one of "MWN", "MOU" or "MOUF" (case insensitive). By default, the algorithm selects
the best one according to AIC using the |
area.direct |
passed as direct argument to getArea |
This algorithm minimizes the square of the distance of the locations from a double-headed hockeystick curve, then estimates the times scale using the ARMA/AR models. Confidence intervals are obtained by bootstrapping the data and reestimating. See example and vignette for implementation.
a list with the following elements
T,X,Y |
Longitude coordinate with NA at prediction times |
p.hat |
Point estimates of parameters |
p.CI |
Data frame of parameter estimates with (approximate) confidence intervals. |
model |
One of "wn", "ou" or "ouf" - the selected model for the residuals. |
hessian |
The hessian of the mean parameters. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | # load simulated tracks
data(SimulatedTracks)
# white noise fit
MWN.fit <- with(MWN.sim, estimate_shift(T=T, X=X, Y=Y))
# estimate_shift also works with POSIX class time. The following also works
MWN.fit <- with(MWN.sim, estimate_shift(T=strptime(MWN.sim$T,"%j", tz = "UTC"), X=X, Y=Y))
summary(MWN.fit)
plot(MWN.fit)
if(interactive()){
# OUF fit
MOUF.fit <- with(MOUF.sim.random,
estimate_shift(T=T, X=X, Y=Y,
model = "ouf",
method = "like"))
summary(MOUF.fit)
plot(MOUF.fit)
# Three range fit:
# it is helpful to have some initital values for these parameters
# because the automated quickfit() method is unreliable for three ranges
# in the example, we set a seed that seems to work
# set.seed(1976)
MOU.3range.fit <- with(MOU.3range,
estimate_shift(T=T, X=X, Y=Y,
model = "ou",
method = "ar",
n.clust = 3))
summary(MOU.3range.fit)
plot(MOU.3range.fit)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.