Local-Linear Estimation and Bandwidth Selection

Kai Sun

Overview

This vignette describes the local-linear tools in spscsfa:

The local-linear estimator uses a generalized product kernel. Numeric z variables are treated as continuous, factors as unordered categorical variables, and ordered factors as ordered categorical variables.

Simulated data

library(spscsfa)


set.seed(42)

n <- 100

x <- rnorm(n)

z1 <- runif(n)

z2 <- runif(n)

v <- rnorm(n, 0, 0.1)

u <- exp(0.1 + 0.1 * z1 + 0.1 * z2) * abs(rnorm(n, 0, 1))

y <- cos(z1 + z2) + sin(z1 - z2) * x + v - u


dat <- data.frame(y = y, x = x, z1 = z1, z2 = z2)

head(dat)

#>             y          x        z1         z2

#> 1  0.53017256  1.3709584 0.8851177 0.48376814

#> 2 -0.36041847 -0.5646982 0.5171111 0.44456953

#> 3  0.94018395  0.3631284 0.8519310 0.06038559

#> 4  0.11902400  0.6328626 0.4427963 0.32750602

#> 5 -0.07457432  0.4042683 0.1578801 0.87842905

#> 6  0.05788620 -0.1061245 0.4423246 0.93060489

Select local-linear bandwidths

llscoefbw() selects fixed bandwidths by least-squares cross-validation. Its search combines a Nelder–Mead optimization from the starting bandwidths with a coarse scan and, when appropriate, additional searches from promising scan points.

The default scan multipliers are

2^c(-2:5)

#> [1]  0.25  0.50  1.00  2.00  4.00  8.00 16.00 32.00

That is, the continuous starting bandwidths are multiplied by 1/4,1/2,1,2,4,8,16,32 for the scan. With mixed continuous and categorical z variables, the scan changes the continuous starting bandwidths together while leaving categorical starting bandwidths unchanged. The grid_scan argument allows a different strictly increasing vector of finite positive multipliers. Setting max.search = 1 skips the scan and runs only the initial search. The following is a flow diagram that briefly illustrates the bandwidth selection algorithm for the local-linear smooth-coefficient estimator: