Density_overlap {MAGMA.R} | R Documentation |
This function shows and quantifies the kernel density overlap of a variable for two or more groups.
Density_overlap(
Data,
variable,
group,
variable_name = NULL,
group_labels = NULL,
group_name = NULL,
step_num = NULL,
step_var = NULL,
verbose = TRUE
)
Data |
A data frame that contains the desired variable for density plotting as well as the specified grouping variable. |
variable |
A character specifying the variable for which the density should be plotted (e.g., "ps_gifted"). |
group |
A character specifying the groups for which the density should be plotted. Can be an independent group comparison (e.g., comparing matched groups) or the comparison of pre and post matched samples. |
variable_name |
A character specifying the name to appear in the plot for the variable. |
group_labels |
A character vector specifying the labels for the groups to ppear in the legend of the plot. |
group_name |
A character specifying the name of the grouping variable to appear in the title of the legend. |
step_num |
An integer specifying the number of cases to be included per group in this post matching comparison. Is based on the step variable of MAGMA. |
step_var |
A character specifying the name of the step variable. |
verbose |
TRUE or FALSE indicating whether matching information should be printed to the console. |
This function enables the comparison of the density of variables for two or more groups. It plots the kernel density separately for each group and quantifies the amount of overlap.
A plot showing the kernel density for a specified variable separately for specified groups and the quantification of this overlap.
Julian Urban
Pastore, M., Loro, P.A.D., Mingione, M., Calcagni, A. (2022). overlapping: Estimation of Overlapping in Empirical Distributions. R package version 2.1, https://CRAN.R-project.org/package=overlapping.
# Estimating density overlap using the data set 'MAGMA_sim_data
# Estimating density overlap for 'ps_gifted' (propensity scores for
# giftedness support)
# Defining plot aesthetics with 'group', 'variable_name', "group_lables',
# and 'group_name'
# Estimating pre-matching density overlap by not specifying 'step_num' and
# 'step_var'
Density_overlap(Data = MAGMA_sim_data,
variable = "ps_gifted",
group = "gifted_support",
step_num = NULL,
step_var = NULL,
variable_name = "Propensity Score",
group_labels = c("No Support", "Support"),
group_name = "Gifted Support")
# Estimating density overlap using the matched data set
#'MAGMA_sim_data_gifted'
# Estimating density overlap for 'ps_gifted' (propensity scores for
# giftedness support)
# Defining plot aesthetics with 'group', 'variable_name', 'group_lables',
# and 'group_name'
# Estimating post-matching overlap for 250 cases per group ('step_num')
# Name of the step variable is 'step'
Density_overlap(Data = MAGMA_sim_data,
variable = "ps_gifted",
group = "gifted_support",
step_num = 250,
step_var = "step_gifted",
variable_name = "Propensity Score",
group_labels = c("No Support", "Support"),
group_name = "Gifted Support")
# Estimating density overlap using the data set 'MAGMA_sim_data
# Estimating density overlap for 'teacher_ability_rating' (ability rated
# from teacher as below average, average, or above average)
# Defining plot aesthetics with 'group', 'variable_name', 'group_lables',
# and 'group_name'
# Estimating pre-matching density overlap by not specifying 'step_num' and
# 'step_var'
Density_overlap(Data = MAGMA_sim_data,
variable = "GPA_school",
group = "teacher_ability_rating",
variable_name = "School Achievement",
group_labels = c("Low", "Medium", "High"),
group_name = "Rating")