Learn R Programming

rddtools (version 1.6.0)

as.npregbw: Convert an rdd_reg object to a npreg object

Description

Convert an rdd_object to a non-parametric regression npreg from package np

Usage

as.npregbw(x, ...)

as.npreg(x, ...)

Arguments

x

Object of class rdd_reg created by rdd_reg_np or rdd_reg_lm

Further arguments passed to the npregbw or npreg

Value

An object of class npreg or npregbw

Details

This function converts an rdd_reg object into an npreg object from package np Note that the output won't be the same, since npreg does not offer a triangular kernel, but a Gaussian or Epanechinkov one. Another reason why estimates might differ slightly is that npreg implements a multivariate kernel, while rdd_reg proceeds as if the kernel was univariate. A simple solution to make the multivariate kernel similar to the univariate one is to set the bandwidth for x and Dx to a large number, so that they converge towards a constant, and one obtains back the univariate kernel.

See Also

as.lm which converts rdd_reg objects into lm.

Examples

Run this code
# NOT RUN {
# Estimate ususal rdd_reg:
 data(house)
 house_rdd <- rdd_data(y=house$y, x=house$x, cutpoint=0)
 reg_nonpara <- rdd_reg_np(rdd_object=house_rdd)

## Convert to npreg:
 reg_nonpara_np <- as.npreg(reg_nonpara)
 reg_nonpara_np
 rdd_coef(reg_nonpara_np, allCo=TRUE, allInfo=TRUE)

## Compare with result obtained with a Gaussian kernel:
 bw_lm <- dnorm(house_rdd$x, sd=rddtools:::getBW(reg_nonpara))
 reg_nonpara_gaus <- rdd_reg_lm(rdd_object=house_rdd, w=bw_lm)
 all.equal(rdd_coef(reg_nonpara_gaus),rdd_coef(reg_nonpara_np)) 
# }

Run the code above in your browser using DataLab