if (FALSE) {
# borrow some data from the BIFIEsurvey package
data(data.timss1)
varGroups <- list(ID = "IDSTUD", wgt = c("TOTWGT","JKZONE"),
covars = c("female", "books", "lang", "migant"), depVar = "ASMMAT")
# error if one variable does not occur in data due to typo
varList <- lapply(varGroups, FUN = function (v) {
existsBackgroundVariables (dat=data.timss1[[1]], variable=v)
})
# correction
varGroups <- list(ID = "IDSTUD", wgt = c("TOTWGT","JKZONE"),
covars = c("female", "books", "lang", "migrant"), depVar = "ASMMAT")
varList <- lapply(varGroups, FUN = function (v) {
existsBackgroundVariables (dat=data.timss1[[1]], variable=v)
})
# however, only one weighting variable is allowed
check <- checkBackgroundVariables (varList, len1 = c("ID", "wgt", "depVar"),
overlap = NULL)
# only one of the covariates should be used for group differences
# difference variable must be included in covars
varGroups <- list(ID = "IDSTUD", wgt = "TOTWGT", covars = c("female", "books", "lang"),
differencesFor = "migrant", depVar = "ASMMAT")
varList <- lapply(varGroups, FUN = function (v) {
existsBackgroundVariables (dat=data.timss1[[1]], variable=v)
})
check <- checkBackgroundVariables (varList, len1 = c("ID", "wgt", "depVar"),
overlap = list(v1 = list(vars = c("covars","differencesFor"), len = 1)))
}Run the code above in your browser using DataLab