gen_y_mmrem | R Documentation |
This function calculates the observed y value from a multiple
membership random effects model based on the value of a predictor, x
(given in .design_x
), population values of the model coefficients
(given in .gamma_x
), school residuals for the schools assigned to
person i (given in .sch_resid
), weights for those school residuals
(given in .sch_weight
), and person residuals. This population
model has fixed slopes and random intercepts. School-level covariates
are not included in this model but are used to construct the school residuals
in gen_u_mmrem
.
gen_y_mmrem(.dat, .x_predictor, .sch_weight, .sch_resid, .per_resid, .gamma_x)
.x_predictor |
Numeric matrix with dimensions n x p (where n is the num
of persons and p is the number of coefficients, including the intercept).
The column of |
.sch_weight |
Numeric matrix with dimensions n x h (where n is the
number of persons and h is the maximum number of schools attended by any
person in the dataset). Rows should sum to 1 (that is, for each student,
the weights assigned to their schools attended should sum to 1). For a school
a student did not attend, the weight should be 0 (that is, if the maximum
number of schools attended was 2 and person A only attended 1 school, then
the weight for their "second school" should be 0, while the weight for
their "first school" should be 1). To simulate the data, all students were
initially assigned a mobility profile (meaning that all students were
assigned h schools to attend), and then only a certain proportion of
students were coded as mobile. For the students who were coded as mobile,
their |
.sch_resid |
Numeric matrix with dimensions n x h (where n is the number of persons and h is the maximum number of schools attended by any person in the dataset). The hth column of the matrix should give the residual for the hth school attended by person i. As mentioned above, all students were initially assigned a mobility profile that included multiple schools, then only a certain proportion of those mobility profiles were retained. |
.per_resid |
Numeric vector with length n (where n is the number of persons in the data). Gives the person-level residual for the model. |
.gamma_x |
Numeric vector with length p (where p is the number of model coefficients, including the intercept). |
NOTE: function has been changed and documentation requires an update
This function returns a vector of length n (where n is the number
of persons in the dataset) of y values calculated based on the population
MMREM model. This population model does not explicitly model correlation
between school residuals, nor does it account for school-level predictors.
Correlations between school residuals and school-level predictors, if
desired, must be incorporated into the .sch_resid
values.
## Not run: ## create sample values # gamma vector (intercept, g00 & effect of x on y, g10) g <- c(10, 1.5) # x & design matrix x <- rnorm(5) d_x <- cbind( xg00 = rep(1, length(x)), xg10 = x ) # school weight matrix s_wt <- cbind( w1 = c(1, 1, 0.5, 0.5, 0.5), w2 = c(0, 0, 0.5, 0.5, 0.5) ) # school residuals matrix (uncorrelated residuals) s_r <- cbind( s1 = rnorm(5), s2 = rnorm(5) ) # person residual vector p_r <- rnorm(5) ## generate y values from the population model gen_y_mmrem( .gamma_x = g, .x_predictor = d_x, .sch_weight = s_wt, .sch_resid = s_r, .per_resid = p_r ) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.