percentileTest.RdConducts a permutation test to compare two groups for medians, percentiles, or proportion below a threshold value.
percentileTest(
formula = NULL,
data = NULL,
x = NULL,
y = NULL,
test = "median",
tau = 0.5,
type = 7,
threshold = NA,
comparison = "<",
r = 1000,
digits = 4,
progress = "TRUE"
)A formula indicating the response variable and the independent variable. e.g. y ~ group.
The data frame to use.
If no formula is given, the response variable for one group.
The response variable for the other group.
The statistic to compare between groups. Can be
"median", "percentile", "iqr",
"proportion",
"mean", or "variance".
If "percentile" is chosen as the test,
tau indicates the percentile to test. Expressed
as a quantile. That is, 0.5 indicates a test for medians.
0.75 indicates a test for 75th percentiles.
The type value passed to the quantile function.
If "proportion" is chosen as the test,
threshold indicates the value of the dependent variable
to use as the threshold. For example, to test if there is a
different in the proportion of observations below $10,000,
threshold = 10000 would be used.
If "proportion" is chosen as the test,
comparison indicates the inequality to use. Options are
"<", "<=", ">", ">=", or , "=="
The number of replicates in the permutation test.
The number of significant digits in the output.
If TRUE, prints a dot for every 1 percent of
progress while conducting the test.
A list of three data frames with the data used, a summary for each group, and the p-value from the test.
The function will test for a difference in medians, percentiles, interquartile ranges, proportion of observations above or below some threshold value, means, or variances between two groups by permutation test.
The permutation test simply permutes the observed values over the two groups and counts how often the calculated statistic is at least as extreme as the original observed statistic.
The input should include either formula and data;
or x and y.
The function removes cases with NA in any of the variables.
If the independent variable has more than two groups, only the first two levels of the factor variable will be used.
The p-value returned is a two-sided test.
The parsing of the formula is simplistic. The first variable on the left side is used as the measurement variable. The first variable on the right side is used for the independent variable.
data(BrendonSmall)
percentileTest(Sodium ~ Instructor,
data=BrendonSmall,
test="median")
#> ....................................................................................................
#>
#> $Test
#> Formula Data Test
#> 1 Sodium ~ Instructor BrendonSmall median
#>
#> $Summary
#> n mean sd min p25 median p75 max iqr
#> 1 Brendon Small 9 1259 64.66 1164 1222 1271 1287 1377 65
#> 2 Jason Penopolis 9 1293 49.84 1199 1273 1281 1329 1368 56
#>
#> $Result
#> p.value
#> 1 p-value 0.579
#>
percentileTest(Sodium ~ Instructor,
data=BrendonSmall,
test="percentile",
tau = 0.75)
#> ....................................................................................................
#>
#> $Test
#> Formula Data Test tau
#> 1 Sodium ~ Instructor BrendonSmall percentile 0.75
#>
#> $Summary
#> n mean sd min p25 median p75 max iqr
#> 1 Brendon Small 9 1259 64.66 1164 1222 1271 1287 1377 65
#> 2 Jason Penopolis 9 1293 49.84 1199 1273 1281 1329 1368 56
#>
#> $Result
#> p.value
#> 1 p-value 0.437
#>
percentileTest(Sodium ~ Instructor,
data=BrendonSmall,
test="proportion",
threshold = 1300)
#> ....................................................................................................
#>
#> $Test
#> Formula Data Test
#> 1 Sodium ~ Instructor BrendonSmall proportion
#>
#> $Summary
#> n mean sd min p25 median p75 max iqr comparison
#> 1 Brendon Small 9 1259 64.66 1164 1222 1271 1287 1377 65 <
#> 2 Jason Penopolis 9 1293 49.84 1199 1273 1281 1329 1368 56 <
#> threshold proportion
#> 1 1300 0.8889
#> 2 1300 0.5556
#>
#> $Result
#> p.value
#> 1 p-value 0.302
#>