Freeman's theta
freemanTheta.RdCalculates Freeman's theta for a table with one ordinal variable and one nominal variable; confidence intervals by bootstrap.
Usage
freemanTheta(
x,
g = NULL,
group = "row",
verbose = FALSE,
progress = FALSE,
ci = FALSE,
conf = 0.95,
type = "perc",
R = 1000,
histogram = FALSE,
digits = 3,
reportIncomplete = FALSE
)Arguments
- x
Either a two-way table or a two-way matrix. Can also be a vector of observations of an ordinal variable.
- g
If
xis a vector,gis the vector of observations for the grouping, nominal variable.- group
If
xis a table or matrix,groupindicates whether the"row"or the"column"variable is the nominal, grouping variable.- verbose
If
TRUE, prints statistics for each comparison.- progress
If
TRUE, prints a message as each comparison is conducted.- ci
If
TRUE, returns confidence intervals by bootstrap. May be slow.- conf
The level for the confidence interval.
- type
The type of confidence interval to use. Can be any of "
norm", "basic", "perc", or "bca". Passed toboot.ci.- R
The number of replications to use for bootstrap.
- histogram
If
TRUE, produces a histogram of bootstrapped values.- digits
The number of significant digits in the output.
- reportIncomplete
If
FALSE(the default),NAwill be reported in cases where there are instances of the calculation of the statistic failing during the bootstrap procedure.
Value
A single statistic, Freeman's theta. Or a small data frame consisting of Freeman's theta, and the lower and upper confidence limits.
Details
Freeman's coefficent of differentiation (theta) is used as a measure of association for a two-way table with one ordinal and one nominal variable. See Freeman (1965).
Currently, the function makes no provisions for NA
values in the data. It is recommended that NAs be removed
beforehand.
Because theta is always positive, if type="perc",
the confidence interval will
never cross zero, and should not
be used for statistical inference.
However, if type="norm", the confidence interval
may cross zero.
When theta is close to 0 or very large, or with small counts in some cells, the confidence intervals determined by this method may not be reliable, or the procedure may fail.
References
Freeman, L.C. 1965. Elementary Applied Statistics for Students in Behavioral Science. Wiley.
Author
Salvatore Mangiafico, mangiafico@njaes.rutgers.edu
Examples
data(Breakfast)
library(coin)
chisq_test(Breakfast, scores = list("Breakfast" = c(-2, -1, 0, 1, 2)))
#>
#> Asymptotic Generalized Pearson Chi-Squared Test
#>
#> data: Breakfast (ordered) by Travel (Walk, Bus, Drive)
#> chi-squared = 8.6739, df = 2, p-value = 0.01308
#>
freemanTheta(Breakfast)
#> Freeman.theta
#> 0.312
### Example from Freeman (1965), Table 10.6
Counts = c(1, 2, 5, 2, 0, 10, 5, 5, 0, 0, 0, 0, 2, 2, 1, 0, 0, 0, 2, 3)
Matrix = matrix(Counts, byrow=TRUE, ncol=5,
dimnames = list(Marital.status = c("Single", "Married",
"Widowed", "Divorced"),
Social.adjustment = c("5","4","3","2","1")))
Matrix
#> Social.adjustment
#> Marital.status 5 4 3 2 1
#> Single 1 2 5 2 0
#> Married 10 5 5 0 0
#> Widowed 0 0 2 2 1
#> Divorced 0 0 0 2 3
freemanTheta(Matrix)
#> Freeman.theta
#> 0.749
### Example after Kruskal Wallis test
data(PoohPiglet)
kruskal.test(Likert ~ Speaker, data = PoohPiglet)
#>
#> Kruskal-Wallis rank sum test
#>
#> data: Likert by Speaker
#> Kruskal-Wallis chi-squared = 16.842, df = 2, p-value = 0.0002202
#>
freemanTheta(x = PoohPiglet$Likert, g = PoohPiglet$Speaker)
#> Freeman.theta
#> 0.64
### Same data, as table of counts
data(PoohPiglet)
XT = xtabs( ~ Speaker + Likert , data = PoohPiglet)
freemanTheta(XT)
#> Freeman.theta
#> 0.64
### Example from Freeman (1965), Table 10.7
Counts = c(52, 28, 40, 34, 7, 9, 16, 10, 8, 4, 10, 9, 12,6, 7, 5)
Matrix = matrix(Counts, byrow=TRUE, ncol=4,
dimnames = list(Preferred.trait = c("Companionability",
"PhysicalAppearance",
"SocialGrace",
"Intelligence"),
Family.income = c("4", "3", "2", "1")))
Matrix
#> Family.income
#> Preferred.trait 4 3 2 1
#> Companionability 52 28 40 34
#> PhysicalAppearance 7 9 16 10
#> SocialGrace 8 4 10 9
#> Intelligence 12 6 7 5
freemanTheta(Matrix, verbose=TRUE)
#>
#> Comparison Di Ti
#> 1 1 1024 6468
#> 2 2 636 4774
#> 3 3 434 4620
#> 4 4 8 1302
#> 5 5 332 1260
#> 6 6 211 930
#>
#> Sum Di = 2645
#> T2 = 19354
#>
#> Freeman.theta
#> 0.137