onevar function

Creates a matrix of one-variable models.

Creates a matrix of one-variable models.

This function simplifies working with one-variable models in, for example, fDMA. It produces a matrix corresponding to the set of models consisting of models with a constant and just one extra variable, and a model with a constant only.

onevar(x)

Arguments

  • x: matrix of independent variables, see mods.incl in fDMA

Returns

matrix, inclusion of a variable is indicated by 1, omitting by 0

Examples

wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- drivers[-1,] ld.drivers[,c(4,6)] <- (diff(drivers[,c(4,6)]))[-1,] ld.drivers[,c(1:2,5,7)] <- (diff(log(drivers[,c(1:2,5,7)])))[-1,] ld.drivers[,c(3,6)] <- ld.drivers[,c(3,6)]/100 mds <- diag(1,ncol(ld.drivers),ncol(ld.drivers)) mds <- cbind(rep(1,ncol(ld.drivers)),mds) mds <- rbind(rep(0,ncol(mds)),mds) mds[1,1] <- 1 m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10,mods.incl=mds) # Equivalently: m2 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10,mods.incl=onevar(ld.drivers))