t2way: A two-way ANOVA for trimmed means, M-estimators, and medians.

Description Usage Arguments Details Value References See Also Examples

View source: R/t2way.R

Description

The t2way function computes a two-way ANOVA for trimmed means with interactions effects. Corresponding post hoc tests are in mcp2atm. pbad2way performs a two-way ANOVA using M-estimators for location with mcp2a for post hoc tests.

Usage

1
2
3
4
t2way(formula, data, tr = 0.2)
pbad2way(formula, data, est = "mom", nboot = 599, pro.dis = FALSE)
mcp2atm(formula, data, tr = 0.2)
mcp2a(formula, data, est = "mom", nboot = 599)

Arguments

formula

an object of class formula.

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".

nboot

number of bootstrap samples.

pro.dis

If FALSE, Mahalanobis distances are used; if TRUE projection distances are computed.

Details

The pbad2way function returns p-values only. If it happens that the variance-covariance matrix in the Mahalanobis distance computation is singular, it is suggested to use the projection distances by setting pro.dis = TRUE.

Value

The functions t2way and pbad2way return an object of class t2way containing:

Qa

first main effect

A.p.value

p-value first main effect

Qb

second main effect

B.p.value

p-value second main effect

Qab

interaction effect

AB.p.value

p-value interaction effect

call

function call

varnames

variable names

The functions mcp2atm and mcp2a return an object of class mcp containing:

effects

list with post hoc comparisons for all effects

contrasts

design matrix

References

Wilcox, R. (2012). Introduction to Robust Estimation and Hypothesis Testing (3rd ed.). Elsevier.

See Also

t1way, med1way

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## 2-way ANOVA on trimmed means
t2way(attractiveness ~ gender*alcohol, data = goggles)

## post hoc tests
mcp2atm(attractiveness ~ gender*alcohol, data = goggles)

## 2-way ANOVA on MOM estimator
pbad2way(attractiveness ~ gender*alcohol, data = goggles)

## post hoc tests
mcp2a(attractiveness ~ gender*alcohol, data = goggles)

## 2-way ANOVA on medians
pbad2way(attractiveness ~ gender*alcohol, data = goggles, est = "median")

## post hoc tests
mcp2a(attractiveness ~ gender*alcohol, data = goggles, est = "median")

## extract design matrix
model.matrix(mcp2a(attractiveness ~ gender*alcohol, data = goggles, est = "median"))

Example output

Call:
t2way(formula = attractiveness ~ gender * alcohol, data = goggles)

                 value p.value
gender          1.6667   0.209
alcohol        48.2845   0.001
gender:alcohol 26.2572   0.001

Call:
mcp2atm(formula = attractiveness ~ gender * alcohol, data = goggles)

                    psihat  ci.lower  ci.upper p-value
gender1           10.00000  -6.00223  26.00223 0.20922
alcohol1          -3.33333 -20.49551  13.82885 0.61070
alcohol2          35.83333  19.32755  52.33911 0.00003
alcohol3          39.16667  22.46796  55.86537 0.00001
gender1:alcohol1  -3.33333 -20.49551  13.82885 0.61070
gender1:alcohol2 -29.16667 -45.67245 -12.66089 0.00025
gender1:alcohol3 -25.83333 -42.53204  -9.13463 0.00080

Call:
pbad2way(formula = attractiveness ~ gender * alcohol, data = goggles)

               p.value
gender          0.1653
alcohol         0.0000
gender:alcohol  0.0000

Call:
mcp2a(formula = attractiveness ~ gender * alcohol, data = goggles)

                    psihat  ci.lower  ci.upper p-value
gender1           14.46429  -7.21429  28.54167 0.10351
alcohol1          -5.00000 -21.87500  14.00000 0.40234
alcohol2          35.80357  20.12500  50.37500 0.00000
alcohol3          40.80357  20.98214  54.53571 0.00000
gender1:alcohol1  -5.00000 -19.37500  12.50000 0.28214
gender1:alcohol2 -32.23214 -45.20833 -15.62500 0.00167
gender1:alcohol3 -27.23214 -42.97619 -10.00000 0.00000

Call:
pbad2way(formula = attractiveness ~ gender * alcohol, data = goggles, 
    est = "median")

               p.value
gender          0.2321
alcohol         0.0000
gender:alcohol  0.0000

Call:
mcp2a(formula = attractiveness ~ gender * alcohol, data = goggles, 
    est = "median")

                 psihat ci.lower ci.upper p-value
gender1            10.0     -7.5     27.5 0.13523
alcohol1           -2.5    -17.5     12.5 0.32387
alcohol2           40.0     20.0     50.0 0.00000
alcohol3           42.5     22.5     55.0 0.00000
gender1:alcohol1   -2.5    -20.0     12.5 0.25710
gender1:alcohol2  -30.0    -45.0    -12.5 0.00000
gender1:alcohol3  -27.5    -42.5    -10.0 0.00000

               gender1 alcohol1 alcohol2 alcohol3 gender1:alcohol1
Female_None          1        1        1        0                1
Female_2 Pints       1       -1        0        1               -1
Female_4 Pints       1        0       -1       -1                0
Male_None           -1        1        1        0               -1
Male_2 Pints        -1       -1        0        1                1
Male_4 Pints        -1        0       -1       -1                0
               gender1:alcohol2 gender1:alcohol3
Female_None                   1                0
Female_2 Pints                0                1
Female_4 Pints               -1               -1
Male_None                    -1                0
Male_2 Pints                  0               -1
Male_4 Pints                  1                1

WRS2 documentation built on May 31, 2017, 2:07 a.m.