Skip to contents

Simulate

run_simulations()
Run Simulations for Estimating ATE
simulate_ate_data_with_weights()
Simulate Data for Average Treatment Effect (ATE) with Sample Weights

Describe Longitudinal Data

margot_count_dyads()
Count Dyads in Longitudinal Data
margot_count_ids()
Count Individual Participants in Longitudinal Data
margot_plot_boxplot()
Create panel data Boxplots using ggplot2
margot_plot_boxplot_covariate()
Create Boxplots with Covariates using ggplot2
margot_plot_discontinuity()
Create a Discontinuity Plot for Multiple Events
margot_plot_histogram()
Create a Histogram with Mean and Standard Deviation Highlights for Each Wave and Variable
margot_plot_response_timeline()
Plot Panel Study Response Timeline
margot_plot_slope()
Create a Slope Plot for Multiple Variables
margot_plot_slope_covariate()
Create a Slope Plot using ggeffects
margot_plot_slope_covariate_batch()
Create a Combined Slope Plot using ggeffects and patchwork
margot_plot_slope_covariate_combo()
Create a Combined Slope Plot using ggeffects and patchwork
margot_summary_panel()
Generate Summary Panel for Margot Study

Check assumptions

create_transition_matrix()
Create transition matrix for state transitions
match_mi_general()
General Matching Function for Multiple Imputation Data
margot_make_tables()
Create Summary Tables Using table1 with Custom Formatting
margot_plot_categorical()
Create a Coloured Histogram with Quantile or Custom Breaks
margot_plot_individual_responses()
Create Individual Longitudinal Response Plots
margot_plot_shift()
Visualize Shifts in Data Distributions with Highlighted Ranges
margot_propensity_model_and_plots()
Create Propensity Score Model and Associated Plots
margot_summary_tables()
Generate summary tables and plots for longitudinal data
transition_table()
Transition Table

Prepare data for models

create_ordered_variable()
Create Ordered Variable Based on Quantile Breaks or Custom Breaks with Informative Labels
impute_and_combine()
Perform multiple imputation on a list of data frames and combine the results
margot_adjust_weights()
Adjust Weights for Censoring and Sample Design with Progress Reporting
margot_amelia_to_mice()
convert an amelia object to a mice object
margot_censor()
Transform year_measured Variable Based on Clustered Conditions Within Waves
margot_compute_gender_weights_by_wave()
Compute Gender-Based Sample Weights by Wave
margot_filter()
Filter Data Based on Exposure Variables
margot_impute_carry_forward()
Impute Missing Values Using Carry Forward in Longitudinal Data
margot_log_transform_vars()
Log-transform Variables in a Data Frame
margot_process_binary_vars()
Process Binary Variables in a Data Frame
margot_process_longitudinal_data()
Process Longitudinal Data for Three Waves
margot_process_longitudinal_data_wider()
Process Longitudinal Data for Multiple Waves
margot_wide()
Transform longitudinal data to wide format with labels
margot_wide_impute_baseline()
Transform to wide data with labels and impute baseline missing values
margot_wide_machine()
This function transforms longitudinal data from long format to wide format, ensuring that baseline measurements are correctly labeled and included. It handles multiple observations per subject across an indefinite number of waves, and allows for the specification of baseline variables, exposure variables, outcome variables, and time-varying confounders.

Treatment effect estimation

causal_contrast_engine()
Compute Causal Contrasts
causal_contrast_marginal()
Causal Contrast Marginal Effects Estimation
double_robust_marginal()
Double Robust Marginal Estimation and Tabulation
margot_causal_forest()
Run Multiple Generalized Random Forest (GRF) Causal Forest Models with Enhanced Features
margot_lmtp()
Batch Process LMTP Models
margot_multi_arm_causal_forest()
Run Multiple Generalized Random Forest (GRF) Multi-Arm Causal Forest Models with Enhanced Features Run Multiple Generalized Random Forest (GRF) Multi-Arm Causal Forest Models with Enhanced Features

Interpret and Report Results

