Date: Wed, 11 Mar 2009 13:39:36 +0000
From: Michael Pearmain <mpearmain at google.com>
Sender: r-help-bounces at r-project.org
Precedence: list
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta;
t=1236778779; bh=FXcHfXd155+Rn9gFIVOikSMaQWI=;
DomainKey-Signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns;
Hi All,
I have a problem trying to forecast 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 <- dlmForecast(CostUSDFilt, nAhead = 1)
after which i return the error message:
Error in mod$m[lastObsIndex, ] : incorrect number of dimensions
Can anyone offer any insight to this problem?
Thanks in advance
Mike
[[alternative HTML version deleted]]