npreg: Nonparametric regression based on data with unknown...

Description Usage Arguments Details Value References See Also Examples

View source: R/unknownME.R

Description

To compute nonparametric regression line from data contaminated with measurement error. The measurement error type is unknown.

Usage

1
 npreg(w, y, e, bw, adjust = 1, n = 512, from, to, cut = 0, na.rm = FALSE,...) 

Arguments

w,y

The observed data W and Y. It is a vector of length at least 3.

e

Observed vector of measurement errors.

bw

Smoothing parameter.

adjust

adjust the range there the PDF is to be evaluated. By default, adjust=1.

n

number of points where the PDF is to be evaluated.

from

the starting point where the PDF is to be evaluated.

to

the starting point where the PDF is to be evaluated.

cut

used to adjust the starting end ending points where the PDF is to be evaluated.

na.rm

is set to FALSE by default: no NA value is allowed.

...

controls

Details

The optimal bandwidth is selected by minimizing abs(Var(f.hat)+Var(E)-Var(Y)).

Value

An object of class “Decon”.

References

Wang, X.F. and Wang, B. (2011). Deconvolution estimation in measurement error models: The R package decon. Journal of Statistical Software, 39(10), 1-24.

See Also

DeconCdf, DeconNpr, DeconCPdf.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
n <- 2000
x <- c(rnorm(n/2,2,1), rnorm(n/2, -2,1))
sig <- .8
u <- sig*rnorm(n)
w <- x+u
e <- rnorm(n, sd=0.2)
y <- x^2-2*x+e
bw1 <- bw.dboot1(w, sig)
u0 <- sig*rnorm(n/2) # typically the size of u0 is smaller than x.
m2 <- npreg(w, y, u0, from=0.9*min(x), to=0.9*max(x))

# plot the results
plot(m2, col="red", lwd=3, lty=2, xlab="x", ylab="m(x)", main="", 
			zero.line=FALSE)
lines(ksmooth(x,y, kernel = "normal", 2, range.x=c(0.9*min(x),0.9*max(x))), 
			lwd=3, lty=1)
lines(ksmooth(w,y, kernel = "normal", 2, range.x=c(0.9*min(x),0.9*max(x))), 
			col="blue", lwd=3, lty=3)

decon documentation built on Oct. 21, 2021, 1:07 a.m.

Related to npreg in decon...