npscoef computes a kernel regression estimate of a one (1)
  dimensional dependent variable on $p$-variate explanatory data,
  using the model $Y_i = W_{i}^{\prime} \gamma (Z_i) + u_i$ where
  $W_i'=(1,X_i')$, given a set of evaluation
  points, training points (consisting of explanatory data and dependent
  data), and a bandwidth specification. A bandwidth specification can be
  a scbandwidth object, or a bandwidth vector, bandwidth type and
  kernel type.npscoef(bws, ...)## S3 method for class 'formula':
npscoef(bws, data = NULL, newdata = NULL, \dots)
## S3 method for class 'call':
npscoef(bws, \dots)
## S3 method for class 'default':
npscoef(bws, txdat, tydat, tzdat, \dots)
## S3 method for class 'scbandwidth':
npscoef(bws,
        txdat = stop("training data 'txdat' missing"),
        tydat = stop("training data 'tydat' missing"),
        tzdat = NULL,
        exdat,
        eydat,
        ezdat,
        residuals = FALSE,
        errors = TRUE,
        iterate = TRUE,
        maxiter = 100,
        tol = .Machine$double.eps,
        leave.one.out = FALSE,
        betas = FALSE,
        ...)
scbandwidth
  object returned from an invocation of npscoefbw, or
    as a vector of bandwidths, with each element $i$ corresponding
    to thebwscaling, bwtype,
    ckertype, ckerorderas.data.frame) containing
    the variables 
    in the model. If not found in data, the variables are taken frozdat, will also correspond to 
    $Z$ from the model eqtxdat. Defaults to
    the training data used to 
    compute the bandwidth object.txdat.txdat.smoothcoefficient object. Defaults to TRUE.smoothcoefficient object. Defaults to
    FALSE.TRUE.100..Machine$double.eps.e[xyz]dat is specified. Defaults to
    FALSE.smoothcoefficient object along with the regression estimates.
    Defaults to FALSE.npscoef returns a smoothcoefficient object.   The generic
  functions fitted, residuals, coef,
  se, and predict,
  extract (or generate) estimated values,
  residuals, coefficients, bootstrapped standard
  errors on estimates, and predictions, respectively, from
  the returned object. Furthermore, the functions summary
  and plot support objects of this type. The returned object
  has the following components:errors = TRUE, standard errors of the
    regression estimatesbetas = TRUE, estimates of the coefficients
    $\gamma$ at the 
    evaluation pointsresiduals = TRUE, in-sample or out-of-sample
    residuals where appropriate (or possible)data.frame function to construct your input data and not
  cbind, since cbind will typically not work as
  intended on mixed data types and will coerce the data to the same
  type.Support for backfitted bandwidths is experimental and is limited in functionality. The code does not support asymptotic standard errors or out of sample estimates with backfitting.
  Cai Z. (2007), 
  Hastie, T. and R. Tibshirani (1993), 
Li, Q. and J.S. Racine (2007), Nonparametric Econometrics: Theory and Practice, Princeton University Press.
  Li, Q. and J.S. Racine (2010), 
Pagan, A. and A. Ullah (1999), Nonparametric Econometrics, Cambridge University Press.
 Racine, J.S. and D. Ouyang and Q. Li (2010), 
bw.nrd, bw.SJ, hist,
  npudens, npudist,
  npudensbw, npscoefbw# EXAMPLE 1 (INTERFACE=FORMULA): 
n <- 250
x <- runif(n)
z <- runif(n, min=-2, max=2)
y <- x*exp(z)*(1.0+rnorm(n,sd = 0.2))
bw <- npscoefbw(y~x|z)
model <- npscoef(bw)
plot(model)
# EXAMPLE 1 (INTERFACE=DATA FRAME): 
n <- 250
x <- runif(n)
z <- runif(n, min=-2, max=2)
y <- x*exp(z)*(1.0+rnorm(n,sd = 0.2))
bw <- npscoefbw(xdat=x, ydat=y, zdat=z)
model <- npscoef(bw)
plot(model)Run the code above in your browser using DataLab