Balance_extract {MAGMA.R}R Documentation

Balance_extract

Description

This function extracts the balance criteria or pairwise effects of a Balance_MAGMA result for a specified sample size.

Usage

Balance_extract(Balance, samplesize, effects = FALSE)

Arguments

Balance

A result of Balance_MAGMA See the function Balance_MAGMA for details.

samplesize

An integer indicating the sample size for which the balance criteria or pairwise effects should be extracted.

effects

Indicates whether balance criteria or pairwise effects should be extracted. The default value FALSE returns the balance criteria, while TRUE leads to the extraction of pairwise effects.

Details

Given a previous computed Balance_MAGMA object, this function enables the extraction of balance criteria or pairwise effects for any desired sample size. This makes it possible to independently check the balance for each possible sample size.

Value

Depends on the effects argument. If FALSE, it returns in a vector containing the balance criteria. If TRUE, it returns a vector containing all possible pairwise effects.

Author(s)

Julian Urban

Examples


# 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


# 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



[Package MAGMA.R version 1.0.1 Index]