View source: R/genXn_longitudinal.R
gen_Xn_longitudinal | R Documentation |
Constructs design matrix using inputs that correspond to a balanced longitudinal study design. Used for power and sample size analysis in the Bayesian setting.
gen_Xn_longitudinal(ids, from, to, num_repeated_measures, poly_degree = 1)
ids |
vector of unique subject ids, usually of length 2 for study design purposes. |
from |
start time of repeated measures for each subject |
to |
end time of repeated measures for each subject |
num_repeated_measures |
desired length of the repeated measures sequence. Should be a non-negative number, will be rounded up if fractional. |
poly_degree |
degree of polynomial in longitudinal model, set to 1 by default. |
Xn: a design matrix that can be used to assess the Bayesian assurance through Monte Carlo sampling using functions presented in this package.
gen_Xn
## Example 1 ## We pass in a vector of subject IDs and specify the start and end ## timepoints along with the desired length of the sequence. ## The resulting design matrix contains vectors of ## ones with lengths that correspond to the number of repeated ## measures for each unique subject. ids <- c(1,2,3,4) gen_Xn_longitudinal(ids, from = 1, to = 10, num_repeated_measures = 4) ## Example 2 ## If we wish to fit a longitudinal model of a higher degree (e.g. ## parabolic, cubic), we need to adjust the `poly_degree` variable # parabolic ids <- c(1,2,3,4) gen_Xn_longitudinal(ids, from = 1, to = 10, num_repeated_measures = 4, poly_degree = 2) # cubic ids <- c(1,2,3,4) gen_Xn_longitudinal(ids, from = 1, to = 10, num_repeated_measures = 4, poly_degree = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.