Library: | times |
See also: | epa |
Quantlet: | elmtest | |
Description: | This quantlet calculates the empirical likelihood test statistic for the conditional expectation E[Y|X=x] of a time series (X,Y). X and Y are one-dimensional. |
Usage: | {el,p,kn,h2} = elmtest(x,y,model{,kernel{,h{,theta}}}) | |
Input: | ||
x | n x 1 vector of x observations | |
y | n x 1 vector of y observations | |
model | string, name of a quantlet that implements the parametric model for the null hypothesis | |
kernel | string, kernel function that is used to calculate the Nadaraya-Watson estimator and the test statistic, if no kernel is given, "epa" is used | |
h | scalar, the bandwidth used for the nonparametric estimation | |
theta | optional parameter for the parametric model | |
Output: | ||
el | scalar, the value of the EL test statistic | |
p | scalar, the p-value of the test, calculated from a chi^2 distribution | |
kn | scalar, degrees of freedom of the chi^2 distribution | |
h2 | scalar, the bandwidth, used for the nonparametric smoother and the test statistic. If the input parameter h is given, h2 = h. |
The quantlet for the parametric null hypothesis must have the following form:
proc(y) = paramodel(x) // or paramodel(x,theta)
...
endp
where x and y are (n x 1) vectors.
randomize(1234) library("smoother") library("kernel") func("elmtest") // definition of the drift function proc(y) = drift(x,theta) y =2*x/(1+x^2)+theta*sin(x) endp proc(el)=eltestexample() n=2000 i=-99 y=0 while(i < n) ; simulation of the time series with theta = 0.06 i = i+1 tmp = drift(y[i+99],0.06)+exp((-(y[i+99]^2))/4)*(2*uniform(1)-1) y = y|tmp endo y=y[101:(n+100)] ; we pre-run the series to ensure stationarity d = createdisplay(1,1) show(d,1,1,y[1:(n-1)]~y[2:n]) ; plot of the drift function + noise h = lpregrot(y[1:(n-1)]~y[2:n]) el = elmtest(y[1:(n-1)],y[2:n],"drift","epa",h,0) ; test about the drift with theta = 0 endp el = eltestexample() el
A plot of the conditional expectation and noise is shown. Contents of el.el [1,] 16.379 ; the value of the test-statistic Contents of el.p [1,] 0.011856 ; the p-value, i.e. 1-cdfchi2(el,kn) Contents of el.kn [1,] 6 ; the degrees of freedom Contents of el.h2 [1,] 0.28261 ; the bandwidth used for the nonparametric fit