createMAICInput: Construct a MAIC input matrix

View source: R/maic.R

createMAICInputR Documentation

Construct a MAIC input matrix

Description

From index patient level data and a set of target baseline characteristics, construct the input matrix to the maic.

Usage

createMAICInput(index, target, dictionary, matching.variables, x = FALSE)

Arguments

index

A matrix or data.frame containing patient-level data

target

A list containing target summary data

dictionary

A data frame containing the columns "match.id", "target.variable", "index.variable" and "match.type"

matching.variables

A character vector indicating the match.id to use

x

Return subject level inputs?

Details

The dictionary is a data frame containing at least 4 vectors:

  • "match.id" - the name of the match, used to refer to it in the matching.variables list

  • "target.variable" - the name of the variable in the target values list use to inform the matching. Use dependent on type

  • "index.variable" - the name of the variable in the index data frame to match on.

  • "match.type" - A string indicating the match type to use. The following values are accepted:

    • minimum - records with index values lower than the target variable will be assigned 0 weight

    • maximum - records with index values greater than the target variable will be assigned 0 weight

    • median - records with index values greater than the target variable will be assigned a value of 1, those lower 0. The target for matching will be a mean of 0.5

    • quantile.X - Generalisation of the median code. records with index values greater than the target variable will be assigned a value of 1, those lower 0. The target for matching will be a mean of 0.X

    • mean - records will match index value directly onto target value

    • proportion - as mean, with index values encoded as 1 = true, 0 = false. If target proportion is exclusive (0 or 1 exactly) then excluded members of the index population shall receive no weighting.

    • sd - a matching on the square of the index value on the sum of the square of the target mean and target standard deviation. The target mean is provided by the "supplementary.target.variable"

    • var - a matching on the square of the index value on the sum of the square of the target mean and the variance specified by the target variable. The target mean is provided by the "supplementary.target.variable"

In addition, the following vector may be necessary:

  • "supplementary.target.variable" - The name of the variable in the target values list that provides e.g. the mean for sd and var matching.

and, for estimating some p-values on difference (e.g. in proportion)

  • "sample.size.variable" - The name of the variable in the target values list that provides the number of subjects in the sample. Only for reporting.

It is possible to use these match types to match on other variables by pre-processing the input correctly.

Finally, the matching.variables is a list or character vector containing match.ids to be acted upon in this MAIC.

Value

An object of class maic.input

Examples

target <- c("Air.Flow" = 60,
           "Water.Temp" = 21,
           "Prop.Acid.Conc.LT.90" = 0.7,
           "min.air.flow" = 55)

stackloss$match.conc.lt.90 <- 
  ifelse(stackloss$Acid.Conc. < 90, 1, 0)

dict <- data.frame(
  "match.id" = 
    c("airflow", "watertemp", 
      "acidconc", "min.airflow"),
  "target.variable" = 
    c("Air.Flow", "Water.Temp",
      "Prop.Acid.Conc.LT.90", "min.air.flow"),
  "index.variable" = 
    c("Air.Flow", "Water.Temp",
      "match.conc.lt.90", "Air.Flow"),
  "match.type" = 
    c("mean", "mean", "proportion", "min"),
  stringsAsFactors = FALSE)

ipmat <- createMAICInput(
  index = stackloss,
  target = target,
  dictionary = dict,
  matching.variables = 
    c("airflow", "watertemp", 
      "acidconc", "min.airflow"))

wts <- maicWeight(ipmat)

rcv <- reportCovariates(
  stackloss, target, dict, 
  matching.variables = 
    c("airflow", "watertemp", 
      "acidconc", "min.airflow"),
  wts)

maic documentation built on April 27, 2022, 5:07 p.m.