Skip to contents

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

margot_make_tables()
Create Summary Tables Using table1 with Custom Formatting
margot_plot_categorical()
Create a coloured histogram with summary lines and optional median
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_transition_table()
Format a Transition Table with observed‑indicator filtering

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_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 in wide format with censoring by missing exposure and silent dummy-coding
margot_wide_machine()
Transform longitudinal data to wide format with baseline imputation and optional NA indicators

Treatment effect estimation

margot_causal_forest()
Run Multiple Generalized Random Forest (GRF) Causal Forest Models with Enhanced Qini Cross-Validation
margot_lmtp()
Batch Process LMTP Models

Interpret and Report Results

margot_bind_tables()
Bind and format domain-specific tables or a single table
margot_bind_models()
Combine multiple batched model outputs (with covariates & metadata)
margot_compare_groups()
Compare subgroups from a causal forest model.
margot_correct_combined_table()
Correct a “combined table” for multiplicity **and** recompute *E*-values
margot_flip_forests()
Flip CATE Estimates and Recalculate Policy Trees for Selected Outcomes
margot_inspect_qini()
Inspect qini diagnostics for one or several models
margot_interpret_policy_batch()
Batch process policy tree interpretations
margot_interpret_policy_tree()
Interpret Policy Tree Results
margot_interpret_qini()
Interpret Qini Results
margot_interpret_rate()
Interpret RATE estimates
margot_interpret_rate_comparison()
Compare and interpret RATE estimates from AUTOC and QINI
margot_lmtp_evalue()
Combine LMTP Summary and E-Value Calculation
margot_model_evalue()
Combine Model Summary and E-Value Calculation for Various Causal Models
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 Visualisations
margot_rate()
Assemble RATE tables (AUTOC and QINI)
margot_rate_batch()
Batch-compute RATEs for each outcome in a margot_causal_forest result
margot_rescue_qini()
Post-process models to recover Qini curves via propensity trimming
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 a policy tree (depth-adaptive)
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()
Batch Process and Plot RATE Curves for Multiple Models
margot_plot_tau()
Create Faceted Tau Hat Distribution Plots

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
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_get_labels()
Get display labels for multiple variable names
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_rescue_qini()
Post-process models to recover Qini curves via propensity trimming
margot_reversed_labels()
Update label map by marking reversed outcomes
margot_save_png()
Save Margot Plot as PNG
margot_size()
Calculate the size of an R object in megabytes
margot_trim_sample_weights()
Standardise and (optionally) trim sample weights at both ends
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

Data and Simulation

df_nz
Legacy New Zealand Attitudes and Values Study (NZAVS) Simulated Data
df_margot_example
Margot Example Dataset
fetch_margot_data()
Fetch Margot Example Data
list_margot_data()
List Available Margot Datasets
clear_margot_cache()
Clear Margot Data Cache
margot_simulate()
Simulate longitudinal exposures, outcomes, and covariates