[R] How to compute Wilk's Lambda

Peter Dalgaard p.dalgaard at biostat.ku.dk
Tue Jun 19 19:13:53 CEST 2007


Dietrich Trenkler wrote:
> Dear helpeRs,
>
> the following data set comes from Johnson/Wichern: Applied Multivariate
> Statistical Analysis, 6th ed, pp. 304-306.
>
> /X <- structure(c(9, 6, 9, 3, 2, 7), .Dim = as.integer(c(3, 2)))
> Y <- structure(c(0, 2, 4, 0), .Dim = as.integer(c(2, 2)))
> Z <- structure(c(3, 1, 2, 8, 9, 7), .Dim = as.integer(c(3, 2)))/
>
> I would like to compute Wilk's Lambda in R, which I know is 0.0385. How
> can I do that? I tried
>
> /U <- rbind(X,Y,Z)
> m <- manova(U~rep(1:3, c(3, 2, 3)))
> summary(m,test="Wilks")/
>
> which gives
>
>
> /                     Df  Wilks approx F num Df den Df  Pr(>F)
> rep(1:3, c(3, 2, 3))  1  0.162   12.930      2      5 0.01057 *
> Residuals             6
> ---
> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1/
>
>
> I suppose the argument rep(1:3, c(3, 2, 3)) in manova() is not appropriate.
>
>   
Exactly. If intended as a grouping, you need to turn it into a factor:

 > m <- manova(U~factor(rep(1:3, c(3, 2, 3))))
 > summary(m,test="Wilks")
Df Wilks approx F num Df den Df Pr(>F)
factor(rep(1:3, c(3, 2, 3))) 2 0.0385 8.1989 4 8 0.006234 **
Residuals 5
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Or, for that matter:

 > anova(lm(U~factor(rep(1:3, c(3, 2, 3)))), test="Wilks")
Analysis of Variance Table

Df Wilks approx F num Df den Df Pr(>F)
(Intercept) 1 0.048 39.766 2 4 0.002293 **
factor(rep(1:3, c(3, 2, 3))) 2 0.038 8.199 4 8 0.006234 **
Residuals 5
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


> Any help is very much appreciated.
>
> Dietrich                   
>
>



More information about the R-help mailing list