R/NWW.R

Defines functions NWW

Documented in NWW

#' Nadaraya-Watson weights.
#' 
#' Computes the Nadaraya-Watson weights.
#' 
#' Possible options for argument window are "gaussian", "epanechnikov",
#' "tricube", "boxcar", "triangular", "quartic" or "cosine".
#' 
#' @param covariate Covariate values for obtaining weights.
#' @param x Covariate value to compute the weight at.
#' @param kernel A character string specifying the desired kernel. See details
#' below for possible options. Defaults to "gaussian" where the gaussian
#' density kernel will be used.
#' @param bw A single numeric value to compute a kernel density bandwidth.
#' @return A vector with Nadaraya-Watson weights.
#' @author Luis Meira-Machado and Marta Sestelo
#' @seealso \code{\link{LLW}}
#' @examples
#' 
#' NWW(covariate = colonCS$age, x=40, kernel = "gaussian", bw = 3)
#' 
NWW <-
  function(covariate, x, kernel="gaussian", bw) {
    spa <- NULL
    len <- length(covariate)
    listg <- .C( "NWWeightsKernel", as.double(covariate), as.integer(len),
                 as.double(x), as.double(bw), as.character(kernel),
                 weight = double(len) )
    return(listg$weight)}

Try the condSURV package in your browser

Any scripts or data that you put into this service are public.

condSURV documentation built on March 7, 2023, 5:19 p.m.