4.4 Random-coefficients linear model
Mathematical representation
(4.5) |
- the model is estimated using observations from groups, each group observed for periods (balanced or unbalanced panels); the total number of observations is and could be equal to one for all (cross-sectional data)
- is the value of the dependent variable for group , observed in period
- is a vector that stores the values of the independent variables which are associated with group-specific coefficients, for group , observed in period
- is an vector that stores the values of the independent variables which are associated with coefficients common to all groups, for group , observed in period ( could be zero)
- is a vector of parameters associated with group
- is a vector of parameters that represents the mean of the s
- is a precision matrix for the distribution of the s
- is an vector of parameters
- is the precision of the error term:
Priors
Parameter | Probability density function | Default hyperparameters |
, | ||
, | ||
, | ||
, | ||
Syntax
where:
- y is the dependent variable name, as it appears in the dataset used for estimation
- z1 z2 zK is a list of the names, as they appear in the dataset used for estimation, of the independent variables which are associated with group-specific coefficients; when a constant term is to be included in the set of group-specific coefficients this must be requested explicitly
- x1 x2 xL is is a list of the names, as they appear in the dataset used for estimation, of the independent variables which are associated with coefficients common to all groups; when a constant term is to be included in the set of common coefficients, this must be requested explicitly
An independent variable could be included in either the x or the z variable list, depending on whether the parameter associated with this variable is common to all groups or not. However, including a variable in both lists would lead to exact multicollinearity and, in this case, BayES will issue an error. |
Before using the lm_rc() function the dataset used for estimation must be declared as a panel dataset using the set_pd() function (see section B.13). In the case of cross-sectional data, the dataset still needs to be declared as a panel, but the group-id variable could be constructed as a list of unique integers using, for example, the range() function. |
For groups observed only once, a group-specific parameter associated with a constant term cannot be distinguished from the error term (). Thus, a warning is produced when a constant term is included in the z list and the dataset contains at least one group which is observed only once. |
The optional arguments for the random-coefficients linear model are:4
Gibbs parameters
| |
"chains" | number of chains to run in parallel (positive integer); the default value is 1 |
"burnin" | number of burn-in draws per chain (positive integer); the default value is 10000 |
"draws" | number of retained draws per chain (positive integer); the default value is 20000 |
"thin" | value of the thinning parameter (positive integer); the default value is 1 |
"seed" | value of the seed for the random-number generator (positive integer); the default value is 42 |
Hyperparameters
| |
"m_gamma" | mean vector of the prior for ( vector); the default value is |
"P_gamma" | precision matrix of the prior for ( symmetric and positive-definite matrix); the default value is |
"V" | scale matrix of the prior for ( symmetric and positive-definite matrix); the default value is |
"n" | degrees-of-freedom parameter of the prior for (real number greater than or equal to ); the default value is |
"m_beta" | mean vector of the prior for ( vector); the default value is |
"P_beta" | precision matrix of the prior for ( symmetric and positive-definite matrix); the default value is |
"a_tau" | shape parameter of the prior for (positive number); the default value is |
"b_tau" | rate parameter of the prior for (positive number); the default value is |
Dataset and log-marginal likelihood
| |
"dataset" | the id value of the dataset that will be used for estimation; the default value is the first dataset in memory (in alphabetical order) |
"logML_CJ" | boolean indicating whether the Chib (1995)/Chib & Jeliazkov (2001) approximation to the log-marginal likelihood should be calculated (truefalse); the default value is false |
Reported Parameters
| variable_name | vector of parameters associated with the independent variables in the z list; these are the means of the group-specific parameters |
| variable_name | vector of parameters associated with the independent variables in the x list |
| tau | precision parameter of the error term, |
| sigma_e | standard deviation of the error term: |
Stored values and post-estimation analysis
If a left-hand-side id value is provided when a random-coefficients linear model is created, then the
following results are saved in the model item and are accessible via the ‘.’ operator:
Samples | a matrix containing the draws from the posterior of , , and the unique elements of |
z1,,zK | vectors containing the draws from the posterior of the mean of the group-specific coefficients (s) associated with variables z1,,zK (the names of these vectors are the names of the variables that were included in the right-hand side of the model) |
x1,,xL | vectors containing the draws from the posterior of the parameters associated with variables x1,,xL (the names of these vectors are the names of the variables that were included in the right-hand side of the model) |
tau | vector containing the draws from the posterior of |
Omega_i_j | vectors containing the draws from the posterior of the unique elements of ; because is symmetric, only of its elements are stored (instead of all elements); i and j index the row and column of , respectively, at which the corresponding element is located |
Omega | matrix that stores the posterior mean of |
logML | the Lewis & Raftery (1997) approximation of the log-marginal likelihood |
logML_CJ | the Chib (1995)/Chib & Jeliazkov (2001) approximation to the log-marginal likelihood; this is available only if the model was estimated with the "logML_CJ"=true option |
gamma_i | matrix that stores the group-specific coefficients for the variables in the z list; the values in this matrix are not guaranteed to be in the same order as the order in which the groups appear in the dataset used for estimation; use the store() function to associate the values in gamma_i with the observations in the dataset |
nchains | the number of chains that were used to estimate the model |
nburnin | the number of burn-in draws per chain that were used when estimating the model |
ndraws | the total number of retained draws from the posterior (chains draws) |
nthin | value of the thinning parameter that was used when estimating the model |
nseed | value of the seed for the random-number generator that was used when estimating the model |
Additionally, the following functions are available for post-estimation analysis (see section B.14):
- diagnostics()
- test()
- pmp()
- store()
The random-coefficients linear model uses the store() function to associate the group-specific parameters (gamma_i) with specific observations and store their values in the dataset used for estimation. The generic syntax for a statement involving the store() function after estimation of a random-coefficients linear model is:
This statement will generate additional variables in the dataset used for estimation of the random-coefficients model, with names constructed by prepending the prefix provided as the second argument to store() to the names of the variables which are associated with group-specific coefficients.
Examples
Example 1
myData.constant = ones(rows(myData), 1);
set_pd( year, id, "dataset" = myData);
// all rhs variables are associated with group-specific coefficients
lm_rc( y ~ constant x1 x2 x3);
Example 2
myData.constant = ones(rows(myData), 1);
set_pd( year, id, "dataset" = myData);
// only the constant term and the coefficient associated with x1 are
// group-specific; the coefficients on x2 and x3 are common to all groups
lm_rc( y ~ constant x1 x2 x3);
Example 3
myData.constant = ones(rows(myData), 1);
set_pd( year, id, "dataset" = myData);
// all rhs variables are associated with group-specific coefficients
model1 = lm_rc(y ~ constant x1 x2 x3,
"burnin"=10000, "draws"=40000, "thin"=4, "chains"=2,
"logML_CJ" = true, "dataset"=myData);
store( gamma_i, rc1_, "model" = model1 );
// only the constant term and the coefficient associated with x1 are
// group-specific; the coefficients on x2 and x3 are common to all groups
model2 = lm_rc( y ~ constant x1 x2 x3,
"burnin"=10000, "draws"=40000, "thin"=4, "chains"=2,
"logML_CJ" = true, "dataset"=myData);
store( gamma_i, rc2_, "model" = model2 );
pmp( { model1, model2 } );
4Optional arguments are always given in option-value pairs (eg. "chains"=3).