gen_z_varcov | R Documentation |
This function constructs the variance-covariance matrix used in generating
multivariate normal values for a school-level predictor, z. The variance-
covariance matrix for the predictor is a square matrix with dimensions of
.n_sch
(total number of schools) x .n_sch
. The values given in
.clust_cov
define a form of a Toeplitz structure, such that the values
on the main diagonal take a value of .clust_cov[1]
, the values on the
first off diagonal take a value of .clust_cov[2]
, etc. All values
not defined by .clust_cov
default to 0.
gen_z_varcov(.n_sch, .clust_cov)
.n_sch |
Numeric scalar. Gives the total number of schools in the
dataset. The variance-covariance matrix for predictor z will have dimensions
|
.clust_cov |
Numeric vector. The first element of the vector gives the
variance of all schools' predictors, z. If present, the second element gives
the covariance of z between schools k and k + 1. The values given in
|
It is important to note that because this simulation is intended for use
with a single school-level predictor, the proportion of variance explained
by the predictor out of the total school-level variance will be equal to
.clust_cov[1] / (residual variance + .clust_cov[1])
.
This function returns a matrix of dimensions .n_sch x .n_sch
,
the variance-covariance matrix for a school-level predictor, z. This matrix
can be used to generate multivariate normal values for predictor z.
## Not run: # give values for the variance (0.8), covariance between schools # k & k + 1 (0.3), and schools k and k + 2 (0.1) cov_vec <- c(0.8, 0.3, 0.1) # output the variance-covariance matrix gen_z_varcov(.n_sch = 50, .clust_cov = cov_vec) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.