| Title: | Bayesian Estimation of Nonlinear Data (BEND) |
|---|---|
| Description: | Provides a set of models to estimate nonlinear longitudinal data using Bayesian estimation methods. These models include the: 1) Bayesian Piecewise Random Effects Model (Bayes_PREM()) which estimates a piecewise random effects (mixture) model for a given number of latent classes and a latent number of possible changepoints in each class, and can incorporate class and outcome predictive covariates (see Lamm (2022) <https://hdl.handle.net/11299/252533> and Lock et al., (2018) <doi:10.1007/s11336-017-9594-5>), 2) Bayesian Crossed Random Effects Model (Bayes_CREM()) which estimates a linear, quadratic, exponential, or piecewise crossed random effects models where individuals are changing groups over time (e.g., students and schools; see Rohloff et al., (2024) <doi:10.1111/bmsp.12334>), and 3) Bayesian Bivariate Piecewise Random Effects Model (Bayes_BPREM()) which estimates a bivariate piecewise random effects model to jointly model two related outcomes (e.g., reading and math achievement; see Peralta et al., (2022) <doi:10.1037/met0000358>). |
| Authors: | Corissa T. Rohloff [aut, cre] (ORCID: <https://orcid.org/0000-0003-3228-4653>), Rik Lamm [aut] (ORCID: <https://orcid.org/0000-0002-3317-6243>), Yadira Peralta [aut] (ORCID: <https://orcid.org/0000-0003-4823-6939>), Nidhi Kohli [aut] (ORCID: <https://orcid.org/0000-0003-4690-2854>), Eric F. Lock [aut] (ORCID: <https://orcid.org/0000-0003-4663-2356>) |
| Maintainer: | Corissa T. Rohloff <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 2.0.1 |
| Built: | 2026-05-19 09:55:24 UTC |
| Source: | https://github.com/crohlo/bend |
Estimates a Bayesian bivariate piecewise random effects models (BPREM) for longitudinal data with two interrelated outcomes. See Peralta et al. (2022) for more details.
Bayes_BPREM( data, id_var, time_var, y1_var, y2_var, iters_adapt = 5000, iters_burn_in = 1e+05, iters_sampling = 50000, thin = 15, save_full_chains = FALSE, save_conv_chains = FALSE, verbose = TRUE )Bayes_BPREM( data, id_var, time_var, y1_var, y2_var, iters_adapt = 5000, iters_burn_in = 1e+05, iters_sampling = 50000, thin = 15, save_full_chains = FALSE, save_conv_chains = FALSE, verbose = TRUE )
data |
Data frame in long format, where each row describes a measurement occasion for a given individual. It is assumed that each individual has the same number of assigned timepoints (a.k.a., rows). There can be missingness in the outcomes ( |
id_var |
Name of column that contains ids for individuals with repeated measures in a longitudinal dataset. |
time_var |
Name of column that contains the time variable. This column cannot contain any missing values. |
y1_var |
Name of column that contains the first outcome variable. Missing values should be denoted by NA. |
y2_var |
Name of column that contains the second outcome variable. Missing values should be denoted by NA. |
iters_adapt |
(optional) Number of iterations for adaptation of jags model (default = 5000). |
iters_burn_in |
(optional) Number of iterations for burn-in (default = 100000). |
iters_sampling |
(optional) Number of iterations for posterior sampling (default = 50000). |
thin |
(optional) Thinning interval for posterior sampling (default = 15). |
save_full_chains |
Logical indicating whether the MCMC chains from rjags should be saved (default = FALSE). Note, this should not be used regularly as it will result in an object with a large file size. |
save_conv_chains |
Logical indicating whether the MCMC chains from rjags should be saved but only for the parameters monitored for convergence (default = FALSE). This would be useful for plotting traceplots for relevant model parameters to evaluate convergence behavior. Note, this should not be used regularly as it will result in an object with a large file size. |
verbose |
Logical controlling whether progress messages/bars are generated (default = TRUE). |
For more information on the model equation and priors implemented in this function, see Peralta et al. (2022).
A list (an object of class BPREM) with elements:
Call |
A list of all specified function arguments. |
Sample Size |
Number of subjects ( |
Data |
Dataset used for estimation. |
Convergence |
Potential scale reduction factor (PSRF) for each parameter ( |
Model_Fit |
Deviance ( |
Fitted_Values |
Data frame with the fitted values for y1 and y2 at each timepoint for each individual. |
Parameter_Estimates |
Data frame with posterior mean and 95% credible intervals for each model parameter. |
Random_Coefficients |
List object with data frames providing random effects and random coefficients for each individual. |
Run_Time |
Total run time for model fitting. |
Full_MCMC_Chains |
If save_full_chains=TRUE, raw MCMC chains from rjags. |
Convergence_MCMC_Chains |
If save_conv_chains=TRUE, raw MCMC chains from rjags but only for the parameters monitored for convergence. |
Corissa T. Rohloff, Yadira Peralta
Peralta, Y., Kohli, N., Lock, E. F., & Davison, M. L. (2022). Bayesian modeling of associations in bivariate piecewise linear mixed-effects models. Psychological Methods, 27(1), 44–64. https://doi.org/10.1037/met0000358
# load simulated data data(SimData_BPREM) # fit Bayes_BPREM() results_bprem <- Bayes_BPREM(data = SimData_BPREM, id_var = "id", time_var = "time", y1_var = "y1", y2_var = "y2") # result summary summary(results_bprem) # plot fitted results plot(results_bprem)# load simulated data data(SimData_BPREM) # fit Bayes_BPREM() results_bprem <- Bayes_BPREM(data = SimData_BPREM, id_var = "id", time_var = "time", y1_var = "y1", y2_var = "y2") # result summary summary(results_bprem) # plot fitted results plot(results_bprem)
Estimates a Bayesian crossed random effects models (CREM) for longitudinal data with dynamic group membership. Four different choices for functional forms are provided: linear, quadratic, exponential, and piecewise. See Rohloff et al. (2024) for more details.
Bayes_CREM( data, ind_id_var, cross_id_var, time_var, y_var, form = "linear", fixed_effects = NULL, iters_adapt = 5000, iters_burn_in = 50000, iters_sampling = 50000, thin = 15, save_full_chains = FALSE, save_conv_chains = FALSE, verbose = TRUE )Bayes_CREM( data, ind_id_var, cross_id_var, time_var, y_var, form = "linear", fixed_effects = NULL, iters_adapt = 5000, iters_burn_in = 50000, iters_sampling = 50000, thin = 15, save_full_chains = FALSE, save_conv_chains = FALSE, verbose = TRUE )
data |
Data frame in long format, where each row describes a measurement occasion for a given individual. It is assumed that each individual has the same number of assigned timepoints (a.k.a., rows). There can be missingness in the outcome ( |
ind_id_var |
Name of column that contains ids for individuals with repeated measures in a longitudinal dataset (e.g., students). |
cross_id_var |
Name of column that contains ids for the crossed factor (e.g., teachers). |
time_var |
Name of column that contains the time variable. This column cannot contain any missing values. |
y_var |
Name of column that contains the outcome variable. Missing values should be denoted by NA. |
form |
Name of the functional form. Options include: ‘linear’ (default), ‘quadratic’, ‘exponential’, ‘piecewise’. |
fixed_effects |
(optional) Starting values for the fixed effects parameters. |
iters_adapt |
(optional) Number of iterations for adaptation of jags model (default = 5000). |
iters_burn_in |
(optional) Number of iterations for burn-in (default = 50000). |
iters_sampling |
(optional) Number of iterations for posterior sampling (default = 50000). |
thin |
(optional) Thinning interval for posterior sampling (default = 15). |
save_full_chains |
Logical indicating whether the MCMC chains from rjags should be saved (default = FALSE). Note, this should not be used regularly as it will result in an object with a large file size. |
save_conv_chains |
Logical indicating whether the MCMC chains from rjags should be saved but only for the parameters monitored for convergence (default = FALSE). This would be useful for plotting traceplots for relevant model parameters to evaluate convergence behavior. Note, this should not be used regularly as it will result in an object with a large file size. |
verbose |
Logical controlling whether progress messages/bars are generated (default = TRUE). |
For more information on the model equation and priors implemented in this function, see Rohloff et al. (2024).
Note, this function differs from the above reference by estimating the covariances between the random effects parameters. The variance-covariance matrices of the individual and group random effects have a scaled inverse-Wishart prior (see Peralta et al., 2022).
A list (an object of class CREM) with elements:
Call |
A list of all specified function arguments. |
Sample Size |
Number of subjects ( |
Data |
Dataset used for estimation. |
Convergence |
Potential scale reduction factor (PSRF) for each parameter ( |
Model_Fit |
Deviance ( |
Fitted_Values |
Data frame with the fitted values at each timepoint for each individual. |
Functional_Form |
Functional form fitted. |
Parameter_Estimates |
Data frame with posterior mean and 95% credible intervals for each model parameter. |
Random_Coefficients |
List object with data frames providing individual random effects, group random effects, and random coefficients for each individual and group. |
Run_Time |
Total run time for model fitting. |
Full_MCMC_Chains |
If save_full_chains=TRUE, raw MCMC chains from rjags. |
Convergence_MCMC_Chains |
If save_conv_chains=TRUE, raw MCMC chains from rjags but only for the parameters monitored for convergence. |
Corissa T. Rohloff
Peralta, Y., Kohli, N., Lock, E. F., & Davison, M. L. (2022). Bayesian modeling of associations in bivariate piecewise linear mixed-effects models. Psychological Methods, 27(1), 44–64. https://doi.org/10.1037/met0000358
Rohloff, C. T., Kohli, N., & Lock, E. F. (2024). Identifiability and estimability of Bayesian linear and nonlinear crossed random effects models. British Journal of Mathematical and Statistical Psychology. https://doi.org/10.1111/bmsp.12334
# load simulated data data(SimData_PCREM) # fit Bayes_CREM() results_pcrem <- Bayes_CREM(data = SimData_PCREM, ind_id_var = "id", cross_id_var = "teacherid", time_var = "time", y_var = "y", form="piecewise") # result summary summary(results_pcrem) # plot fitted results plot(results_pcrem)# load simulated data data(SimData_PCREM) # fit Bayes_CREM() results_pcrem <- Bayes_CREM(data = SimData_PCREM, ind_id_var = "id", cross_id_var = "teacherid", time_var = "time", y_var = "y", form="piecewise") # result summary summary(results_pcrem) # plot fitted results plot(results_pcrem)
Estimates a Bayesian piecewise random effects model (PREM), with some useful extensions. There are three model options included in this function:
PREM estimates a Bayesian piecewise random effects model with a latent number of changepoints (default). Allows the inclusion of outcome-predictive covariates (CI-PREM).
PREMM estimates a piecewise random effects mixture model for a given number of latent classes and a latent number of possible changepoints in each class.
CI-PREMM estimates a covariate influenced piecewise random effects mixture model for a given number of latent classes and a latent number of possible changepoints in each class. Allows the inclusion of outcome- and/or class-predictive covariates.
See Lock et al. (2018) and Lamm (2022) for more details.
Bayes_PREM( data, id_var, time_var, y_var, n_class = 1, max_cp = 2, class_predictive_vars = NULL, outcome_predictive_vars = NULL, scale_prior = "uniform", alpha = 1, cp_prior = "binomial", binom_prob = 0.5, iters_adapt = 1000, iters_burn_in = 20000, iters_sampling = 30000, thin = 15, save_full_chains = FALSE, save_conv_chains = FALSE, verbose = TRUE )Bayes_PREM( data, id_var, time_var, y_var, n_class = 1, max_cp = 2, class_predictive_vars = NULL, outcome_predictive_vars = NULL, scale_prior = "uniform", alpha = 1, cp_prior = "binomial", binom_prob = 0.5, iters_adapt = 1000, iters_burn_in = 20000, iters_sampling = 30000, thin = 15, save_full_chains = FALSE, save_conv_chains = FALSE, verbose = TRUE )
data |
Data frame in long format, where each row describes a measurement occasion for a given individual. It is assumed that each individual has the same number of assigned timepoints (a.k.a., rows). There can be missingness in the outcome ( |
id_var |
Name of column that contains ids for individuals with repeated measures in a longitudinal dataset. |
time_var |
Name of column that contains the time variable. This column cannot contain any missing values. |
y_var |
Name of column that contains the outcome variable. Missing values should be denoted by NA. |
n_class |
Number of latent classes (default = 1). Note, CI-PREMM only allows for two classes. |
max_cp |
Maximum number of changepoints in each latent class (default = 2). |
class_predictive_vars |
Name(s) of column(s) that contain class-predictive covariates (time-invariant only). Give a vector of names if multiple covariates. Note, there cannot be any missingness in the covariates. |
outcome_predictive_vars |
Name(s) of column(s) that contain outcome-predictive covariates (time-varying or -invariant). Give a vector of names if multiple covariates. Note, there cannot be any missingness in the covariates. |
scale_prior |
Prior for the scale parameter for the hierarchical random effects. Options include: ‘uniform’ (scaled uniform prior; default) or ‘hc’ (scaled half-cauchy prior). |
alpha |
Concentration parameter for Dirichlet prior for latent classes (default = 1). This can be a vector of values corresponding to the number of classes (specified by n_class). Note, this is not used for CI-PGMM. |
cp_prior |
Prior for the number of changepoints in each class. Options include: 'binomial' (default) or 'uniform'. |
binom_prob |
Probability for binomial prior, if specified (default = 0.5). |
iters_adapt |
(optional) Number of iterations for adaptation of jags model (default = 1000). |
iters_burn_in |
(optional) Number of iterations for burn-in (default = 20000). |
iters_sampling |
(optional) Number of iterations for posterior sampling (default = 30000). |
thin |
(optional) Thinning interval for posterior sampling (default = 15). |
save_full_chains |
Logical indicating whether the MCMC chains from rjags should be saved (default = FALSE). Note, this should not be used regularly as it will result in an object with a large file size. |
save_conv_chains |
Logical indicating whether the MCMC chains from rjags should be saved but only for the parameters monitored for convergence (default = FALSE). This would be useful for plotting traceplots for relevant model parameters to evaluate convergence behavior. Note, this should not be used regularly as it will result in an object with a large file size. |
verbose |
Logical controlling whether progress messages/bars are generated (default = TRUE). |
For more information on the model equation and priors implemented in this function, see Lamm et al. (2022; CI-PREMM) and Lock et al. (2018; PREMM).
A list (an object of class PREM) with elements:
Call |
A list of all specified function arguments. |
Sample Size |
Number of subjects ( |
Data |
Dataset used for estimation. |
Convergence |
Potential scale reduction factor (PSRF) for each parameter ( |
Model_Fit |
Deviance ( |
Fitted_Values |
Data frame with the fitted values at each timepoint for each individual. |
Parameter_Estimates |
Data frame with posterior mean and 95% credible intervals for each model parameter. |
Random_Coefficients |
List object with data frames providing random coefficients for each individual. |
Run_Time |
Total run time for model fitting. |
Full_MCMC_Chains |
If save_full_chains=TRUE, raw MCMC chains from rjags. |
Convergence_MCMC_Chains |
If save_conv_chains=TRUE, raw MCMC chains from rjags but only for the parameters monitored for convergence. |
Class_Information contains a list with elements:
class_membership |
Vector of length n with class membership assignments for each individual. |
individ_class_probability |
nxC matrix with each individual’s probabilities of belonging to each class conditional on their class-predictive covariates (when applicable) and growth curve. |
unconditional_class_probability |
This output will differ based on which model was fit. For a PREM or CI-PREM, this will equal 1 as there is only one class. For a PREMM or CI-PREMM with only outcome-predictive covariates, this will be a vector of length C denoting the population probability of belonging to each class. For a CI-PREMM with class-predictive covariates, this will be a vector of length n denoting the probability of each individual belonging to the non-reference class (Class 2) based on their class-predictive covariates only. |
Corissa T. Rohloff, Rik Lamm, Eric F. Lock
Lamm, R. (2022). Incorporation of covariates in Bayesian piecewise growth mixture models. https://hdl.handle.net/11299/252533
Lock, E. F., Kohli, N., & Bose, M. (2018). Detecting multiple random changepoints in Bayesian piecewise growth mixture models. Psychometrika, 83(3), 733–750. https://doi.org/10.1007/s11336-017-9594-5
# load simulated data data(SimData_PREM) # PREM --------------------------------------------------------------------------------- # fit Bayes_PREM() results_prem <- Bayes_PREM(data = SimData_PREM, id_var = "id", time_var = "time", y_var = "y") # result summary summary(results_prem) # plot fitted results plot(results_prem) # CI-PREM --------------------------------------------------------------------------------- # fit Bayes_PREM() results_ciprem <- Bayes_PREM(data = SimData_PREM, id_var = "id", time_var = "time", y_var = "y", outcome_predictive_vars = "outcome_pred_1") # result summary summary(results_ciprem) # plot fitted results plot(results_ciprem) # PREMM --------------------------------------------------------------------------------- # fit Bayes_PREM() results_premm <- Bayes_PREM(data = SimData_PREM, id_var = "id", time_var = "time", y_var = "y", n_class = 2) # result summary summary(results_premm) # plot fitted results plot(results_premm) # CI-PREMM --------------------------------------------------------------------------------- # fit Bayes_PREM() results_cipremm <- Bayes_PREM(data = SimData_PREM, id_var = "id", time_var = "time", y_var = "y", n_class = 2, class_predictive_vars = c("class_pred_1", "class_pred_2"), outcome_predictive_vars = "outcome_pred_1") # result summary summary(results_cipremm) # plot fitted results plot(results_cipremm)# load simulated data data(SimData_PREM) # PREM --------------------------------------------------------------------------------- # fit Bayes_PREM() results_prem <- Bayes_PREM(data = SimData_PREM, id_var = "id", time_var = "time", y_var = "y") # result summary summary(results_prem) # plot fitted results plot(results_prem) # CI-PREM --------------------------------------------------------------------------------- # fit Bayes_PREM() results_ciprem <- Bayes_PREM(data = SimData_PREM, id_var = "id", time_var = "time", y_var = "y", outcome_predictive_vars = "outcome_pred_1") # result summary summary(results_ciprem) # plot fitted results plot(results_ciprem) # PREMM --------------------------------------------------------------------------------- # fit Bayes_PREM() results_premm <- Bayes_PREM(data = SimData_PREM, id_var = "id", time_var = "time", y_var = "y", n_class = 2) # result summary summary(results_premm) # plot fitted results plot(results_premm) # CI-PREMM --------------------------------------------------------------------------------- # fit Bayes_PREM() results_cipremm <- Bayes_PREM(data = SimData_PREM, id_var = "id", time_var = "time", y_var = "y", n_class = 2, class_predictive_vars = c("class_pred_1", "class_pred_2"), outcome_predictive_vars = "outcome_pred_1") # result summary summary(results_cipremm) # plot fitted results plot(results_cipremm)
Extracts the posterior class probabilities for each individual from a fitted model of class "PREM".
getClassProb(x, ...) ## S3 method for class 'PREM' getClassProb(x, ...) ## S3 method for class 'getClassProb.PREM' print(x, ...)getClassProb(x, ...) ## S3 method for class 'PREM' getClassProb(x, ...) ## S3 method for class 'getClassProb.PREM' print(x, ...)
x |
An object of class "PREM". |
... |
Additional arguments. |
Returns a list of the posterior class probabilities for each individual.
Corissa T. Rohloff
# load fitted model results data(results_prem) # get class probabilities getClassProb(results_prem)# load fitted model results data(results_prem) # get class probabilities getClassProb(results_prem)
Extracts the random coefficients from a fitted model of class "BPREM", "CREM", or "PREM".
getCoef(x, ...) ## S3 method for class 'BPREM' getCoef(x, ...) ## S3 method for class 'CREM' getCoef(x, ...) ## S3 method for class 'PREM' getCoef(x, ...) ## S3 method for class 'getCoef' print(x, ...)getCoef(x, ...) ## S3 method for class 'BPREM' getCoef(x, ...) ## S3 method for class 'CREM' getCoef(x, ...) ## S3 method for class 'PREM' getCoef(x, ...) ## S3 method for class 'getCoef' print(x, ...)
x |
An object of class "BPREM", "CREM", or "PREM". |
... |
Additional arguments. |
Returns a data frame of the random coefficients for each individual/group.
Corissa T. Rohloff
# load fitted model results data(results_prem) # get random coefficients getCoef(results_prem)# load fitted model results data(results_prem) # get random coefficients getCoef(results_prem)
Extracts the individual fitted values from a fitted model of class "BPREM", "CREM", or "PREM".
getFitted(x, ...) ## S3 method for class 'BPREM' getFitted(x, ...) ## S3 method for class 'CREM' getFitted(x, ...) ## S3 method for class 'PREM' getFitted(x, ...) ## S3 method for class 'getFitted' print(x, ...)getFitted(x, ...) ## S3 method for class 'BPREM' getFitted(x, ...) ## S3 method for class 'CREM' getFitted(x, ...) ## S3 method for class 'PREM' getFitted(x, ...) ## S3 method for class 'getFitted' print(x, ...)
x |
An object of class "BPREM", "CREM", or "PREM". |
... |
Additional arguments. |
Returns a data frame of the fitted values for each individual and timepoint.
Corissa T. Rohloff
# load fitted model results data(results_prem) # get fitted values getFitted(results_prem)# load fitted model results data(results_prem) # get fitted values getFitted(results_prem)
Extracts the fixed effects parameter estimates from a fitted model of class "BPREM", "CREM", or "PREM".
getFixEf(x, ...) ## S3 method for class 'BPREM' getFixEf(x, ...) ## S3 method for class 'CREM' getFixEf(x, ...) ## S3 method for class 'PREM' getFixEf(x, ...) ## S3 method for class 'getFixEf' print(x, ...)getFixEf(x, ...) ## S3 method for class 'BPREM' getFixEf(x, ...) ## S3 method for class 'CREM' getFixEf(x, ...) ## S3 method for class 'PREM' getFixEf(x, ...) ## S3 method for class 'getFixEf' print(x, ...)
x |
An object of class "BPREM", "CREM", or "PREM". |
... |
Additional arguments. |
Returns a vector or data frame of fixed effects parameter values.
Corissa T. Rohloff
# load fitted model results data(results_bprem) # get fixed effects getFixEf(results_bprem)# load fitted model results data(results_bprem) # get fixed effects getFixEf(results_bprem)
Extracts the K (number of changepoints) probabilities from a fitted model of class "PREM".
getKProb(x, ...) ## S3 method for class 'PREM' getKProb(x, ...) ## S3 method for class 'getKProb.PREM' print(x, ...)getKProb(x, ...) ## S3 method for class 'PREM' getKProb(x, ...) ## S3 method for class 'getKProb.PREM' print(x, ...)
x |
An object of class "PREM". |
... |
Additional arguments. |
Returns a list of the posterior probabilities for each possible number of changepoints, for each class.
Corissa T. Rohloff
# load fitted model results data(results_prem) # get changepoint probabilities getKProb(results_prem)# load fitted model results data(results_prem) # get changepoint probabilities getKProb(results_prem)
Extracts the model fit information from a fitted model of class "BPREM", "CREM", or "PREM".
getModelFit(x, ...) ## S3 method for class 'BPREM' getModelFit(x, ...) ## S3 method for class 'CREM' getModelFit(x, ...) ## S3 method for class 'PREM' getModelFit(x, ...) ## S3 method for class 'getModelFit' print(x, ...)getModelFit(x, ...) ## S3 method for class 'BPREM' getModelFit(x, ...) ## S3 method for class 'CREM' getModelFit(x, ...) ## S3 method for class 'PREM' getModelFit(x, ...) ## S3 method for class 'getModelFit' print(x, ...)
x |
An object of class "BPREM", "CREM", or "PREM". |
... |
Additional arguments. |
Returns a vector of the model fit information (deviance, pD, DIC).
Corissa T. Rohloff
# load fitted model results data(results_prem) # get model fit getModelFit(results_prem)# load fitted model results data(results_prem) # get model fit getModelFit(results_prem)
Extracts the random effects from a fitted model of class "BPREM" or "CREM".
getRanEf(x, ...) ## S3 method for class 'BPREM' getRanEf(x, ...) ## S3 method for class 'CREM' getRanEf(x, ...) ## S3 method for class 'getRanEf' print(x, ...)getRanEf(x, ...) ## S3 method for class 'BPREM' getRanEf(x, ...) ## S3 method for class 'CREM' getRanEf(x, ...) ## S3 method for class 'getRanEf' print(x, ...)
x |
An object of class "BPREM" or "CREM". |
... |
Additional arguments. |
Returns a list of the random effects for each individual/group.
Corissa T. Rohloff
# load fitted model results data(results_bprem) # get random effects getRanEf(results_bprem)# load fitted model results data(results_bprem) # get random effects getRanEf(results_bprem)
Extracts the random effects variance-covariance matrix from a fitted model of class "BPREM", "CREM", or "PREM".
getVarCov(x, ...) ## S3 method for class 'BPREM' getVarCov(x, ...) ## S3 method for class 'CREM' getVarCov(x, ...) ## S3 method for class 'PREM' getVarCov(x, ...) ## S3 method for class 'getVarCov.BPREM' print(x, ...) ## S3 method for class 'getVarCov.CREM' print(x, ...) ## S3 method for class 'getVarCov.PREM' print(x, ...)getVarCov(x, ...) ## S3 method for class 'BPREM' getVarCov(x, ...) ## S3 method for class 'CREM' getVarCov(x, ...) ## S3 method for class 'PREM' getVarCov(x, ...) ## S3 method for class 'getVarCov.BPREM' print(x, ...) ## S3 method for class 'getVarCov.CREM' print(x, ...) ## S3 method for class 'getVarCov.PREM' print(x, ...)
x |
An object of class "BPREM", "CREM", or "PREM". |
... |
Additional arguments. |
Returns a list of the random effects variance-covariance matrices.
Corissa T. Rohloff
# load fitted model results data(results_prem) # get random effects variance-covariance matrices getVarCov(results_prem)# load fitted model results data(results_prem) # get random effects variance-covariance matrices getVarCov(results_prem)
Generates a "spaghetti plot" of observed longitudinal trajectories for each individual. If the results from a BEND function are supplied, the trajectory defined by the mean parameters is shown in bold. If fitting a mixture (PREMM or CI-PREMM) or bivariate model (BPREM), the mean trajectories for classes or outcomes will be distinguished by color.
plot_BEND( data, id_var, time_var, y_var, y2_var = NULL, results = NULL, xlab = "X", ylab = "Y", colors = NULL, mean_colors = NULL, legend_pos = "topright", ... )plot_BEND( data, id_var, time_var, y_var, y2_var = NULL, results = NULL, xlab = "X", ylab = "Y", colors = NULL, mean_colors = NULL, legend_pos = "topright", ... )
data |
Data frame in long format, where each row describes a measurement occasion for a given individual. It is assumed that each individual has the same number of assigned timepoints (a.k.a., rows). |
id_var |
Name of column that contains ids for individuals with repeated measures in a longitudinal dataset. |
time_var |
Name of column that contains the time variable. |
y_var |
Name of column that contains the outcome variable. |
y2_var |
(for |
results |
The output of |
xlab |
X-axis label for the generated plot. |
ylab |
Y-axis label for the generated plot. |
colors |
Colors for each class ( |
mean_colors |
Colors for the trajectory defined by the mean parameters for each class ( |
legend_pos |
(optional) Option to change legend position (default = "topright"). |
... |
(optional) Other parameters to pass to the |
No return value, called to generate plot.
Corissa T. Rohloff
# load simulated data data(SimData_PREM) # plot observed data plot_BEND(data = SimData_PREM, id_var = "id", time_var = "time", y_var = "y") # load fitted model results data(results_prem) # plot fitted results plot_BEND(data = SimData_PREM, id_var = "id", time_var = "time", y_var = "y", results = results_prem)# load simulated data data(SimData_PREM) # plot observed data plot_BEND(data = SimData_PREM, id_var = "id", time_var = "time", y_var = "y") # load fitted model results data(results_prem) # plot fitted results plot_BEND(data = SimData_PREM, id_var = "id", time_var = "time", y_var = "y", results = results_prem)
Provides a fitted plot of a BPREM model, as returned by Bayes_BPREM().
## S3 method for class 'BPREM' plot( x, xlab = "X", ylab = "Y", colors = NULL, mean_colors = NULL, legend_pos = "topright", ... )## S3 method for class 'BPREM' plot( x, xlab = "X", ylab = "Y", colors = NULL, mean_colors = NULL, legend_pos = "topright", ... )
x |
An object of class "BPREM" (returned by |
xlab |
X-axis label for the generated plot. |
ylab |
Y-axis label for the generated plot. |
colors |
Colors for each class outcome. By default, up to 2 colors are provided in the following order: "blue" (outcome 1), "red" (outcome 2). |
mean_colors |
Colors for the trajectory defined by the mean parameters for each outcome. By default, up to 2 colors are provided in the following order: "darkblue" (outcome 1), "darkred" (outcome 2). |
legend_pos |
(optional) Option to change legend position (default = "topright"). |
... |
(optional) Other parameters to pass to the |
No return value.
Corissa T. Rohloff
# load fitted model results data(results_bprem) # plot fitted results plot(results_bprem)# load fitted model results data(results_bprem) # plot fitted results plot(results_bprem)
Provides a fitted plot of a CREM model, as returned by Bayes_CREM().
## S3 method for class 'CREM' plot( x, xlab = "X", ylab = "Y", colors = NULL, mean_colors = NULL, legend_pos = "topright", ... )## S3 method for class 'CREM' plot( x, xlab = "X", ylab = "Y", colors = NULL, mean_colors = NULL, legend_pos = "topright", ... )
x |
An object of class "CREM" (returned by |
xlab |
X-axis label for the generated plot. |
ylab |
Y-axis label for the generated plot. |
colors |
Color for observed trajectories (optional). Default is "grey". |
mean_colors |
Colors for the trajectory defined by the mean parameters for each outcome (optional). Default is "black". |
legend_pos |
(optional) Option to change legend position (default = "topright"). |
... |
(optional) Other parameters to pass to the |
No return value.
Corissa T. Rohloff
# load fitted model results data(results_pcrem) # plot fitted results plot(results_pcrem)# load fitted model results data(results_pcrem) # plot fitted results plot(results_pcrem)
Provides a fitted plot of a PREM model, as returned by Bayes_PREM().
## S3 method for class 'PREM' plot( x, xlab = "X", ylab = "Y", colors = NULL, mean_colors = NULL, legend_pos = "topright", ... )## S3 method for class 'PREM' plot( x, xlab = "X", ylab = "Y", colors = NULL, mean_colors = NULL, legend_pos = "topright", ... )
x |
An object of class "PREM" (returned by |
xlab |
X-axis label for the generated plot. |
ylab |
Y-axis label for the generated plot. |
colors |
Colors for each class ( |
mean_colors |
Colors for the trajectory defined by the mean parameters for each class ( |
legend_pos |
(optional) Option to change legend position (default = "topright"). |
... |
(optional) Other parameters to pass to the |
No return value.
Corissa T. Rohloff
# load fitted model results data(results_prem) # plot fitted results plot(results_prem)# load fitted model results data(results_prem) # plot fitted results plot(results_prem)
Provides a summary of a BPREM model, as returned by Bayes_BPREM().
## S3 method for class 'BPREM' print(x, ...)## S3 method for class 'BPREM' print(x, ...)
x |
An object of class "BPREM" (returned by |
... |
Additional arguments. |
Returns a list of key parameter estimates.
Corissa T. Rohloff
# load fitted model results data(results_bprem) # print results print(results_bprem)# load fitted model results data(results_bprem) # print results print(results_bprem)
Provides a summary of a CREM model, as returned by Bayes_CREM().
## S3 method for class 'CREM' print(x, ...)## S3 method for class 'CREM' print(x, ...)
x |
An object of class "CREM" (returned by |
... |
Additional arguments. |
Returns a list of key parameter estimates.
Corissa T. Rohloff
# load fitted model results data(results_pcrem) # print results print(results_pcrem)# load fitted model results data(results_pcrem) # print results print(results_pcrem)
Provides a summary of a PREM model, as returned by Bayes_PREM().
## S3 method for class 'PREM' print(x, ...)## S3 method for class 'PREM' print(x, ...)
x |
An object of class "PREM" (returned by |
... |
Additional arguments. |
Returns a list of key parameter estimates.
Corissa T. Rohloff
# load fitted model results data(results_prem) # print results print(results_prem)# load fitted model results data(results_prem) # print results print(results_prem)
Simulated data for a bivariate piecewise random effects model (BPREM) using SimData_BPREM. Included to demonstrate the use of summary.BPREM().
Results from fitting a bivariate piecewise random effects model (BPREM) to SimData_BPREM (returned by Bayes_BPREM(...)).
data(results_bprem) results_bpremdata(results_bprem) results_bprem
A list (an object of class BPREM) with fitted model results.
results_bpremA list object with elements:
Function arguments
Data set sample size
Data used for model fitting
Convergence status
Model fit information
Fitted outcome values
Parameter estimates
Random coefficient estimates
Model run time
Simulated data for a piecewise crossed random effects model (PCREM) using SimData_CREM. Included to demonstrate the use of summary.CREM().
Results from fitting a piecewise crossed random effects model (PCREM) to SimData_PCREM (returned by Bayes_CREM(...)).
data(results_pcrem) results_pcremdata(results_pcrem) results_pcrem
A list (an object of class CREM) with fitted model results.
results_pcremA list object with elements:
Function arguments
Data set sample size
Data used for model fitting
Convergence status
Model fit information
Fitted outcome values
Parameter estimates
Random coefficient estimates
Model run time
Fitted results for a piecewise random effects model (PREM) using SimData_PREM. Included to demonstrate the use of plot_BEND() and summary.PREM().
Results from fitting a piecewise random effects model (PREM) to SimData_PREM (returned by Bayes_PREM(...)).
data(results_prem) results_premdata(results_prem) results_prem
A list (an object of class PREM) with fitted model results.
results_premA list object with elements:
Function arguments
Data set sample size
Data used for model fitting
Convergence status
Model fit information
Fitted outcome values
Parameter estimates
Random coefficient estimates
Model run time
Simulated data for a bivariate piecewise random effects model (BPREM) with 7 timepoints collected on 30 individuals.
A simulated dataset for the bivariate piecewise random effects model (BPREM).
data(SimData_BPREM) SimData_BPREMdata(SimData_BPREM) SimData_BPREM
A data frame with 210 rows and 4 variables.
SimData_BPREMA data frame with 210 rows and 4 columns:
Individual ids
Time
Outcome 1
Outcome 2
id ID for each individual.
time Timepoints for each individual.
y1 Outcome 1.
y2 Outcome 2.
Simulated data for a piecewise crossed random effects model (PCREM) with 7 timepoints collected on 30 individuals.
A simulated dataset for the piecewise crossed random effects model (PCREM).
data(SimData_PCREM) SimData_PCREMdata(SimData_PCREM) SimData_PCREM
A data frame with 210 rows and 4 variables.
SimData_PCREMA data frame with 210 rows and 4 columns:
Individual ids
Teacher ids
Time
Outcome
id ID for each individual.
teacherid ID for each teacher.
time Timepoints for each individual.
y Outcome.
Simulated data for a piecewise random effects model (PREM) and useful extensions (CI-PREM, PREMM, CI-PREMM) with 18 timepoints collected on 30 individuals.
A simulated dataset for the piecewise random effects model (PREM).
data(SimData_PREM) SimData_PREMdata(SimData_PREM) SimData_PREM
A data frame with 540 rows and 6 variables.
SimData_PREMA data frame with 540 rows and 6 columns:
Individual ids
Time
Outcome
First Class-Predictive Covariate
Second Class-Predictive Covariate
First Outcome-Predictive Covariate
id ID for each individual.
time Timepoints for each individual.
y Outcome.
class_pred_1 First class predictive covariate (time-invariant).
class_pred_2 Second class predictive covariate (time-invariant).
outcome_pred_1 Outcome predictive covariate (time-varying).
Provides a summary of a BPREM model, as returned by Bayes_BPREM().
## S3 method for class 'BPREM' summary(object, ...) ## S3 method for class 'summary.BPREM' print(x, ...)## S3 method for class 'BPREM' summary(object, ...) ## S3 method for class 'summary.BPREM' print(x, ...)
object |
An object of class "BPREM" (returned by |
... |
Additional arguments. |
x |
An object of class "summary.BPREM". |
Returns a list of key parameter estimates.
Corissa T. Rohloff
# load fitted model results data(results_bprem) # result summary summary(results_bprem)# load fitted model results data(results_bprem) # result summary summary(results_bprem)
Provides a summary of a CREM model, as returned by Bayes_CREM().
## S3 method for class 'CREM' summary(object, ...) ## S3 method for class 'summary.CREM' print(x, ...)## S3 method for class 'CREM' summary(object, ...) ## S3 method for class 'summary.CREM' print(x, ...)
object |
An object of class "CREM" (returned by |
... |
Additional arguments. |
x |
An object of class "summary.CREM". |
Returns a list of key parameter estimates.
Corissa T. Rohloff
# load fitted model results data(results_pcrem) # result summary summary(results_pcrem)# load fitted model results data(results_pcrem) # result summary summary(results_pcrem)
Provides a summary of a PREM model, as returned by Bayes_PREM().
## S3 method for class 'PREM' summary(object, ...) ## S3 method for class 'summary.PREM' print(x, ...)## S3 method for class 'PREM' summary(object, ...) ## S3 method for class 'summary.PREM' print(x, ...)
object |
An object of class "PREM" (returned by |
... |
Additional arguments. |
x |
An object of class "summary.PREM". |
Returns a list of key parameter estimates.
Corissa T. Rohloff
# load fitted model results data(results_prem) # result summary summary(results_prem)# load fitted model results data(results_prem) # result summary summary(results_prem)