t1way_ci
#' @title A heteroscedastic one-way ANOVA for trimmed means with confidence interval for effect size.
Custom function to get confidence intervals for effect size measure for robust ANOVA.
- Keywords
- internal
Usage
t1way_ci(data, x, y, tr = 0.1, nboot = 100, conf.level = 0.95,
conf.type = "norm", ...)
Arguments
- data
A dataframe (or a tibble) from which variables specified are to be taken. A matrix or tables will not be accepted.
- x
The grouping variable from the dataframe
data
.- y
The response (a.k.a. outcome or dependent) variable from the dataframe
data
.- tr
Trim level for the mean when carrying out
robust
tests. If you get error stating "Standard error cannot be computed because of Winsorized variance of 0 (e.g., due to ties). Try to decrease the trimming level.", try to play around with the value oftr
, which is by default set to0.1
. Lowering the value might help.- nboot
Number of bootstrap samples for computing confidence interval for the effect size (Default:
100
).- conf.level
Scalar between 0 and 1. If unspecified, the defaults return
95%
lower and upper confidence intervals (0.95
).- conf.type
A vector of character strings representing the type of intervals required. The value should be any subset of the values
"norm"
,"basic"
,"perc"
,"bca"
. For more, see?boot::boot.ci
.- ...
Arguments passed on to
boot::boot
- data
The data as a vector, matrix or data frame. If it is a matrix or data frame then each row is considered as one multivariate observation.
- statistic
A function which when applied to data returns a vector containing the statistic(s) of interest. When
sim = "parametric"
, the first argument tostatistic
must be the data. For each replicate a simulated dataset returned byran.gen
will be passed. In all other casesstatistic
must take at least two arguments. The first argument passed will always be the original data. The second will be a vector of indices, frequencies or weights which define the bootstrap sample. Further, if predictions are required, then a third argument is required which would be a vector of the random indices used to generate the bootstrap predictions. Any further arguments can be passed tostatistic
through the…
argument.- R
The number of bootstrap replicates. Usually this will be a single positive integer. For importance resampling, some resamples may use one set of weights and others use a different set of weights. In this case
R
would be a vector of integers where each component gives the number of resamples from each of the rows of weights.- sim
A character string indicating the type of simulation required. Possible values are
"ordinary"
(the default),"parametric"
,"balanced"
,"permutation"
, or"antithetic"
. Importance resampling is specified by including importance weights; the type of importance resampling must still be specified but may only be"ordinary"
or"balanced"
in this case.- stype
A character string indicating what the second argument of
statistic
represents. Possible values of stype are"i"
(indices - the default),"f"
(frequencies), or"w"
(weights). Not used forsim = "parametric"
.- strata
An integer vector or factor specifying the strata for multi-sample problems. This may be specified for any simulation, but is ignored when
sim = "parametric"
. Whenstrata
is supplied for a nonparametric bootstrap, the simulations are done within the specified strata.- L
Vector of influence values evaluated at the observations. This is used only when
sim
is"antithetic"
. If not supplied, they are calculated through a call toempinf
. This will use the infinitesimal jackknife provided thatstype
is"w"
, otherwise the usual jackknife is used.- m
The number of predictions which are to be made at each bootstrap replicate. This is most useful for (generalized) linear models. This can only be used when
sim
is"ordinary"
.m
will usually be a single integer but, if there are strata, it may be a vector with length equal to the number of strata, specifying how many of the errors for prediction should come from each strata. The actual predictions should be returned as the final part of the output ofstatistic
, which should also take an argument giving the vector of indices of the errors to be used for the predictions.- weights
Vector or matrix of importance weights. If a vector then it should have as many elements as there are observations in
data
. When simulation from more than one set of weights is required,weights
should be a matrix where each row of the matrix is one set of importance weights. Ifweights
is a matrix thenR
must be a vector of lengthnrow(weights)
. This parameter is ignored ifsim
is not"ordinary"
or"balanced"
.- ran.gen
This function is used only when
sim = "parametric"
when it describes how random values are to be generated. It should be a function of two arguments. The first argument should be the observed data and the second argument consists of any other information needed (e.g. parameter estimates). The second argument may be a list, allowing any number of items to be passed toran.gen
. The returned value should be a simulated data set of the same form as the observed data which will be passed tostatistic
to get a bootstrap replicate. It is important that the returned value be of the same shape and type as the original dataset. Ifran.gen
is not specified, the default is a function which returns the originaldata
in which case all simulation should be included as part ofstatistic
. Use ofsim = "parametric"
with a suitableran.gen
allows the user to implement any types of nonparametric resampling which are not supported directly.- mle
The second argument to be passed to
ran.gen
. Typically these will be maximum likelihood estimates of the parameters. For efficiencymle
is often a list containing all of the objects needed byran.gen
which can be calculated using the original data set only.- simple
logical, only allowed to be
TRUE
forsim = "ordinary", stype = "i", n = 0
(otherwise ignored with a warning). By default an
byR
index array is created: this can be large and ifsimple = TRUE
this is avoided by sampling separately for each replication, which is slower but uses less memory.- parallel
The type of parallel operation to be used (if any). If missing, the default is taken from the option
"boot.parallel"
(and if that is not set,"no"
).- ncpus
integer: number of processes to be used in parallel operation: typically one would chose this to the number of available CPUs.
- cl
An optional parallel or snow cluster for use if
parallel = "snow"
. If not supplied, a cluster on the local machine is created for the duration of theboot
call.
Examples
# NOT RUN {
set.seed(123)
ggstatsplot:::t1way_ci(
data = dplyr::filter(ggplot2::msleep, vore != "insecti"),
x = vore,
y = brainwt,
tr = 0.05,
nboot = 50,
conf.level = 0.99,
conf.type = "perc"
)
# }
# NOT RUN {
# }