simpleSmoothers {locpol}R Documentation

Simple smoother

Description

Computes simple kernel smoothing

Usage

  simpleSmootherC(x, y, xeval, bw, kernel, weig = rep(1, length(y)))
  simpleSqSmootherC(x, y, xeval, bw, kernel)

Arguments

x x covariate data values.
y y response data values.
xeval Vector with evaluation points.
bw Smoothing parameter, bandwidth.
kernel Kernel used to perform the estimation, see Kernels
weig weights if they are required.

Details

Computes simple smoothing, that is to say: it averages y values times kernel evaluated on x values. simpleSqSmootherC does the average with the square of such values.

Value

Both functions returns a data.frame with

x $x$ evaluation points.
reg the smoothed values at x points.

...

Author(s)

Jorge Luis Ojeda Cabrera.

See Also

PRDenEstC, Kernel characteristics

Examples

        size <- 1000
        x <- runif(100)
        bw <- 0.125
        kernel <- EpaK
        xeval <- 1:9/10
        y <- rep(1,100) 
        ##      x kern. aver. should give density f(x)
        prDen <- PRDenEstC(x,xeval,bw,kernel)$den
        ssDen <- simpleSmootherC(x,y,xeval,bw,kernel)$reg
        all(abs(prDen-ssDen)<1e-15)
        ##      x kern. aver. should be f(x)*R2(K) aprox.
        s2Den <- simpleSqSmootherC(x,y,xeval,bw,kernel)$reg
        summary( abs(prDen*RK(kernel)-s2Den) )
        summary( abs(1*RK(kernel)-s2Den) )
        ##      x kern. aver. should be f(x)*R2(K) aprox.
        for(n in c(1000,1e4,1e5))
        {
                s2D <- simpleSqSmootherC(runif(n),rep(1,n),xeval,bw,kernel)$reg
                cat("\n",n,"\n")
                print( summary( abs(1*RK(kernel)-s2D) ) )
        }

[Package locpol version 0.2-0 Index]