# dlmModReg: Create a DLM representation of a regression model In dlm: Bayesian and Likelihood Analysis of Dynamic Linear Models

## Description

The function creates a dlm representation of a linear regression model.

## Usage

 ```1 2 3``` ```dlmModReg(X, addInt = TRUE, dV = 1, dW = rep(0, NCOL(X) + addInt), m0 = rep(0, length(dW)), C0 = 1e+07 * diag(nrow = length(dW))) ```

## Arguments

 `X` the design matrix `addInt` logical: should an intercept be added? `dV` variance of the observation noise. `dW` diagonal elements of the variance matrix of the system noise. `m0` m0, the expected value of the pre-sample state vector. `C0` C0, the variance matrix of the pre-sample state vector.

## Details

By setting `dW` equal to a nonzero vector one obtains a DLM representation of a dynamic regression model. The default value zero of `dW` corresponds to standard linear regression. Only univariate regression is currently covered.

## Value

An object of class dlm representing the specified regression model.

## Author(s)

Giovanni Petris [email protected]

## References

Giovanni Petris (2010), An R Package for Dynamic Linear Models. Journal of Statistical Software, 36(12), 1-16. http://www.jstatsoft.org/v36/i12/.
Petris, Petrone, and Campagnoli, Dynamic Linear Models with R, Springer (2009).
West and Harrison, Bayesian forecasting and dynamic models (2nd ed.), Springer, 1997.

`dlmModARMA`, `dlmModPoly`, `dlmModSeas`

## Examples

 ```1 2 3``` ```x <- matrix(runif(6,4,10), nc = 2); x dlmModReg(x) dlmModReg(x, addInt = FALSE) ```

### Example output

```         [,1]     [,2]
[1,] 6.912061 4.879447
[2,] 7.914793 8.925021
[3,] 8.450109 8.301106
\$FF
[,1] [,2] [,3]
[1,]    1    1    1

\$V
[,1]
[1,]    1

\$GG
[,1] [,2] [,3]
[1,]    1    0    0
[2,]    0    1    0
[3,]    0    0    1

\$W
[,1] [,2] [,3]
[1,]    0    0    0
[2,]    0    0    0
[3,]    0    0    0

\$JFF
[,1] [,2] [,3]
[1,]    0    1    2

\$X
[,1]  [,2]
[1,] 6.912 4.879
[2,] 7.915 8.925
[3,] ...

\$m0
[1] 0 0 0

\$C0
[,1]  [,2]  [,3]
[1,] 1e+07 0e+00 0e+00
[2,] 0e+00 1e+07 0e+00
[3,] 0e+00 0e+00 1e+07

\$FF
[,1] [,2]
[1,]    1    1

\$V
[,1]
[1,]    1

\$GG
[,1] [,2]
[1,]    1    0
[2,]    0    1

\$W
[,1] [,2]
[1,]    0    0
[2,]    0    0

\$JFF
[,1] [,2]
[1,]    1    2

\$X
[,1]  [,2]
[1,] 6.912 4.879
[2,] 7.915 8.925
[3,] ...

\$m0
[1] 0 0

\$C0
[,1]  [,2]
[1,] 1e+07 0e+00
[2,] 0e+00 1e+07
```

dlm documentation built on June 14, 2018, 1:03 a.m.