Learn R Programming

psychmeta (version 2.7.0)

impute_artifacts: Impute missing and impossible artifact values

Description

Impute missing and impossible artifact values

Usage

impute_artifacts(
  sample_id = NULL,
  construct_id = NULL,
  measure_id = NULL,
  art_vec,
  cat_moderator_matrix,
  impute_method = "bootstrap_mod",
  art_type = "rel",
  n_vec = rep(1, length(art_vec))
)

Value

A vector of artifacts that includes imputed values.

Arguments

sample_id

Study ID value.

construct_id

Construct name or other designator.

measure_id

Measure name or other designator.

art_vec

Vector of artifact values

cat_moderator_matrix

Matrix of categorical moderators

impute_method

Method to use for imputing artifacts. Choices are:

  • bootstrap_mod = select random values from the most specific moderator categories available.

  • bootstrap_full = select random values from the full vector of artifacts.

  • simulate_mod = generate random values from the distribution with the mean and variance of observed artifacts from the most specific moderator categories available (uses rnorm for u ratios and rbeta for reliability values).

  • simulate_full = generate random values from the distribution with the mean and variance of all observed artifacts (uses rnorm for u ratios and rbeta for reliability values).

  • wt_mean_mod = replace missing values with the sample-size weighted mean of the distribution of artifacts from the most specific moderator categories available.

  • wt_mean_full = replace missing values with the sample-size weighted mean of the full distribution of artifacts.

  • unwt_mean_mod = replace missing values with the unweighted mean of the distribution of artifacts from the most specific moderator categories available.

  • unwt_mean_full = replace missing values with the unweighted mean of the full distribution of artifacts.

  • replace_unity = replace missing values with 1 (not recommended)

  • stop = stop evaluations when missing artifacts are encountered

art_type

Type of artifacts to be imputed: "rel" for reliabilities and "u" for u ratios.

n_vec

Vector of sample sizes associated with the elements of art_vec.

Examples

Run this code
# art_vec <- c(.6, .7, NA, .8, .9, NA)
# cat_moderator_matrix <- matrix(c(rep(1, 3), rep(2, 3)))
# art_type <- "rel"
# n_vec <- c(50, 200, 100, 50, 200, 100)
#
# ## Compute unweighted means
# impute_artifacts(art_vec = art_vec, cat_moderator_matrix = cat_moderator_matrix,
#                 impute_method = "unwt_mean_full", art_type = art_type, n_vec = n_vec)
# impute_artifacts(art_vec = art_vec, cat_moderator_matrix = cat_moderator_matrix,
#                 impute_method = "unwt_mean_mod", art_type = art_type, n_vec = n_vec)
#
# ## Compute weighted means
# impute_artifacts(art_vec = art_vec, cat_moderator_matrix = cat_moderator_matrix,
#                 impute_method = "wt_mean_full", art_type = art_type, n_vec = n_vec)
# impute_artifacts(art_vec = art_vec, cat_moderator_matrix = cat_moderator_matrix,
#                 impute_method = "wt_mean_mod", art_type = art_type, n_vec = n_vec)
#
# ## Simulate from distribution with the mean and variance of the observed artifacts
# impute_artifacts(art_vec = art_vec, cat_moderator_matrix = cat_moderator_matrix,
#                 impute_method = "simulate_full", art_type = art_type, n_vec = n_vec)
# impute_artifacts(art_vec = art_vec, cat_moderator_matrix = cat_moderator_matrix,
#                 impute_method = "simulate_mod", art_type = art_type, n_vec = n_vec)
#
# ## Sample random values from the observed distribution of artifacts
# impute_artifacts(art_vec = art_vec, cat_moderator_matrix = cat_moderator_matrix,
#                 impute_method = "bootstrap_mod", art_type = art_type, n_vec = n_vec)
# impute_artifacts(art_vec = art_vec, cat_moderator_matrix = cat_moderator_matrix,
#                 impute_method = "bootstrap_full", art_type = art_type, n_vec = n_vec)
#
# ## If all values are missing from a moderator category, the program will run
# ## full-data imputation on the remaining missing values:
# impute_artifacts(art_vec = c(NA, NA, NA, .7, .8, .9), cat_moderator_matrix = cat_moderator_matrix,
#                 impute_method = "bootstrap_mod", art_type = art_type, n_vec = n_vec)

Run the code above in your browser using DataLab