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

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()
Visualise 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
margot_transition_table()
Format a 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 Using Baseline Wave Proportions
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 dyadic 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()
Transform longitudinal data to wide format with baseline imputation and NA indicators

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 Qini Cross-Validation
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

Interpret and Report Results

margot_bind_tables()
Bind and Format Domain-Specific Tables
margot_compare_groups()
Compare Treatment Effects Between Groups
margot_flip_forests()
Flip CATE Estimates for Selected Outcomes in GRF Model Results
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, unless all estimates with E_Value > 1 (and E_Val_bound > 1) are requested. Each outcome's interpretation starts with a separate paragraph heading. Additionally, it includes a final paragraph indicating that all other effect estimates presented either weak or unreliable evidence for causality.
margot_interpret_policy_batch()
Batch process policy tree interpretations
margot_interpret_policy_tree()
Interpret Policy Tree Results
margot_interpret_qini()
Interpret Qini Results for Both Binary and Multi-Arm Treatments
margot_interpret_rate()
Interpret RATE estimates in markdown
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_omnibus_hetero_test()
Omnibus Heterogeneity Test for GRF Models
margot_planned_subgroups_batch()
Batch process heterogeneity analyses across multiple outcome domains
margot_policy()
Batch Processing of Policy Trees and Related Visualizations
margot_rate()
Format RATE Results into Readable Tables
margot_subset_model()
Subset Model Results for Binary and Categorical Exposures
margot_subset_batch()
Batch Process Subset Models for Causal Forests
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_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
margot_plot_rate_batch() margot_plot_batch_rate()
Batch Process and Plot RATE Curves for Multiple Models (New Function)

Utility functions

back_transform_logmean()
Back-transform Log-transformed Mean
back_transform_log_z()
Back Transform Z-Score to Original Log-Transformed Scale
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_back_transform_log_z()
Create Z-score to Original Scale Mapping for Log-Transformed Data
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
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