sign_test: Sign Test

View source: R/sign_test.R

sign_testR Documentation

Sign Test

Description

Perform a sign test for a paired sample on variables of a data set. The output is printed as a LaTeX table that mimics the look of SPSS output.

Usage

sign_test(data, variables, exact = FALSE)

## S3 method for class 'sign_test_SPSS'
to_SPSS(
  object,
  statistics = c("test", "frequencies"),
  version = r2spss_options$get("version"),
  ...
)

## S3 method for class 'sign_test_SPSS'
print(
  x,
  statistics = c("frequencies", "test"),
  version = r2spss_options$get("version"),
  ...
)

signTest(data, variables, exact = FALSE)

Arguments

data

a data frame containing the variables.

variables

a character vector specifying two numeric variables containing the paired observations.

exact

a logical indicating whether or not to include the exact p-value using the binomial distribution. Note that the p-value using the normal approximation is always reported.

object, x

an object of class "sign_test_SPSS" as returned by function sign_test.

statistics

a character string or vector specifying which SPSS tables to produce. Available options are "frequencies" for a summary of the frequencies and "test" for test results. For the to_SPSS method, only one option is allowed (the default is the table of test results), but the print method allows several options (the default is to print all tables).

version

a character string specifying whether the table should mimic the content and look of recent SPSS versions ("modern") or older versions (<24; "legacy"). The main difference in terms of content is that small p-values are displayed differently.

...

additional arguments to be passed down to format_SPSS.

Details

The print method first calls the to_SPSS method followed by to_latex. Further customization can be done by calling those two functions separately, and modifying the object returned by to_SPSS.

Value

An object of class "sign_test_SPSS" with the following components:

statistics

a data frame containing information on the number of observations with negative and positive differences.

asymptotic

a list containing the results of the test using the normal approximation.

exact

if requested, a numeric vector containing the exact two-sided p-value, one-sided p-value, and point probability using the binomial distribution.

variables

a character vector containing the names of the two numeric variables with the paired observations.

n

an integer giving the number of observations.

The to_SPSS method returns an object of class "SPSS_table" which contains all relevant information in the required format to produce the LaTeX table. See to_latex for possible components and how to further customize the LaTeX table based on the returned object.

The print method produces a LaTeX table that mimics the look of SPSS output.

Note

LaTeX tables that mimic recent versions of SPSS (version = "modern") may require several LaTeX compilations to be displayed correctly.

Author(s)

Andreas Alfons

Examples

# load data
data("Exams")

# test whether grades differ between the
# regular exam and the resit
sign_test(Exams, c("Regular", "Resit"))


r2spss documentation built on May 25, 2022, 5:05 p.m.