expand_sch: expand_sch

View source: R/expand_sch.R

expand_schR Documentation

expand_sch

Description

This function expands school-level information generated by gen_u_mmrem, repeating each school's info a number of times equal to the number of students attending each school. That is, if there are .n_stu per school and .n_sch, the final output should have .n_stu * .n_sch rows.

Usage

expand_sch(.sch_dat, .n_stu, .n_sch)

Arguments

.sch_dat

A matrix or dataframe. The school-level information created by the gen_u_mmrem function.

.n_stu

A numeric scalar. The number of students attending each school. Note: this is not the total number of students in the dataset, merely the number of students per school.

.n_sch

Numeric scalar. Gives the total number of schools in the dataset. The variance-covariance matrix for predictor z will have dimensions .n_sch x .n_sch.

Value

This function returns a dataframe with a number of rows equal to .n_stu * .n_sch. The columns of the input data (.sch_dat) are retained in the output.

Examples

## Not run: 

# generate data using the gen_u_mmrem function
dat <- gen_u_mmrem(.n_sch = 10)

# expand the data to repeat school information for each student
# attending a given school
expand_sch(dat, .n_stu = 10, .n_sch = 10)


## End(Not run)

tessaleejohnson/corclus documentation built on Oct. 11, 2022, 3:46 a.m.