Nothing
# This file is automatically generated, you probably don't want to edit this
anovaRMNPOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"anovaRMNPOptions",
inherit = jmvcore::Options,
public = list(
initialize = function(
measures = NULL,
pairs = FALSE,
desc = FALSE,
plots = FALSE,
plotType = "means", ...) {
super$initialize(
package="jmv",
name="anovaRMNP",
requiresData=TRUE,
...)
private$..measures <- jmvcore::OptionVariables$new(
"measures",
measures,
suggested=list(
"continuous"),
permitted=list(
"numeric"))
private$..pairs <- jmvcore::OptionBool$new(
"pairs",
pairs,
default=FALSE)
private$..desc <- jmvcore::OptionBool$new(
"desc",
desc,
default=FALSE)
private$..plots <- jmvcore::OptionBool$new(
"plots",
plots,
default=FALSE)
private$..plotType <- jmvcore::OptionList$new(
"plotType",
plotType,
options=list(
"means",
"medians"),
default="means")
self$.addOption(private$..measures)
self$.addOption(private$..pairs)
self$.addOption(private$..desc)
self$.addOption(private$..plots)
self$.addOption(private$..plotType)
}),
active = list(
measures = function() private$..measures$value,
pairs = function() private$..pairs$value,
desc = function() private$..desc$value,
plots = function() private$..plots$value,
plotType = function() private$..plotType$value),
private = list(
..measures = NA,
..pairs = NA,
..desc = NA,
..plots = NA,
..plotType = NA)
)
anovaRMNPResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"anovaRMNPResults",
inherit = jmvcore::Group,
active = list(
table = function() private$.items[["table"]],
comp = function() private$.items[["comp"]],
desc = function() private$.items[["desc"]],
plot = function() private$.items[["plot"]]),
private = list(),
public=list(
initialize=function(options) {
super$initialize(
options=options,
name="",
title="Repeated Measures ANOVA (Non-parametric)")
self$add(jmvcore::Table$new(
options=options,
name="table",
title="Friedman",
rows=1,
clearWith=list(
"measures"),
columns=list(
list(
`name`="stat",
`title`="\u03C7\u00B2",
`type`="number"),
list(
`name`="df",
`title`="df",
`type`="integer"),
list(
`name`="p",
`title`="p",
`type`="number",
`format`="zto,pvalue"))))
self$add(jmvcore::Table$new(
options=options,
name="comp",
title="Pairwise Comparisons (Durbin-Conover)",
refs="PMCMR",
visible="(pairs)",
clearWith=list(
"measures"),
columns=list(
list(
`name`="i1",
`title`="",
`type`="text"),
list(
`name`="sep",
`title`="",
`content`="-",
`type`="text",
`format`="narrow"),
list(
`name`="i2",
`title`="",
`type`="text"),
list(
`name`="stat",
`title`="Statistic",
`type`="number"),
list(
`name`="p",
`title`="p",
`type`="number",
`format`="zto,pvalue"))))
self$add(jmvcore::Table$new(
options=options,
name="desc",
title="Descriptives",
visible="(desc)",
clearWith=list(
"measures"),
columns=list(
list(
`name`="level",
`title`="",
`type`="text"),
list(
`name`="mean",
`title`="Mean",
`type`="number"),
list(
`name`="median",
`title`="Median",
`type`="number"))))
self$add(jmvcore::Image$new(
options=options,
name="plot",
title="Descriptive Plot",
visible="(plots)",
renderFun=".plot",
clearWith=list(
"plotType",
"measures")))}))
anovaRMNPBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"anovaRMNPBase",
inherit = jmvcore::Analysis,
public = list(
initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) {
super$initialize(
package = "jmv",
name = "anovaRMNP",
version = c(1,0,0),
options = options,
results = anovaRMNPResults$new(options=options),
data = data,
datasetId = datasetId,
analysisId = analysisId,
revision = revision,
pause = NULL,
completeWhenFilled = TRUE,
requiresMissings = FALSE,
weightsSupport = 'auto')
}))
#' Repeated Measures ANOVA (Non-parametric)
#'
#' The Friedman test is used to explore the relationship between a continuous
#' dependent variable and a categorical explanatory variable, where the
#' explanatory variable is 'within subjects' (where multiple measurements are
#' from the same subject). It is analagous to Repeated Measures ANOVA, but
#' with the advantage of being non-parametric, and not requiring the
#' assumptions of normality or homogeneity of variances. However, it has the
#' limitation that it can only test a single explanatory variable at a time.
#'
#'
#' @examples
#' data('bugs', package = 'jmv')
#'
#' anovaRMNP(bugs, measures = vars(LDLF, LDHF, HDLF, HDHF))
#'
#' #
#' # REPEATED MEASURES ANOVA (NON-PARAMETRIC)
#' #
#' # Friedman
#' # ------------------------
#' # X² df p
#' # ------------------------
#' # 55.8 3 < .001
#' # ------------------------
#' #
#'
#' @param data the data as a data frame
#' @param measures a vector of strings naming the repeated measures variables
#' @param pairs \code{TRUE} or \code{FALSE} (default), perform pairwise
#' comparisons
#' @param desc \code{TRUE} or \code{FALSE} (default), provide descriptive
#' statistics
#' @param plots \code{TRUE} or \code{FALSE} (default), provide a descriptive
#' plot
#' @param plotType \code{'means'} (default) or \code{'medians'}, the error
#' bars to use in the plot
#' @return A results object containing:
#' \tabular{llllll}{
#' \code{results$table} \tab \tab \tab \tab \tab a table of the Friedman test results \cr
#' \code{results$comp} \tab \tab \tab \tab \tab a table of the pairwise comparisons \cr
#' \code{results$desc} \tab \tab \tab \tab \tab a table containing the descriptives \cr
#' \code{results$plot} \tab \tab \tab \tab \tab a descriptives plot \cr
#' }
#'
#' Tables can be converted to data frames with \code{asDF} or \code{\link{as.data.frame}}. For example:
#'
#' \code{results$table$asDF}
#'
#' \code{as.data.frame(results$table)}
#'
#' @export
anovaRMNP <- function(
data,
measures,
pairs = FALSE,
desc = FALSE,
plots = FALSE,
plotType = "means") {
if ( ! requireNamespace("jmvcore", quietly=TRUE))
stop("anovaRMNP requires jmvcore to be installed (restart may be required)")
if ( ! missing(measures)) measures <- jmvcore::resolveQuo(jmvcore::enquo(measures))
if (missing(data))
data <- jmvcore::marshalData(
parent.frame(),
`if`( ! missing(measures), measures, NULL))
options <- anovaRMNPOptions$new(
measures = measures,
pairs = pairs,
desc = desc,
plots = plots,
plotType = plotType)
analysis <- anovaRMNPClass$new(
options = options,
data = data)
analysis$run()
analysis$results
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.