localtest | R Documentation |
This function can be used to test the equality of the M critical points estimated from the respective level-specific curves.
localtest( formula, data = data, na.action = "na.omit", der, smooth = "kernel", weights = NULL, nboot = 500, h0 = -1, h = -1, nh = 30, kernel = "epanech", p = 3, kbin = 100, rankl = NULL, ranku = NULL, seed = NULL, cluster = TRUE, ncores = NULL, ci.level = 0.95, ... )
formula |
An object of class |
data |
An optional data frame, matrix or list required by
the formula. If not found in data, the variables are taken from
|
na.action |
A function which indicates what should happen when the data contain 'NA's. The default is 'na.omit'. |
der |
Number which determines any inference process.
By default |
smooth |
Type smoother used: |
weights |
Prior weights on the data. |
nboot |
Number of bootstrap repeats. |
h0 |
The kernel bandwidth smoothing parameter for the global effect (see references for more details at the estimation). Large values of the bandwidth lead to smoothed estimates; smaller values of the bandwidth lead lo undersmoothed estimates. By default, cross validation is used to obtain the bandwidth. |
h |
The kernel bandwidth smoothing parameter for the partial effects. |
nh |
Integer number of equally-spaced bandwidth on which the
|
kernel |
A character string specifying the desired kernel.
Defaults to |
p |
Degree of polynomial to be used. Its value must be the value of derivative + 1. The default value is 3 due to the function returns the estimation, first and second derivative. |
kbin |
Number of binning nodes over which the function is to be estimated. |
rankl |
Number or vector specifying the minimum value for the
interval at which to search the |
ranku |
Number or vector specifying the maximum value for the
interval at which to search the |
seed |
Seed to be used in the bootstrap procedure. |
cluster |
A logical value. If |
ncores |
An integer value specifying the number of cores to be used
in the parallelized procedure. If |
ci.level |
Level of bootstrap confidence interval. Defaults to 0.95 (corresponding to 95%). Note that the function accepts a vector of levels. |
... |
Other options. |
localtest
can be used to test the equality of the
M critical points estimated from the respective level-specific curves.
Note that, even if the curves and/or their derivatives are different, it is
possible for these points to be equal.
For instance, taking the maxima of the first derivatives into account, interest lies in testing the following null hypothesis
H_0: x_{01} = … = x_{0M}
versus the general alternative
H_1: x_{0i} \ne x_{0j} \quad {\rm{for}} \quad {\rm{some}} \quad i, j \in \{ 1, …, M\}.
The above hypothesis is true if d=x_{0j}-x_{0k}=0 where
(j,k)= argmax \quad (l,m) \quad \{1 ≤q l<m ≤q M\} \quad |x_{0l}-x_{0m}|,
otherwise H_0 is false. It is important to highlight that, in practice, the true x_{0j} are not known, and consequently neither is d, so an estimate \hat d = \hat x_{0j}-\hat x_{0k} is used, where, in general, \hat x_{0l} are the estimates of x_{0l} based on the estimated curves \hat m_l with l = 1, … , M.
Needless to say, since \hat d is only an estimate of the true d, the sampling uncertainty of these estimates needs to be acknowledged. Hence, a confidence interval (a,b) is created for d for a specific level of confidence (95%). Based on this, the null hypothesis is rejected if zero is not contained in the interval.
Note that if this hypothesis is rejected (and the factor has more than
two levels), one option could be to use the maxp.diff
function in
order to obtain the differences between each pair of factor's levels.
Note that the models fitted by localtest
function are specified
in a compact symbolic form. The ~ operator is basic in the formation
of such models. An expression of the form y ~ model
is interpreted as
a specification that the response y
is modelled by a predictor
specified symbolically by model
. The possible terms consist of a
variable name or a variable name and a factor name separated by : operator.
Such a term is interpreted as the interaction of the continuous variable and
the factor. However, if smooth = "splines"
, the formula is based on the function
formula.gam of the mgcv package.
The estimate of d value is returned and its confidence interval for a specific-level of confidence, i.e. 95%. Additionally, it is shown the decision, accepted or rejected, of the local test. Based on the null hypothesis is rejected if a zero value is not within the interval.
Marta Sestelo, Nora M. Villanueva and Javier Roca-Pardinas.
Sestelo, M. (2013). Development and computational implementation of estimation and inference methods in flexible regression models. Applications in Biology, Engineering and Environment. PhD Thesis, Department of Statistics and O.R. University of Vigo.
Sestelo, M., Villanueva, N.M., Meira-Machado, L., Roca-Pardinas, J. (2017). npregfast: An R Package for Nonparametric Estimation and Inference in Life Sciences. Journal of Statistical Software, 82(12), 1-27.
library(npregfast) data(barnacle) localtest(DW ~ RC : F, data = barnacle, der = 1, seed = 130853, nboot = 100) # localtest(height ~ s(age, by = sex), data = children, seed = 130853, # der = 1, smooth = "splines")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.