eps_hat: Residual calculation

Description Usage Arguments Details Value Examples

View source: R/cond_var.R

Description

Calculates residuals after nonparametric regression using lprobust or locPolSmootherC.

Usage

1
eps_hat(y, x, deg, kern = "epa", var.reg = "npr", n.max = 500)

Arguments

y

vector of dependent variables

x

vector of regressors

deg

degree of local polynomial regression to be used

kern

kernel used to calculate conditional variance function; supports "tri", "epa", "uni", and "gau". Default is kern = "epa".

var.reg

nonparametric regression method used to calculate residuals; either "npr" (standing for nprobust package) or "locpol" (standing for locpol package). Default is var.reg = "npr".

n.max

maximum number of observations allowed where the regression function estimator is evaluated when var.reg = "npr". If length(x) > n.max, the regression function estimator is evaluated over a grid of the length n.max, and the regression function estimate over x is obtained by linear interpolation. The default is n.max = 500.

Details

For now, only kern = "tri" and kern = "epa" are supported when var.reg = "locpol".

Value

vector of residuals with the same length as y

Examples

1
2
3
4
x <- seq(from = -1, to = 1, length.out = 500)
y <- x^2 + stats::rnorm(500, 0, 0.1)
eps_hat(y, x, 1)
eps_hat(y, x, 1, var.reg = "locpol")

koohyun-kwon/HTEBand documentation built on Dec. 21, 2021, 7:42 a.m.