impute_categorical_covariates {ImputeLongiCovs} | R Documentation |
impute_categorical_covariates
Description
impute_categorical_covariates imputes longitudinal categorical covariates through a joint model that accommodates initial, forward, backward, and intermittent transitions.
Usage
impute_categorical_covariates(
input_data,
patient_id,
number_of_transitions,
covariates_initial = NULL,
covariates_transition = NULL,
missing_variable_levels,
startingyear = NULL,
without_trans_prob,
m = 1
)
Arguments
input_data |
A dataset in a format similar to 'analyses_data'. This dataset must contain the variables "state_from", which is the status at the beginning of the transition (say smoker in 2010), "state_to", which is the status at the end of the transition (say ex-smoker in 2011) and "tran_Year", which is an integer variable that is equal to the number of transitions. "tran_Year" == 1 means that the transition occurs from 2010 to 2011, "tran_Year" == 2, from 2011 to 2012, up to the total number of transitions Also, it must contain "prob_matrix" which captures all the transitions ("initial", "forward", "backward", "intermittent", "observed") that was calculated with the 'create_probMatrix' function |
patient_id |
A character variable that specifies the column name with the unique Id of the patient |
number_of_transitions |
The number of transitions needed. For example for years 2010, 2011 and 2012 there exist 2 transitions. |
covariates_initial |
The covariates to be used in the initial model |
covariates_transition |
The covariates to be used in the transition model |
missing_variable_levels |
The levels of the missing categorical outcome (e.g. "smoker", "ex-smoker", "never-smoker") |
startingyear |
If the starting year per patient has no missing values, specify it |
without_trans_prob |
This statement is useful when there are very high proportions of missing data and our initial and transition model cannot converge. It provides the user with two options. One, to "notImpute", namely to return NA and two, to "ImputeEqualProbabilities", i.e., the user can sample with equal probabilities. |
m |
Numeric, the number of imputed datasets |
Details
It encloses three different functions. The 'initial_forward_function' imputes the longitudinal categorical covariate of interest based on whether in that transition the 'prob_matrix' of a patient was 'initial' or 'forward'. The 'imputeIntermittent' imputes the longitudinal categorical covariate for the intermittent transition and the 'backward_function' imputes the longitudinal categorical covariate for the backward transition.
Value
a list of m data frames with no missing values in the categorical outcome
References
()
Examples
impute_categorical_covariates(analyses_data,
patient_id = "patient_id",
number_of_transitions = 2,
covariates_initial = c("cardio_state_from", "flu_vaccination_state_from"),
covariates_transition = c("cardio_state_to", "flu_vaccination_state_to"),
missing_variable_levels = c("never-smoker", "smoker", "ex-smoker"),
startingyear = NULL,
without_trans_prob = "notImpute",
m = 2)