normalgamma {estimateW} | R Documentation |
A Markov Chain Monte Carlo (MCMC) sampler for a linear panel model
Description
The sampler uses independent Normal-inverse-Gamma priors to estimate a linear panel data model. The function is
used for an illustration on using the beta_sampler
and sigma_sampler
classes.
Usage
normalgamma(
Y,
tt,
X = matrix(1, nrow(Y), 1),
niter = 200,
nretain = 100,
beta_prior = beta_priors(k = ncol(X)),
sigma_prior = sigma_priors()
)
Arguments
Y |
numeric |
tt |
single number greater or equal to 1. Denotes the number of time observations. |
X |
numeric |
niter |
single number greater or equal to 1, indicating the total number of draws. Will be automatically coerced to integer. The default value is 200. |
nretain |
single number greater or equal to 0, indicating the number of draws kept after the burn-in. Will be automatically coerced to integer. The default value is 100. |
beta_prior |
list containing priors for the slope coefficients |
sigma_prior |
list containing priors for the error variance |
Details
The considered model takes the form:
with .
(
) collects the
cross-sectional observations for time
.
(
) is a matrix of explanatory variables.
(
) is an unknown slope parameter matrix.
After vertically staking the cross-sections
(
),
(
), with
, the final model can be expressed as:
where . Note that the input
data matrices have to be ordered first by the cross-sectional (spatial) units and then stacked by time.
Examples
n = 20; tt = 10; k = 3
X = matrix(stats::rnorm(n*tt*k),n*tt,k)
Y = X %*% c(1,0,-1) + stats::rnorm(n*tt,0,.5)
res = normalgamma(Y,tt,X)