Local linear trend model
Definition
The local linear trend block describes the following trend component:
lt+1=lt+nt+ξt nt+1=nt+μt ξt∼N(0,σ2σ2l) μt∼N(0,σ2σ2n)It conforms to the general SSF by setting the state vector
αt=(ltnt)and the transition matrices
Tt=(1101) Vt=(σ2σ2l00σ2σ2n)Depending on the estimation algorithm used, it may be preferrable to slightly modify the model and set σ2=1
jd3_ssf_locallineartrend
R users can use this function to define local linear trend model that belongs to the JD+ class JD3_SsfItem
output
Object of the JD+ class JD3_SsfItem
:
usage
jd3_ssf_locallineartrend(name, levelVariance, slopevariance, fixedLevelVariance, fixedSlopeVariance )
Argument | Definition | Default | Remarks |
---|---|---|---|
name | string with the name of the component | ex. "trend", do not forget the commmas | |
levelVariance | double for the value of σ2l | 1 | variance of the level innovation is actually σ2σ2l |
slopeVariance | double for the value of σ2n | 0.01 | variance of the slope innovation is actually σ2σ2n |
fixedLevelVariance | logical that triggers estimation of σ2l (FALSE) or fixes it (TRUE) to a pre-specified value set by the parameter levelVariance | FALSE | |
fixedSlopeVariance | logical that triggers estimation of σ2n (FALSE) or fixes it (TRUE) to a pre-specified value set by the parameter slopeVariance | FALSE |
Examples of use
jd3_ssf_locallineartrend("trend")
jd3_ssf_locallineartrend("trend", levelVariance=1, slopeVariance=0.001,fixedLevelVariance=FALSE, fixedSlopeVariance=FALSE) // default
jd3_ssf_locallineartrend("trend", levelVariance=1, slopeVariance=0.001,fixedLevelVariance=TRUE, fixedSlopeVariance=FALSE) // default
Application
In this example we design a model based on a random walk with drift specification.
Create Model:
- The very first thing one needs to do is to create the model object, which will be called “yourModel”:
yourModel<-jd3_ssf_model()
Specify latent variables (transition equations):
- Second, we add our random walk with drift and name it as “trend”. We fix the slope variance to zero in order to ensure
that this component becomes a constant. In the absence of further arguments the variance of the level is not specified among the arguments and it is therefore
the only parameter to estimate (by default, fixedLevelVariance=FALSE):
add(yourModel, jd3_ssf_locallineartrend("trend", slopeVariance=0, fixedSlopeVariance=TRUE) )
Measurement equation design:
Let’s define the following measurement equation (see Measurements)
eq1:yt=lt+ϵ1,t eq2:yt+h|t=lt+hc+ϵ2,tThe first equation represents an observed variable yt that measures (with an error ϵ1,t) the latent factor lt, which is assumed to follow a random walk with drift. The second variable represents a h-steps ahead forecast for yt, which is given by the h-steps ahead forecast of the trend lt+hc. Note that lt and nt=c are the two elements of the state vector in the local linear trend model defined above. The subindex t in nt in not necessary because we have set the slopeVariance to zero and therefore this term is constant over time (i.e. it represents the constant drift component).
- Let’s assign the names “eq1” and “eq2” to our measurement equations, where the time series are called “y” (yt) and “yh” (yt+h|t)
The I.I.D. measurement error component var(ϵ1,t)=σ2σ2ϵ1 will be identified using the normalization
assumption that σ2ϵ1=1. In turn, var(ϵ2,t) is left unrestricted.
eq1 <-jd3_ssf_equation("y", variance=1, fixed=TRUE) add(eq1, "trend") eq2 <-jd3_ssf_equation("yh", variance=1, fixed=FALSE) add(eq2, "trend", jd3_ssf_loadings(c(1,2),c(1,h)) )