1
$\begingroup$

I am trying to forecast predict new observations of interest rates given new data using the DLM modeling framework.

Essentially, my problem is this:

I have a training set (a set of data i want to fit my model to) and a test set (new predictor data, i wish to use to run through the trained model to predict new values of interest rates)

train<-1:(n-20); test<-(n-19):(n-4); 

I have created a training and test set:

training<-CP1981.ts[train,] 
testing<-CP1981.ts[test,]

Below would be what im using for the independent variables

x<-ts(data.frame(training[,"r_surv"],training[,"r_fire"],training[,"ExpINF"],training[,"TauCoreCPI"],training[,"c1"],training[,"c2"],training[,"c3"],training[,"c5"],training[,"c7"],training[,"c10"],training[,"c10"]),start=c(1981,2),frequency=4)

GS10R<-ts(data.frame(training[,"GS10_12"]),start=c(1981,2),frequency=4)

mod<-dlmModReg(x,addInt=FALSE, dV =1,dW = rep(.60, 11),
          m0 = rep(0, length(dW)),
          C0 = 1e+07 * diag(nrow = length(dW)))


outS<-dlmSmooth(GS10R,mod)
outF<-dlmFilter(GS10R,mod)

At this stage i want to use the old mod, throw in new data from my testing set:

x1<-ts(data.frame(testing[,"r_surv"],testing[,"r_fire"],testing[,"TauCoreCPI"],testing[,"c1"],testing[,"c2"],testing[,"c3"],testing[,"c5"],testing[,"c7"],testing[,"c10"],testing[,"c20"]),start=c(2010,3),frequency=4)
# 

How do i produce new yt's given my new xt's?

There is the predict() function for lm. Is there an analogous function or way to do this with dlm?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.