add.ps: add p-values from t-tests

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/add.ps.R

Description

Adds p-values comparing the different cells at each x-axis position with a reference cell. Uses a syntax similar to raw.means.plot2.

Usage

1
2
3
4
5
add.ps(data, col.id, col.offset, col.x, col.value, fun.aggregate = "mean", 
ref.offset = 1, prefixes, test = "t",
alternative = c("two.sided", "less", "greater"), distribution = approximate(100000),
mu = 0, paired = FALSE, var.equal = FALSE, 
lty = 0, ...)

Arguments

data

A data.frame

col.id

character vector specifying the id column.

col.offset

character vector specifying the offset column.

col.x

character vector specifying the x-axis column.

col.value

character vector specifying the data column.

fun.aggregate

Function or function name used for aggregating the results. Default is "mean".

ref.offset

Scalar numeric indicating the reference level to be tested against. The default is 1 corresponding to levels(factor(d[,col.offset]))[1].

prefixes

character vector of the indices for the p-values. If missing corresponds to levels(factor(d.new[,col.offset]))[-ref.offset].

test

character of length 1, which test to use. currently implemented are c("t", "stats.wilcoxon", "Wilcoxon", "permutation", "median"). c("Wilcoxon", "permutation", "median") are called via afex::compare.2.vectors.

alternative

same as in t.test

distribution

distribution argument to coin, see Distribution or , IndependenceTest. Defaults to approximate(100000) indicating an approximation of the excat conditional distribution with 100.000 Monte Carlo samples. One can use "exact" for small samples and if paired = FALSE.

mu

same as in t.test

paired

same as in t.test

var.equal

same as in t.test

lty

line type of axis, Default is 0 (i.e., no line).

...

further arguments passed to axis.

Details

This function computes t-tests comparing the values at each x-axis position for each condition against the reference condition at and adds the p-values to the axis.

This functions uses the same syntax as raw.means.plot2 and should be used in addition to it. Note that values are ordered according to the col.id so paired = TRUE should be fine.

Value

axis is plotted.

Author(s)

Henrik Singmann

See Also

raw.means.plot as the accompanying main functions.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## Not run: 
#The examples uses the OBrienKaiser dataset from car and needs reshape.
# This extends the examples from raw.means.plot
require(reshape)
require(car)
data(OBrienKaiser)
OBKnew <- cbind(factor(1:nrow(OBrienKaiser)), OBrienKaiser)
colnames(OBKnew)[1] <- "id"
OBK.long <- melt(OBKnew)
OBK.long[, c("measurement", "time")] <- t(vapply(strsplit(as.character(OBK.long$variable), "\\."),  "[", c("", "")))

# For this example the position at each x-axis are within-subject comparisons!
raw.means.plot2(OBK.long, "id", "measurement", "gender", "value")
add.ps(OBK.long, "id", "measurement", "gender", "value", paired = TRUE) #reference is "fup"

raw.means.plot2(OBK.long, "id", "measurement", "gender", "value")
add.ps(OBK.long, "id", "measurement", "gender", "value", ref.offset = 2, paired = TRUE) #reference is "post"

# Use R's standard (i.e., Welch test)
raw.means.plot2(OBK.long, "id", "treatment", "gender", "value")
add.ps(OBK.long, "id", "treatment", "gender", "value", prefixes = c("p(control vs. A)", "p(control vs. B)"))

# Use standard t-test
raw.means.plot2(OBK.long, "id", "treatment", "gender", "value")
add.ps(OBK.long, "id", "treatment", "gender", "value", var.equal = TRUE, prefixes = c("p(control vs. A)", "p(control vs. B)"))


## End(Not run)

raw.means.plot documentation built on May 2, 2019, 5 p.m.