| Title: | State Space Framework and Structural Time Series with 'JDemetra+ 3.x' |
|---|---|
| Description: | R Interface to 'JDemetra+ 3.x' (<https://github.com/jdemetra>) time series analysis software. It offers access to several functions on state space models and structural time series. |
| Authors: | Jean Palate [aut, cre], Tanguy Barthelemy [art] |
| Maintainer: | Jean Palate <[email protected]> |
| License: | file LICENSE |
| Version: | 2.4.1.9000 |
| Built: | 2026-05-08 09:20:24 UTC |
| Source: | https://github.com/rjdverse/rjd3sts |
Creates the state space form of an airline model;
.airline(period = 12, theta = -0.6, btheta = -0.8).airline(period = 12, theta = -0.6, btheta = -0.8)
period |
Period of the model. |
theta |
Regular moving average parameter. |
btheta |
Seasonal moving average parameter. |
The raw state space form of the Airline model.
ssf<-.airline(24) .dk_likelihood(ssf, rjd3toolkit::ABS$X0.2.09.10.M)ssf<-.airline(24) .dk_likelihood(ssf, rjd3toolkit::ABS$X0.2.09.10.M)
Computes the diffuse likelihood by means of the augmented Kalman filter.
.akf_likelihood( ssf, data, qtype = c("NORMAL", "PARTIAL_TRIANGULARIZATION", "FULL_TRIANGULARIZATION", "QR"), collapsing = TRUE, rescalingFactor = TRUE ).akf_likelihood( ssf, data, qtype = c("NORMAL", "PARTIAL_TRIANGULARIZATION", "FULL_TRIANGULARIZATION", "QR"), collapsing = TRUE, rescalingFactor = TRUE )
ssf |
A state space form. |
data |
Arrays of data. |
qtype |
Type of the initialization in the augmented Kalman filter |
rescalingFactor |
True if the innovation covariance matrix is defined up to a scaling factor. |
The diffuse likelihood
sarima<-.sarima(12, NULL, 1, -.6, NULL, 1, -.5) ssf<-.ssf(sarima, .loading(0)) .akf_likelihood(ssf, rjd3toolkit::ABS$X0.2.09.10.M)sarima<-.sarima(12, NULL, 1, -.6, NULL, 1, -.5) ssf<-.ssf(sarima, .loading(0)) .akf_likelihood(ssf, rjd3toolkit::ABS$X0.2.09.10.M)
Creates an ARIMA state block (representation I)
.arima(ar, delta, ma, var = 1).arima(ar, delta, ma, var = 1)
ar |
Stationary auto-regressive polynomial, including the constant (=1). True signs. |
delta |
Non-stationary auto-regressive polynomial, including the constant (=1). True signs. |
ma |
Moving average polynomial, including the constant (=1). True signs. |
var |
Variance of the innovations |
A raw java state block.
sb<-.arima(c(1, -.5), NULL, c(1,-.8)) .ssf_P0(sb)sb<-.arima(c(1, -.5), NULL, c(1,-.8)) .ssf_P0(sb)
Creates an ARIMA state block (representation II)
.arima2(ar, delta, ma, var = 1).arima2(ar, delta, ma, var = 1)
ar |
Stationary auto-regressive polynomial, including the constant (=1). True signs. |
delta |
Non-stationary auto-regressive polynomial, including the constant (=1). True signs. |
ma |
Moving average polynomial, including the constant (=1). True signs. |
var |
Variance of the innovations |
A raw java state block
sb<-.arima2(c(1, -.5), NULL, c(1,-.8)) .ssf_P0(sb)sb<-.arima2(c(1, -.5), NULL, c(1,-.8)) .ssf_P0(sb)
Title
.bsm2spec(jbsm, fixed = FALSE, fixedCycle = TRUE).bsm2spec(jbsm, fixed = FALSE, fixedCycle = TRUE)
fixedCycle |
bsm<-bsm_model(12) jbsm<-.r2jd_bsm(bsm) jspec<-.bsm2spec(jbsm)bsm<-bsm_model(12) jbsm<-.r2jd_bsm(bsm) jspec<-.bsm2spec(jbsm)
Title
.bsm2ucm(jbsm, normalized = TRUE).bsm2ucm(jbsm, normalized = TRUE)
normalized |
bsm<-bsm_model(12) jbsm<-.r2jd_bsm(bsm) jucm<-.bsm2ucm(jbsm)bsm<-bsm_model(12) jbsm<-.r2jd_bsm(bsm) jucm<-.bsm2ucm(jbsm)
Title
.circular_loading(period, start = 0).circular_loading(period, start = 0)
start |
Title
.ckms_likelihood(ssf, data, rescalingFactor = TRUE).ckms_likelihood(ssf, data, rescalingFactor = TRUE)
rescalingFactor |
Title
.cyclical_loading(period, start = 0).cyclical_loading(period, start = 0)
start |
Computes the diffuse likelihood by means of the diffuse Kalman filter (Durbin-Koopman).
.dk_likelihood(ssf, data, sqr = TRUE, rescalingFactor = TRUE).dk_likelihood(ssf, data, sqr = TRUE, rescalingFactor = TRUE)
ssf |
A state space form. |
data |
Arrays of data. |
sqr |
Square root diffuse initialization, if any |
rescalingFactor |
True if the innovation covariance matrix is defined up to a scaling factor. |
The diffuse likelihood
sarima<-.sarima(12, NULL, 1, -.6, NULL, 1, -.5) ssf<-.ssf(sarima, .loading(0)) .dk_likelihood(ssf, rjd3toolkit::ABS$X0.2.09.10.M)sarima<-.sarima(12, NULL, 1, -.6, NULL, 1, -.5) ssf<-.ssf(sarima, .loading(0)) .dk_likelihood(ssf, rjd3toolkit::ABS$X0.2.09.10.M)
Title
.loading(pos, weights = NULL).loading(pos, weights = NULL)
weights |
Creates a composite loading
.loading_composite(dims, cmps).loading_composite(dims, cmps)
dims |
The dimensions of the corresponding state blocks |
cmps |
The loadings |
l<-.loading_composite(c(1,2,3), list(.loading(0), .loading(0), .loading(0))) .ssf_Z(l, 6, 0)l<-.loading_composite(c(1,2,3), list(.loading(0), .loading(0), .loading(0))) .ssf_Z(l, 6, 0)
Creates a local level state block
.local_level(var = 1, start = NaN).local_level(var = 1, start = NaN)
var |
Innovation variance of local level |
start |
Initial value of the state block. Should be NaN for a diffuse initialization |
A wrapper around the java object (class JD3_RawStateBlock).
sb<-.local_level(1.5, 0) .ssf_T(sb, 0)sb<-.local_level(1.5, 0) .ssf_T(sb, 0)
Creates a local linear trend state block.
.local_linear_trend(lvar, svar = 0).local_linear_trend(lvar, svar = 0)
lvar |
Innovation variance of the level equation. |
svar |
Innovation variance of the slope equation. |
A wrapper around the java object (class JD3_RawStateBlock).
sb<-.local_linear_trend(1.5, 0.5) .ssf_T(sb, 0)sb<-.local_linear_trend(1.5, 0.5) .ssf_T(sb, 0)
Title
.mssf(component, measurements).mssf(component, measurements)
measurements |
Creates a white noise.
.noise(var = 1).noise(var = 1)
var |
Variance of the noise. |
A wrapper around the java object (class JD3_RawStateBlock).
sb<-.noise(.01) .ssf_T(sb, 0)sb<-.noise(.01) .ssf_T(sb, 0)
Title
.proc_diffuselikelihood(jrslt, prefix).proc_diffuselikelihood(jrslt, prefix)
prefix |
Creates an ARMA state block
.sarima(period, phi, d = 1, theta, bphi, bd = 1, btheta).sarima(period, phi, d = 1, theta, bphi, bd = 1, btheta)
period |
Period of the seasonality |
phi |
Regular stationary auto-regressive polynomial. True signs, without the constant |
d |
Regular differencing order |
theta |
Regular moving average polynomial. True signs, without the constant |
bphi |
Seasonal stationary auto-regressive polynomial. True signs, without the constant |
bd |
Seasonal differencing order |
btheta |
Seasonal moving average polynomial. True signs, without the constant |
A raw java state block
sb<-.sarima(12, c(0.5, -.2, .1), 1, -.8, NULL, 1, -.6) .ssf_P0(sb)sb<-.sarima(12, c(0.5, -.2, .1), 1, -.8, NULL, 1, -.6) .ssf_P0(sb)
Creates an ARMA state block (representation I)
.sarma(period, phi, theta, bphi, btheta).sarma(period, phi, theta, bphi, btheta)
period |
Period of the seasonality |
phi |
Regular stationary auto-regressive polynomial. True signs, without the constant |
theta |
Regular moving average polynomial. True signs, without the constant |
bphi |
Seasonal stationary auto-regressive polynomial. True signs, without the constant |
btheta |
Seasonal moving average polynomial. True signs, without the constant |
A raw java state block
sb<-.sarma(12, c(0.5, -.2, .1), -.8, NULL, -.6) .ssf_P0(sb)sb<-.sarma(12, c(0.5, -.2, .1), -.8, NULL, -.6) .ssf_P0(sb)
Creates an ARMA state block (representation II)
.sarma2(period, phi, theta, bphi, btheta).sarma2(period, phi, theta, bphi, btheta)
period |
Period of the seasonality |
phi |
Regular stationary auto-regressive polynomial. True signs, without the constant |
theta |
Regular moving average polynomial. True signs, without the constant |
bphi |
Seasonal stationary auto-regressive polynomial. True signs, without the constant |
btheta |
Seasonal moving average polynomial. True signs, without the constant |
A raw java state block
sb<-.sarma2(12, c(0.5, -.2, .1), -.8, NULL, -.6) .ssf_P0(sb)sb<-.sarma2(12, c(0.5, -.2, .1), -.8, NULL, -.6) .ssf_P0(sb)
Creates a seasonal component, corresponding to a multivariate random walk, with an aggregation constraint to 0 and various covariances for the innovations of the transition equation.
.seasonal( period, type = c("Trigonometric", "Crude", "HarrisonStevens", "Dummy"), var = 1 ).seasonal( period, type = c("Trigonometric", "Crude", "HarrisonStevens", "Dummy"), var = 1 )
period |
Period of the seasonality |
type |
Type of the innovations of the transition equation |
var |
Variance of the innovations |
A wrapper around the java object (class JD3_RawStateBlock)
sb<-.seasonal(4, "HarrisonStevens", .01) .ssf_V(sb, 0)sb<-.seasonal(4, "HarrisonStevens", .01) .ssf_V(sb, 0)
Title
.ssf(component, loading, evar = 0).ssf(component, loading, evar = 0)
evar |
Transforms a time invariant state space form based on functions into a state space models represented by matrices.
.ssf_as_time_invariant(jssf).ssf_as_time_invariant(jssf)
jssf |
The object oriented (java) state space form, which should be time invariant |
A new Java object based on matrices
ll<-.local_linear_trend(0.1, 0.1) s<-.seasonal(12, var=.5) m<-.composite(list(ll, s)) ssf1<-.ssf(m, .loading(c(0,2)), 1) ssf2<-.ssf_as_time_invariant(ssf1) ll1<-.akf_likelihood(ssf1, rjd3toolkit::ABS$X0.2.09.10.M) ll2<-.akf_likelihood(ssf2, rjd3toolkit::ABS$X0.2.09.10.M) print(ll1$ll-ll2$ll)ll<-.local_linear_trend(0.1, 0.1) s<-.seasonal(12, var=.5) m<-.composite(list(ll, s)) ssf1<-.ssf(m, .loading(c(0,2)), 1) ssf2<-.ssf_as_time_invariant(ssf1) ll1<-.akf_likelihood(ssf1, rjd3toolkit::ABS$X0.2.09.10.M) ll2<-.akf_likelihood(ssf2, rjd3toolkit::ABS$X0.2.09.10.M) print(ll1$ll-ll2$ll)
Computes smoothed states by means of the augmented Kalman filter in the case of diffuse initialization
.ssf_smooth( ssf, data, all = TRUE, qtype = c("NORMAL", "PARTIAL_TRIANGULARIZATION", "FULL_TRIANGULARIZATION", "QR") ).ssf_smooth( ssf, data, all = TRUE, qtype = c("NORMAL", "PARTIAL_TRIANGULARIZATION", "FULL_TRIANGULARIZATION", "QR") )
ssf |
A state space form. |
data |
Arrays of data. |
all |
True if the covariances of the smoothed states are compted. |
qtype |
Type of the initialization in the augmented Kalman filter |
A matrix with the smoothed states and - if requested - their standard deviations.
Gets the transition matrix.
.ssf_T(x, pos = 0).ssf_T(x, pos = 0)
x |
A state block or a state space form. |
pos |
The 0-based position (use 0 for time invariant models) |
The requested matrix.
sarima<-.sarma(12, .9, -.6, .9, -.5) .ssf_T(sarima)sarima<-.sarma(12, .9, -.6, .9, -.5) .ssf_T(sarima)
Gets the covariance of the innovations in the transition equation.
.ssf_V(x, pos = 0).ssf_V(x, pos = 0)
x |
A state block or a state space form. |
pos |
The 0-based position (use 0 for time invariant models) |
The requested matrix.
sarima<-.sarma(12, .9, -.6, .9, -.5) .ssf_V(sarima)sarima<-.sarma(12, .9, -.6, .9, -.5) .ssf_V(sarima)
Gets the loading vector. It should have the same length as the corresponding state block.
.ssf_Z(x, n, pos).ssf_Z(x, n, pos)
x |
Loading |
n |
the Length of the corresponding state block (on which the loading will be applied) |
pos |
0-based position of the filter |
the loading vector
Retrieves the dimension of a state block
.state_dim(x).state_dim(x)
x |
A state block |
The length of the state block
s<-.seasonal(12) .state_dim(s)s<-.seasonal(12) .state_dim(s)
Gets the state of the state space form
.state_of(ssf).state_of(ssf)
ssf |
A state space form |
A state block
Adds a state block or a measurement equation to a given state space model
add(model, item)add(model, item)
model |
A state space model |
item |
A state block or a measurement equation |
model<-model() llt<-locallineartrend("llt") add(model,llt)model<-model() llt<-locallineartrend("llt") add(model,llt)
Add a building block to the considered equation
add_equation(equation, item, coeff = 1, fixed = TRUE, loading = NULL)add_equation(equation, item, coeff = 1, fixed = TRUE, loading = NULL)
equation |
the equation |
item |
the block of the state array that will be linked to the observation corresponding to this equation through the specified loading and coefficient |
coeff |
the value of the coefficient associated to the block of latent variables defined by |
fixed |
logical that triggers estimation of coeff (FALSE) or fixes it (TRUE) to a pre-specified value |
loading |
the loading that links the block to the observations |
eq<- equation('eq1') ll<-locallevel('ll') n<-noise("n", variance = 1, fixed = TRUE) add_equation(eq, ll) add_equation(eq, n, coeff=0.1, fixed=FALSE)eq<- equation('eq1') ll<-locallevel('ll') n<-noise("n", variance = 1, fixed = TRUE) add_equation(eq, ll) add_equation(eq, n, coeff=0.1, fixed=FALSE)
Title
aggregation(name, components)aggregation(name, components)
components |
Functions to create an autoregressive model (ar) or a
modified autoregressive model (ar2)
ar( name, ar, fixedar = FALSE, variance = 0.01, fixedvariance = FALSE, nlags = 0, zeroinit = FALSE ) ar2( name, ar, fixedar = FALSE, variance = 0.01, fixedvariance = FALSE, nlags = 0, nfcasts = 0 )ar( name, ar, fixedar = FALSE, variance = 0.01, fixedvariance = FALSE, nlags = 0, zeroinit = FALSE ) ar2( name, ar, fixedar = FALSE, variance = 0.01, fixedvariance = FALSE, nlags = 0, nfcasts = 0 )
ar |
vector of the AR coefficients (See @details Additional details...). |
fixedar |
boolean that triggers the estimation of the AR coefficients ( |
variance |
the variance ( |
fixedvariance |
boolean that triggers the estimation of the variance ( |
nlags |
integer specifying how many lags of the state variable are needed |
zeroinit |
boolean determining the initial condition for the state variable,
which is equal to zero if |
nfcasts |
integer specifying how many forecasts of the state variable are needed |
The AR process is defined by
The stability of the auto-regressive polynomial is not checked.
An element of type "JD3_SsfStateBlock" (wrapper around the corresponding Java object))
b_ar<-ar("my_ar", c(.8,-.3,.2), variance=1) block_p0(b_ar)b_ar<-ar("my_ar", c(.8,-.3,.2), variance=1) block_p0(b_ar)
Autoregressive Integrated Moving Average (ARIMA) Model
arima(name, ar, diff, ma, var = 1, fixed = FALSE)arima(name, ar, diff, ma, var = 1, fixed = FALSE)
fixed |
Autoregressive Moving Average (ARMA) Model
arma(name, ar, fixedar = FALSE, ma, fixedma = FALSE, var = 1, fixedvar = FALSE)arma(name, ar, fixedar = FALSE, ma, fixedma = FALSE, var = 1, fixedvar = FALSE)
fixedvar |
Title
bsm_model( period, noise.var = 1, level.var = 1, slope.var = NULL, seasonal.var = 1, seasonal.model = c("HarrisonStevens", "Trigonometric", "Dummy", "Crude", "Fixed"), cycle.var = NULL, cycle.dumpingfactor = 0.9, cycle.length = 6 )bsm_model( period, noise.var = 1, level.var = 1, slope.var = NULL, seasonal.var = 1, seasonal.model = c("HarrisonStevens", "Trigonometric", "Dummy", "Crude", "Fixed"), cycle.var = NULL, cycle.dumpingfactor = 0.9, cycle.length = 6 )
cycle.length |
Title
bsm_to_ucm(bsm, normalized = TRUE)bsm_to_ucm(bsm, normalized = TRUE)
normalized |
Position of the components
components_pos(model)components_pos(model)
model |
Estimated model |
The first position of the different blocks in the state array
model<-model() ll<-locallevel("ll") seas<-seasonal("seas", 12, "Crude") n<-noise("n") add(model,ll) add(model,seas) add(model,n) emodel<-estimate(model, rjd3toolkit::Retail$BookStores) print(components_pos(emodel))model<-model() ll<-locallevel("ll") seas<-seasonal("seas", 12, "Crude") n<-noise("n") add(model,ll) add(model,seas) add(model,n) emodel<-estimate(model, rjd3toolkit::Retail$BookStores) print(components_pos(emodel))
Title
cumul(name, core, period, start = 0)cumul(name, core, period, start = 0)
start |
Title
cycle( name, factor = 0.9, period = 60, fixed = FALSE, variance = 0.01, fixedvariance = FALSE )cycle( name, factor = 0.9, period = 60, fixed = FALSE, variance = 0.01, fixedvariance = FALSE )
name |
Name of the block |
variance |
Variance of the innovations |
fixedvariance |
Indicates if the variance if fixed |
Create equation
equation(name, variance = 0, fixed = TRUE)equation(name, variance = 0, fixed = TRUE)
fixed |
Estimate a SSF Model
estimate( model, data, marginal = FALSE, concentrated = TRUE, initialization = c("Augmented_Robust", "Diffuse", "SqrtDiffuse", "Augmented", "Augmented_NoCollapsing"), optimizer = c("LevenbergMarquardt", "MinPack", "BFGS", "LBFGS"), precision = 1e-15, initialParameters = NULL )estimate( model, data, marginal = FALSE, concentrated = TRUE, initialization = c("Augmented_Robust", "Diffuse", "SqrtDiffuse", "Augmented", "Augmented_NoCollapsing"), optimizer = c("LevenbergMarquardt", "MinPack", "BFGS", "LBFGS"), precision = 1e-15, initialParameters = NULL )
model |
the model |
data |
a matrix containing the data (one time series per column, time series dimension on the rows) |
marginal |
logical value used to specify whether the marginal likelihood definition is used (TRUE) or not (FALSE) during the optimization. The marginal likelihood is recommended when there is at least one variable that loads on a non-stationary latent variable and the loading coefficient needs to be estimated. |
concentrated |
logical value used to specify whether the likelihood is concentrated (TRUE) or not (FALSE) during the optimization |
initialization |
initialization method. |
precision |
indicating the largest likelihood deviations that make the algorithm stop. |
initialParameters |
Title
filtered_states_stdev(model)filtered_states_stdev(model)
model |
Title
filtering_states_stdev(model)filtering_states_stdev(model)
model |
Title
loading(pos = NULL, weights = NULL)loading(pos = NULL, weights = NULL)
pos |
defines the position of each one of the elements of the block of states defined.
|
weights |
defines the weights associated to each one of the state variables included in the block. |
Title
loading_cyclical(period, startpos)loading_cyclical(period, startpos)
startpos |
Title
loading_periodic(period, startpos)loading_periodic(period, startpos)
startpos |
Give all the loadings for a given variable
loadings(object, var = 1)loadings(object, var = 1)
object |
Estimated model |
var |
loadings for the given variable (or equation). Useless in the case of univariate models |
A matrix with the requested loadings. The number of rows corresponds to the number of observations.
model<-model() llt<-locallineartrend("llt") seas<-seasonal("seas", 12, "Crude") n<-noise("n") add(model,llt) add(model,seas) add(model,n) y<-rjd3toolkit::Retail$BookStores emodel<-estimate(model, y) print(loadings(emodel))model<-model() llt<-locallineartrend("llt") seas<-seasonal("seas", 12, "Crude") n<-noise("n") add(model,llt) add(model,seas) add(model,n) y<-rjd3toolkit::Retail$BookStores emodel<-estimate(model, y) print(loadings(emodel))
Local Level
locallevel(name, variance = 0.01, fixed = FALSE, initial = NaN)locallevel(name, variance = 0.01, fixed = FALSE, initial = NaN)
name |
Name of the block |
variance |
the value of the variance ( |
fixed |
boolean that triggers estimation of |
initial |
initial value of the level ( |
ll<-locallevel('ll', variance=1) print(block_t(ll))ll<-locallevel('ll', variance=1) print(block_t(ll))
Local linear trend state block
locallineartrend( name, levelVariance = 0.01, slopeVariance = 0.01, fixedLevelVariance = FALSE, fixedSlopeVariance = FALSE )locallineartrend( name, levelVariance = 0.01, slopeVariance = 0.01, fixedLevelVariance = FALSE, fixedSlopeVariance = FALSE )
name |
Name of the block |
levelVariance |
variance of the level ( |
fixedLevelVariance, fixedSlopeVariance
|
boolean that triggers
the estimation of the variances |
llt<-locallineartrend('llt', levelVariance=1, slopeVariance=.25) print(block_t(llt))llt<-locallineartrend('llt', levelVariance=1, slopeVariance=.25) print(block_t(llt))
Title
ltd_airline( name, length, period, th0 = -0.6, th1 = -0.6, bth0 = -0.6, bth1 = -0.6, fixedth = FALSE, variance = 0.01, fixedvariance = FALSE )ltd_airline( name, length, period, th0 = -0.6, th1 = -0.6, bth0 = -0.6, bth1 = -0.6, fixedth = FALSE, variance = 0.01, fixedvariance = FALSE )
fixedvariance |
Modeling errors in surveys with overlapping panels
msae(name, nwaves, ar, fixedar = TRUE, lag = 1) msae2(name, vars, fixedvars = FALSE, ar, fixedar = TRUE, lag = 1) msae3(name, vars, fixedvars = FALSE, ar, fixedar = TRUE, k, lag = 1)msae(name, nwaves, ar, fixedar = TRUE, lag = 1) msae2(name, vars, fixedvars = FALSE, ar, fixedar = TRUE, lag = 1) msae3(name, vars, fixedvars = FALSE, ar, fixedar = TRUE, k, lag = 1)
name |
Name of the block |
nwaves |
integer representing the number of waves |
ar |
matrix representing the covariance structure of the wave specific survey error. |
fixedar |
logical that triggers the estimation of the correlation patterns ( |
lag |
integer specifying the number of time periods (in the base frequency) that compose the survey period. This coincides with the number of time periods an individual has to wait between two different waves. Note that if the survey period is one quarter, all of them have already responded in the previous wave exactly 3 months ago (because individuals are always interviewed at the same stint during each survey period). |
Title
msignal(object, m, pos = NULL, stdev = FALSE)msignal(object, m, pos = NULL, stdev = FALSE)
object |
Estimated model |
stdev |
Noise state block
noise(name, variance = 0.01, fixed = FALSE)noise(name, variance = 0.01, fixed = FALSE)
name |
Name of the block |
variance |
Variance of the noise |
fixed |
Indicates if the variance is fixed |
n<-noise("n", 1) block_t(n)n<-noise("n", 1) block_t(n)
Get Parameters of SSF Model
parameters(model)parameters(model)
model |
Title
periodic(name, period, harmonics, variance = 0.01, fixedvariance = FALSE)periodic(name, period, harmonics, variance = 0.01, fixedvariance = FALSE)
name |
Name of the block |
fixedvariance |
Title
## S3 method for class 'JD3STS' print(x, ...)## S3 method for class 'JD3STS' print(x, ...)
... |
Time Varying Regressors
reg(name, x, var = NULL, fixed = FALSE)reg(name, x, var = NULL, fixed = FALSE)
x |
matrix containing the regressors |
fixed |
Title
reg_td( name, period, start, length, groups = c(1, 2, 3, 4, 5, 6, 0), contrast = TRUE, variance = 1, fixed = FALSE )reg_td( name, period, start, length, groups = c(1, 2, 3, 4, 5, 6, 0), contrast = TRUE, variance = 1, fixed = FALSE )
fixed |
Title
sae(name, ar, fixedar = FALSE, lag = 1, zeroinit = FALSE)sae(name, ar, fixedar = FALSE, lag = 1, zeroinit = FALSE)
name |
Name of the block |
zeroinit |
Title
sarima( name, period, orders, seasonal, parameters = NULL, fixedparameters = FALSE, var = 1, fixedvariance = FALSE )sarima( name, period, orders, seasonal, parameters = NULL, fixedparameters = FALSE, var = 1, fixedvariance = FALSE )
fixedvariance |
Seasonal state block
seasonal( name, period, type = c("Trigonometric", "Crude", "HarrisonStevens", "Dummy"), variance = 0.01, fixed = FALSE )seasonal( name, period, type = c("Trigonometric", "Crude", "HarrisonStevens", "Dummy"), variance = 0.01, fixed = FALSE )
name |
Name of the block |
period |
Period of the seasonality |
type |
Type of the seasonal component |
variance |
Innovation variance |
fixed |
Indicates if the variance is fixed |
seas1<-seasonal("seas1", 12, "HarrisonStevens", variance=1) print(block_v(seas1)) seas2<-seasonal("seas2", 12, "Trigonometric", variance=1) print(block_v(seas2))seas1<-seasonal("seas1", 12, "HarrisonStevens", variance=1) print(block_v(seas1)) seas2<-seasonal("seas2", 12, "Trigonometric", variance=1) print(block_v(seas2))
Title
seasonalbreaks( y, period = NA, level = 1, slope = 1, noise = 1, seasonal = c("HarrisonStevens", "Trigonometric", "Dummy", "Crude", "Fixed", "Unused"), X = NULL, X.td = NULL )seasonalbreaks( y, period = NA, level = 1, slope = 1, noise = 1, seasonal = c("HarrisonStevens", "Trigonometric", "Dummy", "Crude", "Fixed", "Unused"), X = NULL, X.td = NULL )
y |
input time series. |
period |
annual frequency. |
level |
-1 = no level, 0 = fixed level, 1 = sotchastic level |
seasonal |
Seasonal model |
X |
Regression variables (same length as y) or NULL |
X.td |
Groups of days for trading days regressors. The length of the array must be 7.
It indicates to what group each week day belongs.
The first item corresponds to Mondays and the last one to Sundays. The group used for contrasts (usually Sundays) is identified by 0. The other groups are identified by 1, 2,... n (<= 6).
For instance, usual trading days are defined by |
x<-rjd3toolkit::Retail$BookStores seasonalbreaks(x)x<-rjd3toolkit::Retail$BookStores seasonalbreaks(x)
Title
signal(object, obs = 1, pos = NULL, loading = NULL, stdev = FALSE)signal(object, obs = 1, pos = NULL, loading = NULL, stdev = FALSE)
stdev |
Retrieves the components of the model (univariate case) or the components corresponding to a given equation (multivariate case)
smoothed_components(model, equation = 1, fast = TRUE)smoothed_components(model, equation = 1, fast = TRUE)
model |
Estimated state space model |
equation |
Equation containing the components |
fast |
if true, only the components are computed. Otherwise, their stdev are also computed (not returned but available for future use). |
A matrix with the components
model<-model() llt<-locallineartrend("llt") seas<-seasonal("seas", 12, "Crude") n<-noise("n") add(model,llt) add(model,seas) add(model,n) y<-rjd3toolkit::Retail$BookStores emodel<-estimate(model, y) scmp<-smoothed_components(emodel) high<-cbind(scmp[,1], y-scmp[,2]) low<-scmp[,c(2,3)] matplot(high, type='l') matplot(low, type='l')model<-model() llt<-locallineartrend("llt") seas<-seasonal("seas", 12, "Crude") n<-noise("n") add(model,llt) add(model,seas) add(model,n) y<-rjd3toolkit::Retail$BookStores emodel<-estimate(model, y) scmp<-smoothed_components(emodel) high<-cbind(scmp[,1], y-scmp[,2]) low<-scmp[,c(2,3)] matplot(high, type='l') matplot(low, type='l')
Retrieves the standard deviations of the components of the model (univariate case) or of the components corresponding to a given equation (multivariate case)
smoothed_components_stdev(model, equation = 1)smoothed_components_stdev(model, equation = 1)
model |
Estimated state space model |
equation |
Equation containing the components |
A matrix with the stdev of the components
Standard deviations of the smoothed states
smoothed_states_stdev(model)smoothed_states_stdev(model)
model |
Estimated model |
A matrix with the standard deviations of the states (a row corresponding to one time point)
model<-model() ll<-locallevel("ll") seas<-seasonal("seas", 12, "Crude") n<-noise("n") add(model,ll) add(model,seas) add(model,n) emodel<-estimate(model, rjd3toolkit::Retail$BookStores) ess<-smoothed_states_stdev(emodel) cmps<-ess[,c(1,2,13)] matplot(cmps, type='l')model<-model() ll<-locallevel("ll") seas<-seasonal("seas", 12, "Crude") n<-noise("n") add(model,ll) add(model,seas) add(model,n) emodel<-estimate(model, rjd3toolkit::Retail$BookStores) ess<-smoothed_states_stdev(emodel) cmps<-ess[,c(1,2,13)] matplot(cmps, type='l')
Title
splines_daily(name, startYear, knots, start = 1, variance = 1, fixed = FALSE)splines_daily(name, startYear, knots, start = 1, variance = 1, fixed = FALSE)
fixed |
Title
splines_generic( name, period, knots, order = 4, start = 1, variance = 1, fixed = FALSE )splines_generic( name, period, knots, order = 4, start = 1, variance = 1, fixed = FALSE )
fixed |
Title
splines_regular( name, period, nknots = 0, knots = NULL, start = 1, variance = 1, fixed = FALSE )splines_regular( name, period, nknots = 0, knots = NULL, start = 1, variance = 1, fixed = FALSE )
fixed |
Title
ssf(initialization, dynamics, measurement)ssf(initialization, dynamics, measurement)
measurement |
Title
sts( y, X = NULL, X.td = NULL, level = 1, slope = 1, cycle = -1, noise = 1, seasonal = c("Trigonometric", "Dummy", "Crude", "HarrisonStevens", "Fixed", "Unused"), diffuse.regs = TRUE, tol = 1e-09 )sts( y, X = NULL, X.td = NULL, level = 1, slope = 1, cycle = -1, noise = 1, seasonal = c("Trigonometric", "Dummy", "Crude", "HarrisonStevens", "Fixed", "Unused"), diffuse.regs = TRUE, tol = 1e-09 )
y |
input time series. |
X |
Regression variables (same length as y) or NULL |
X.td |
Groups of days for trading days regressors. The length of the array must be 7.
It indicates to what group each week day belongs.
The first item corresponds to Mondays and the last one to Sundays. The group used for contrasts (usually Sundays) is identified by 0. The other groups are identified by 1, 2,... n (<= 6).
For instance, usual trading days are defined by |
level |
-1 = no level, 0 = fixed level, 1 = sotchastic level |
seasonal |
Seasonal model |
tol |
x<-rjd3toolkit::Retail$BookStores sts(x)x<-rjd3toolkit::Retail$BookStores sts(x)
Forecast with STS model
sts_forecast(y, model = c("none", "td2", "td3", "td7", "full"), nf = 12)sts_forecast(y, model = c("none", "td2", "td3", "td7", "full"), nf = 12)
y |
Series |
model |
Model for calendar effects
|
nf |
number of forecasts |
fcasts<-sts_forecast(rjd3toolkit::ABS$X0.2.09.10.M)fcasts<-sts_forecast(rjd3toolkit::ABS$X0.2.09.10.M)
Title
sts_outliers( y, period = NA, X = NULL, X.td = NULL, level = 1, slope = 1, noise = 1, seasonal = c("Trigonometric", "Dummy", "Crude", "HarrisonStevens", "Fixed", "Unused"), ao = TRUE, ls = TRUE, so = FALSE, cv = 0, tcv = 0, estimation.forward = c("Score", "Point", "Full"), estimation.backward = c("Point", "Score", "Full") )sts_outliers( y, period = NA, X = NULL, X.td = NULL, level = 1, slope = 1, noise = 1, seasonal = c("Trigonometric", "Dummy", "Crude", "HarrisonStevens", "Fixed", "Unused"), ao = TRUE, ls = TRUE, so = FALSE, cv = 0, tcv = 0, estimation.forward = c("Score", "Point", "Full"), estimation.backward = c("Point", "Score", "Full") )
y |
input time series. |
period |
annual frequency. |
X |
Regression variables (same length as y) or NULL |
X.td |
Groups of days for trading days regressors. The length of the array must be 7.
It indicates to what group each week day belongs.
The first item corresponds to Mondays and the last one to Sundays. The group used for contrasts (usually Sundays) is identified by 0. The other groups are identified by 1, 2,... n (<= 6).
For instance, usual trading days are defined by |
level |
-1 = no level, 0 = fixed level, 1 = sotchastic level |
seasonal |
Seasonal model |
ao, ls, so
|
boolean indicating if additive outliers ( |
estimation.backward |
x<-rjd3toolkit::Retail$BookStores sts_outliers(x)x<-rjd3toolkit::Retail$BookStores sts_outliers(x)
Title
sts_raw( y, period = NA, X = NULL, X.td = NULL, level = 1, slope = 1, cycle = -1, noise = 1, seasonal = c("Trigonometric", "Dummy", "Crude", "HarrisonStevens", "Fixed", "Unused"), diffuse.regs = TRUE, tol = 1e-09 )sts_raw( y, period = NA, X = NULL, X.td = NULL, level = 1, slope = 1, cycle = -1, noise = 1, seasonal = c("Trigonometric", "Dummy", "Crude", "HarrisonStevens", "Fixed", "Unused"), diffuse.regs = TRUE, tol = 1e-09 )
tol |
Title
tdairline_estimation(s, td = NULL, vartd = FALSE, precision = 1e-09)tdairline_estimation(s, td = NULL, vartd = FALSE, precision = 1e-09)
precision |
Title
var_ar( name, ar, fixedar = FALSE, stderr, scale = 1, fixed = FALSE, zeroinit = FALSE )var_ar( name, ar, fixedar = FALSE, stderr, scale = 1, fixed = FALSE, zeroinit = FALSE )
name |
Name of the block |
zeroinit |
Title
var_locallevel(name, std, scale = 1, fixed = FALSE, initial = NaN)var_locallevel(name, std, scale = 1, fixed = FALSE, initial = NaN)
initial |
Title
var_locallineartrend( name, lstd, sstd = NULL, levelScale = 1, slopeScale = 1, fixedLevelScale = FALSE, fixedSlopeScale = FALSE )var_locallineartrend( name, lstd, sstd = NULL, levelScale = 1, slopeScale = 1, fixedLevelScale = FALSE, fixedSlopeScale = FALSE )
fixedSlopeScale |
Title
var_noise(name, std, scale = 1, fixed = FALSE)var_noise(name, std, scale = 1, fixed = FALSE)
fixed |
Time Varying Regressor
var_reg(name, x, stderr, scale = 1, fixed = FALSE)var_reg(name, x, stderr, scale = 1, fixed = FALSE)
x |
Regression variable. Numerics |
stderr |
Standard error of the innovations of the coefficient (1 in extrapolation) |
scale |
Scaling factor |
fixed |
Fixed scaling factor |
x<-rjd3toolkit::Retail$BookStores std<-rep(1, length(x)) std[c(20, 50, 150)]<-5 v<-var_reg("vx", x, std, 0.1)x<-rjd3toolkit::Retail$BookStores std<-rep(1, length(x)) std[c(20, 50, 150)]<-5 v<-var_reg("vx", x, std, 0.1)
Title
var_seasonal( name, period, type = c("Trigonometric", "Crude", "HarrisonStevens", "Dummy"), std, scale = 1, fixed = FALSE )var_seasonal( name, period, type = c("Trigonometric", "Crude", "HarrisonStevens", "Dummy"), std, scale = 1, fixed = FALSE )
fixed |