assoc.twocont.by.Rd
Measures the association between two continuous variables with Pearson, Spearman and Kendall correlations, for each category of a group variable.
assoc.twocont.by(x, y, by, weights = NULL, na.rm = FALSE,
nperm = NULL, distrib = "asympt")
numeric vector : a continuous variable
numeric vector : a continuous variable
factor : the group variable
numeric vector of weights. If NULL (default), uniform weights (i.e. all equal to 1) are used.
logical, indicating whether NA values should be silently removed before the computation proceeds. Default is FALSE.
numeric. Number of permutations for the permutation test of independence. If NULL (default), no permutation test is performed.
the null distribution of permutation test of independence can be approximated by its asymptotic distribution ("asympt"
, default) or via Monte Carlo resampling ("approx"
.
A list of items, one for each category of the groupe variable. Each item is a data frame with Pearson, Spearman and Kendall correlations. The correlation value is in the first row and a p-value from a permutation (so non parametric) test of independence is in the second row.
## Hollander & Wolfe (1973), p. 187f.
## Assessment of tuna quality. We compare the Hunter L measure of
## lightness to the averages of consumer panel scores (recoded as
## integer values from 1 to 6 and averaged over 80 such values) in
## 9 lots of canned tuna.
x <- c(44.4, 45.9, 41.9, 53.3, 44.7, 44.1, 50.7, 45.2, 60.1)
y <- c( 2.6, 3.1, 2.5, 5.0, 3.6, 4.0, 5.2, 2.8, 3.8)
group <- factor(c("A","B","C","C","B","A","A","C","B"))
assoc.twocont.by(x,y,group,nperm=100)
#> $A
#> pearson spearman kendall
#> value 0.8206552 0.5000000 0.3333333
#> permutation.pvalue 0.1137043 0.2529296 0.3120744
#>
#> $B
#> pearson spearman kendall
#> value 0.6702388 0.500000 0.3333333
#> permutation.pvalue 0.1867822 0.235401 0.2945368
#>
#> $C
#> pearson spearman kendall
#> value 0.98472301 1.00000000 1.00000000
#> permutation.pvalue 0.08867954 0.08515329 0.05856106
#>