R/facet.h.R

Defines functions facet

Documented in facet

# This file is automatically generated, you probably don't want to edit this

facetOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
    "facetOptions",
    inherit = jmvcore::Options,
    public = list(
        initialize = function(
            dep = NULL,
            id = NULL,
            facet = NULL,
            rm = FALSE,
            im = FALSE,
            inter = FALSE,
            raw = FALSE,
            sm = FALSE,
            ifit = FALSE,
            pm = FALSE,
            pfit = FALSE,
            plot1 = FALSE,
            width1 = 500,
            height1 = 500,
            plot2 = FALSE,
            width2 = 500,
            height2 = 500,
            plot3 = FALSE,
            width3 = 500,
            height3 = 500,
            angle = 0,
            plot4 = FALSE,
            width4 = 500,
            height4 = 500,
            plot5 = FALSE,
            num = 1,
            width5 = 500,
            height5 = 500,
            plot6 = FALSE,
            num1 = 1,
            width6 = 500,
            height6 = 500,
            plot7 = FALSE,
            width7 = 500,
            height7 = 500,
            angle1 = 0,
            plot8 = FALSE,
            width8 = 500,
            height8 = 500,
            g = FALSE,
            d = FALSE,
            formula = "value ~ (1 | subject) + (1 | task) + (1 | rater:task) + (1 | subject:task)",
            mea = FALSE,
            error = FALSE, ...) {

            super$initialize(
                package="snowIRT",
                name="facet",
                requiresData=TRUE,
                ...)

            private$..dep <- jmvcore::OptionVariable$new(
                "dep",
                dep,
                suggested=list(
                    "continuous"),
                permitted=list(
                    "numeric"))
            private$..id <- jmvcore::OptionVariable$new(
                "id",
                id,
                suggested=list(
                    "nominal"),
                permitted=list(
                    "factor"))
            private$..facet <- jmvcore::OptionVariables$new(
                "facet",
                facet,
                suggested=list(
                    "nominal"),
                permitted=list(
                    "factor"))
            private$..rm <- jmvcore::OptionBool$new(
                "rm",
                rm,
                default=FALSE)
            private$..im <- jmvcore::OptionBool$new(
                "im",
                im,
                default=FALSE)
            private$..inter <- jmvcore::OptionBool$new(
                "inter",
                inter,
                default=FALSE)
            private$..raw <- jmvcore::OptionBool$new(
                "raw",
                raw,
                default=FALSE)
            private$..sm <- jmvcore::OptionBool$new(
                "sm",
                sm,
                default=FALSE)
            private$..ifit <- jmvcore::OptionBool$new(
                "ifit",
                ifit,
                default=FALSE)
            private$..pm <- jmvcore::OptionBool$new(
                "pm",
                pm,
                default=FALSE)
            private$..pfit <- jmvcore::OptionBool$new(
                "pfit",
                pfit,
                default=FALSE)
            private$..plot1 <- jmvcore::OptionBool$new(
                "plot1",
                plot1,
                default=FALSE)
            private$..width1 <- jmvcore::OptionInteger$new(
                "width1",
                width1,
                default=500)
            private$..height1 <- jmvcore::OptionInteger$new(
                "height1",
                height1,
                default=500)
            private$..plot2 <- jmvcore::OptionBool$new(
                "plot2",
                plot2,
                default=FALSE)
            private$..width2 <- jmvcore::OptionInteger$new(
                "width2",
                width2,
                default=500)
            private$..height2 <- jmvcore::OptionInteger$new(
                "height2",
                height2,
                default=500)
            private$..plot3 <- jmvcore::OptionBool$new(
                "plot3",
                plot3,
                default=FALSE)
            private$..width3 <- jmvcore::OptionInteger$new(
                "width3",
                width3,
                default=500)
            private$..height3 <- jmvcore::OptionInteger$new(
                "height3",
                height3,
                default=500)
            private$..angle <- jmvcore::OptionNumber$new(
                "angle",
                angle,
                min=0,
                max=90,
                default=0)
            private$..plot4 <- jmvcore::OptionBool$new(
                "plot4",
                plot4,
                default=FALSE)
            private$..width4 <- jmvcore::OptionInteger$new(
                "width4",
                width4,
                default=500)
            private$..height4 <- jmvcore::OptionInteger$new(
                "height4",
                height4,
                default=500)
            private$..plot5 <- jmvcore::OptionBool$new(
                "plot5",
                plot5,
                default=FALSE)
            private$..num <- jmvcore::OptionInteger$new(
                "num",
                num,
                default=1,
                min=1)
            private$..width5 <- jmvcore::OptionInteger$new(
                "width5",
                width5,
                default=500)
            private$..height5 <- jmvcore::OptionInteger$new(
                "height5",
                height5,
                default=500)
            private$..plot6 <- jmvcore::OptionBool$new(
                "plot6",
                plot6,
                default=FALSE)
            private$..num1 <- jmvcore::OptionInteger$new(
                "num1",
                num1,
                default=1,
                min=1)
            private$..width6 <- jmvcore::OptionInteger$new(
                "width6",
                width6,
                default=500)
            private$..height6 <- jmvcore::OptionInteger$new(
                "height6",
                height6,
                default=500)
            private$..plot7 <- jmvcore::OptionBool$new(
                "plot7",
                plot7,
                default=FALSE)
            private$..width7 <- jmvcore::OptionInteger$new(
                "width7",
                width7,
                default=500)
            private$..height7 <- jmvcore::OptionInteger$new(
                "height7",
                height7,
                default=500)
            private$..angle1 <- jmvcore::OptionNumber$new(
                "angle1",
                angle1,
                min=0,
                max=90,
                default=0)
            private$..plot8 <- jmvcore::OptionBool$new(
                "plot8",
                plot8,
                default=FALSE)
            private$..width8 <- jmvcore::OptionInteger$new(
                "width8",
                width8,
                default=500)
            private$..height8 <- jmvcore::OptionInteger$new(
                "height8",
                height8,
                default=500)
            private$..g <- jmvcore::OptionBool$new(
                "g",
                g,
                default=FALSE)
            private$..d <- jmvcore::OptionBool$new(
                "d",
                d,
                default=FALSE)
            private$..formula <- jmvcore::OptionString$new(
                "formula",
                formula,
                default="value ~ (1 | subject) + (1 | task) + (1 | rater:task) + (1 | subject:task)")
            private$..mea <- jmvcore::OptionBool$new(
                "mea",
                mea,
                default=FALSE)
            private$..error <- jmvcore::OptionBool$new(
                "error",
                error,
                default=FALSE)

            self$.addOption(private$..dep)
            self$.addOption(private$..id)
            self$.addOption(private$..facet)
            self$.addOption(private$..rm)
            self$.addOption(private$..im)
            self$.addOption(private$..inter)
            self$.addOption(private$..raw)
            self$.addOption(private$..sm)
            self$.addOption(private$..ifit)
            self$.addOption(private$..pm)
            self$.addOption(private$..pfit)
            self$.addOption(private$..plot1)
            self$.addOption(private$..width1)
            self$.addOption(private$..height1)
            self$.addOption(private$..plot2)
            self$.addOption(private$..width2)
            self$.addOption(private$..height2)
            self$.addOption(private$..plot3)
            self$.addOption(private$..width3)
            self$.addOption(private$..height3)
            self$.addOption(private$..angle)
            self$.addOption(private$..plot4)
            self$.addOption(private$..width4)
            self$.addOption(private$..height4)
            self$.addOption(private$..plot5)
            self$.addOption(private$..num)
            self$.addOption(private$..width5)
            self$.addOption(private$..height5)
            self$.addOption(private$..plot6)
            self$.addOption(private$..num1)
            self$.addOption(private$..width6)
            self$.addOption(private$..height6)
            self$.addOption(private$..plot7)
            self$.addOption(private$..width7)
            self$.addOption(private$..height7)
            self$.addOption(private$..angle1)
            self$.addOption(private$..plot8)
            self$.addOption(private$..width8)
            self$.addOption(private$..height8)
            self$.addOption(private$..g)
            self$.addOption(private$..d)
            self$.addOption(private$..formula)
            self$.addOption(private$..mea)
            self$.addOption(private$..error)
        }),
    active = list(
        dep = function() private$..dep$value,
        id = function() private$..id$value,
        facet = function() private$..facet$value,
        rm = function() private$..rm$value,
        im = function() private$..im$value,
        inter = function() private$..inter$value,
        raw = function() private$..raw$value,
        sm = function() private$..sm$value,
        ifit = function() private$..ifit$value,
        pm = function() private$..pm$value,
        pfit = function() private$..pfit$value,
        plot1 = function() private$..plot1$value,
        width1 = function() private$..width1$value,
        height1 = function() private$..height1$value,
        plot2 = function() private$..plot2$value,
        width2 = function() private$..width2$value,
        height2 = function() private$..height2$value,
        plot3 = function() private$..plot3$value,
        width3 = function() private$..width3$value,
        height3 = function() private$..height3$value,
        angle = function() private$..angle$value,
        plot4 = function() private$..plot4$value,
        width4 = function() private$..width4$value,
        height4 = function() private$..height4$value,
        plot5 = function() private$..plot5$value,
        num = function() private$..num$value,
        width5 = function() private$..width5$value,
        height5 = function() private$..height5$value,
        plot6 = function() private$..plot6$value,
        num1 = function() private$..num1$value,
        width6 = function() private$..width6$value,
        height6 = function() private$..height6$value,
        plot7 = function() private$..plot7$value,
        width7 = function() private$..width7$value,
        height7 = function() private$..height7$value,
        angle1 = function() private$..angle1$value,
        plot8 = function() private$..plot8$value,
        width8 = function() private$..width8$value,
        height8 = function() private$..height8$value,
        g = function() private$..g$value,
        d = function() private$..d$value,
        formula = function() private$..formula$value,
        mea = function() private$..mea$value,
        error = function() private$..error$value),
    private = list(
        ..dep = NA,
        ..id = NA,
        ..facet = NA,
        ..rm = NA,
        ..im = NA,
        ..inter = NA,
        ..raw = NA,
        ..sm = NA,
        ..ifit = NA,
        ..pm = NA,
        ..pfit = NA,
        ..plot1 = NA,
        ..width1 = NA,
        ..height1 = NA,
        ..plot2 = NA,
        ..width2 = NA,
        ..height2 = NA,
        ..plot3 = NA,
        ..width3 = NA,
        ..height3 = NA,
        ..angle = NA,
        ..plot4 = NA,
        ..width4 = NA,
        ..height4 = NA,
        ..plot5 = NA,
        ..num = NA,
        ..width5 = NA,
        ..height5 = NA,
        ..plot6 = NA,
        ..num1 = NA,
        ..width6 = NA,
        ..height6 = NA,
        ..plot7 = NA,
        ..width7 = NA,
        ..height7 = NA,
        ..angle1 = NA,
        ..plot8 = NA,
        ..width8 = NA,
        ..height8 = NA,
        ..g = NA,
        ..d = NA,
        ..formula = NA,
        ..mea = NA,
        ..error = NA)
)

facetResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
    "facetResults",
    inherit = jmvcore::Group,
    active = list(
        instructions = function() private$.items[["instructions"]],
        text1 = function() private$.items[["text1"]],
        text = function() private$.items[["text"]],
        rm = function() private$.items[["rm"]],
        im = function() private$.items[["im"]],
        sm = function() private$.items[["sm"]],
        raw = function() private$.items[["raw"]],
        inter = function() private$.items[["inter"]],
        ifit = function() private$.items[["ifit"]],
        pm = function() private$.items[["pm"]],
        pfit = function() private$.items[["pfit"]],
        plot1 = function() private$.items[["plot1"]],
        plot2 = function() private$.items[["plot2"]],
        plot3 = function() private$.items[["plot3"]],
        plot7 = function() private$.items[["plot7"]],
        plot8 = function() private$.items[["plot8"]],
        plot4 = function() private$.items[["plot4"]],
        plot5 = function() private$.items[["plot5"]],
        plot6 = function() private$.items[["plot6"]],
        g = function() private$.items[["g"]],
        d = function() private$.items[["d"]],
        mea = function() private$.items[["mea"]],
        error = function() private$.items[["error"]]),
    private = list(),
    public=list(
        initialize=function(options) {
            super$initialize(
                options=options,
                name="",
                title="Many Facet Rasch Model",
                refs="snowIRT")
            self$add(jmvcore::Html$new(
                options=options,
                name="instructions",
                title="Instructions",
                visible=TRUE))
            self$add(jmvcore::Preformatted$new(
                options=options,
                name="text1",
                title=" "))
            self$add(jmvcore::Preformatted$new(
                options=options,
                name="text",
                title="WLE Reliability"))
            self$add(jmvcore::Table$new(
                options=options,
                name="rm",
                title="Rater measure",
                visible="(rm)",
                clearWith=list(
                    "dep",
                    "id",
                    "facet"),
                refs="TAM",
                columns=list(
                    list(
                        `name`="name", 
                        `title`="", 
                        `type`="text", 
                        `content`="($key)"),
                    list(
                        `name`="measure", 
                        `title`="Measure", 
                        `type`="number"),
                    list(
                        `name`="se", 
                        `title`="SE", 
                        `type`="number"))))
            self$add(jmvcore::Table$new(
                options=options,
                name="im",
                title="Task measure",
                visible="(im)",
                clearWith=list(
                    "dep",
                    "id",
                    "facet"),
                refs="TAM",
                columns=list(
                    list(
                        `name`="name", 
                        `title`="", 
                        `type`="text", 
                        `content`="($key)"),
                    list(
                        `name`="measure", 
                        `title`="Measure", 
                        `type`="number"),
                    list(
                        `name`="se", 
                        `title`="SE", 
                        `type`="number"))))
            self$add(jmvcore::Table$new(
                options=options,
                name="sm",
                title="Step measure",
                visible="(sm)",
                clearWith=list(
                    "dep",
                    "id",
                    "facet"),
                refs="TAM",
                columns=list(
                    list(
                        `name`="name", 
                        `title`="", 
                        `type`="text", 
                        `content`="($key)"),
                    list(
                        `name`="measure", 
                        `title`="Measure", 
                        `type`="number"),
                    list(
                        `name`="se", 
                        `title`="SE", 
                        `type`="number"))))
            self$add(jmvcore::Table$new(
                options=options,
                name="raw",
                title="Interaction: raw score",
                visible="(raw)",
                clearWith=list(
                    "dep",
                    "id",
                    "facet"),
                refs="TAM",
                columns=list(
                    list(
                        `name`="name", 
                        `title`="", 
                        `type`="text", 
                        `content`="($key)"),
                    list(
                        `name`="rater", 
                        `title`="Rater", 
                        `type`="text"),
                    list(
                        `name`="task", 
                        `title`="Task", 
                        `type`="text"),
                    list(
                        `name`="score", 
                        `title`="Score", 
                        `type`="number"))))
            self$add(jmvcore::Table$new(
                options=options,
                name="inter",
                title="Interaction: Measure",
                visible="(inter)",
                clearWith=list(
                    "dep",
                    "id",
                    "facet"),
                refs="TAM",
                columns=list(
                    list(
                        `name`="name", 
                        `title`="", 
                        `type`="text", 
                        `content`="($key)"),
                    list(
                        `name`="rater", 
                        `title`="Rater", 
                        `type`="text"),
                    list(
                        `name`="task", 
                        `title`="Task", 
                        `type`="text"),
                    list(
                        `name`="measure", 
                        `title`="Measure", 
                        `type`="number"),
                    list(
                        `name`="se", 
                        `title`="SE", 
                        `type`="number"))))
            self$add(jmvcore::Table$new(
                options=options,
                name="ifit",
                title="Interaction fit: Rater X Task",
                visible="(ifit)",
                clearWith=list(
                    "dep",
                    "id",
                    "facet"),
                refs="TAM",
                columns=list(
                    list(
                        `name`="name", 
                        `title`="", 
                        `type`="text", 
                        `content`="($key)"),
                    list(
                        `name`="rater", 
                        `title`="Rater", 
                        `type`="text"),
                    list(
                        `name`="task", 
                        `title`="Task", 
                        `type`="text"),
                    list(
                        `name`="outfit", 
                        `title`="Outfit", 
                        `type`="number"),
                    list(
                        `name`="infit", 
                        `title`="Infit", 
                        `type`="number"),
                    list(
                        `name`="marker", 
                        `title`="Diagnosis", 
                        `type`="text"))))
            self$add(jmvcore::Table$new(
                options=options,
                name="pm",
                title="Person measure",
                visible="(pm)",
                clearWith=list(
                    "dep",
                    "id",
                    "facet"),
                refs="TAM",
                columns=list(
                    list(
                        `name`="name", 
                        `title`="", 
                        `type`="text", 
                        `content`="($key)"),
                    list(
                        `name`="ps", 
                        `title`="Score", 
                        `type`="integer"),
                    list(
                        `name`="pt", 
                        `title`="Theta", 
                        `type`="number"),
                    list(
                        `name`="pe", 
                        `title`="SE", 
                        `type`="number"))))
            self$add(jmvcore::Table$new(
                options=options,
                name="pfit",
                title="Person fit",
                visible="(pfit)",
                clearWith=list(
                    "dep",
                    "id",
                    "facet"),
                refs="TAM",
                columns=list(
                    list(
                        `name`="name", 
                        `title`="", 
                        `type`="text", 
                        `content`="($key)"),
                    list(
                        `name`="outfit", 
                        `title`="Outfit", 
                        `type`="number"),
                    list(
                        `name`="infit", 
                        `title`="Infit", 
                        `format`="number"),
                    list(
                        `name`="marker", 
                        `title`="Diagnosis", 
                        `type`="text"))))
            self$add(jmvcore::Image$new(
                options=options,
                name="plot1",
                title="Rater plot",
                visible="(plot1)",
                renderFun=".plot1",
                refs="snowIRT",
                clearWith=list(
                    "dep",
                    "id",
                    "facet",
                    "width1",
                    "height1")))
            self$add(jmvcore::Image$new(
                options=options,
                name="plot2",
                title="Task plot",
                visible="(plot2)",
                renderFun=".plot2",
                refs="snowIRT",
                clearWith=list(
                    "dep",
                    "id",
                    "facet",
                    "width2",
                    "height2")))
            self$add(jmvcore::Image$new(
                options=options,
                name="plot3",
                title="Interaction: Rater X Task",
                visible="(plot3)",
                renderFun=".plot3",
                refs="snowIRT",
                clearWith=list(
                    "dep",
                    "id",
                    "facet",
                    "width3",
                    "height3",
                    "angle")))
            self$add(jmvcore::Image$new(
                options=options,
                name="plot7",
                title="Interaction Fit: Rater X Task",
                visible="(plot7)",
                renderFun=".plot7",
                refs="snowIRT",
                clearWith=list(
                    "dep",
                    "id",
                    "facet",
                    "width7",
                    "height7",
                    "angle1")))
            self$add(jmvcore::Image$new(
                options=options,
                name="plot8",
                title="Person Fit",
                visible="(plot8)",
                renderFun=".plot8",
                refs="snowIRT",
                clearWith=list(
                    "dep",
                    "id",
                    "facet",
                    "width8",
                    "height8")))
            self$add(jmvcore::Image$new(
                options=options,
                name="plot4",
                title="Wright Map",
                visible="(plot4)",
                renderFun=".plot4",
                refs="snowIRT",
                clearWith=list(
                    "dep",
                    "id",
                    "facet",
                    "width4",
                    "height4")))
            self$add(jmvcore::Image$new(
                options=options,
                name="plot5",
                title="Expected Scores Curve",
                visible="(plot5)",
                renderFun=".plot5",
                refs="snowIRT",
                clearWith=list(
                    "dep",
                    "id",
                    "facet",
                    "num",
                    "width5",
                    "height5")))
            self$add(jmvcore::Image$new(
                options=options,
                name="plot6",
                title="Item Response Curve",
                visible="(plot6)",
                renderFun=".plot6",
                refs="snowIRT",
                clearWith=list(
                    "dep",
                    "id",
                    "facet",
                    "num1",
                    "width6",
                    "height6")))
            self$add(jmvcore::Table$new(
                options=options,
                name="g",
                title="Variance components: G study",
                visible="(g)",
                clearWith=list(
                    "dep",
                    "id",
                    "facet"),
                refs="gtheory",
                columns=list(
                    list(
                        `name`="name", 
                        `title`="Source", 
                        `type`="text", 
                        `content`="($key)"),
                    list(
                        `name`="var", 
                        `title`="variance", 
                        `type`="number"),
                    list(
                        `name`="percent", 
                        `title`="Percent", 
                        `type`="number"),
                    list(
                        `name`="n", 
                        `title`="n", 
                        `type`="integer"))))
            self$add(jmvcore::Table$new(
                options=options,
                name="d",
                title="Variance components: D study",
                visible="(d)",
                clearWith=list(
                    "dep",
                    "id",
                    "facet"),
                refs="gtheory",
                columns=list(
                    list(
                        `name`="name", 
                        `title`="Source", 
                        `type`="text", 
                        `content`="($key)"),
                    list(
                        `name`="var", 
                        `title`="Variance", 
                        `type`="number"),
                    list(
                        `name`="percent", 
                        `title`="Percent", 
                        `type`="number"),
                    list(
                        `name`="n", 
                        `title`="n", 
                        `type`="integer"))))
            self$add(jmvcore::Table$new(
                options=options,
                name="mea",
                title="Coefficients",
                visible="(mea)",
                rows=1,
                clearWith=list(
                    "dep",
                    "id",
                    "facet"),
                refs="gtheory",
                columns=list(
                    list(
                        `name`="name", 
                        `title`="", 
                        `type`="text", 
                        `content`="D Study"),
                    list(
                        `name`="generalizability", 
                        `title`="Generalizability", 
                        `type`="number"),
                    list(
                        `name`="dependability", 
                        `title`="Dependability", 
                        `type`="number"),
                    list(
                        `name`="universe", 
                        `title`="Universe score variance", 
                        `type`="number"))))
            self$add(jmvcore::Table$new(
                options=options,
                name="error",
                title="Error variance",
                visible="(error)",
                rows=1,
                clearWith=list(
                    "dep",
                    "id",
                    "facet"),
                refs="gtheory",
                columns=list(
                    list(
                        `name`="name", 
                        `title`="", 
                        `type`="text", 
                        `content`="D Study"),
                    list(
                        `name`="relative", 
                        `title`="Relative", 
                        `type`="number"),
                    list(
                        `name`="absolute", 
                        `title`="Absolute", 
                        `type`="number"))))}))

facetBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
    "facetBase",
    inherit = jmvcore::Analysis,
    public = list(
        initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) {
            super$initialize(
                package = "snowIRT",
                name = "facet",
                version = c(1,0,0),
                options = options,
                results = facetResults$new(options=options),
                data = data,
                datasetId = datasetId,
                analysisId = analysisId,
                revision = revision,
                pause = NULL,
                completeWhenFilled = FALSE,
                requiresMissings = FALSE,
                weightsSupport = 'auto')
        }))

#' Many Facet Rasch Model
#'
#' 
#' @param data .
#' @param dep .
#' @param id .
#' @param facet .
#' @param rm .
#' @param im .
#' @param inter .
#' @param raw .
#' @param sm .
#' @param ifit .
#' @param pm .
#' @param pfit .
#' @param plot1 .
#' @param width1 .
#' @param height1 .
#' @param plot2 .
#' @param width2 .
#' @param height2 .
#' @param plot3 .
#' @param width3 .
#' @param height3 .
#' @param angle .
#' @param plot4 .
#' @param width4 .
#' @param height4 .
#' @param plot5 .
#' @param num .
#' @param width5 .
#' @param height5 .
#' @param plot6 .
#' @param num1 .
#' @param width6 .
#' @param height6 .
#' @param plot7 .
#' @param width7 .
#' @param height7 .
#' @param angle1 .
#' @param plot8 .
#' @param width8 .
#' @param height8 .
#' @param g .
#' @param d .
#' @param formula .
#' @param mea .
#' @param error .
#' @return A results object containing:
#' \tabular{llllll}{
#'   \code{results$instructions} \tab \tab \tab \tab \tab a html \cr
#'   \code{results$text1} \tab \tab \tab \tab \tab a preformatted \cr
#'   \code{results$text} \tab \tab \tab \tab \tab a preformatted \cr
#'   \code{results$rm} \tab \tab \tab \tab \tab a table \cr
#'   \code{results$im} \tab \tab \tab \tab \tab a table \cr
#'   \code{results$sm} \tab \tab \tab \tab \tab a table \cr
#'   \code{results$raw} \tab \tab \tab \tab \tab a table \cr
#'   \code{results$inter} \tab \tab \tab \tab \tab a table \cr
#'   \code{results$ifit} \tab \tab \tab \tab \tab a table \cr
#'   \code{results$pm} \tab \tab \tab \tab \tab a table \cr
#'   \code{results$pfit} \tab \tab \tab \tab \tab a table \cr
#'   \code{results$plot1} \tab \tab \tab \tab \tab an image \cr
#'   \code{results$plot2} \tab \tab \tab \tab \tab an image \cr
#'   \code{results$plot3} \tab \tab \tab \tab \tab an image \cr
#'   \code{results$plot7} \tab \tab \tab \tab \tab an image \cr
#'   \code{results$plot8} \tab \tab \tab \tab \tab an image \cr
#'   \code{results$plot4} \tab \tab \tab \tab \tab an image \cr
#'   \code{results$plot5} \tab \tab \tab \tab \tab an image \cr
#'   \code{results$plot6} \tab \tab \tab \tab \tab an image \cr
#'   \code{results$g} \tab \tab \tab \tab \tab a table \cr
#'   \code{results$d} \tab \tab \tab \tab \tab a table \cr
#'   \code{results$mea} \tab \tab \tab \tab \tab a table \cr
#'   \code{results$error} \tab \tab \tab \tab \tab a table \cr
#' }
#'
#' Tables can be converted to data frames with \code{asDF} or \code{\link{as.data.frame}}. For example:
#'
#' \code{results$rm$asDF}
#'
#' \code{as.data.frame(results$rm)}
#'
#' @export
facet <- function(
    data,
    dep,
    id,
    facet,
    rm = FALSE,
    im = FALSE,
    inter = FALSE,
    raw = FALSE,
    sm = FALSE,
    ifit = FALSE,
    pm = FALSE,
    pfit = FALSE,
    plot1 = FALSE,
    width1 = 500,
    height1 = 500,
    plot2 = FALSE,
    width2 = 500,
    height2 = 500,
    plot3 = FALSE,
    width3 = 500,
    height3 = 500,
    angle = 0,
    plot4 = FALSE,
    width4 = 500,
    height4 = 500,
    plot5 = FALSE,
    num = 1,
    width5 = 500,
    height5 = 500,
    plot6 = FALSE,
    num1 = 1,
    width6 = 500,
    height6 = 500,
    plot7 = FALSE,
    width7 = 500,
    height7 = 500,
    angle1 = 0,
    plot8 = FALSE,
    width8 = 500,
    height8 = 500,
    g = FALSE,
    d = FALSE,
    formula = "value ~ (1 | subject) + (1 | task) + (1 | rater:task) + (1 | subject:task)",
    mea = FALSE,
    error = FALSE) {

    if ( ! requireNamespace("jmvcore", quietly=TRUE))
        stop("facet requires jmvcore to be installed (restart may be required)")

    if ( ! missing(dep)) dep <- jmvcore::resolveQuo(jmvcore::enquo(dep))
    if ( ! missing(id)) id <- jmvcore::resolveQuo(jmvcore::enquo(id))
    if ( ! missing(facet)) facet <- jmvcore::resolveQuo(jmvcore::enquo(facet))
    if (missing(data))
        data <- jmvcore::marshalData(
            parent.frame(),
            `if`( ! missing(dep), dep, NULL),
            `if`( ! missing(id), id, NULL),
            `if`( ! missing(facet), facet, NULL))

    for (v in id) if (v %in% names(data)) data[[v]] <- as.factor(data[[v]])
    for (v in facet) if (v %in% names(data)) data[[v]] <- as.factor(data[[v]])

    options <- facetOptions$new(
        dep = dep,
        id = id,
        facet = facet,
        rm = rm,
        im = im,
        inter = inter,
        raw = raw,
        sm = sm,
        ifit = ifit,
        pm = pm,
        pfit = pfit,
        plot1 = plot1,
        width1 = width1,
        height1 = height1,
        plot2 = plot2,
        width2 = width2,
        height2 = height2,
        plot3 = plot3,
        width3 = width3,
        height3 = height3,
        angle = angle,
        plot4 = plot4,
        width4 = width4,
        height4 = height4,
        plot5 = plot5,
        num = num,
        width5 = width5,
        height5 = height5,
        plot6 = plot6,
        num1 = num1,
        width6 = width6,
        height6 = height6,
        plot7 = plot7,
        width7 = width7,
        height7 = height7,
        angle1 = angle1,
        plot8 = plot8,
        width8 = width8,
        height8 = height8,
        g = g,
        d = d,
        formula = formula,
        mea = mea,
        error = error)

    analysis <- facetClass$new(
        options = options,
        data = data)

    analysis$run()

    analysis$results
}
hyunsooseol/snowIRT documentation built on March 20, 2024, 8 p.m.