Description Usage Arguments Details Value Examples
This performs grid search to find the best bandwidth for the fitted semiparametric binary response model.
1 2 3 4 5 6 | BandwidthGridSearch(
fit,
criterion = "McF.R2",
n.bandwidth = 50,
bandwidth = NULL
)
|
fit |
a fitted 'semiBRM' object. |
criterion |
a character indicating the criterion to be used for evaluation. It can be one in c("McF.R2", "accuracy", "precision") (see Details). |
n.bandwidth |
an integer of the number of bandwidths to be searched. |
bandwidth |
a vector of bandwidths to be evaluated. |
Evaluation is based on in-sample semiparametric conditional probability Pr(Y=1|X), which is obtained from the leave-one-out version of the Gaussian Nadaraya-Watson estimator.
This function first randomly generates n.bandwidth
candidates from a uniform distribution
with range [h0/3, 3*h0]
, where h0
is the Silverman's rule of thumb bandwidth,
h0 = sd(v)*1.06*N^(-1/5)
. Then, it computes 'performance' according to the given
criterion
over the candidates and picks up the 'best' one.
criterion = "McF.R2"
employs the McFadden’s pseudo R-squared for assessment.
For criterion = "accuracy"
or criterion = "precision"
, the function first predicts
binary response using the semiparametric conditional probability, assigning 1 if
the probability is greater than or equal to 0.5 and 0 otherwise. Then, it calculates the
confusion matrix and predictive accuracy or precision. In turn, the maximizer of the predictive
accuracy or precision becomes the best bandwidth.
a list with bandwidth.best
: the best bandwidth found, criterion.value
:
its criterion value, criterion
: the choice of criterion, and bandwith
:
the scoreboard for candidates.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # data generating process
N <- 500L
X1 <- rnorm(N)
X2 <- (X1 + 2*rnorm(N))/sqrt(5) + 1
X3 <- rnorm(N)^2/sqrt(2)
X <- cbind(X1, X2, X3)
beta <- c(2, 2, -1, -1)
V <- as.vector(cbind(X, 1)%*%beta)
Y <- ifelse(V >= rnorm(N), 1L, 0L)
# parameter estimation
qmle <- semiBRM(x = X, y = Y, control = list(iterlim=50))
# bandwidth search
h1 <- BandwidthGridSearch(qmle)
h2 <- BandwidthGridSearch(qmle, criterion = "accuracy", bandwidth = h1$bandwidth[,1L])
h3 <- BandwidthGridSearch(qmle, criterion = "precision", bandwidth = h1$bandwidth[,1L])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.