Questions tagged [dlm]

dlm refers to the R package for Bayesian and likelihood analysis of dynamic linear models.

Filter by
Sorted by
Tagged with
0 votes
0 answers
16 views

State-Space model with time-varying error in R

I am trying to estimate the following local level model in R: $y_t = \theta_t + v_t$ $\theta_t = \theta_{t-1} + w_t$ where $y$ is the observable variable and $\theta$ is the latent variable. This ...
user avatar
  • 1
0 votes
0 answers
33 views

DLM package in R: No convergence

I am trying to decompose an observable time series $y$ into a permanent component $\bar{y}$ and a transitory component $\tilde{y}$. In my model, the transitory component follows a stationary $AR(1)$ ...
user avatar
  • 1
0 votes
0 answers
56 views

Kalman Filter with External Control Input in R

I am facing a problem with Kalman filtering. I am not possible to find some package in RStudio with state equation containing Control Input (x_k=Fx_{k-1}+Gu_{k-1}+q_{k-1}). Does anybody know some ...
user avatar
  • 1
0 votes
0 answers
57 views

Is this the right way to set up a kalman filter in dlm based on random walk?

I have just started learning the filter for forecasting (please be gentle...), as well as the dlm package and its applications. I have the following code stolen from link but instead of ARMA I used a ...
user avatar
  • 1
1 vote
1 answer
105 views

Understanding questions regarding the Kalman filter

I have a few questions about the Kalman filter in R (dlm package): Given the function dlmFilter, there is the output time ...
user avatar
  • 41
2 votes
1 answer
79 views

How to visualize results of the distributed lag model using mgcv package

I'm recently reading the book entitled "Generalized Additive Models --- An Introduction with R 2nd edition". When reading chapter 7.4.2--- a distributed lag model for pollution related death,...
user avatar
1 vote
0 answers
12 views

dlmForecast error : "dlmForecast only works with constant models"

