span.H.select: A method to select the span of the sequence of lambda's for...

Description Usage Arguments Author(s) References See Also Examples

View source: R/NPsimex.R

Description

To compute the optimal span of the sequence of lambda's for the case of heteroscedastic error.

Usage

1
 span.H.select(W, msigma, span=c(2,4,6,8,10,12,25), approx=FALSE, from=min(W), to=max(W), n.user=128, n.lambda=50, lambda="SJ", bw="SJ", adjust=1, na.rm = FALSE, ...)

Arguments

W

The observed data. It is a vector of length at least 10.

msigma

The standard deviation σ of measurement error. It is a single positive numeric value.

span

span is user-defined grids where the PDF will be evaluated.

approx

FALSE by default; if TRUE, the lose function uses the same one as the one of the homoscedastic error case with the average of measurement error variances

from

the starting point where the PDF is to be evaluated.

to

the starting point where the PDF is to be evaluated.

n.user

number of points where the PDF is to be evaluated.

n.lambda

number of points of lambda's.

lambda

Specifies the first lambda. It can be a single numeric value which has been pre-determined; or computed with the specific density bandwidth selector: 'nrd0', 'nrd', 'ucv', 'bcv', 'SJ'.

bw

Specifies the bandwidth of 'W'. It can be a single numeric value which has been pre-determined; or computed with the specific density bandwidth selector: 'nrd0', 'nrd', 'ucv', 'bcv', 'SJ'.

adjust

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

na.rm

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

...

control

Author(s)

X.F. Wang wangx6@ccf.org

References

Wang, X.F., Sun, J. and Fan, Z. (2011). Deconvolution density estimation with heteroscedastic errors using SIMEX.

See Also

simex.density.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
plot.simex.density <- function(X.simex,X,...){
	plot(X.simex$x, X.simex$y, type="l", xlab="x", ylab="density", lwd=3, lty=2, col=2,...)
	lines(density(X, bw="SJ"), lwd=3)
	}

############### Heteroscadestic error
N <- 1000
set.seed(123); X <- c(rnorm(N/2, mean=-2), rnorm(N/2,mean=2)); U <- rnorm(N,sd=1); msigma <- runif(N,min=0.3,max=0.5)
W <- X + msigma*U

plot.simex.density <- function(X.simex,X,...){
	plot(X.simex$x, X.simex$y, type="l", xlab="x", ylab="density", lwd=3, lty=2, col=2,...)
	lines(density(X, bw="SJ"), lwd=3)
	}


#---- Select the optimal lambda span
par(mfrow=c(1,2))
spans <- span.H.select(W, msigma, span=c(2,4,6,8,10,12,16,25), approx=TRUE)
plot(spans$span, spans$ISE, type="o", xlab="span", ylab="ISE") 

X.simex <- simex.H.density(W, msigma=msigma, adjust=1, n.lambda=50, span=spans$span[order(spans$ISE)[1]])
plot.simex.density(X.simex, X,ylim=c(0,0.25))

## more computational time needed if approx=FALSE.

# spans <- span.H.select(W, msigma, span=c(2,4,6,8,10,12,16,25), approx=FALSE)
# plot(spans$span, spans$ISE, type="o", xlab="span", ylab="ISE") 
# 
# X.simex <- simex.H.density(W, msigma=msigma, adjust=1, n.lambda=50, span=spans$span[order(spans$ISE)[1]])
# plot.simex.density(X.simex, X,ylim=c(0,0.25))

NPsimex documentation built on May 1, 2019, 6:32 p.m.