knitr::opts_chunk$set(echo = FALSE)
knitr::opts_chunk$set(options(knitr.kable.NA = ''))

title: "r report.title" date: "r format(Sys.Date(), '%B %d, %Y')"


Summary

if(dataset.name != "dataset"){
  cat("**Dataset:**", dataset.name)
  cat("\n\n")
}

Measure: r if(measure.name == "measure") outputs$item.name.range else paste0(measure.name, " (", outputs$item.name.range, ")")

Comparison groups: r if(length(outputs$dif.groups) == 2) paste(outputs$dif.groups, collapse = " and ") else paste(outputs$dif.groups, collapse = ", ")

Items with no variance: r outputs$no.var.items

Items with no variance within comparison groups: r outputs$no.var.by.group.items

DIF detection method: r if(biased.items == "IRT") biased.items else paste(biased.items, "using", match.type, "Scores")

Total number of biased items: r paste(n.biased, "out of", outputs$n.items)

Type of DIF: r dif.type

if(dif.type == "uniform"){
  if(n.biased > 0){

  cat("*Number of items uniformly biased toward each group*")
  cat("\n\n")
  toward.flex <- format_flex(toward)
  cat(knitr::knit_print(toward.flex))
  cat("\n\n")
  }
}
if(outputs$no.var.items != "none"){

  cat("\n\n")
  cat("^a^ Items were not included in any DIF analysis and were not used to compute 
      treatment effects.")
  cat("\n\n")
}


if(outputs$no.var.by.group.items != "none"){

  cat("\n\n")
  cat("^b^ Items were not included in the IRT-based DIF analysis and were not used 
      to compute IRT-based treatment effects.")
  cat("\n\n")
}

DIF Detection Methods

Note. Logical values in bias columns are based on p-values adjusted with the Benjamini & Hochberg (1995) method rather than directly on the p-value columns.

Biased Item Summary

if(nrow(biased.items.table) != 0){
    bi.flex <- format_flex(biased.items.table)
    cat(knitr::knit_print(bi.flex))
    cat("\n\n")
    cat("&nbsp;  ")
    cat("*Note:* X = method determined item to be biased")
    cat("\n\n")
} else {
    cat("Item bias was not detected by any of the selected methods")
    cat("\n\n")
}
if(!is.null(dif.analysis$MH)){

  cat("## Mantel-Haenszel")
  cat("\n\n")

  if(class(dif.analysis$MH$item.level) == "character"){

    cat(dif.analysis$MH$item.level)
    cat("\n\n")

  } else {

    MHtab <- format_flex(dif.analysis$MH$item.level, bold.bias = "item")
    cat(knitr::knit_print(MHtab))
    cat("\n\n")
  }
}
if(!is.null(dif.analysis$logistic)){

  cat("## Logistic Regression")
  cat("\n\n")

  cat("#### Model Comparisons")
  cat("\n\n")

  logglobtab <- format_flex(dif.analysis$logistic$global.level, bold.bias = "global")
  cat(knitr::knit_print(logglobtab))
  cat("\n\n")

  cat("&nbsp;  ")
  cat("\n\n")
  cat("#### Item-level Tests")
  cat("\n\n")

  if(class(dif.analysis$logistic$item.level) == "character"){

    cat(dif.analysis$logistic$item.level)
    cat("\n\n")

  } else {

    logitemtab <- format_flex(dif.analysis$logistic$item.level, bold.bias = "item")
    cat(knitr::knit_print(logitemtab))
    cat("\n\n")
  }

}
if(!is.null(dif.analysis$IRT)){

  cat("## Item Response Theory")
  cat("\n\n")

  cat("#### Model Comparisons")
  cat("\n\n")

  irtglobtab <- format_flex(dif.analysis$IRT$global.level, bold.bias = "global")
  cat(knitr::knit_print(irtglobtab))
  cat("\n\n")

  cat("&nbsp;  ")
  cat("\n\n")
  cat("#### Item-level Tests")
  cat("\n\n")

  if(class(dif.analysis$IRT$item.level) == "character"){

    cat(dif.analysis$IRT$item.level)
    cat("\n\n")

  } else {

    irtitemtab <- format_flex(dif.analysis$IRT$item.level, bold.bias = "item")
    cat(knitr::knit_print(irtitemtab))
    cat("\n\n")
  }
}
if(!is.null(dif.analysis$loess)){
  cat("## Graphical Analysis via loess")
  cat("\n\n")
  print(dif.analysis$loess$plot)
  cat("\n\n")
  cat("*Note.* Polytomous items are unit scaled when calculating the total or rest score. Thus, the maximum score is equal to the number of items.")
  cat("\n\n")
}


knickodem/WBdif documentation built on Feb. 3, 2024, 2:20 a.m.