lambda.test: Goodman and Kruskal's lambda

View source: R/lambda.R

lambda.testR Documentation

Goodman and Kruskal's lambda

Description

Computes Goodman and Kruskal's lambda for given table.

Usage

lambda.test(table, direction = 0)

Arguments

table

a table of two variables or a data.frame representation of the cross-table of the two variables without marginals

direction

numeric value of c(0, 1, 2) where 1 means the lambda value computed for row, 2 for columns and 0 for both

Value

computed lambda value(s) for row/col of given table

References

  • Goodman, L.A., Kruskal, W.H. (1954) Measures of association for cross classifications. Part I. Journal of the American Statistical Association 49, 732–764

Examples

## Not run: 
## quick example
x <- data.frame(x = c(5, 4, 3), y = c(9, 8, 7), z = c(7, 11, 22), zz = c(1, 15, 8))
lambda.test(x)    # 0.1 and 0.18333
lambda.test(t(x)) # 0.18333 and 0.1

## historical data (see the references above: p. 744)
men.hair.color <- data.frame(
b1 = c(1768, 946, 115),
b2 = c(807, 1387, 438),
b3 = c(189, 746, 288),
b4 = c(47, 53, 16)
)
row.names(men.hair.color) <- paste0('a', 1:3)
lambda.test(men.hair.color)
lambda.test(t(men.hair.color))

## some examples on mtcars
lambda.test(table(mtcars$am, mtcars$gear))
lambda.test(table(mtcars$gear, mtcars$am))
lambda.test(table(mtcars$am, mtcars$gear), 1)
lambda.test(table(mtcars$am, mtcars$gear), 2)

## End(Not run)

rapportools documentation built on March 22, 2022, 1:06 a.m.