margot_compare_groups()
Compare Treatment Effects Between Groups
margot_omnibus_hetero_test()
Omnibus Heterogeneity Test for GRF Models
margot_interpret_marginal()
This function interprets the output of causal effect analysis, providing a compact report. It only reports coefficients and E-values with **Evidence** or **Strong evidence** for causality. The language is suitable for scientific reports, avoiding explanations of treatment effects and E-values. Each outcome's interpretation starts with a separate paragraph heading using `####`. Additionally, it includes a final paragraph indicating that all other effect estimates presented either weak or unreliable evidence for causality.
margot_interpret_policy_tree()
Interpret Policy Tree Results
margot_interpret_policy_batch()
Batch Process Policy Tree Interpretations
margot_interpret_qini()
Interpret Qini Results for Both Binary and Multi-Arm Treatments
margot_lmtp_evalue()
Combine LMTP Summary and E-Value Calculation
margot_lmtp_tab()
Summarise LMTP Output into a Data Frame
margot_model_evalue()
Combine Model Summary and E-Value Calculation for Various Causal Models
margot_model_tab()
Summarise LMTP or Causal Forest Output into a Data Frame
margot_policy()
Batch Processing of Policy Trees and Related Visualizations
margot_subset_model()
Subset Model Results for Binary and Categorical Exposures
margot_summary_cate_difference_gain()
Compute Difference in Gains and Integrated Difference Between Reference and Comparison Curves

Visualise Causal Effect Estimates

margot_plot()
Create a Margot Plot with Interpretation
margot_plot_batch_rate()
Batch Process and Plot RATE Curves for Multiple Models
margot_plot_decision_tree()
Plot a Decision Tree from Margot Causal Forest Results
margot_plot_multi_arm()
Create a Multi-arm Margot Plot with User-specified Contrast
margot_plot_policy_combo()
Create a Combined Decision Tree and Policy Relationship Graph
margot_plot_policy_tree()
Plot Policy Tree Results
margot_plot_qini()
Plot Qini Curves from margot_multi_arm_causal_forest Results
margot_plot_rate()
Plot Rank Average Treatment Effect

Utility functions

back_transform_logmean()
Back-transform Log-transformed Mean
back_transform_zscore()
Back Transform Z-Score to Original Scale
construct_formula()
Construct a Formula for Regression Models
here_read()
Read Data Frame or Object from RDS File in a Specified Directory
here_save()
Save Data Frame as RDS File in a Specified Directory
here_read_qs()
Read Data Frame or Object from qs File in a Specified Directory
here_save_qs()
Save Data Frame or Object to qs File in a Specified Directory with Enhanced Compression
lmtp_evalue_tab()
Calculate E-values for LMTP Output
margot_log_transform_vars()
Log-transform Variables in a Data Frame
margot_plot_create_options()
Create Plot Options for Margot Plot
margot_plot_exposure()
Create a separate exposure plot
margot_process_binary_vars()
Process Binary Variables in a Data Frame
margot_prop_missing()
Proportion of missing data at baseline
margot_save_png()
Save Margot Plot as PNG
margot_size()
Calculate the size of an R object in megabytes
prepare_panel_data()
Prepare Panel Data for Timeline Visualization
pretty_number()
Format Numbers with Commas
read_multiple_images()
Read Multiple Images from a Folder
remove_numeric_attributes()
Remove Attributes from Numeric Columns in a Data Frame
regress_with_covariates()
Generalized Linear Regression with Covariates
select_and_rename_cols()
Select and Rename Columns Based on Criteria
transform_table_rownames()
Transform Table Row Names with CLI Feedback

Simulated data

df_nz
df_nz: Example Data Frame

Deprecated Functions

coloured_histogram()
Create a Coloured Histogram Highlighting Specific Ranges (DEPRECATED)
coloured_histogram_sd()
Visualize Distribution with Mean and Standard Deviation Highlights
coloured_histogram_shift()
Visualise Shifts in Data Distributions with Highlighted Ranges (DEPRECATED)
coloured_histogram_quantiles()
Visualise Distribution with Automatically Calculated Quantile Highlights (DEPRECATED)
margot_plot_hist()
Create a Coloured Histogram with Quantile or Custom Breaks (DEPRECATED)