dma {dma} R Documentation

## Dynamic model averaging for continuous outcomes

### Description

Implemtent dynamic model averaging for continuous outcomes as described in Raftery, A.E., Karny, M., and Ettler, P. (2010). Online Prediction Under Model Uncertainty Via Dynamic Model Averaging: Application to a Cold Rolling Mill. Technometrics 52:52-66. Along with the values described below, plot() creates a plot of the posterior model probabilities over time and model-averaged fitted values and print() returns model matrix and posterior model probabilities. There are TT time points, K models, and d total covariates.

### Usage

dma(x, y, models.which, lambda=0.99, gamma=0.99,
eps=.001/nrow(models.which), delay=0, initialperiod=200)


### Arguments

 x TTxd matrix of system inputs y TT-vector of system outputs models.which Kxd matrix, with 1 row per model and 1 col per variable indicating whether that variable is in the model (the state theta is of dim (model.dim+1); the extra 1 for the intercept) lambda parameter forgetting factor gamma flatterning parameter for model updating eps regularization parameter for regularizing posterior model model probabilities away from zero delay When y_t is controlled, only y_t-delay-1 and before are available. This is determined by the machine. Note that delay as defined here corresponds to (k-1) in the Ettler et al (2007, MixSim) paper. Thus k=25 in the paper corresponds to delay=24. initialperiod length of initial period. Performance is summarized with and without the first initialperiod samples.

### Value

 yhat.bymodel TTxK matrix whose tk element gives yhat for yt for model k yhat.ma TT vector whose t element gives the model-averaged yhat for yt pmp TTxK matrix whose tk element is the post prob of model k at t thetahat KxTTx(nvar+1) array whose ktj element is the estimate of theta_j-1 for model k at t Vtheta KxTTx(nvar+1) array whose ktj element is the variance of theta_j-1 for model k at t thetahat.ma TTx(nvar+1) matrix whose tj element is the model-averaged estimate of theta_j-1 at t Vtheta.ma TTx(nvar+1) matrix whose tj element is the model-averaged variance of thetahat_j-1 at t mse.bymodel MSE for each model mse.ma MSE of model-averaged prediction mseinitialperiod.bymodel MSE for each model excluding the first initialperiod samples mseinitialperiod.ma MSE of model averaging excluding the first initialperiod samples model.forget forgetting factor for the model switching matrix

### References

Raftery, A.E., Karny, M., and Ettler, P. (2010). Online Prediction Under Model Uncertainty Via Dynamic Model Averaging: Application to a Cold Rolling Mill. Technometrics 52:52-66.

### Examples

#simulate some data to test
#first, static coefficients
coef<-c(1.8,3.4,-2,3,-2.8,3)
coefmat<-cbind(rep(coef[1],200),rep(coef[2],200),
rep(coef[3],200),rep(coef[4],200),
rep(coef[5],200),rep(coef[6],200))
#then, dynamic ones
coefmat<-cbind(coefmat,seq(1,2.45,length.out=nrow(coefmat)),
seq(-.75,-2.75,length.out=nrow(coefmat)),
c(rep(-1.5,nrow(coefmat)/2),rep(-.5,nrow(coefmat)/2)))
npar<-ncol(coefmat)-1
dat<-matrix(rnorm(200*(npar),0,1),200,(npar))
ydat<-rowSums((cbind(rep(1,nrow(dat)),dat))[1:100,]*coefmat[1:100,])
ydat<-c(ydat,rowSums((cbind(rep(1,nrow(dat)),dat)*coefmat)[-c(1:100),c(6:9)]))
mmat<-matrix(c(c(1,0,1,0,0,rep(1,(npar-7)),0,0),
c(rep(0,(npar-4)),rep(1,4)),rep(1,npar)),3,npar,byrow=TRUE)
dma.test<-dma(dat,ydat,mmat,lambda=.99,gamma=.99,initialperiod=20)
plot(dma.test)


[Package dma version 1.4-0 Index]