I have a dataset with intervention dummy variable to be incorporated inside the measurement equation (let's call Lambda) I picture my measurement and state are as below : measurement : Lambda + Et ...
user avatar
0 votes
0 answers
61 views

Issues with exogenous variable (dlm package R)

I would like to determine the parameters of the state space model \begin{align} \xi_{i+1}&= \widetilde{G}\xi_t+\phi x_t + V_{t+1} \\ R_{t}&= H^T\xi_t +\eta_t \end{align} using dlmMLE and then ...
user avatar
  • 41
2 votes
0 answers
75 views

State space model to invert moving average of AR1 process whose mean temporarily jumps up once

This is a follow up query of this question. Here is the problem statement: I have an AR1 process say x[t] whose mean jumps up in a given time period. ie. $x[t]-\mu[t] = \phi (x[t-1] -\mu[t-1]) + \...
user avatar
0 votes
1 answer
122 views

Using a state space model to invert a moving average

Here is the problem :- We have an AR(1) process, $x[t]$, ie, $(x[t] - \mu) = \phi(x[t-1]-\mu) + \epsilon_x[t] $ where $Var(\epsilon_x[t]) = \sigma_x^2$ and $Mean(\epsilon_x[t])=0$ ie. $x[t] = (\mu - \...
user avatar
1 vote
0 answers
43 views

How to interpret the coefficients in a time varying linear regression model?

How do I interpret the coefficients in a time varying linear regression model (in particular theta2). Formula from the book “Dynamic Linear Models with R” As I understand, at time t theta2 is the ...
user avatar
  • 11
1 vote
1 answer
147 views

MLE estimation of mean-adjusted state-space model

I am trying to estimate coefficients of a state-space model described in Diebold et.al (2006) with data and scripts here: $$y_t = Zf_t + \epsilon_t$$ $$f_t-\mu_t = T(f_{t-1}-\mu)+\eta_t$$ The main ...
user avatar
  • 159
0 votes
1 answer
173 views

multivariate seasonal time series in dlm in r

I am trying to build a dynamic linear model in R for my bivariate seasonal (monthly ) time series. I found the following resources which help me to model bivariate cases but there is no seasonality ...
user avatar
  • 1
0 votes
1 answer
404 views

DLM package in R to estimate a state space model with drifts

I am trying to use the DLM package in R to estimate a state space model where the measurement and transition equations are as follows. The measurement equations are: $$ \begin{align} \left( \begin{...
user avatar
  • 1
1 vote
0 answers
170 views

Comparison of fit from OLS, GLS, GLM, ARIMA and DLM

I've been comparing the fit of OLS, GLS, GLM, ARIMA and DLM modelling approaches to my 20 observation time series data set. I had originally done so using RMSE, but wondered whether you could use AIC ...
user avatar
1 vote
1 answer
77 views

Use of Dyanmic Linear Models in Interrupted Time Series

I've been undertaking research in which I use an Interrupted Time Series [ITS] approach to attempt to quantify the effect of a policy intervention. An ITS approach segments the data into two periods, ...
user avatar
1 vote
2 answers
71 views

dlmSmooth increases fluctuations

I am currently working with State Space models for the first time and am trying to estimate an error correction model with an unobserved I(2) process, $\mu_t$. I have specified a model in R using the ...
user avatar
  • 11
1 vote
1 answer
89 views

Help with state space model

I am trying to estimate the following state space model: \begin{equation} y_t = y^{gap}_{t} + y^*_t \end{equation} \begin{equation} y^{gap}_{t} = \alpha_{1}y^{gap}_{t-1}+\alpha_{3}y^{gap}_{t-2} +\...
user avatar
2 votes
0 answers
225 views

Dynamic Linear Model (DLM) vs Weighted Linear Regression

In Applied Bayesian Forecasting and Time Series Analysis (1994, page 14), they state: The passage of time erodes the value of information - sales figures from six months ago are potentially less ...
user avatar
  • 883
2 votes
0 answers
74 views

FFBS algorithm for estimating mean log-return parameter in stochastic volatility jump model

I am currently attempting to replicate this model: https://arxiv.org/pdf/1809.01501.pdf in r. My (first) problem is regarding how to sample from conditional posterior for mu, $(μ_{(j)}|Y_n, J_{(j−1)}...
user avatar
0 votes
1 answer
292 views

Two time-varying coefficients in Kalman filter with DLM package [closed]

I am trying to estimate a model that has two time varying coefficients in R using the "DLM" package. My measurement equation would be = Yt = F1tx1t + F2tx2t + v The state equations are: F1t = F1t-...
user avatar
0 votes
1 answer
143 views

Can someone explain me how cumulative association in distributed lag models works?

I'm trying to fit some distributed lag models with dlnm package in R. When I specify cumul=TRUE, I obtain extra parameters ...
user avatar
  • 247
2 votes
1 answer
240 views

Parameter estimation in Dynamic Linear Models

I am currently developing a DLM of the following form $$\underset{k \times 1} {y_t} = \underset{k \times n}A \underset{n \times 1}{\theta_t} + \epsilon_t$$ $$\theta_t = \mu + \underset{n \times n}B\...
user avatar
1 vote
0 answers
212 views

Multilevel dynamic linear models in R

I am interested in fitting a multilevel bayesian structural time series with a hierarchical structure of the dynamic regression coefficients. The reason I want to do this is is that I have a number of ...
user avatar
  • 255
0 votes
1 answer
118 views

Custom Space State model using DLM in R

DLM package in R can model linear space state models of the form: I have a different category of equation which is also a linear polynomial equation of order 1 with constant coefficients. I would ...
user avatar
1 vote
0 answers
100 views

Hierarchical time series using DLM

I am developing a forecasting solution using R's dlm package and it is proving to be very useful for most of our requirements. However, I am also keen on sharing information among different time ...
user avatar
  • 11
1 vote
0 answers
80 views

Time varying representation of Okun's law

I've estimated a dynamic linear model to capture time varying parameters in an Okun's law type of model: I set the starting values for the state vector all equal to zero and estimate the system ...
user avatar
1 vote
1 answer
194 views

What do the outputs of the function dlmSmooth from R's dlm package mean?

In the vignette for the R package dlm: link on page 12, the author runs the function dlmSmooth to smooth the data and the function returns an object which is ...
user avatar
  • 11
1 vote
0 answers
146 views

Unable to recover time varying AR1 parameter from State Space model

I am trying to do a Time varying parameters regression. The equation is as follows: $y_t = a + b_t * x_{1t} + \epsilon_t$ Here a is fixed while $b_t$ is AR1. My state space equations are : There ...
user avatar
1 vote
1 answer
609 views

Estimating State Space Model Parameters

I'm having a bit of difficulty estimating parameters in DLM in R and I was wondering if I could get a bit of help with it. I have a system of equations given as: $p_{t} = m_{t} + s_{t}$ $m_{t} = m_{...
user avatar
1 vote
0 answers
153 views

Parameter estimation using dlmModReg

I am trying to use dlmModReg to estimate the regression coefficient lambda (fixed) of the explanatory variable x (27 zeroes followed by one) as applied to the Nile data. My code is this - ...
user avatar
  • 11
4 votes
3 answers
8k views

Simple explanation of dynamic linear models

I'm looking for a really simple explanation of what a dynamic linear model is as I need to explain this to a non-technical audience. I have looked around for examples but they are very maths heavy. I ...
user avatar
  • 301
7 votes
1 answer
2k views

Difference between Cholesky decomposition and log-cholesky Decomposition

Is there any difference between a Cholesky decomposition and a log-cholesky decomposition? If yes, what is the difference? In the paper "An R package for dynamic linear models" by Giovanni Petris ( ...
user avatar
  • 4,912
0 votes
1 answer
811 views

Convert a state-space model with exogenous input to one without

I have a state space model of the form \begin{align} x_{t+1} &= Ax_t + Bu_t + w_t\\ y_t &= Cx_t + Du_t + v_t \end{align} where $u$ is the exogenous input. Also, $ w_t \sim N(0, Q)$ and $v_t \...
user avatar
  • 150
0 votes
0 answers
507 views

ARIMA model for GDP

I am working through example 3.2.6 in 'Dynamic linear models with R' by Petris. I have download the quarterly deseasonalised USA GDP data located here: http://definetti.uark.edu/dlm/ (it's the data ...
user avatar
  • 301
1 vote
0 answers
117 views

Dynamic Linear Models - prior specification

I am using the DLM package to make forecasts for some of my time series. I wonder how the priors should be elicited. For a Local State space model, one needs to specify the level of data prior to t=1....
user avatar
2 votes
1 answer
937 views

DLM representation of ARIMA models

I am working through example 3.2.6 in 'Dynamic linear models with R' by Petris. I have download the USA GDP data located here: http://definetti.uark.edu/dlm/ The example starts by estimating the ...
user avatar
  • 301
0 votes
1 answer
372 views

ARIMA in state space and Kalman filter for predicted values [closed]

Given the coefficients of an arima Model arimaM <- arima(y, order = c(1,0,2), transform.pars = FALSE, fixed = c(0.5,2,1.5,NA)) how can I compute the one step ...
user avatar
2 votes
0 answers
279 views

Missing data in Gibbs sampling for dynamic linear models

Suppose I have the following DLM: $x_t = \Phi x_{t-1} + w_t$ $y_t = A x_t + v_t$ $x_0 \sim N(\mu_0,\Sigma_0)$ $w_t \sim N(0,Q)$ $v_t \sim N(0,R)$ Let $\Theta = \{\mu_0,\Sigma_0,\Phi,Q,A,R\}$. I ...
user avatar
  • 21
0 votes
1 answer
215 views

Creating DLM object in R : Non symmetric W (error matrix in state equation)

I am using DLM package in R for estimating state space model While creating DLM object in R I am getting the following error "Error in all.equal(x\$W, t(x\$W)) && all (eigen(x\$W)$values >= 0)...
user avatar
2 votes
1 answer
317 views

DLM implementation of the mean reverting model

I am trying to use DLM package in R to estimate a state space repersentation of the term structure model, where observation and state equation are as follows $y(t )= F* x_t +e_t$ $x_t- \mu = G* (x_{...
user avatar
1 vote
1 answer
2k views

Normalized data on a rolling window

I have a whole set of data on [0,T] with an observation variable y(t), and a feature x(t), ...
user avatar
0 votes
0 answers
105 views

Verifying that dlm is working correctly

I am new to the dlm package and I am writing a simulation to verify that dlm is working correctly. Here is how I proceed: I create an AR1 series with parameters $\phi$ and $\sigma^2$. Then I try to ...
user avatar
0 votes
1 answer
1k views

multi-factor time-varying CAPM using kalman filter

I am trying to implement a time-varying CAPM model using the kalman filter. I have already found numerous examples in R and python using the DLM and the pykalman packages but the problem is that they ...
user avatar
  • 173
1 vote
0 answers
83 views

Correct way of building a confidence interval

My AR(1) model is $y_t = \phi y_{t-1} + \epsilon_t \quad where \quad \epsilon_t \sim \mathcal{N}(0,1) $ Here $\sigma^2 = Var(\epsilon_t) = 1$ Basically in this code I generate random values for phi ...
user avatar
0 votes
1 answer
496 views

Difference between Dynamic Factor Model (DFM) and Dynamic Linear Model (DLM)

one simple question: what is the difference between a Dynamic Factor Model (DFM) and a Dynamic Linear Model (DLM) ?
user avatar
1 vote
0 answers
982 views

How does the dlmMLE function work?

How does the dlmMLE in package dlm in R work? Are the maximum likelihood estimates coming from the Kalman filter or by numerical optimization. If it is using numerical optimization,what is the ...
user avatar
1 vote
1 answer
171 views

Model approach for extending Dynamic Linear Models - Nested Regression Relationships

I have three multivariate random variables $X_t$, $Y_t$, and $Z_t$. I have been very happily modeling the relationship between $Y_t$ and $X_t$ through a dynamic linear model $$Y_t = X_t\beta_t + ...
user avatar
  • 878
0 votes
0 answers
405 views

Different AIC values using lm, dlm and dlmodeler

I would like to compare a model with time varying slope coefficient to a model with constant slope coefficient. In order to do this, I use the R package "dlm" to set up the models and calculate the ...
user avatar
1 vote
0 answers
261 views

DLM model for data with seasonality

I am trying to explore the changing relationship between two monthly time series data. DLM package in R comes into my attention as I would like to see the beta change between the two dataset $A$ (...
user avatar
  • 11