deamer.ke: Density estimation with known error density

Description Usage Arguments Details Value Warning Author(s) References See Also Examples

Description

deamerKE performs a deconvolution estimation of the density of a noisy variable ('y') under the hypothesis of a known density of the noise ("KE" for "known error"). deamerKE allows to choose between a Gaussian or a Laplace density for the noise. The standard deviation of the noise (resp. the scale parameter) is required. By default, deamerKE will consider the noise centered around zero.

Usage

1
deamerKE(y, mu, sigma, noise.type, grid.length = 100, from, to, na.rm = FALSE)

Arguments

y

Numeric. The vector of noisy observations

mu

Numeric. The (known) mean of the noise. Defaults to zero.

sigma

Numeric. The (known) standard deviation of the noise if noise.type="Gaussian" or scale if noise.type="Laplace"

noise.type

Character. Defines the type of density for the noise. Only "Gaussian" or "Laplace" are supported. Defaults to "Gaussian"

grid.length

Numeric. Optional. The number of points of the grid the estimation is performed on. Defaults to 100.

from

Numeric. Optional. The lower bound of the grid the estimation is performed on. Defaults to min(y).

to

Numeric. Optional. The upper bound of the grid the estimation is performed on. Defaults to max(y).

na.rm

Logical. Optional. If na.rm=TRUE, NAs will be removed before estimation. Defaults to FALSE.

Details

The model is y = x + e where x has an unknown density f and e is a symmetric variable around mu (either Laplace or Gaussian). Therefore, deamerKE can directly handle non-centered noise by specifying mu.
The Gaussian mean and standard deviation have the general meaning. The Laplace density function is parameterized as:

exp(-|x-mu|/sigma)/(2sigma)

Value

An object of class 'deamer'

Warning

deamerKE is not implemented for heteroscedastic errors.

Author(s)

Julien Stirnemann <j.stirnemann@gmail.com>

References

Comte F, Rozenholc Y, Taupin M-L. Penalized Contrast Estimator for Adaptive Density Deconvolution. The Canadian Journal of Statistics / La Revue Canadienne de Statistique. 2006; 34(3):431-52.

See Also

deamer, deamerRO, deamerSE, deamer-class

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#########################################################
#EXAMPLE 1: known error, Laplacian

set.seed(12345)
n=1000
rff=function(x){
  u=rbinom(x, 1, 0.5)
  X=u*rnorm(x, -2, 1)+(1-u)*rnorm(x,2,1)
  return(X)
}
x <- rff(n) #a mixed gaussian distribution

# true density function:
f.true=function(x) (0.5/(sqrt(2*pi)))*(exp(-0.5*(x+2)^2) + exp(-0.5*(x-2)^2))

e <- rlaplace(n, 0, 0.5)
y <- x + e

est <- deamerKE(y, noise.type="laplace", sigma=0.5)
est

curve(f.true(x), -6, 6, lwd=2, lty=3)
lines(est, lwd=2)
lines(density(y), lwd=2, lty=4)
legend("topleft", bty="n", lty=c(1,3,4), lwd=2, legend=c("deamerKE", "true density", 
       "kernel density\nof noisy obs."))

#########################################################
#EXAMPLE 2: known error, Laplacian and non-centered 

set.seed(12345)
n=1000
rff=function(x){
  u=rbinom(x, 1, 0.5)
  X=u*rnorm(x, -2, 1)+(1-u)*rnorm(x,2,1)
  return(X)
}
x <- rff(n) #a mixed gaussian distribution

# true density function:
f.true=function(x) (0.5/(sqrt(2*pi)))*(exp(-0.5*(x+2)^2) + exp(-0.5*(x-2)^2))

e <- rlaplace(n, 2, 0.5) #mean=2 and not zero!
y <- x + e

est <- deamerKE(y, noise.type="laplace", mu=2, from=-4, to=4, sigma=0.5)
est

curve(f.true(x), -6, 6, lwd=2, lty=3)
lines(est, lwd=2)
lines(density(y), lwd=2, lty=4)
legend("topleft", bty="n", lty=c(1,3,4), lwd=2, legend=c("deamerKE", "true density", 
       "kernel density\nof noisy obs."))

deamer documentation built on May 2, 2019, 12:36 p.m.