# This file is automatically generated, you probably don't want to edit this
difOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"difOptions",
inherit = jmvcore::Options,
public = list(
initialize = function(
vars = NULL,
group = NULL,
raju = FALSE,
mh = FALSE,
padjust = "BH",
padjust1 = "BH",
zplot = FALSE,
plot3 = FALSE,
plot1 = FALSE,
gmh = FALSE,
fn = "2,3,4",
plot2 = FALSE,
padjust2 = "BH",
width1 = 500,
height1 = 500,
width2 = 500,
height2 = 500,
width3 = 500,
height3 = 500,
width4 = 500,
height4 = 500,
num = 1, ...) {
super$initialize(
package="snowIRT",
name="dif",
requiresData=TRUE,
...)
private$..vars <- jmvcore::OptionVariables$new(
"vars",
vars,
suggested=list(
"continuous"),
permitted=list(
"numeric"))
private$..group <- jmvcore::OptionVariable$new(
"group",
group,
suggested=list(
"nominal"),
permitted=list(
"factor",
"numeric"))
private$..raju <- jmvcore::OptionBool$new(
"raju",
raju,
default=FALSE)
private$..mh <- jmvcore::OptionBool$new(
"mh",
mh,
default=FALSE)
private$..padjust <- jmvcore::OptionList$new(
"padjust",
padjust,
options=list(
"none",
"holm",
"hochberg",
"hommel",
"bonferroni",
"BH",
"BY",
"fdr"),
default="BH")
private$..padjust1 <- jmvcore::OptionList$new(
"padjust1",
padjust1,
options=list(
"none",
"holm",
"hochberg",
"hommel",
"bonferroni",
"BH",
"BY",
"fdr"),
default="BH")
private$..zplot <- jmvcore::OptionBool$new(
"zplot",
zplot,
default=FALSE)
private$..plot3 <- jmvcore::OptionBool$new(
"plot3",
plot3,
default=FALSE)
private$..plot1 <- jmvcore::OptionBool$new(
"plot1",
plot1,
default=FALSE)
private$..gmh <- jmvcore::OptionBool$new(
"gmh",
gmh,
default=FALSE)
private$..fn <- jmvcore::OptionString$new(
"fn",
fn,
default="2,3,4")
private$..plot2 <- jmvcore::OptionBool$new(
"plot2",
plot2,
default=FALSE)
private$..padjust2 <- jmvcore::OptionList$new(
"padjust2",
padjust2,
options=list(
"none",
"holm",
"hochberg",
"hommel",
"bonferroni",
"BH",
"BY",
"fdr"),
default="BH")
private$..width1 <- jmvcore::OptionInteger$new(
"width1",
width1,
default=500)
private$..height1 <- jmvcore::OptionInteger$new(
"height1",
height1,
default=500)
private$..width2 <- jmvcore::OptionInteger$new(
"width2",
width2,
default=500)
private$..height2 <- jmvcore::OptionInteger$new(
"height2",
height2,
default=500)
private$..width3 <- jmvcore::OptionInteger$new(
"width3",
width3,
default=500)
private$..height3 <- jmvcore::OptionInteger$new(
"height3",
height3,
default=500)
private$..width4 <- jmvcore::OptionInteger$new(
"width4",
width4,
default=500)
private$..height4 <- jmvcore::OptionInteger$new(
"height4",
height4,
default=500)
private$..num <- jmvcore::OptionInteger$new(
"num",
num,
default=1,
min=1)
self$.addOption(private$..vars)
self$.addOption(private$..group)
self$.addOption(private$..raju)
self$.addOption(private$..mh)
self$.addOption(private$..padjust)
self$.addOption(private$..padjust1)
self$.addOption(private$..zplot)
self$.addOption(private$..plot3)
self$.addOption(private$..plot1)
self$.addOption(private$..gmh)
self$.addOption(private$..fn)
self$.addOption(private$..plot2)
self$.addOption(private$..padjust2)
self$.addOption(private$..width1)
self$.addOption(private$..height1)
self$.addOption(private$..width2)
self$.addOption(private$..height2)
self$.addOption(private$..width3)
self$.addOption(private$..height3)
self$.addOption(private$..width4)
self$.addOption(private$..height4)
self$.addOption(private$..num)
}),
active = list(
vars = function() private$..vars$value,
group = function() private$..group$value,
raju = function() private$..raju$value,
mh = function() private$..mh$value,
padjust = function() private$..padjust$value,
padjust1 = function() private$..padjust1$value,
zplot = function() private$..zplot$value,
plot3 = function() private$..plot3$value,
plot1 = function() private$..plot1$value,
gmh = function() private$..gmh$value,
fn = function() private$..fn$value,
plot2 = function() private$..plot2$value,
padjust2 = function() private$..padjust2$value,
width1 = function() private$..width1$value,
height1 = function() private$..height1$value,
width2 = function() private$..width2$value,
height2 = function() private$..height2$value,
width3 = function() private$..width3$value,
height3 = function() private$..height3$value,
width4 = function() private$..width4$value,
height4 = function() private$..height4$value,
num = function() private$..num$value),
private = list(
..vars = NA,
..group = NA,
..raju = NA,
..mh = NA,
..padjust = NA,
..padjust1 = NA,
..zplot = NA,
..plot3 = NA,
..plot1 = NA,
..gmh = NA,
..fn = NA,
..plot2 = NA,
..padjust2 = NA,
..width1 = NA,
..height1 = NA,
..width2 = NA,
..height2 = NA,
..width3 = NA,
..height3 = NA,
..width4 = NA,
..height4 = NA,
..num = NA)
)
difResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"difResults",
inherit = jmvcore::Group,
active = list(
instructions = function() private$.items[["instructions"]],
text = function() private$.items[["text"]],
raju = function() private$.items[["raju"]],
mh = function() private$.items[["mh"]],
zplot = function() private$.items[["zplot"]],
plot1 = function() private$.items[["plot1"]],
gmh = function() private$.items[["gmh"]],
plot2 = function() private$.items[["plot2"]],
plot3 = function() private$.items[["plot3"]]),
private = list(),
public=list(
initialize=function(options) {
super$initialize(
options=options,
name="",
title="Raju & Mantel-Haenszel method",
refs="snowIRT")
self$add(jmvcore::Html$new(
options=options,
name="instructions",
title="Instructions",
visible=TRUE))
self$add(jmvcore::Preformatted$new(
options=options,
name="text",
title=""))
self$add(jmvcore::Table$new(
options=options,
name="raju",
title="`Raju\u2019s area method - ${padjust}`",
visible="(raju)",
rows="(vars)",
clearWith=list(
"vars",
"group",
"padjust"),
refs="difR",
columns=list(
list(
`name`="name",
`title`="",
`type`="text",
`content`="($key)"),
list(
`name`="zstat",
`title`="Statistic"),
list(
`name`="p",
`title`="p",
`format`="zto,pvalue"),
list(
`name`="padjust",
`title`="Adj.p",
`format`="zto,pvalue"),
list(
`name`="delta",
`title`="deltaRaju"),
list(
`name`="es",
`title`="Effect size",
`type`="text"))))
self$add(jmvcore::Table$new(
options=options,
name="mh",
title="` Mantel-Haenszel method - ${padjust1}`",
visible="(mh)",
rows="(vars)",
clearWith=list(
"vars",
"group",
"padjust1"),
refs="difR",
columns=list(
list(
`name`="name",
`title`="",
`type`="text",
`content`="($key)"),
list(
`name`="mhstat",
`title`="MH Chi-square"),
list(
`name`="p",
`title`="p",
`format`="zto,pvalue"),
list(
`name`="padjust",
`title`="Adj.p",
`format`="zto,pvalue"))))
self$add(jmvcore::Image$new(
options=options,
name="zplot",
title="Z statistic plot",
renderFun=".plot",
visible="(zplot)",
refs="difR",
clearWith=list(
"vars",
"group",
"padjust",
"width1",
"height1")))
self$add(jmvcore::Image$new(
options=options,
name="plot1",
title="Mantel-Haenszel plot",
renderFun=".plot1",
visible="(plot1)",
refs="difR",
clearWith=list(
"vars",
"group",
"padjust1",
"width3",
"height3")))
self$add(jmvcore::Table$new(
options=options,
name="gmh",
title="` Generalized Mantel-Haenszel method - ${padjust2}`",
visible="(gmh)",
rows="(vars)",
clearWith=list(
"vars",
"group",
"padjust2"),
refs="difR",
columns=list(
list(
`name`="name",
`title`="",
`type`="text",
`content`="($key)"),
list(
`name`="gmhstat",
`title`="MH Chi-square"),
list(
`name`="p",
`title`="p",
`format`="zto,pvalue"),
list(
`name`="padjust",
`title`="Adj.p",
`format`="zto,pvalue"))))
self$add(jmvcore::Image$new(
options=options,
name="plot2",
title="Generalized Mantel-Haenszel plot",
renderFun=".plot2",
visible="(plot2)",
refs="difR",
clearWith=list(
"vars",
"group",
"padjust2",
"width4",
"height4")))
self$add(jmvcore::Image$new(
options=options,
name="plot3",
title="Item Characteristic Curve plot for DIF",
renderFun=".plot3",
visible="(plot3)",
refs="difR",
clearWith=list(
"vars",
"group",
"padjust",
"width2",
"height2",
"num")))}))
difBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"difBase",
inherit = jmvcore::Analysis,
public = list(
initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) {
super$initialize(
package = "snowIRT",
name = "dif",
version = c(1,0,0),
options = options,
results = difResults$new(options=options),
data = data,
datasetId = datasetId,
analysisId = analysisId,
revision = revision,
pause = NULL,
completeWhenFilled = FALSE,
requiresMissings = FALSE,
weightsSupport = 'auto')
}))
#' Raju & Mantel-Haenszel method
#'
#'
#' @param data The data as a data frame.
#' @param vars .
#' @param group A string naming the grouping variable from \code{data}
#' @param raju .
#' @param mh .
#' @param padjust .
#' @param padjust1 .
#' @param zplot .
#' @param plot3 .
#' @param plot1 .
#' @param gmh .
#' @param fn .
#' @param plot2 .
#' @param padjust2 .
#' @param width1 .
#' @param height1 .
#' @param width2 .
#' @param height2 .
#' @param width3 .
#' @param height3 .
#' @param width4 .
#' @param height4 .
#' @param num .
#' @return A results object containing:
#' \tabular{llllll}{
#' \code{results$instructions} \tab \tab \tab \tab \tab a html \cr
#' \code{results$text} \tab \tab \tab \tab \tab a preformatted \cr
#' \code{results$raju} \tab \tab \tab \tab \tab a table \cr
#' \code{results$mh} \tab \tab \tab \tab \tab a table \cr
#' \code{results$zplot} \tab \tab \tab \tab \tab an image \cr
#' \code{results$plot1} \tab \tab \tab \tab \tab an image \cr
#' \code{results$gmh} \tab \tab \tab \tab \tab a table \cr
#' \code{results$plot2} \tab \tab \tab \tab \tab an image \cr
#' \code{results$plot3} \tab \tab \tab \tab \tab an image \cr
#' }
#'
#' Tables can be converted to data frames with \code{asDF} or \code{\link{as.data.frame}}. For example:
#'
#' \code{results$raju$asDF}
#'
#' \code{as.data.frame(results$raju)}
#'
#' @export
dif <- function(
data,
vars,
group,
raju = FALSE,
mh = FALSE,
padjust = "BH",
padjust1 = "BH",
zplot = FALSE,
plot3 = FALSE,
plot1 = FALSE,
gmh = FALSE,
fn = "2,3,4",
plot2 = FALSE,
padjust2 = "BH",
width1 = 500,
height1 = 500,
width2 = 500,
height2 = 500,
width3 = 500,
height3 = 500,
width4 = 500,
height4 = 500,
num = 1) {
if ( ! requireNamespace("jmvcore", quietly=TRUE))
stop("dif requires jmvcore to be installed (restart may be required)")
if ( ! missing(vars)) vars <- jmvcore::resolveQuo(jmvcore::enquo(vars))
if ( ! missing(group)) group <- jmvcore::resolveQuo(jmvcore::enquo(group))
if (missing(data))
data <- jmvcore::marshalData(
parent.frame(),
`if`( ! missing(vars), vars, NULL),
`if`( ! missing(group), group, NULL))
options <- difOptions$new(
vars = vars,
group = group,
raju = raju,
mh = mh,
padjust = padjust,
padjust1 = padjust1,
zplot = zplot,
plot3 = plot3,
plot1 = plot1,
gmh = gmh,
fn = fn,
plot2 = plot2,
padjust2 = padjust2,
width1 = width1,
height1 = height1,
width2 = width2,
height2 = height2,
width3 = width3,
height3 = height3,
width4 = width4,
height4 = height4,
num = num)
analysis <- difClass$new(
options = options,
data = data)
analysis$run()
analysis$results
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.