# Defining the names of the metric and binary covariates
covariates_vector <- c("GPA_school", "IQ_score", "Motivation", "parents_academic", "gender")
# Estimating balance of a two-group matching using the data set
# 'MAGMA_sim_data'.
# Matching variable 'gifted_support' (received giftedness support yes or no)
Balance_gifted <- Balance_MAGMA(Data = MAGMA_sim_data[MAGMA_sim_data$step_gifted < 200, ],
group = "gifted_support",
covariates = covariates_vector,
step = "step_gifted")
# Balance criteria for 100 cases per group
# Balance criteria
Balance_100_gifted <- Balance_extract(Balance = Balance_gifted,
samplesize = 100,
effects = FALSE)
Balance_100_gifted
# Pairwise effects
Balance_100_gifted_effects <- Balance_extract(Balance = Balance_gifted,
samplesize = 100,
effects = TRUE)
Balance_100_gifted_effects
# \donttest{
# 2x2 matching using the data set 'MAGMA_sim_data'
# Matching variables are 'gifted_support' (received giftedness support yes
# or no) and 'enrichment' (participated in enrichment or not)
# 'MAGMA_sim_data_gift_enrich' contains the result of the matching
# 2x2 matching is equivalent to four-group matching
MAGMA_sim_data_gift_enrich <- MAGMA(Data = MAGMA_sim_data,
group = c("gifted_support", "enrichment"),
dist = "ps_2x2",
cores = 2)
# Estimating balance. Covariates same as above
Balance_2x2 <- Balance_MAGMA(Data = MAGMA_sim_data_gift_enrich,
group = c("gifted_support", "enrichment"),
covariates = covariates_vector,
step = "step") # Step created during matching
str(Balance_2x2)
# Balance criteria for 125 cases per group
# Balance criteria
Balance_125_2x2 <- Balance_extract(Balance = Balance_2x2,
samplesize = 125,
effects = FALSE)
Balance_125_2x2
# Pairwise effects
Balance_125_2x2_effects <- Balance_extract(Balance = Balance_2x2,
samplesize = 125,
effects = TRUE)
Balance_125_2x2_effects
# }
Run the code above in your browser using DataLab