forked from helske/bssm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap_filter.Rd
More file actions
83 lines (71 loc) · 2.12 KB
/
Copy pathbootstrap_filter.Rd
File metadata and controls
83 lines (71 loc) · 2.12 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bootstrap_filter.R
\name{bootstrap_filter}
\alias{bootstrap_filter}
\alias{bootstrap_filter.gaussian}
\alias{bootstrap_filter.nongaussian}
\alias{bootstrap_filter.ssm_nlg}
\alias{bootstrap_filter.ssm_sde}
\title{Bootstrap Filtering}
\usage{
bootstrap_filter(model, particles, ...)
\method{bootstrap_filter}{gaussian}(
model,
particles,
seed = sample(.Machine$integer.max, size = 1),
...
)
\method{bootstrap_filter}{nongaussian}(
model,
particles,
seed = sample(.Machine$integer.max, size = 1),
...
)
\method{bootstrap_filter}{ssm_nlg}(
model,
particles,
seed = sample(.Machine$integer.max, size = 1),
...
)
\method{bootstrap_filter}{ssm_sde}(
model,
particles,
L,
seed = sample(.Machine$integer.max, size = 1),
...
)
}
\arguments{
\item{model}{of class \code{bsm_lg}, \code{bsm_ng} or \code{svm}.}
\item{particles}{Number of particles.}
\item{...}{Ignored.}
\item{seed}{Seed for RNG.}
\item{L}{Integer defining the discretization level for SDE models.}
}
\value{
List with samples (\code{alpha}) from the filtering distribution and corresponding weights (\code{weights}),
as well as filtered and predicted states and corresponding covariances (\code{at}, \code{att}, \code{Pt}, \code{Ptt}),
and estimated log-likelihood (\code{logLik}).
}
\description{
Function \code{bootstrap_filter} performs a bootstrap filtering with stratification
resampling.
}
\examples{
set.seed(1)
x <- cumsum(rnorm(50))
y <- rnorm(50, x, 0.5)
model <- bsm_lg(y, sd_y = 0.5, sd_level = 1, P1 = 1)
out <- bootstrap_filter(model, particles = 1000)
ts.plot(cbind(y, x, out$att), col = 1:3)
ts.plot(cbind(kfilter(model)$att, out$att), col = 1:3)
data("poisson_series")
model <- bsm_ng(poisson_series, sd_level = 0.1, sd_slope = 0.01,
P1 = diag(1, 2), distribution = "poisson")
out <- bootstrap_filter(model, particles = 100)
ts.plot(cbind(poisson_series, exp(out$att[, 1])), col = 1:2)
}
\references{
Gordon, N. J., Salmond, D. J., & Smith, A. F. M. (1993).
Novel approach to nonlinear/non-Gaussian Bayesian state estimation. IEE Proceedings-F, 140, 107–113.
}