bwtrim: A robust two-way mixed ANOVA using trimmed means.

View source: R/bwtrim.R

bwtrimR Documentation

A robust two-way mixed ANOVA using trimmed means.

Description

The bwtrim function computes a two-way between-within subjects ANOVA on the trimmed means. It is designed for one between-subjects variable and one within-subjects variable. The functions sppba, sppbb, and sppbi compute the main fixed effect, the main within-subjects effect, and the interaction effect only, respectively, using bootstrap. For these 3 functions the user can choose an M-estimator for group comparisons.

Usage

bwtrim(formula, id, data, tr = 0.2, ...)
tsplit(formula, id, data, tr = 0.2, ...)
sppba(formula, id, data, est = "mom", avg = TRUE, nboot = 500, MDIS = FALSE, ...)
sppbb(formula, id, data, est = "mom", nboot = 500, ...)
sppbi(formula, id, data, est = "mom", nboot = 500, ...)

Arguments

formula

an object of class formula.

id

subject ID.

data

an optional data frame for the input data.

tr

trim level for the mean.

est

Estimate to be used for the group comparisons: either "onestep" for one-step M-estimator of location using Huber's Psi, "mom" for the modified one-step (MOM) estimator of location based on Huber's Psi, or "median".

avg

If TRUE, the analysis is done by averaging K measures of location for each level of the fixed effect, and then comparing averages by testing the hypothesis that all pairwise differences are equal to zero. If FALSE the analysis is done by testing whether K equalities are simultaneously true.

nboot

number of bootstrap samples.

MDIS

if TRUE the depths of the points in the bootstrap cloud are based on Mahalanobis distance, if FALSE a projection distance is used.

...

currently ignored.

Details

The tsplit function is doing exactly the same thing as bwtrim. It is kept in the package in order to be consistent with older versions of the Wilcox (2012) book. For sppba, sppbb, and sppbi the analysis is carried out on the basis of all pairs of difference scores. The null hypothesis is that all such differences have a robust location value of zero. In the formula interface it is required to specify full model.

Value

bwtrim returns an object of class "bwtrim" containing:

Qa

first main effect

A.p.value

p-value first main effect

A.df

df F-distribution first main effect

Qb

second main effect

B.p.value

p-value second main effect

B.df

df F-distribution second main effect

Qab

interaction effect

AB.p.value

p-value interaction effect

AB.df

df F-distribution interaction

call

function call

varnames

variable names

sppba, sppbb, and sppbi returns an object of class "spp" containing:

test

value of the test statistic

p.value

p-value

contrasts

contrasts matrix

References

Wilcox, R. (2017). Introduction to Robust Estimation and Hypothesis Testing (4th ed.). Elsevier.

See Also

t2way

Examples

## data need to be on long format
pictureLong <- reshape(picture, direction = "long", varying = list(3:4), idvar = "case",
timevar = c("pictype"), times = c("couple", "alone"))
pictureLong$pictype <- as.factor(pictureLong$pictype)
colnames(pictureLong)[4] <- "friend_requests"

## 2-way within-between subjects ANOVA
bwtrim(friend_requests ~ relationship_status*pictype, id = case, data = pictureLong)

## between groups effect only (MOM estimator)
sppba(friend_requests ~ relationship_status*pictype, case, data = pictureLong)

## within groups effect only (MOM estimator)
sppbb(friend_requests ~ relationship_status*pictype, case, data = pictureLong)

## interaction effect only (MOM estimator)
sppbi(friend_requests ~ relationship_status*pictype, case, data = pictureLong)


WRS2 documentation built on March 19, 2024, 3:08 a.m.

Related to bwtrim in WRS2...