132 <strong>np</strong>scoefbwoptimal bandwidths. If specified as a vector, then additional arguments willneed to be supplied as necessary to specify the bandwidth type, kernel types,selection methods, and so on. This can be left unset.... additional arguments supplied to specify the regression type, bandwidth type,kernel types, selection methods, and so on, detailed below.bandwidth.computea logical value which specifies whether to do a numerical search for bandwidthsor not. If set to FALSE, a scbandwidth object will be returned with bandwidthsset to those specified in bws. Defaults to TRUE.bwmethodbwscalingbwtypeckertypeckerordernmultiwhich method was used to select bandwidths. cv.ls specifies least-squarescross-validation, which is all that is currently supported. Defaults to cv.ls.a logical value that when set to TRUE the supplied bandwidths are interpretedas ‘scale factors’ (c j ), otherwise when the value is FALSE they are interpretedas ‘raw bandwidths’ (h j for continuous datatypes, λ j for discrete datatypes). Forcontinuous datatypes, c j and h j are related by the formula h j = c j σ j n −1/(2P +l) ,where σ j is the standard deviation of continuous variable j, n the number of observations,P the order of the kernel, and l the number of continuous variables.For discrete datatypes, c j and h j are related by the formula h j = c j n −2/(2P +l) ,where here j denotes discrete variable j. Defaults to FALSE.character string used for the continuous variable bandwidth type, specifying thetype of bandwidth provided. Defaults to fixed. Option summary:fixed: fixed bandwidths or scale factorsgeneralized_nn: generalized nearest neighborsadaptive_nn: adaptive nearest neighborscharacter string used to specify the continuous kernel type. Can be set as gaussian,epanechnikov, or uniform. Defaults to gaussian.numeric value specifying kernel order (one of (2,4,6,8)). Kernel order specifiedalong with a uniform continuous kernel type will be ignored. Defaults to2.integer number of times to restart the process of finding extrema of the crossvalidationfunction from different (random) initial points. Defaults to min(5,ncol(xdat)).optim.method method used by optim for minimization of the objective function. See ?optimfor references. Defaults to "Nelder-Mead".the default method is an implementation of that of Nelder and Mead (1965),that uses only function values and is robust but relatively slow. It will workreasonably well for non-differentiable functions.method "BFGS" is a quasi-Newton method (also known as a variable metricalgorithm), specifically that published simultaneously in 1970 by Broyden,Fletcher, Goldfarb and Shanno. This uses function values and gradients to buildup a picture of the surface to be optimized.method "CG" is a conjugate gradients method based on that by Fletcher andReeves (1964) (but with the option of Polak-Ribiere or Beale-Sorenson updates).Conjugate gradient methods will generally be more fragile than theBFGS method, but as they do not store a matrix they may be successful in muchlarger optimization problems.
<strong>np</strong>scoefbw 133optim.maxattemptsmaximum number of attempts taken trying to achieve successful convergence inoptim. Defaults to 100.optim.abstol the absolute convergence tolerance used by optim. Only useful for non-negativefunctions, as a tolerance for reaching zero. Defaults to .Machine$double.eps.optim.reltol relative convergence tolerance used by optim. <strong>The</strong> algorithm stops if it is unableto reduce the value by a factor of ’reltol * (abs(val) + reltol)’ at a step.Defaults to sqrt(.Machine$double.eps), typically about 1e-8.optim.maxit maximum number of iterations used by optim. Defaults to 500.cv.iterate boolean value specifying whether or not to perform iterative, cross-validatedbackfitting on the data. See details for limitations of the backfitting procedure.Defaults to FALSE.cv.num.iterationsinteger specifying the number of times to iterate the backfitting process over allcovariates. Defaults to 1.backfit.iterateboolean value specifying whether or not to iterate evaluations of the smoothcoefficient estimator, for extra accuracy, during the cross-validated backfittingprocedure. Defaults to FALSE.backfit.maxiterinteger specifying the maximum number of times to iterate the evaluation ofthe smooth coefficient estimator in the attempt to obtain the desired accuracy.Defaults to 100.Detailsbackfit.toltolerance to determine convergence of iterated evaluations of the smooth coefficientestimator. Defaults to .Machine$double.eps.<strong>np</strong>scoefbw implements a variety of methods for semiparametric regression on multivariate (p+qvariate)explanatory data defined over a set of possibly continuous data. <strong>The</strong> approach is based onLi and Racine (2003) who employ ‘generalized product kernels’ that admit a mix of continuous anddiscrete datatypes.Three classes of kernel estimators for the continuous datatypes are available: fixed, adaptive nearestneighbor,and generalized nearest-neighbor. Adaptive nearest-neighbor bandwidths change witheach sample realization in the set, x i , when estimating the density at the point x. Generalizednearest-neighbor bandwidths change with the point at which the density is estimated, x. Fixedbandwidths are constant over the support of x.<strong>np</strong>scoefbw may be invoked either with a formula-like symbolic description of variables on whichbandwidth selection is to be performed or through a simpler interface whereby data is passed directlyto the function via the xdat, ydat, and zdat parameters. Use of these two interfaces ismutually exclusive.Data contained in the data frame xdat may be continuous and in zdat may be of mixed type. Datacan be entered in an arbitrary order and data types will be detected automatically by the routine (see<strong>np</strong> for details).Data for which bandwidths are to be estimated may be specified symbolically. A typical descriptionhas the form dependent data ~ parametric explanatory data | no<strong>np</strong>arametric
- Page 1 and 2:
The np PackageFebruary 16, 2008Vers
- Page 3 and 4:
Italy 3Examplesdata("cps71")attach(
- Page 5 and 6:
wage1 5Examplesdata("oecdpanel")att
- Page 7 and 8:
gradients 7## S3 method for class '
- Page 9 and 10:
np 9A variety of bandwidth methods
- Page 11 and 12:
npcmstest 11npcmstestKernel Consist
- Page 13 and 14:
npcmstest 13ReferencesAitchison, J.
- Page 15 and 16:
npcdens 15npcdensKernel Conditional
- Page 17 and 18:
npcdens 17Valuenpcdens returns a co
- Page 19 and 20:
npcdens 19# Gaussian kernel (defaul
- Page 21 and 22:
npcdens 21# (1993) (see their descr
- Page 23 and 24:
npcdensbw 23fit
- Page 25 and 26:
npcdensbw 25na.actionxdatydatbwspro
- Page 27 and 28:
npcdensbw 27data. The approach is b
- Page 29 and 30:
npconmode 29# depending on the spee
- Page 31 and 32:
npconmode 31tydatexdateydata one (1
- Page 33 and 34:
npconmode 33lwt,family=binomial(lin
- Page 35 and 36:
npudens 35npudensKernel Density and
- Page 37 and 38:
npudens 37Author(s)Tristen Hayfield
- Page 39 and 40:
npudens 39# EXAMPLE 1 (INTERFACE=DA
- Page 41 and 42:
npudensbw 41library("datasets")data
- Page 43 and 44:
npudensbw 43bwsa bandwidth specific
- Page 45 and 46:
npudensbw 45fvalobjective function
- Page 47 and 48:
npudensbw 47# previous examples.bw
- Page 49 and 50:
npudensbw 49# previous examples.bw
- Page 51 and 52:
npksum 51Argumentsformuladatanewdat
- Page 53 and 54:
npksum 53Usage IssuesIf you are usi
- Page 55 and 56:
npksum 55# the bandwidth object its
- Page 57 and 58:
npksum 57ss
- Page 59 and 60:
npplot 59plot.behavior = c("plot","
- Page 61 and 62:
npplot 61xtrim = 0.0,neval = 50,com
- Page 63 and 64:
npplot 63xdatydatzdatxqyqzqxtrimytr
- Page 65 and 66:
npplot 65DetailsValuenpplot is a ge
- Page 67 and 68:
npplot 67year.seq
- Page 69 and 70:
npplot 69# npplot(). When npplot()
- Page 71 and 72:
npplreg 71## S3 method for class 'c
- Page 73 and 74:
npplreg 73residR2MSEMAEMAPECORRSIGN
- Page 75 and 76:
npplreg 75# Plot the regression sur
- Page 77 and 78:
npplregbw 77and dependent data), an
- Page 79 and 80:
npplregbw 79Detailsnpplregbw implem
- Page 81 and 82: npplregbw 81x2
- Page 83 and 84: npqcmstest 83npqcmstestKernel Consi
- Page 85 and 86: npqcmstest 85Author(s)Tristen Hayfi
- Page 87 and 88: npqreg 87ftol = 1.19209e-07,tol = 1
- Page 89 and 90: npqreg 89Li, Q. and J.S. Racine (20
- Page 91 and 92: npreg 91Usagenpreg(bws, ...)## S3 m
- Page 93 and 94: npreg 93residR2MSEMAEMAPECORRSIGNif
- Page 95 and 96: npreg 95summary(model)# Use npplot(
- Page 97 and 98: npreg 97# - this may take a few min
- Page 99 and 100: npreg 99# then a noisy samplen
- Page 101 and 102: npregbw 101## S3 method for class '
- Page 103 and 104: npregbw 103ckerorderukertypeokertyp
- Page 105 and 106: npregbw 105ReferencesAitchison, J.
- Page 107 and 108: npsigtest 107bw
- Page 109 and 110: npsigtest 109Author(s)Tristen Hayfi
- Page 111 and 112: npindex 111Usagenpindex(bws, ...)##
- Page 113 and 114: npindex 113MAEMAPECORRSIGNif method
- Page 115 and 116: npindex 115x2
- Page 117 and 118: npindex 117# x1 is chi-squared havi
- Page 119 and 120: npindexbw 119# plotting via persp()
- Page 121 and 122: npindexbw 121methodnmultithe single
- Page 123 and 124: npindexbw 123allows one to deploy t
- Page 125 and 126: npscoef 125x1
- Page 127 and 128: npscoef 127Valueeydatezdaterrorsres
- Page 129 and 130: npscoef 129# We could manually plot
- Page 131: npscoefbw 131optim.abstol,optim.max
- Page 135 and 136: npscoefbw 135ReferencesAitchison, J
- Page 137 and 138: uocquantile 137uocquantileCompute Q
- Page 139: INDEX 139npconmode, 29npindex, 110n