The function suberbData()
computes standard error or confidence interval for various descriptive
statistics under various designs, sampling schemes, population size and purposes,
according to the suberb
framework. See (Cousineau et al. 2021)
for more.
superbData(
data,
BSFactors = NULL,
WSFactors = NULL,
WSDesign = "fullfactorial",
factorOrder = NULL,
variables,
statistic = "mean",
errorbar = "CI",
gamma = 0.95,
adjustments = list(purpose = "single", popSize = Inf, decorrelation = "none",
samplingDesign = "SRS"),
preprocessfct = NULL,
postprocessfct = NULL,
clusterColumn = ""
)
Dataframe in wide format
The name of the columns containing the between-subject factor(s)
The name of the within-subject factor(s)
the within-subject design if not a full factorial design (default "fullfactorial")
Order of factors as shown in the graph (x axis, groups, horizontal panels, vertical panels)
The dependent variable(s)
The summary statistic function to use
The function that computes the error bar. Should be "CI" or "SE" or any function name. Defaults to "CI"
The coverage factor; necessary when errorbar == "CI". Default is 0.95.
List of adjustments as described below.
Default is adjustments = list(purpose = "single", popSize = Inf, decorrelation = "none", samplingDesign = "SRS")
is a transform (or vector of) to be performed first on data matrix of each group
is a transform (or vector of)
used in conjunction with samplingDesign = "CRS", indicates which column contains the cluster membership
a list with (1) the summary statistics in summaryStatistics (2) the raw data in long format in rawData (using numeric levels for repeated-measure variables).
The possible adjustements are the following
popsize: Size of the population under study. Defaults to Inf
purpose: The purpose of the comparisons. Defaults to "single". Can be "single", "difference", or "tryon".
decorrelation: Decorrelation method for repeated measure designs. Chooses among the methods "CM", "LM", "CA" or "none". Defaults to "none".
samplingDesign: Sampling method to obtain the sample. implemented sampling is "SRS" (Simple Randomize Sampling) and "CRS" (Cluster-Randomized Sampling).
Cousineau D, Goulet M, Harding B (2021). “Summary plots with adjusted error bars: The superb framework with an implementation in R.” Advances in Methods and Practices in Psychological Science, 4, 1--18. doi:10.1177/25152459211035109 .
# Basic example using a built-in dataframe as data;
# by default, the mean is computed and the error bar are 95% confidence intervals
# (it also produces a $rawData dataframe, not shown here)
res <- superbData(ToothGrowth, BSFactors = c("dose", "supp"),
variables = "len")
res$summaryStatistics
#> dose supp center lowerwidth upperwidth
#> 1 0.5 OJ 13.23 -3.190283 3.190283
#> 2 0.5 VC 7.98 -1.964824 1.964824
#> 3 1 OJ 22.70 -2.797727 2.797727
#> 4 1 VC 16.77 -1.799343 1.799343
#> 5 2 OJ 26.06 -1.899314 1.899314
#> 6 2 VC 26.14 -3.432090 3.432090
# Example introducing adjustments for pairwise comparisons
# and assuming that the whole population is limited to 200 persons
res <- superbData(ToothGrowth, BSFactors = c("dose", "supp"),
variables = "len",
statistic = "median", errorbar = "CI", gamma = .80,
adjustments = list( purpose = "difference", popSize = 200) )
res$summaryStatistics
#> dose supp center lowerwidth upperwidth
#> 1 0.5 OJ 12.25 -3.369569 3.369569
#> 2 0.5 VC 7.15 -2.075242 2.075242
#> 3 1 OJ 23.45 -2.954953 2.954953
#> 4 1 VC 16.50 -1.900462 1.900462
#> 5 2 OJ 25.95 -2.006051 2.006051
#> 6 2 VC 25.95 -3.624965 3.624965
# Note that you can achieve the same with formulas
superb( len ~ dose + supp, ToothGrowth, showPlot=FALSE)
#> $summaryStatistics
#> dose supp center lowerwidth upperwidth
#> 1 0.5 OJ 13.23 -3.190283 3.190283
#> 2 0.5 VC 7.98 -1.964824 1.964824
#> 3 1 OJ 22.70 -2.797727 2.797727
#> 4 1 VC 16.77 -1.799343 1.799343
#> 5 2 OJ 26.06 -1.899314 1.899314
#> 6 2 VC 26.14 -3.432090 3.432090
#>
#> $rawData
#> dose supp id DV
#> 1 0.5 VC 1 4.2
#> 2 0.5 VC 2 11.5
#> 3 0.5 VC 3 7.3
#> 4 0.5 VC 4 5.8
#> 5 0.5 VC 5 6.4
#> 6 0.5 VC 6 10.0
#> 7 0.5 VC 7 11.2
#> 8 0.5 VC 8 11.2
#> 9 0.5 VC 9 5.2
#> 10 0.5 VC 10 7.0
#> 11 1 VC 11 16.5
#> 12 1 VC 12 16.5
#> 13 1 VC 13 15.2
#> 14 1 VC 14 17.3
#> 15 1 VC 15 22.5
#> 16 1 VC 16 17.3
#> 17 1 VC 17 13.6
#> 18 1 VC 18 14.5
#> 19 1 VC 19 18.8
#> 20 1 VC 20 15.5
#> 21 2 VC 21 23.6
#> 22 2 VC 22 18.5
#> 23 2 VC 23 33.9
#> 24 2 VC 24 25.5
#> 25 2 VC 25 26.4
#> 26 2 VC 26 32.5
#> 27 2 VC 27 26.7
#> 28 2 VC 28 21.5
#> 29 2 VC 29 23.3
#> 30 2 VC 30 29.5
#> 31 0.5 OJ 31 15.2
#> 32 0.5 OJ 32 21.5
#> 33 0.5 OJ 33 17.6
#> 34 0.5 OJ 34 9.7
#> 35 0.5 OJ 35 14.5
#> 36 0.5 OJ 36 10.0
#> 37 0.5 OJ 37 8.2
#> 38 0.5 OJ 38 9.4
#> 39 0.5 OJ 39 16.5
#> 40 0.5 OJ 40 9.7
#> 41 1 OJ 41 19.7
#> 42 1 OJ 42 23.3
#> 43 1 OJ 43 23.6
#> 44 1 OJ 44 26.4
#> 45 1 OJ 45 20.0
#> 46 1 OJ 46 25.2
#> 47 1 OJ 47 25.8
#> 48 1 OJ 48 21.2
#> 49 1 OJ 49 14.5
#> 50 1 OJ 50 27.3
#> 51 2 OJ 51 25.5
#> 52 2 OJ 52 26.4
#> 53 2 OJ 53 22.4
#> 54 2 OJ 54 24.5
#> 55 2 OJ 55 24.8
#> 56 2 OJ 56 30.9
#> 57 2 OJ 57 26.4
#> 58 2 OJ 58 27.3
#> 59 2 OJ 59 29.4
#> 60 2 OJ 60 23.0
#>