fit_ssm: Correlated Random Walk Filter

Description Usage Arguments Details Value Examples

Description

Correlated Random Walk Filter

Usage

1
2
3
4
fit_ssm(d, subset = rep(TRUE, nrow(d)), tstep = 2.4/24, nu = 5,
  gamma = 0.5, soth = TRUE, common.tau = FALSE, parameters = NULL,
  optim = c("nlminb", "optim"), verbose = FALSE, amf = amfCRAWL(),
  span = 0.3)

Arguments

d

a data frame of observations

subset

a logical vector indicating the subset of data records to be filtered

tstep

the time step to predict to (in days)

nu

degrees of freedom parameter

gamma

the autocorrelation parameter used to estimate initial parameters

soth

if TRUE states occur on the hour, starting with the hour immediately preceeding the time of the first observation; if FALSE states occur relative to the time of the first observation

common.tau

estimate a single error sd for both longitude and latitude

parameters

the TMB parameter list

optim

numerical optimizer

verbose

report progress during minimization

amf

ARGOS error multiplication factors

span

the span parameter for the loess fits used to estimate initial locations

Details

Fit a correlated random walk to filter a track and predict locations on a regular time step.

The input track is given as a dataframe where each row is an observed location, with columns

'date'

observation time (as GMT POSIXct),

'lon'

observed longitude,

'lat'

observed latitude,

'lc'

location class.

The TMB parameter list can be specified directly with the parameters argument. Otherwise suitable parameter values are estimated from predicted locations estimated by fitting loess smooths to the raw observations.

The filtering model assumes the errors in longitude and latitude are proportional to scale factors determined by the location class. The scale factors are specified through the amf argument. By default the function uses the same scaling factors for location accuracy as used in the R package crawl for ARGOS data.

Value

a list with components

predicted

a data.frame of predicted location states

fitted

a data.frame of fitted locations

par

model parameter summmary

data

the input data.frame

subset

the input subset vector

tstep

the prediction time step

common.tau

has a common tau been estimated

opt

the object returned by the optimizer

tmb

the TMB object

aic

the calculated Akaike Information Criterion

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Fit DCRW model for state filtering and regularization
data(ellie)
fit <- fit_ssm(ellie, tstep = 6 / 24)

## plot predicted track over observations
plot(lat ~ lon, fit$data, pch = 3, col = "firebrick")
points(lat ~ lon, fit$predicted, pch = 19, cex = 0.5, col = "dodgerblue")

## plot residuals for longitude and latitude
layout(matrix(1:2, 2, 1))
lon.res <- fit$data$lon - fit$fitted$lon
lat.res <- fit$data$lat - fit$fitted$lat
plot(fit$data$date, lon.res, xlab = "")
abline(h = 0, lty = 2, col = "red")
plot(fit$data$date, lat.res, xlab = "date")
abline(h = 0, lty = 2, col = "red")

ianjonsen/ssmTMB documentation built on July 5, 2019, 3:03 p.m.