Description Usage Arguments Value Examples
Constructs a nonGaussian basic structural model with local level or local trend component, a seasonal component, and regression component (or subset of these components).
1 2 3  ng_bsm(y, sd_level, sd_slope, sd_seasonal, sd_noise, distribution, phi,
u = 1, beta, xreg = NULL, period = frequency(y), a1, P1,
state_intercept)

y 
Vector or a 
sd_level 
A fixed value or a prior for the standard error of the noise in level equation. See priors for details. 
sd_slope 
A fixed value or a prior for the standard error of the noise in slope equation. See priors for details. If missing, the slope term is omitted from the model. 
sd_seasonal 
A fixed value or a prior for the standard error of the noise in seasonal equation. See priors for details. If missing, the seasonal component is omitted from the model. 
sd_noise 
Prior for the standard error of the additional noise term. See priors for details. If missing, no additional noise term is used. 
distribution 
distribution of the observation. Possible choices are

phi 
Additional parameter relating to the nonGaussian distribution. For Negative binomial distribution this is the dispersion term, and for other distributions this is ignored. 
u 
Constant parameter for nonGaussian models. For Poisson and negative binomial distribution, this corresponds to the offset term. For binomial, this is the number of trials. 
beta 
Prior for the regression coefficients. 
xreg 
Matrix containing covariates. 
period 
Length of the seasonal component i.e. the number of
observations per season. Default is 
a1 
Prior means for the initial states (level, slope, seasonals). Defaults to vector of zeros. 
P1 
Prior covariance for the initial states (level, slope, seasonals). Default is diagonal matrix with 1e5 on the diagonal. 
state_intercept 
Intercept terms for state equation, given as a m times n matrix. 
Object of class ng_bsm
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21  model < ng_bsm(Seatbelts[, "VanKilled"], distribution = "poisson",
sd_level = halfnormal(0.01, 1),
sd_seasonal = halfnormal(0.01, 1),
beta = normal(0, 0, 10),
xreg = Seatbelts[, "law"])
## Not run:
set.seed(123)
mcmc_out < run_mcmc(model, n_iter = 5000, nsim = 10)
mcmc_out$acceptance_rate
theta < expand_sample(mcmc_out, "theta")
plot(theta)
summary(theta)
library("ggplot2")
ggplot(as.data.frame(theta[,1:2]), aes(x = sd_level, y = sd_seasonal)) +
geom_point() + stat_density2d(aes(fill = ..level.., alpha = ..level..),
geom = "polygon") + scale_fill_continuous(low = "green",high = "blue") +
guides(alpha = "none")
## End(Not run)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.