globaltest: Testing the equality of the _M_ curves specific to each level

Description Usage Arguments Details Value Author(s) References Examples

View source: R/globaltest.R


This function can be used to test the equality of the M curves specific to each level.


globaltest(formula, data, na.action = "na.omit", der, smooth = "kernel",
  weights = NULL, nboot = 500, h0 = -1, h = -1, nh = 30,
  kernel = "epanech", p = 3, kbin = 100, seed = NULL, cluster = TRUE,
  ncores = NULL, ...)



An object of class formula: a sympbolic description of the model to be fitted. The details of model specification are given under 'Details'.


An optional data frame, matrix or list required by the formula. If not found in data, the variables are taken from environment(formula), typically the environment from which globaltest is called.


A function which indicates what should happen when the data contain 'NA's. The default is 'na.omit'.


Number which determines any inference process. By default 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 or second derivative, respectively.


Type smoother used: smooth = "kernel" for local polynomial kernel smoothers and smooth = "splines" for splines using the mgcv package.


Prior weights on the data.


Number of bootstrap repeats.


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.


The kernel bandwidth smoothing parameter for the partial effects.


Integer number of equally-spaced bandwidth on which the h is discretised, to speed up computation.


A character string specifying the desired kernel. Defaults to 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, with "triang" and "gaussian" term, respectively.


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.


Number of binning nodes over which the function is to be estimated.


Seed to be used in the bootstrap procedure.


A logical value. If 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 computation. R takes time to distribute tasks across the processors also it will need time for binding them all together later on. Therefore, if the time for distributing and gathering pieces together is greater than the time need for single-thread computing, it does not worth parallelize.


An integer value specifying the number of cores to be used in the parallelized procedure. If NULL (default), the number of cores to be used is equal to the number of cores of the machine - 1.


Other options.


globaltest can be used to test the equality of the M curves specific to each level. This bootstrap based test assumes the following null hypothesis:

H_0^r: m_1^r(\cdot) = … = m_M^r(\cdot)

versus the general alternative

H_1^r: m_i^r (\cdot) \ne m_j^r (\cdot) \quad \rm{for} \quad \rm{some} \quad \emph{i}, \emph{j} \in \{ 1, …, M\}.

Note that, if H_0 is not rejected, then the equality of critical points will also accepted.

To test the null hypothesis, it is used a test statistic, T, based on direct nonparametric estimates of the curves.

If the null hypothesis is true, the T value should be close to zero but is generally greater. The test rule based on T consists of rejecting the null hypothesis if T > T^{1- α}, where T^p is the empirical p-percentile of T under the null hypothesis. To obtain this percentile, we have used bootstrap techniques. See details in references.

Note that the models fitted by globaltest 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 T value and the p-value are returned. Additionally, it is shown the decision, accepted or rejected, of the global test. The null hypothesis is rejected if the p-value< 0.05.


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.


globaltest(DW ~ RC : F, data = barnacle, der = 1, seed = 130853, nboot = 100)

# globaltest(height ~ s(age, by = sex), data = children, 
# seed = 130853, der = 0, smooth = "splines")

npregfast documentation built on Dec. 1, 2017, 1:03 a.m.