np.ancova {PLRModels} | R Documentation |
Nonparametric analysis of covariance
Description
This routine tests the equality of L
nonparametric regression curves (m_1, ..., m_L
) from samples {(Y_{ki}, t_i): i=1,...,n}
, k=1,...,L
, where:
Y_{ki}= m_k(t_i) + \epsilon_{ki}.
The unknown functions m_k
are smooth, fixed equally spaced design is considered, and the random errors, \epsilon_{ki}
, are allowed to be time series. The test statistic used for testing the null hypothesis, H0: m_1 = ...= m_L
, derives from a Cramer-von-Mises-type functional based on different distances between nonparametric estimators of the regression functions.
Usage
np.ancova(data = data, h.seq = NULL, w = NULL, estimator = "NW",
kernel = "quadratic", time.series = FALSE, Tau.eps = NULL,
h0 = NULL, lag.max = 50, p.max = 3, q.max = 3, ic = "BIC",
num.lb = 10, alpha = 0.05)
Arguments
data |
|
h.seq |
the statistic test is performed using each bandwidth in the vector |
w |
support interval of the weigth function in the test statistic. If |
estimator |
allows us the choice between “NW” (Nadaraya-Watson) or “LLP” (Local Linear Polynomial). The default is “NW”. |
kernel |
allows us the choice between “gaussian”, “quadratic” (Epanechnikov kernel), “triweight” or “uniform” kernel. The default is “quadratic”. |
time.series |
it denotes whether the data are independent (FALSE) or if data is a time series (TRUE). The default is FALSE. |
Tau.eps |
|
h0 |
if |
lag.max |
if |
p.max |
if |
q.max |
if |
ic |
if |
num.lb |
if |
alpha |
if |
Details
A weight function (specifically, the indicator function 1_{[w[1] , w[2]]}
) is introduced in the test statistic to allow elimination (or at least significant reduction) of boundary effects from the estimate of m(t_i)
.
If Tau.eps=NULL
and the routine is not able to suggest an approximation for Tau.eps
, it warns the user with a message saying that the model could be not appropriate and then it shows the results. In order to construct Tau.eps
, the procedures suggested in Muller and Stadmuller (1988) and Herrmann et al. (1992) can be followed.
For more details, see Vilar-Fernandez and Gonzalez-Manteiga (2004).
Value
A list with a dataframe containing:
h.seq |
sequence of bandwidths used in the test statistic. |
Q.m |
values of the test statistic (one for each bandwidth in |
Q.m.normalised |
normalised value of Q.m. |
p.value |
p-values of the corresponding statistic tests (one for each bandwidth in |
Moreover, if data
is a time series and Tau.eps
is not especified:
pv.Box.test |
p-values of the Ljung-Box test for the model fitted to the residuals. |
pv.t.test |
p-values of the t.test for the model fitted to the residuals. |
ar.ma |
ARMA orders for the model fitted to the residuals. |
Author(s)
German Aneiros Perez ganeiros@udc.es
Ana Lopez Cheda ana.lopez.cheda@udc.es
References
Dette, H. and Neumeyer, N. (2001) Nonparametric analysis of covariance. Ann. Statist. 29, no. 5, 1361-1400.
Herrmann, E., Gasser, T. and Kneip, A. (1992) Choice of bandwidth for kernel regression when residuals are correlated. Biometrika 79, 783-795
Muller, H.G. and Stadmuller, U. (1988) Detecting dependencies in smooth regression models. Biometrika 75, 639-650
Vilar-Fernandez, J.M. and Gonzalez-Manteiga, W. (2004) Nonparametric comparison of curves with dependent errors. Statistics 38, 81-99.
See Also
Other related functions are np.est
, par.ancova
and plrm.ancova
.
Examples
# EXAMPLE 1: REAL DATA
data <- matrix(10,120,2)
data(barnacles1)
barnacles1 <- as.matrix(barnacles1)
data[,1] <- barnacles1[,1]
data <- diff(data, 12)
data[,2] <- 1:nrow(data)
data2 <- matrix(10,120,2)
data(barnacles2)
barnacles2 <- as.matrix(barnacles2)
data2[,1] <- barnacles2[,1]
data2 <- diff(data2, 12)
data2[,2] <- 1:nrow(data2)
data3 <- matrix(0, nrow(data),ncol(data)+1)
data3[,1] <- data[,1]
data3[,2:3] <- data2
np.ancova(data=data3)
# EXAMPLE 2: SIMULATED DATA
## Example 2.1: dependent data: true null hypothesis
set.seed(1234)
# We generate the data
n <- 100
t <- ((1:n)-0.5)/n
m1 <- function(t) {0.25*t*(1-t)}
f <- m1(t)
epsilon1 <- arima.sim(list(order = c(1,0,0), ar=0.7), sd = 0.01, n = n)
y1 <- f + epsilon1
epsilon2 <- arima.sim(list(order = c(0,0,1), ma=0.5), sd = 0.02, n = n)
y2 <- f + epsilon2
data_eq <- cbind(y1, y2, t)
# We apply the test
np.ancova(data_eq, time.series=TRUE)
## Example 2.2: dependent data: false null hypothesis
# We generate the data
n <- 100
t <- ((1:n)-0.5)/n
m3 <- function(t) {0.25*t*(1-t)}
m4 <- function(t) {0.25*t*(1-t)*0.75}
f3 <- m3(t)
epsilon3 <- arima.sim(list(order = c(1,0,0), ar=0.7), sd = 0.01, n = n)
y3 <- f3 + epsilon3
f4 <- m4(t)
epsilon4 <- arima.sim(list(order = c(0,0,1), ma=0.5), sd = 0.02, n = n)
y4 <- f4 + epsilon4
data_neq<- cbind(y3, y4, t)
# We apply the test
np.ancova(data_neq, time.series=TRUE)