Title: | Statistical Modeling of Animal Movements |
---|---|
Description: | Animal movement models including Moving-Resting Process with Embedded Brownian Motion (Yan et al., 2014, <doi:10.1007/s10144-013-0428-8>; Pozdnyakov et al., 2017, <doi:10.1007/s11009-017-9547-6>), Brownian Motion with Measurement Error (Pozdnyakov et al., 2014, <doi:10.1890/13-0532.1>), Moving-Resting-Handling Process with Embedded Brownian Motion (Pozdnyakov et al., 2020, <doi:10.1007/s11009-020-09774-1>), Moving-Resting Process with Measurement Error (Hu et al., 2021, <doi:10.1111/2041-210X.13694>), Moving-Moving Process with two Embedded Brownian Motions. |
Authors: | Chaoran Hu [aut, cre], Vladimir Pozdnyakov [aut], Jun Yan [aut] |
Maintainer: | Chaoran Hu <[email protected]> |
License: | GPL (>= 3.0) |
Version: | 0.7.2 |
Built: | 2024-11-06 06:24:28 UTC |
Source: | CRAN |
Auxiliary for preparing discrete distribution used to approximate standard normal. This function generates order statistics of standard normal with same probability assigned. Then, the discrete distribution is standardized to variance one and mean zero.
approxNormalOrder(m) approxNormalOrder2(m, width)
approxNormalOrder(m) approxNormalOrder2(m, width)
m |
int, the number of order statistics used |
width |
the width between two consecutive grid points. |
This function use EnvStats::evNormOrdStats
to get
the order statisics of standard normal distribution. The
same probability is assigned for each order statistics.
A numeric matrix with first column is support of discrete distribution and second column is corresponding p.m.f..
Chaoran Hu
EnvStats::evNormOrdStats
for order
statisics of standard normal. fitMRMEapprox
for fit MRME with approximated measurement error.
Density for time spent in moving or resting in a time interval, unconditional or conditional on the initial state.
dtm(w, t, lamM, lamR, s0 = NULL) dtr(w, t, lamM, lamR, s0 = NULL)
dtm(w, t, lamM, lamR, s0 = NULL) dtr(w, t, lamM, lamR, s0 = NULL)
w |
time points at which the density is to be evaluated |
t |
length of the time interval |
lamM |
rate parameter of the exponentially distributed duration in moving |
lamR |
rate parameter of the exponentially distributed duration in resting |
s0 |
initial state. If |
dtm
returns the density for time in moving;
dtr
returns the density for time in resting.
a vector of the density evaluated at w
.
dtr()
: Density of time spent in resting
Yan, J., Chen, Y., Lawrence-Apfel, K., Ortega, I. M., Pozdnyakov, V., Williams, S., and Meyer, T. (2014) A moving-resting process with an embedded Brownian motion for animal movements. Population Ecology. 56(2): 401–415.
lamM <- 1 lamR <- c(1/2, 1, 2) lr <- length(lamR) totalT <- 10 old.par <- par(no.readonly=TRUE) par(mfrow=c(1, 2), mar=c(2.5, 2.5, 1.1, 0.1), mgp=c(1.5, 0.5, 0), las=1) curve(dtm(x, totalT, 1, 1/2, "m"), 0, totalT, lty=1, ylim=c(0, 0.34), xlab="M(10)", ylab="density") curve(dtm(x, totalT, 1, 1, "m"), 0, totalT, lty=2, add=TRUE) curve(dtm(x, totalT, 1, 2, "m"), 0, totalT, lty=3, add=TRUE) mtext(expression("S(0) = 1")) legend("topleft", legend = expression(lambda[r] == 1/2, lambda[r] == 1, lambda[r] == 2), lty = 1:lr) curve(dtm(x, totalT, 1, 1/2, "r"), 0, totalT, lty=1, ylim=c(0, 0.34), xlab="M(10)", ylab="density") curve(dtm(x, totalT, 1, 1, "r"), 0, totalT, lty=2, add=TRUE) curve(dtm(x, totalT, 1, 2, "r"), 0, totalT, lty=3, add=TRUE) mtext(expression("S(0) = 0")) legend("topleft", legend = expression(lambda[r] == 1/2, lambda[r] == 1, lambda[r] == 2), lty = 1:lr) par(old.par)
lamM <- 1 lamR <- c(1/2, 1, 2) lr <- length(lamR) totalT <- 10 old.par <- par(no.readonly=TRUE) par(mfrow=c(1, 2), mar=c(2.5, 2.5, 1.1, 0.1), mgp=c(1.5, 0.5, 0), las=1) curve(dtm(x, totalT, 1, 1/2, "m"), 0, totalT, lty=1, ylim=c(0, 0.34), xlab="M(10)", ylab="density") curve(dtm(x, totalT, 1, 1, "m"), 0, totalT, lty=2, add=TRUE) curve(dtm(x, totalT, 1, 2, "m"), 0, totalT, lty=3, add=TRUE) mtext(expression("S(0) = 1")) legend("topleft", legend = expression(lambda[r] == 1/2, lambda[r] == 1, lambda[r] == 2), lty = 1:lr) curve(dtm(x, totalT, 1, 1/2, "r"), 0, totalT, lty=1, ylim=c(0, 0.34), xlab="M(10)", ylab="density") curve(dtm(x, totalT, 1, 1, "r"), 0, totalT, lty=2, add=TRUE) curve(dtm(x, totalT, 1, 2, "r"), 0, totalT, lty=3, add=TRUE) mtext(expression("S(0) = 0")) legend("topleft", legend = expression(lambda[r] == 1/2, lambda[r] == 1, lambda[r] == 2), lty = 1:lr) par(old.par)
'estimate' function returns the estimate result of 'smam::fitXXXX' from smam package.
estimate(x, ...) ## S3 method for class 'smam_mrme' estimate(x, ...) ## S3 method for class 'smam_mr' estimate(x, ...) ## S3 method for class 'smam_mm' estimate(x, ...) ## S3 method for class 'smam_mrh' estimate(x, ...) ## S3 method for class 'smam_bmme' estimate(x, ...)
estimate(x, ...) ## S3 method for class 'smam_mrme' estimate(x, ...) ## S3 method for class 'smam_mr' estimate(x, ...) ## S3 method for class 'smam_mm' estimate(x, ...) ## S3 method for class 'smam_mrh' estimate(x, ...) ## S3 method for class 'smam_bmme' estimate(x, ...)
x |
a fitted object from one of 'smam::fitXXXX' functions |
... |
other arguments |
## time consuming example #tgrid <- seq(0, 100, length=100) #set.seed(123) #dat <- rMRME(tgrid, 1, 0.5, 1, 0.01, "m") ## fit whole dataset to the MRME model #fit <- fitMRME(dat, start=c(1, 0.5, 1, 0.01)) #fit ## get covariance matrix of estimators #estimate(fit)
## time consuming example #tgrid <- seq(0, 100, length=100) #set.seed(123) #dat <- rMRME(tgrid, 1, 0.5, 1, 0.01, "m") ## fit whole dataset to the MRME model #fit <- fitMRME(dat, start=c(1, 0.5, 1, 0.01)) #fit ## get covariance matrix of estimators #estimate(fit)
'estVarMRME_Godambe' uses Godambe information matrix to obtain variance matrix of estimators from 'fitMRME'. 'estVarMRME_pBootstrap' uses parametric bootstrap to obtain variance matrix of estimators from 'fitMRME'. 'estVarMRMEnaive_Godambe' use Godambe information matrix to obtain variance matrix of estimators from 'fitMRME_naive'. 'estVarMRMEnaive_pBootstrap' uses parametric bootstrap to obtain variance matrix of estimators from 'fitMRME_naive'.
estVarMRME_Godambe( est_theta, data, nBS, numThreads = 1, gradMethod = "simple", integrControl = integr.control() ) estVarMRME_pBootstrap( est_theta, data, nBS, detailBS = FALSE, numThreads = 1, integrControl = integr.control() ) estVarMRMEnaive_Godambe( est_theta, data, nBS, numThreads = 1, gradMethod = "simple", integrControl = integr.control() ) estVarMRMEnaive_pBootstrap( est_theta, data, nBS, detailBS = FALSE, numThreads = 1, integrControl = integr.control() )
estVarMRME_Godambe( est_theta, data, nBS, numThreads = 1, gradMethod = "simple", integrControl = integr.control() ) estVarMRME_pBootstrap( est_theta, data, nBS, detailBS = FALSE, numThreads = 1, integrControl = integr.control() ) estVarMRMEnaive_Godambe( est_theta, data, nBS, numThreads = 1, gradMethod = "simple", integrControl = integr.control() ) estVarMRMEnaive_pBootstrap( est_theta, data, nBS, detailBS = FALSE, numThreads = 1, integrControl = integr.control() )
est_theta |
estimators of MRME model |
data |
data used to process estimation |
nBS |
number of bootstrap. |
numThreads |
the number of threads for parallel computation. If its value is greater than 1, then parallel computation will be processed. Otherwise, serial computation will be processed. |
gradMethod |
method used for numeric gradient ( |
integrControl |
a list of control parameters for the |
detailBS |
whether or not output estimation results during bootstrap, which can be used to generate bootstrap CI. |
variance-covariance matrix of estimators
Chaoran Hu
## Not run: ## time consuming example tgrid <- seq(0, 10*100, length=100) set.seed(123) dat <- rMRME(tgrid, 1, 0.5, 1, 0.01, "m") estVarMRME_Godambe(c(1, 0.5, 1, 0.01), dat, nBS = 10) estVarMRME_pBootstrap(c(1, 0.5, 1, 0.01), dat, nBS = 10) estVarMRMEnaive_Godambe(c(1, 0.5, 1, 0.01), dat, nBS = 10) estVarMRMEnaive_pBootstrap(c(1, 0.5, 1, 0.01), dat, nBS = 10) estVarMRME_Godambe(c(1, 0.5, 1, 0.01), dat, nBS = 10, numThreads = 6) estVarMRME_pBootstrap(c(1, 0.5, 1, 0.01), dat, nBS = 10, numThreads = 6) estVarMRMEnaive_Godambe(c(1, 0.5, 1, 0.01), dat, nBS = 10, numThreads = 6) estVarMRMEnaive_pBootstrap(c(1, 0.5, 1, 0.01), dat, nBS = 10, numThreads = 6) estVarMRMEnaive_pBootstrap(c(1, 0.5, 1, 0.01), dat, nBS = 10, numThreads = 6) ## End(Not run)
## Not run: ## time consuming example tgrid <- seq(0, 10*100, length=100) set.seed(123) dat <- rMRME(tgrid, 1, 0.5, 1, 0.01, "m") estVarMRME_Godambe(c(1, 0.5, 1, 0.01), dat, nBS = 10) estVarMRME_pBootstrap(c(1, 0.5, 1, 0.01), dat, nBS = 10) estVarMRMEnaive_Godambe(c(1, 0.5, 1, 0.01), dat, nBS = 10) estVarMRMEnaive_pBootstrap(c(1, 0.5, 1, 0.01), dat, nBS = 10) estVarMRME_Godambe(c(1, 0.5, 1, 0.01), dat, nBS = 10, numThreads = 6) estVarMRME_pBootstrap(c(1, 0.5, 1, 0.01), dat, nBS = 10, numThreads = 6) estVarMRMEnaive_Godambe(c(1, 0.5, 1, 0.01), dat, nBS = 10, numThreads = 6) estVarMRMEnaive_pBootstrap(c(1, 0.5, 1, 0.01), dat, nBS = 10, numThreads = 6) estVarMRMEnaive_pBootstrap(c(1, 0.5, 1, 0.01), dat, nBS = 10, numThreads = 6) ## End(Not run)
A dataset of GPS coordinates of a mature female mountain lion living in the Gros Ventre Mountain Range near Jackson, Wyoming. The data were collected by a code-only GPS wildlife tracking collar from 2009 to 2012.
f109
f109
A data frame with 3919 rows and 4 variables:
Date when the GPS coordinates were collected
Standardized time when the GPS coordinates were collected (unit: hour)
Standardized UTM easting (unit: km)
Standardized UTM northing (unit: km)
The original format of 'f109' dataset.
f109raw
f109raw
A data frame with 3917 rows and 3 variables:
Date and time when the GPS coordinates were collected (unit: year)
Standardized UTM easting (unit: meter)
Standardized UTM northing (unit: meter)
Given discretely observed animal movement locations, fit a Brownian
motion model with measurement errors. Using segment
to fit
part of observations to the model. A practical application of this
feature is seasonal analysis.
fitBMME( data, start = NULL, segment = NULL, method = "Nelder-Mead", optim.control = list() ) fitBmme(data, start = NULL, method = "Nelder-Mead", optim.control = list())
fitBMME( data, start = NULL, segment = NULL, method = "Nelder-Mead", optim.control = list() ) fitBmme(data, start = NULL, method = "Nelder-Mead", optim.control = list())
data |
a data.frame whose first column is the observation time, and other
columns are location coordinates. If |
start |
starting value of the model, a vector of two component, one for sigma (sd of BM) and the other for delta (sd for measurement error). If unspecified (NULL), a moment estimator will be used assuming equal sigma and delta. |
segment |
character variable, name of the column which indicates segments,
in the given |
method |
the method argument to feed |
optim.control |
a list of control that is passed down to |
The joint density of the increment data is multivariate normal with a sparse (tri-diagonal) covariance matrix. Sparse matrix operation from package Matrix is used for computing efficiency in handling large data.
A list of the following components:
estimate |
the estimated parameter vector |
var.est |
variance matrix of the estimator |
loglik |
loglikelihood evaluated at the estimate |
convergence |
convergence code from optim |
Pozdnyakov V., Meyer, TH., Wang, Y., and Yan, J. (2013) On modeling animal movements using Brownian motion with measurement error. Ecology 95(2): p247–253. doi:doi:10.1890/13-0532.1.
set.seed(123) tgrid <- seq(0, 500, by = 1) dat <- rBMME(tgrid, sigma = 1, delta = 0.5) ## using whole dataset to fit BMME fit <- fitBMME(dat) fit ## using part of dataset to fit BMME batch <- c(rep(0, 100), rep(1, 200), rep(0, 50), rep(2, 100), rep(0, 51)) dat.segment <- cbind(dat, batch) fit.segment <- fitBMME(dat.segment, segment = "batch") head(dat.segment) fit.segment
set.seed(123) tgrid <- seq(0, 500, by = 1) dat <- rBMME(tgrid, sigma = 1, delta = 0.5) ## using whole dataset to fit BMME fit <- fitBMME(dat) fit ## using part of dataset to fit BMME batch <- c(rep(0, 100), rep(1, 200), rep(0, 50), rep(2, 100), rep(0, 51)) dat.segment <- cbind(dat, batch) fit.segment <- fitBMME(dat.segment, segment = "batch") head(dat.segment) fit.segment
Fit a Moving-Moving Model with 2 Embedded Brownian Motion with animal movement data at discretely observation times by maximizing a full likelihood constructed from the marginal density of increment. 'estVarMM' uses parametric bootstrap to obtain variance matrix of estimators from 'fitMM'.
fitMM( data, start, logtr = FALSE, method = "Nelder-Mead", optim.control = list(), integrControl = integr.control() ) estVarMM( est_theta, data, nBS, detailBS = FALSE, numThreads = 1, integrControl = integr.control() )
fitMM( data, start, logtr = FALSE, method = "Nelder-Mead", optim.control = list(), integrControl = integr.control() ) estVarMM( est_theta, data, nBS, detailBS = FALSE, numThreads = 1, integrControl = integr.control() )
data |
data used to process estimation |
start |
starting value of the model, a vector of four components in the order of rate for moving1, rate for moving2, and volatility1(larger), volatility2(smaller). |
logtr |
logical, if TRUE parameters are estimated on the log scale. |
method |
the method argument to feed |
optim.control |
a list of control to be passed to |
integrControl |
a list of control parameters for the |
est_theta |
estimators of MRME model |
nBS |
number of bootstrap. |
detailBS |
whether or not output estimation results during bootstrap, which can be used to generate bootstrap CI. |
numThreads |
the number of threads for parallel computation. If its value is greater than 1, then parallel computation will be processed. Otherwise, serial computation will be processed. |
a list of the following components:
estimate |
the esimated parameter vector |
loglik |
maximized loglikelihood or composite loglikelihood evaluated at the estimate |
convergence |
convergence code from |
Yan, J., Chen, Y., Lawrence-Apfel, K., Ortega, I. M., Pozdnyakov, V., Williams, S., and Meyer, T. (2014) A moving-resting process with an embedded Brownian motion for animal movements. Population Ecology. 56(2): 401–415.
Pozdnyakov, V., Elbroch, L., Labarga, A., Meyer, T., and Yan, J. (2017) Discretely observed Brownian motion governed by telegraph process: estimation. Methodology and Computing in Applied Probability. doi:10.1007/s11009-017-9547-6.
## Not run: ## time consuming example tgrid <- seq(0, 100, length=100) set.seed(123) dat <- rMM(tgrid, 1, 0.1, 1, 0.1, "m1") ## fit whole dataset to the MR model fit <- fitMM(dat, start=c(1, 0.1, 1, 0.1)) fit var <- estVarMM(fit$estimate, dat, nBS = 10, numThreads = 6) var ## End(Not run)
## Not run: ## time consuming example tgrid <- seq(0, 100, length=100) set.seed(123) dat <- rMM(tgrid, 1, 0.1, 1, 0.1, "m1") ## fit whole dataset to the MR model fit <- fitMM(dat, start=c(1, 0.1, 1, 0.1)) fit var <- estVarMM(fit$estimate, dat, nBS = 10, numThreads = 6) var ## End(Not run)
Fit a Moving-Resting Model with Embedded Brownian Motion with animal
movement data at discretely observation times by maximizing a composite
likelihood constructed from the marginal density of increment.
Using segment
to fit part of observations to the model. A practical
application of this feature is seasonal analysis.
fitMR( data, start, segment = NULL, likelihood = c("full", "composite"), logtr = FALSE, method = "Nelder-Mead", optim.control = list(), integrControl = integr.control() ) fitMovRes( data, start, likelihood = c("full", "composite"), logtr = FALSE, method = "Nelder-Mead", optim.control = list(), integrControl = integr.control() )
fitMR( data, start, segment = NULL, likelihood = c("full", "composite"), logtr = FALSE, method = "Nelder-Mead", optim.control = list(), integrControl = integr.control() ) fitMovRes( data, start, likelihood = c("full", "composite"), logtr = FALSE, method = "Nelder-Mead", optim.control = list(), integrControl = integr.control() )
data |
a data.frame whose first column is the observation time, and other
columns are location coordinates. If |
start |
starting value of the model, a vector of three components in the order of rate for moving, rate for resting, and volatility. |
segment |
character variable, name of the column which indicates segments,
in the given |
likelihood |
a character string specifying the likelihood type to maximize in estimation. This can be "full" for full likelihood or "composite' for composite likelihood. |
logtr |
logical, if TRUE parameters are estimated on the log scale. |
method |
the method argument to feed |
optim.control |
a list of control to be passed to |
integrControl |
a list of control parameters for the |
a list of the following components:
estimate |
the esimated parameter vector |
loglik |
maximized loglikelihood or composite loglikelihood evaluated at the estimate |
convergence |
convergence code from |
likelihood |
likelihood type (full or composite) from the input |
Yan, J., Chen, Y., Lawrence-Apfel, K., Ortega, I. M., Pozdnyakov, V., Williams, S., and Meyer, T. (2014) A moving-resting process with an embedded Brownian motion for animal movements. Population Ecology. 56(2): 401–415.
Pozdnyakov, V., Elbroch, L., Labarga, A., Meyer, T., and Yan, J. (2017) Discretely observed Brownian motion governed by telegraph process: estimation. Methodology and Computing in Applied Probability. doi:10.1007/s11009-017-9547-6.
## Not run: ## time consuming example tgrid <- seq(0, 10, length=500) set.seed(123) ## make it irregularly spaced tgrid <- sort(sample(tgrid, 30)) # change to 400 for a larger sample dat <- rMR(tgrid, 1, 2, 25, "m") ## fit whole dataset to the MR model fit.fl <- fitMR(dat, start=c(2, 2, 20), likelihood = "full") fit.fl fit.cl <- fitMR(dat, start=c(2, 2, 20), likelihood = "composite") fit.cl ## fit part of dataset to the MR model batch <- c(rep(0, 5), rep(1, 7), rep(0, 4), rep(2, 10), rep(0, 4)) dat.segment <- cbind(dat, batch) fit.segment <- fitMR(dat.segment, start = c(2, 2, 20), segment = "batch", likelihood = "full") head(dat.segment) fit.segment ## End(Not run)
## Not run: ## time consuming example tgrid <- seq(0, 10, length=500) set.seed(123) ## make it irregularly spaced tgrid <- sort(sample(tgrid, 30)) # change to 400 for a larger sample dat <- rMR(tgrid, 1, 2, 25, "m") ## fit whole dataset to the MR model fit.fl <- fitMR(dat, start=c(2, 2, 20), likelihood = "full") fit.fl fit.cl <- fitMR(dat, start=c(2, 2, 20), likelihood = "composite") fit.cl ## fit part of dataset to the MR model batch <- c(rep(0, 5), rep(1, 7), rep(0, 4), rep(2, 10), rep(0, 4)) dat.segment <- cbind(dat, batch) fit.segment <- fitMR(dat.segment, start = c(2, 2, 20), segment = "batch", likelihood = "full") head(dat.segment) fit.segment ## End(Not run)
Fit a Moving-Resting-Handling Model with Embedded Brownian Motion with
animal movement data at discretely observation times by maximizing
a full likelihood. Using segment
to fit part of observations to
the model. A practical application of this feature is seasonal analysis.
fitMRH( data, start, segment = NULL, numThreads = RcppParallel::defaultNumThreads() * 3/4, lower = c(0.001, 0.001, 0.001, 0.001, 0.001), upper = c(10, 10, 10, 10, 0.999), integrControl = integr.control(), print_level = 3 )
fitMRH( data, start, segment = NULL, numThreads = RcppParallel::defaultNumThreads() * 3/4, lower = c(0.001, 0.001, 0.001, 0.001, 0.001), upper = c(10, 10, 10, 10, 0.999), integrControl = integr.control(), print_level = 3 )
data |
a data.frame whose first column is the observation time, and other
columns are location coordinates. If |
start |
The initial value for optimization, in the order of rate of moving, rate of resting, rate of handling, volatility and switching probability. |
segment |
character variable, name of the column which indicates segments,
in the given |
numThreads |
int, the number of threads allocated for parallel computation. The default setup is 3/4 available threads. If this parameter is less or equal to 1, the serial computation will be processed. |
lower , upper
|
Lower and upper bound for optimization. |
integrControl |
Integration control vector includes rel.tol, abs.tol, and subdivisions. |
print_level |
print_level passed to nloptr::nloptr. Possible values: 0 (default): no output; 1: show iteration number and value of objective function; 2: 1 + show value of (in)equalities; 3: 2 + show value of controls. |
A list of estimation result with following components:
estimate |
the estimated parameter vector |
loglik |
maximized loglikelihood or composite loglikelihood evaluated at the estimate |
convergence |
convergence code from |
data |
fitted data |
Chaoran Hu
Pozdnyakov, V., Elbroch, L.M., Hu, C. et al. On Estimation for Brownian Motion Governed by Telegraph Process with Multiple Off States. Methodol Comput Appl Probab 22, 1275–1291 (2020). doi:10.1007/s11009-020-09774-1
rMRH
for simulation.
## Not run: ## time consuming example set.seed(06269) tgrid <- seq(0, 400, by = 8) dat <- rMRH(tgrid, 4, 0.5, 0.1, 5, 0.8, 'm') fitMRH(dat, c(4, 0.5, 0.1, 5, 0.8)) ## parallel process fitMRH(dat, c(4, 0.5, 0.1, 5, 0.8), numThreads = -1) ## serial process ## fit part of dataset to the MRH model batch <- c(rep(0, 10), rep(1, 7), rep(0, 10), rep(2, 10), rep(0, 14)) dat.segment <- cbind(dat, batch) fit.segment <- fitMRH(dat.segment, start = c(4, 0.5, 0.1, 5, 0.8), segment = "batch") head(dat.segment) fit.segment ## End(Not run)
## Not run: ## time consuming example set.seed(06269) tgrid <- seq(0, 400, by = 8) dat <- rMRH(tgrid, 4, 0.5, 0.1, 5, 0.8, 'm') fitMRH(dat, c(4, 0.5, 0.1, 5, 0.8)) ## parallel process fitMRH(dat, c(4, 0.5, 0.1, 5, 0.8), numThreads = -1) ## serial process ## fit part of dataset to the MRH model batch <- c(rep(0, 10), rep(1, 7), rep(0, 10), rep(2, 10), rep(0, 14)) dat.segment <- cbind(dat, batch) fit.segment <- fitMRH(dat.segment, start = c(4, 0.5, 0.1, 5, 0.8), segment = "batch") head(dat.segment) fit.segment ## End(Not run)
'fitMRME' fits a Moving-Resting Model with Measurement Error. The measurement
error is modeled by Guassian noise. Using segment
to fit part
of observations to the model. A practical application of this feature
is seasonal analysis.
fitMRME( data, start, segment = NULL, lower = c(1e-06, 1e-06, 1e-06, 1e-06), upper = c(10, 10, 10, 10), print_level = 3, integrControl = integr.control() ) fitMRME_naive( data, start, segment = NULL, lower = c(1e-06, 1e-06, 1e-06, 1e-06), upper = c(10, 10, 10, 10), integrControl = integr.control() ) fitMRMEapprox( data, start, segment = NULL, approx_norm_even = approxNormalOrder(5), approx_norm_odd = approxNormalOrder(6), method = "Nelder-Mead", optim.control = list(), integrControl = integr.control() )
fitMRME( data, start, segment = NULL, lower = c(1e-06, 1e-06, 1e-06, 1e-06), upper = c(10, 10, 10, 10), print_level = 3, integrControl = integr.control() ) fitMRME_naive( data, start, segment = NULL, lower = c(1e-06, 1e-06, 1e-06, 1e-06), upper = c(10, 10, 10, 10), integrControl = integr.control() ) fitMRMEapprox( data, start, segment = NULL, approx_norm_even = approxNormalOrder(5), approx_norm_odd = approxNormalOrder(6), method = "Nelder-Mead", optim.control = list(), integrControl = integr.control() )
data |
a data.frame whose first column is the observation time, and other
columns are location coordinates. If |
start |
starting value of the model, a vector of four components in the order of rate for moving, rate for resting, volatility, and s.d. of Guassian measurement error. |
segment |
character variable, name of the column which indicates segments,
in the given |
lower , upper
|
Lower and upper bound for optimization. |
print_level |
print_level passed to nloptr::nloptr. Possible values: 0 (default): no output; 1: show iteration number and value of objective function; 2: 1 + show value of (in)equalities; 3: 2 + show value of controls. |
integrControl |
a list of control parameters for the |
approx_norm_even , approx_norm_odd
|
numeric matrixes specify the
discrete distributions used to approximate standard normal distribution.
The first column is support of discrete distribution and the second
column is probability mass function. |
method |
the method argument to feed |
optim.control |
a list of control to be passed to |
a list of the following components:
estimate |
the esimated parameter vector |
loglik |
maximized loglikelihood or composite loglikelihood evaluated at the estimate |
convergence |
convergence code from |
data |
fitted data |
Chaoran Hu
Hu, C., Elbroch, L.M., Meyer, T., Pozdnyakov, V. and Yan, J. (2021), Moving-resting process with measurement error in animal movement modeling. Methods in Ecology and Evolution. doi:10.1111/2041-210X.13694
## time consuming example #tgrid <- seq(0, 10*100, length=100) #set.seed(123) #dat <- rMRME(tgrid, 1, 0.5, 1, 0.01, "m") ## fit whole dataset to the MRME model #fit <- fitMRME(dat, start=c(1, 0.5, 1, 0.01)) #fit ## fit whole dataset to the MRME model with naive composite likelihood #fit.naive <- fitMRME_naive(dat, start=c(1, 0.5, 1, 0.01)) #fit.naive ## fit whole dataset to the MRME model with approximate error #fit.approx <- fitMRMEapprox(dat, start=c(1, 0.5, 1, 0.01)) #fit.approx ## fit part of dataset to the MR model #batch <- c(rep(0, 5), rep(1, 17), rep(0, 4), rep(2, 30), rep(0, 4), rep(3, 40)) #dat.segment <- cbind(dat, batch) #fit.segment <- fitMRME(dat.segment, start = c(1, 0.5, 1, 0.01), segment = "batch") #fit.segment.approx <- fitMRMEapprox(dat.segment, start = c(1, 0.5, 1, 0.01), segment = "batch") #head(dat.segment) #fit.segment
## time consuming example #tgrid <- seq(0, 10*100, length=100) #set.seed(123) #dat <- rMRME(tgrid, 1, 0.5, 1, 0.01, "m") ## fit whole dataset to the MRME model #fit <- fitMRME(dat, start=c(1, 0.5, 1, 0.01)) #fit ## fit whole dataset to the MRME model with naive composite likelihood #fit.naive <- fitMRME_naive(dat, start=c(1, 0.5, 1, 0.01)) #fit.naive ## fit whole dataset to the MRME model with approximate error #fit.approx <- fitMRMEapprox(dat, start=c(1, 0.5, 1, 0.01)) #fit.approx ## fit part of dataset to the MR model #batch <- c(rep(0, 5), rep(1, 17), rep(0, 4), rep(2, 30), rep(0, 4), rep(3, 40)) #dat.segment <- cbind(dat, batch) #fit.segment <- fitMRME(dat.segment, start = c(1, 0.5, 1, 0.01), segment = "batch") #fit.segment.approx <- fitMRMEapprox(dat.segment, start = c(1, 0.5, 1, 0.01), segment = "batch") #head(dat.segment) #fit.segment
Estimate the state at each time point under the Moving-Resting
process with Embedded Brownian Motion with animal movement data at
discretely time points. See the difference between fitStateMR
and fitViterbiMR
in detail part. Using fitPartialViterbiMR
to estimate the state within a small piece of time interval.
fitStateMR(data, theta, cutoff = 0.5, integrControl = integr.control()) fitViterbiMR(data, theta, cutoff = 0.5, integrControl = integr.control()) fitPartialViterbiMR( data, theta, cutoff = 0.5, startpoint, pathlength, integrControl = integr.control() )
fitStateMR(data, theta, cutoff = 0.5, integrControl = integr.control()) fitViterbiMR(data, theta, cutoff = 0.5, integrControl = integr.control()) fitPartialViterbiMR( data, theta, cutoff = 0.5, startpoint, pathlength, integrControl = integr.control() )
data |
a |
theta |
the parameters for Moving-Resting model, in the order of rate of moving, rate of resting, volatility. |
cutoff |
the cut-off point for prediction. |
integrControl |
Integration control vector includes rel.tol, abs.tol, and subdivisions. |
startpoint |
Start time point of interested time interval. |
pathlength |
the length of interested time interval. |
fitStateMR
estimates the most likely state by maximizing
the probability of , where X is the whole
data and
is the possible sates at
(moving, resting).
fitViterbiMR
estimates the most likely state path by maximizing
, where
X is the whole data and
is the possible
state path.
fitPartialViterbiMR
estimates the most likely state path of
a small peice of time interval, by maximizing the probability of
,
where
is the start time point and
is the length of interested
time interval.
A data.frame
contains estimated results, with elements:
original data be estimated.
conditional probability of moving, resting (p.m
,
p.r
), which is for
fitStateMR
; for
fitViterbiMR
, where is
;
and
for
fitPartialViterbiMR
.
estimated states with 1-moving, 0-resting.
Chaoran Hu
rMR
for simulation.
fitMR
for estimation of parameters.
set.seed(06269) tgrid <- seq(0, 400, by = 8) dat <- rMR(tgrid, 4, 3.8, 5, 'm') fitStateMR(dat, c(4, 3.8, 5), cutoff = 0.5) fitViterbiMR(dat, c(4, 3.8, 5), cutoff = 0.5) fitPartialViterbiMR(dat, c(4, 3.8, 5), cutoff = 0.5, 20, 10)
set.seed(06269) tgrid <- seq(0, 400, by = 8) dat <- rMR(tgrid, 4, 3.8, 5, 'm') fitStateMR(dat, c(4, 3.8, 5), cutoff = 0.5) fitViterbiMR(dat, c(4, 3.8, 5), cutoff = 0.5) fitPartialViterbiMR(dat, c(4, 3.8, 5), cutoff = 0.5, 20, 10)
Estimate the state at each time point under the Moving-Resting-Handling
process with Embedded Brownian Motion with animal movement data at
discretely time points. See the difference between fitStateMRH
and fitViterbiMRH
in detail part. Using fitPartialViterbiMRH
to estimate the state during a small piece of time interval.
fitStateMRH(data, theta, integrControl = integr.control()) fitViterbiMRH(data, theta, integrControl = integr.control()) fitPartialViterbiMRH( data, theta, startpoint, pathlength, integrControl = integr.control() )
fitStateMRH(data, theta, integrControl = integr.control()) fitViterbiMRH(data, theta, integrControl = integr.control()) fitPartialViterbiMRH( data, theta, startpoint, pathlength, integrControl = integr.control() )
data |
a |
theta |
the parameters for Moving-Resting-Handling model, in the order of rate of moving, rate of resting, rate of handling, volatility and switching probability. |
integrControl |
Integration control vector includes rel.tol, abs.tol, and subdivisions. |
startpoint |
Start time point of interested time interval. |
pathlength |
the length of interested time interval. |
fitStateMRH
estimates the most likely state by maximizing
the probability of , where X is the whole
data and
is the possible sates at
(moving, resting
or handling).
fitViterbiMRH
estimates the most likely state path by maximizing
, where
X is the whole data and
is the possible
state path.
fitPartialViterbiMRH
estimates the most likely state path of
a small peice of time interval, by maximizing the probability of
,
where
is the start time point and
is the length of interested
time interval.
A data.frame
contains estimated results, with elements:
original data be estimated.
conditional probability of moving, resting, handling (p.m
,
p.r
, p.h
), which is for
fitStateMRH
; for
fitViterbiMRH
, where is
;
and
for
fitPartialViterbiMRH
.
estimated states with 0-moving, 1-resting, 2-handling.
Chaoran Hu
Pozdnyakov, V., Elbroch, L.M., Hu, C., Meyer, T., and Yan, J. (2018+) On estimation for Brownian motion governed by telegraph process with multiple off states. <arXiv:1806.00849>
rMRH
for simulation.
fitMRH
for estimation of parameters.
## Not run: ## time consuming example set.seed(06269) tgrid <- seq(0, 400, by = 8) dat <- rMRH(tgrid, 4, 0.5, 0.1, 5, 0.8, 'm') fitStateMRH(dat, c(4, 0.5, 0.1, 5, 0.8)) fitViterbiMRH(dat, c(4, 0.5, 0.1, 5, 0.8)) fitPartialViterbiMRH(dat, c(4, 0.5, 0.1, 5, 0.8), 20, 10) ## End(Not run)
## Not run: ## time consuming example set.seed(06269) tgrid <- seq(0, 400, by = 8) dat <- rMRH(tgrid, 4, 0.5, 0.1, 5, 0.8, 'm') fitStateMRH(dat, c(4, 0.5, 0.1, 5, 0.8)) fitViterbiMRH(dat, c(4, 0.5, 0.1, 5, 0.8)) fitPartialViterbiMRH(dat, c(4, 0.5, 0.1, 5, 0.8), 20, 10) ## End(Not run)
Auxiliary function for the numerical integration used in the likelihood and composite likelihood functions. Typically only used internally by 'fitMR' and 'fitMRH'.
integr.control( rel.tol = .Machine$double.eps^0.25, abs.tol = rel.tol, subdivisions = 100L )
integr.control( rel.tol = .Machine$double.eps^0.25, abs.tol = rel.tol, subdivisions = 100L )
rel.tol |
relative accuracy requested. |
abs.tol |
absolute accuracy requested. |
subdivisions |
the maximum number of subintervals. |
The arguments are the same as integrate
, but passed
down to the C API of Rdqags used by integrate
.
A list with components named as the arguments.
A Brownian bridge is a continuous-time stochastic process B(t) whose probability distribution is the conditional probability distribution of a standard Wiener process W(t) subject to the condition (when standardized) that W(T) = 0, so that the process is pinned to the same value at both t = 0 and t = T. The implementation here is a generalized Brownian bridge that allows start point and end point at different locations.
rBB(time, start_pt, end_pt, sigma)
rBB(time, start_pt, end_pt, sigma)
time |
time points at which observations are to be simulated |
start_pt |
the start point location of Brownian bridge |
end_pt |
the end point location of Brownian brige |
sigma |
volatility parameter of the Brownian motion |
A data.frame
whose first column is the time points
and second column is coordinate of the locations.
## Brownian bridge starting from location 0 and ending at location 1 ## with sigma 0.1 from time 0 to time 10 plot(rBB(seq(0, 10, length.out = 100), 0, 1, 0.1), type = "l")
## Brownian bridge starting from location 0 and ending at location 1 ## with sigma 0.1 from time 0 to time 10 plot(rBB(seq(0, 10, length.out = 100), 0, 1, 0.1), type = "l")
Given the volatility parameters of a Brownian motion and normally distributed measurement errors, generate the process at discretely observed time points of a given dimension.
rBMME(time, dim = 2, sigma = 1, delta = 1) rBmme(time, dim = 2, sigma = 1, delta = 1)
rBMME(time, dim = 2, sigma = 1, delta = 1) rBmme(time, dim = 2, sigma = 1, delta = 1)
time |
vector of time points at which observations are to be sampled |
dim |
(integer) dimension of the Brownian motion |
sigma |
volatility parameter (sd) of the Brownian motion |
delta |
sd parameter of measurement error |
A data.frame
whose first column is the time points and whose
other columns are coordinates of the locations.
Pozdnyakov V., Meyer, TH., Wang, Y., and Yan, J. (2013) On modeling animal movements using Brownian motion with measurement error. Ecology 95(2): p247–253. doi:doi:10.1890/13-0532.1.
tgrid <- seq(0, 10, length = 1001) ## make it irregularly spaced tgrid <- sort(sample(tgrid, 800)) dat <- rBMME(tgrid, 1, 1) plot(dat[,1], dat[,2], xlab="t", ylab="X(t)", type="l")
tgrid <- seq(0, 10, length = 1001) ## make it irregularly spaced tgrid <- sort(sample(tgrid, 800)) dat <- rBMME(tgrid, 1, 1) plot(dat[,1], dat[,2], xlab="t", ylab="X(t)", type="l")
A moving-moving process consists of two states: moving (large) and moving (small). The transition between the two states is modeled by an alternating renewal process, with exponentially distributed duration. An animal moves according to two Brownian motions with different volatility parameters.
rMM(time, lamM1, lamM2, sigma1, sigma2, s0, dim = 2)
rMM(time, lamM1, lamM2, sigma1, sigma2, s0, dim = 2)
time |
time points at which observations are to be simulated |
lamM1 |
rate parameter of the exponential duration while moving1 |
lamM2 |
rate parameter of the exponential duration while moving2 |
sigma1 |
volatility parameter of the Brownian motion while moving1 |
sigma2 |
volatility parameter of the Brownian motion while moving2 |
s0 |
the state at time 0, must be one of "m1" or "m2", for moving1 and moving2, respectively |
dim |
(integer) dimension of the Brownian motion |
A data.frame
whose first column is the time points and whose
other columns are coordinates of the locations.
Yan, J., Chen, Y., Lawrence-Apfel, K., Ortega, I. M., Pozdnyakov, V., Williams, S., and Meyer, T. (2014) A moving-resting process with an embedded Brownian motion for animal movements. Population Ecology. 56(2): 401–415.
Pozdnyakov, V., Elbroch, L., Labarga, A., Meyer, T., and Yan, J. (2017) Discretely observed Brownian motion governed by telegraph process: estimation. Methodology and Computing in Applied Probability. doi:10.1007/s11009-017-9547-6.
tgrid <- seq(0, 100, length=100) dat <- rMM(tgrid, 1, 0.1, 1, 0.1, "m1") plot(dat[,1], dat[,2], xlab="t", ylab="X(t)", type='l')
tgrid <- seq(0, 100, length=100) dat <- rMM(tgrid, 1, 0.1, 1, 0.1, "m1") plot(dat[,1], dat[,2], xlab="t", ylab="X(t)", type='l')
A moving-resting process consists of two states: moving and resting. The transition between the two states is modeled by an alternating renewal process, with exponentially distributed duration. An animal stays at the same location while resting, and moves according to a Brownian motion while moving.
rMR(time, lamM, lamR, sigma, s0, dim = 2, state = FALSE) rMovRes(time, lamM, lamR, sigma, s0, dim = 2) rMRME(time, lamM, lamR, sigma, sig_err, s0, dim = 2, state = FALSE)
rMR(time, lamM, lamR, sigma, s0, dim = 2, state = FALSE) rMovRes(time, lamM, lamR, sigma, s0, dim = 2) rMRME(time, lamM, lamR, sigma, sig_err, s0, dim = 2, state = FALSE)
time |
time points at which observations are to be simulated |
lamM |
rate parameter of the exponential duration while moving |
lamR |
rate parameter of the exponential duration while resting |
sigma |
volatility parameter of the Brownian motion while moving |
s0 |
the state at time 0, must be one of "m" or "r", for moving and resting, respectively |
dim |
(integer) dimension of the Brownian motion |
state |
indicates whether the simulation show the states at given time points. |
sig_err |
s.d. of Gaussian white noise |
A data.frame
whose first column is the time points and whose
other columns are coordinates of the locations.
Yan, J., Chen, Y., Lawrence-Apfel, K., Ortega, I. M., Pozdnyakov, V., Williams, S., and Meyer, T. (2014) A moving-resting process with an embedded Brownian motion for animal movements. Population Ecology. 56(2): 401–415.
Pozdnyakov, V., Elbroch, L., Labarga, A., Meyer, T., and Yan, J. (2017) Discretely observed Brownian motion governed by telegraph process: estimation. Methodology and Computing in Applied Probability. doi:10.1007/s11009-017-9547-6.
tgrid <- seq(0, 10, length=1001) ## make it irregularly spaced tgrid <- sort(sample(tgrid, 800)) dat <- rMR(tgrid, 1, 1, 1, "m") plot(dat[,1], dat[,2], xlab="t", ylab="X(t)", type='l') dat2 <- rMR(tgrid, 1, 1, 1, "m", state = TRUE) head(dat2) dat3 <- rMRME(tgrid, 1, 1, 1, 0.01, "m", state = TRUE) head(dat3) plot(dat3[,1], dat3[,3], xlab="t", ylab="Z(t)=X(t)+GWN(0.01)", type="l")
tgrid <- seq(0, 10, length=1001) ## make it irregularly spaced tgrid <- sort(sample(tgrid, 800)) dat <- rMR(tgrid, 1, 1, 1, "m") plot(dat[,1], dat[,2], xlab="t", ylab="X(t)", type='l') dat2 <- rMR(tgrid, 1, 1, 1, "m", state = TRUE) head(dat2) dat3 <- rMRME(tgrid, 1, 1, 1, 0.01, "m", state = TRUE) head(dat3) plot(dat3[,1], dat3[,3], xlab="t", ylab="Z(t)=X(t)+GWN(0.01)", type="l")
A moving-resting process consists of two states: moving and resting. The transition between the two states is modeled by an alternating renewal process, with exponentially distributed duration. An animal stays at the same location while resting, and moves according to a Brownian motion while moving. A moving-resting bridge is an extension of Brownian bridge that uses moving-resting process to bridge given starting point and ending point.
rMRB(time, start_pt, end_pt, lamM, lamR, sigma, s0)
rMRB(time, start_pt, end_pt, lamM, lamR, sigma, s0)
time |
time points at which observations are to be simulated |
start_pt |
the start point location of Brownian bridge (numeric for one dimension, vector for multiple dimension) |
end_pt |
the end point location of Brownian brige (numeric for one dimension, vector for multiple dimension) |
lamM |
rate parameter of the exponential duration while moving |
lamR |
rate parameter of the exponential duration while resting |
sigma |
volatility parameter of the Brownian motion while moving |
s0 |
the state at time 0, must be one of "m" or "r", for moving and resting, respectively |
A data.frame
whose first column is the time points and whose
other columns are coordinates of the locations.
tgrid <- seq(0, 10, length=1001) ## make it irregularly spaced tgrid <- sort(sample(tgrid, 800)) ## a 2-dim moving-resting bridge starting from c(0, 0) ## and ending at c(10, -10) dat <- rMRB(tgrid, start_pt = c(0, 0), end_pt = c(10, -10), lamM = 1, lamR = 1, sigma = 1, "m") par(mfrow = c(2, 1)) plot(dat[,1], dat[,2], xlab="t", ylab="X(t)", type='l') plot(dat[,1], dat[,3], xlab="t", ylab="X(t)", type='l') par(mfrow = c(1, 1))
tgrid <- seq(0, 10, length=1001) ## make it irregularly spaced tgrid <- sort(sample(tgrid, 800)) ## a 2-dim moving-resting bridge starting from c(0, 0) ## and ending at c(10, -10) dat <- rMRB(tgrid, start_pt = c(0, 0), end_pt = c(10, -10), lamM = 1, lamR = 1, sigma = 1, "m") par(mfrow = c(2, 1)) plot(dat[,1], dat[,2], xlab="t", ylab="X(t)", type='l') plot(dat[,1], dat[,3], xlab="t", ylab="X(t)", type='l') par(mfrow = c(1, 1))
A moving-resting-handling process consists of three states: moving, resting and handling. The transition between the three states is modeled by an alternating renewal process, with expenentially distributed duration. An animal stays at the same location while resting and handling (the choice of resting and handling depends on Bernoulli distribution), and moves according to a Brownian motion while moving state. The sequence of states is moving, resting or staying, moving, resting or staying ... or versus
rMRH(time, lamM, lamR, lamH, sigma, p, s0, dim = 2, state = FALSE)
rMRH(time, lamM, lamR, lamH, sigma, p, s0, dim = 2, state = FALSE)
time |
time points at which observations are to be simulated |
lamM |
rate parameter of the exponential duration while moving |
lamR |
rate parameter of the exponential duration while resting |
lamH |
rate parameter of the exponential duration while handling |
sigma |
volatility parameter of the Brownian motion while moving |
p |
probability of choosing resting, and 1-p is probability of choosing handling |
s0 |
the state at time 0, must be one of "m" (moving), "r" (resting) or "h" (handling). |
dim |
(integer) dimension of the Brownian motion |
state |
indicates whether the simulation show the states at given time points. |
A data.frame
whose first column is the time points and whose
other columns are coordinates of the locations. If state
is
TRUE
, the second column will be the simulation state.
Chaoran Hu
Pozdnyakov, V., Elbroch, L.M., Hu, C., Meyer, T., and Yan, J. (2018+) On estimation for Brownian motion governed by telegraph process with multiple off states. <arXiv:1806.00849>
fitMRH
for fitting model.
set.seed(06269) tgrid <- seq(0, 8000, length.out=1001) dat <- rMRH(time=tgrid, lamM=4, lamR=0.04, lamH=0.2, sigma=1000, p=0.5, s0="m", dim=2) plot(dat$time, dat$X1, type='l') plot(dat$time, dat$X2, type='l') plot(dat$X1, dat$X2, type='l') set.seed(06269) ## show the usage of state dat2 <- rMRH(time=tgrid, lamM=4, lamR=0.04, lamH=0.2, sigma=1000, p=0.5, s0="m", dim=2, state=TRUE) head(dat) head(dat2)
set.seed(06269) tgrid <- seq(0, 8000, length.out=1001) dat <- rMRH(time=tgrid, lamM=4, lamR=0.04, lamH=0.2, sigma=1000, p=0.5, s0="m", dim=2) plot(dat$time, dat$X1, type='l') plot(dat$time, dat$X2, type='l') plot(dat$X1, dat$X2, type='l') set.seed(06269) ## show the usage of state dat2 <- rMRH(time=tgrid, lamM=4, lamR=0.04, lamH=0.2, sigma=1000, p=0.5, s0="m", dim=2, state=TRUE) head(dat) head(dat2)
Return subsets of data from each year, which is in given
time interval between startDate
and endDate
.
seasonFilter(data, startDate, endDate)
seasonFilter(data, startDate, endDate)
data |
The data be filtered, which has the same format
as the output from |
startDate , endDate
|
Start point and end point of time interval during a year, which has the format "MM-DD". |
A data.frame
with inputted data and additional
column 'BATCH' indicates which subset of inputted data is located
within given time interval. In column 'BATCH', different integers
stands for different segments and 0 stands for outside given time
interval.
Chaoran Hu
Animal movement models including Moving-Resting Process with Embedded Brownian Motion, Brownian Motion with Measurement Error, Moving-Resting-Handling Process with Embedded Brownian Motion, Moving-Resting Process with Measurement Error, Moving-Moving Process with two Embedded Brownian Motions.
*maintainer, author* Chaoran Hu [email protected]
*author* Vladimir Pozdnyakov [email protected]
*author* Jun Yan [email protected]
Transfer the raw location dataset of animal to the standard dataset,
which is acceptable in this packages. The raw dataset contains at least
four components: 1. t1
: data information. 2. dt..hr.
: the
difference of time between two sample points. 3. e1
: the GPS
coordinate of east-west. 4. n1
: the GPS coordinate of north-south.
(These weird variable names are from the original GPS data. We will
change them in later version.)
transfData(data, dateFormat, roundValue = NULL, lengthUnit = "km")
transfData(data, dateFormat, roundValue = NULL, lengthUnit = "km")
data |
The raw dataset. |
dateFormat |
Charater string indicates the format of date variable. |
roundValue |
Round GPS coordinate to |
lengthUnit |
Charater string indicates the length unit of GPS coordinate, which can be "m" or "km"(default). Usually, we recommend not change the default setup of this parameter. Otherwise, numerical computation problem will happen. |
A data.frame
containing the following components, which is
standard format of dataset in this package:
date: tells us the date of collecting this sample point.
cumTime: cumulative time line. The collection of this data starts from time 0 in this time line. (Time unit is hours.)
centerE: the centered east-west GPS coordinate with the center is
the starting point (when cumTime[1]
).
centerN: the centered north-south GPS coordinate with the center is
the starting point (when cumTime[1]
).
Chaoran Hu
as.Date
has parameter format
, which is the
same as the parameter dateFormat
in this function.
This function calculates variance covariance matrix for estimators from smam package. Different methods will be used for different 'smam' models.
## S3 method for class 'smam_mrme' vcov( object, nBS = 25, detailBS = TRUE, numThreads = 5, gradMethod = "simple", vcovMethod = "pBootstrap", integrControl = integr.control(), ... ) ## S3 method for class 'smam_mm' vcov( object, nBS = 25, detailBS = TRUE, numThreads = 5, integrControl = integr.control(), ... ) ## S3 method for class 'smam_mrh' vcov(object, numThreads = 5, integrControl = integr.control(), ...) ## S3 method for class 'smam_mr' vcov(object, ...) ## S3 method for class 'smam_bmme' vcov(object, ...)
## S3 method for class 'smam_mrme' vcov( object, nBS = 25, detailBS = TRUE, numThreads = 5, gradMethod = "simple", vcovMethod = "pBootstrap", integrControl = integr.control(), ... ) ## S3 method for class 'smam_mm' vcov( object, nBS = 25, detailBS = TRUE, numThreads = 5, integrControl = integr.control(), ... ) ## S3 method for class 'smam_mrh' vcov(object, numThreads = 5, integrControl = integr.control(), ...) ## S3 method for class 'smam_mr' vcov(object, ...) ## S3 method for class 'smam_bmme' vcov(object, ...)
object |
a fitted object from one of 'smam::fitXXXX' functions |
nBS |
number of bootstrap. |
detailBS |
whether or not output estimation results of bootstrap, which can be used to generate bootstrap CI. Required when ‘vcovMethod==’pBootstrap''. |
numThreads |
the number of threads for parallel computation. If its value is greater than 1, then parallel computation will be processed. Otherwise, serial computation will be processed. |
gradMethod |
method used for numeric gradient ( |
vcovMethod |
method of calculating variance covariance matrix. This should be one of 'pBootstrap' (default) and 'Godambe'. |
integrControl |
a list of control parameters for the |
... |
Optional arguments that are not used |
## time consuming example #tgrid <- seq(0, 100, length=100) #set.seed(123) #dat <- rMRME(tgrid, 1, 0.5, 1, 0.01, "m") ## fit whole dataset to the MRME model #fit <- fitMRME(dat, start=c(1, 0.5, 1, 0.01)) #fit ## get covariance matrix of estimators #vcov(fit)
## time consuming example #tgrid <- seq(0, 100, length=100) #set.seed(123) #dat <- rMRME(tgrid, 1, 0.5, 1, 0.01, "m") ## fit whole dataset to the MRME model #fit <- fitMRME(dat, start=c(1, 0.5, 1, 0.01)) #fit ## get covariance matrix of estimators #vcov(fit)