search for: dlmmodpoly

Displaying 8 results from an estimated 8 matches for "dlmmodpoly".

2013 Mar 08
0
using dlmModPoly in library dlm
Hi Group, I'm trying to build a model to predict a product's sale price. I'm researching the dlm package. Looks like I should use dlmModPoly, dlmMLE, dlmFilter, dlmSmooth, and finally dlmForecast. I'm looking at the Nile River example and I have a few questions: 1. If I only want to predict future sale price based on observed sale price, I should use a univariate model, correct? 2. how do I initiate value for dV an...
2011 Jun 30
0
Specifying State Space model to decompose structural shocks
...e dlm package, which suggests that multivariate series can be represented by combining two univariate expressions. First, I need to write a function and then use dlmMLE to estimate it. For example, I can start by writing a function x, which combines two univariate expressions: ab<-function(x) { dlmModPoly()%+%dlmModPoly() } fit<-dlmMLE(data, parm=c(....), build=ab) However, I am not sure how to write my model within this function. For instance, when I just run the expression inside above function, I get: > dlmModPoly()%+%dlmModPoly() $FF [,1] [,2] [,3] [,4] [1,] 1 0 0 0 [2,...
2009 May 10
1
Help with kalman-filterd betas using the dlm package
...odel, in other worlds the transition equition either follow a RW or AR(1) model. This is how I think it would be set up; I will have my time-series Y,X, where Y is the response variable this setup should give me a RW process if I have understood the example correctly mydlmModel = dlmModReg(X) + dlmModPoly(order=1) and then run on the dlm model dlmFilter(Y,mydlmModel ) but setting up a AR(1) process is unclear, should I use dlmModPoly or the dlmModARMA to set up the model. And at last but not the least, how do I set up a proper build function to use with dlmMLE to optimize the starting values. Re...
2014 Jan 08
0
Strange behaviour of `dlm` package
...25021560, 25724331, 25990336, 26602038, 27292250, 28891954, 29659700, 31533579, 32513666, 33628559, 34494451)) plot(hotann, ylab="Annual hotel bookings") # Analysis with log data tsdata <- log(hotann) buildfun <- function (x) { dlmModPoly(order = 2, dV = exp(x[1]), dW = c(0,exp(x[2]))) } fit <- dlmMLE(y=tsdata, parm=c(0,0), build=buildfun) # Warning: a numerically singular 'V' has been slightly perturbed to make it nonsingular fit$conv dlmTsdata <- buildfun(fit$par) tsdataFilter <- dlmFilter(tsdata, mod=dlmTsdata)...
2011 Nov 18
0
Kalman Filter with dlm
...lman Filter model for flu forecasting as shown below. Y - Target Variable X1 - Predictor1 X2 - Predictor2 While forecasting into the future, I will NOT have data for all three variables. So, I am predicting X1 and X2 using two Kalman filters. The code is below x1.model <- dlmModSeas(52) + dlmModPoly(1, dV=5, dW=10) x2.model <- dlmModSeas(52) + dlmModPoly(1, dV=10, dW=10) x1.filter <- dlmFilter(c(train$x1, rep(NA, noofsteps)), x1.model) x2.filter <- dlmFilter(c(train$x2, rep(NA, noofsteps)), x2.model) Now, I am forecasting Y using the predicted X1 and X2 as below pred <- c...
2009 Mar 11
1
Forecasting with dlm
...ast using the dlm package, can anyone offer any advise? I setup my problem as follows, (following the manual as much as possible) data for example to run code CostUSD <- c(27.24031,32.97051, 38.72474, 22.78394, 28.58938, 49.85973, 42.93949, 35.92468) library(dlm) buildFun <- function(x) { dlmModPoly(1, dV = exp(x[1]), dW = exp(x[2])) } fit <- dlmMLE(CostUSD, parm = c(0,0), build = buildFun) fit$conv dlmCostUSD <- buildFun(fit$par) V(dlmCostUSD) W(dlmCostUSD) #For comparison StructTS(CostUSD, "level") CostUSDFilt <- dlmFilter(CostUSD, dlmCostUSD) CostUSDFore <- dlmForecas...
2011 Jul 29
0
dlmSum(...) and non-constant state space models
...c[,5] <- lagr(pc[,4])> names(pc) <- c("b","d","p","w","w1")> pc <- ts(pc, start=1650, frequency=1)> dr <- lm(pc[,4]~pc[,3])> pos <- lm(pc[,2]~pc[,4])> > # set up SS models> ssm1 <- function(parm){+ rwdw <- dlmModPoly(order=2, + dV = exp(parm[1]), + dW = exp(parm[2:3]),+ m0 = c(coef(dr)[1],0), + C0 = diag(2)*10)+ slpw <- dlmModReg(X=pc[,3], + addInt = FALSE, + dV = exp(parm[4]), +...
2012 Jan 23
0
problems with dlmBSample of the dlm package
...hile dlmFilter works perfectly. I think that my_mod is correct, because the output of my_dlmFilter$mod is fine. Where is my mistake or my misunderstanding? This is the code: function (orig_ts){ library(dlm) dV_T <- 20000 dW_T <- c(100,10) m0_T <- rep(0,2) C0_T <- 10000*diag(nrow=2) my_dlmModPoly <- dlmModPoly(order=2, dV_T, dW_T, m0_T, C0_T) dV_S <- 20000 dW_S <- c(500,0,0) m0_S <- rep(0,3) C0_S <- 10000*diag(nrow=3) my_dlmModSeas <- dlmModSeas(frequency=4, dV_S, dW_S, m0_S, C0_S) my_mod <- my_dlmModPoly + my_dlmModSeas my_dlmFilter <- dlmFilter(orig_ts, my_mod)...