localtest(formula, data = data, 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, ...)formula: a sympbolic
description of the model to be fitted. The details of model
specification are given under 'Details'.formula.der is NULL. If this term is 0,
the testing procedures is applied for the estimate. If it is 1 or
2, it is designed for the first smooth = "kernel" for local polynomial
kernel smoothers and smooth = "splines" for splines using the
mgcv package.h is discretised, to speed up computation.kernel = "epanech", where the Epanechnikov
density function kernel will be used. Also, several types of kernel funcitons
can be used: triangular and Gaussian density function,
x value which maximizes the
estimate, first or second derivative (for each level). The default
is the minimum data value.x value which maximizes the
estimate, first or second derivative (for each level). The default
is the maximum data value.TRUE (default), the
bootstrap procedure is parallelized (only for smooth = "splines".
Note that there are cases
(e.g., a low number of bootstrap repetitions) that R will gain in
performance through serial NULL (default), the number of cores
to be used is equal to the number of cores of the machine - 1.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} = \ldots = x_{0M}$$
versus the general alternative
$$H_1: x_{0i} \ne x_{0j} \quad {\rm{for}} \quad {\rm{some}} \quad \emph{i}, \emph{j} \in { 1, \ldots, M}.$$
The above hypothesis is true if $d=x_{0j}-x_{0k}=0$ where
$$(j,k)= argmax \quad (l,m) \quad {1 \leq l 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, \ldots , 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 Note that the models fitted by maxp.diff function in
order to obtain the differences between each pair of factor's levels.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.
library(npregfast)
data(barnacle)
localtest(DW ~ RC : F, data = barnacle, der = 1, seed = 130853, nboot = 100)Run the code above in your browser using DataLab