build_traj {trajmsm} | R Documentation |
Wrapper for flexmix
Description
Call the package flexmix to build trajectory groups
Usage
build_traj(
obsdata,
formula,
number_traj,
identifier,
family = "binomial",
seed = 945,
control = list(iter.max = 1000, minprior = 0),
...
)
Arguments
obsdata |
Data to build trajectory groups in long format. |
formula |
Designate the formula to model the longitudinal variable of interest. |
number_traj |
An integer to fix the number of trajectory groups. |
identifier |
A string to designate the column name for the unique identifier. |
family |
Designate the type of distribution ("gaussian", "binomial", "poisson", "gamma"). |
seed |
Set a seed for replicability. |
control |
Object of class FLXcontrol. |
... |
Additional arguments passed to the flexmix function. |
Value
A list containing the posterior probability matrix and the fitted trajectory model.
Examples
obsdata_long = gendata(n = 1000,format = "long", total_followup = 6, seed = 945)
formula = as.formula(cbind(statins, 1 - statins) ~ time)
restraj = build_traj(obsdata = obsdata_long, number_traj = 3, formula = formula, identifier = "id")
[Package trajmsm version 0.1.0 Index]