deamerclass: Objects of class 'deamer'

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

Description

The deamer class defines the objects produced by deamer.default or any of deamerKE, deamerSE or deamerRO. Objects of class deamer can be used in generic functions such as plot, print and predict.
The default function deamer assumes the user is familiar with all 3 methods "se", "ke" and "ro" (see deamer and details), whereas method-specific wrappers deamerKE, deamerSE, deamerRO are intended for those who are not.

Usage

1
2
3
4
5
## Default S3 method:
deamer(y, errors, replicates, mu,  sigma, noise.type, method,
       grid.length, from, to, na.rm)
## S3 method for class 'deamer'
predict(object, newdata, na.rm,...)

Arguments

y

Numeric. The vector of noisy observations.

errors

Numeric. The vector of the auxiliary sample of errors. Does not need to be the same length as 'y'.

replicates

Numeric. A 2-column matrix or 2-column numeric data-frame. Contains one replicate observation in each row. The number of rows does not need to match length(y).

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"

method

Character. Only one of "ke", "se", "ro". Defines the estimation method. See details.

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.

object

An object of class deamer

newdata

Numeric vector (possibly single valued).

...

Further arguments for generic functions

Details

The estimation method is chosen according to the method argument. For known density noise, method="ke" and arguments 'mu' and 'sigma' should be supplied. For estimation with an auxiliary sample of errors method="se" and argument 'errors' should be supplied. For estimation with an auxiliary sample of replicates, method="ro" and argument 'replicates' should be supplied. For further details on each of these models, see deamer and functions deamerKE, deamerSE and deamerRO respectively. These functions are wrappers for deamer.default and have a more straightforward usage.

Value

y

The input vector.

f

The deconvolution estimate of the density of x, estimated over supp.

n

Length of input vector.

M

Sample size of pure errors (argument 'errors' with method="se" or deamerSE) or replicate observations (argument 'replicates' with method="ro" or deamerRO). For method="ke" or deamerKE, M=NULL

method

The method of estimation. Possible values: "kegauss" for known Gaussian noise, "kelap" for known Laplace noise, "se" for sample of pure errors, "ro" for replicate noisy observations.

mu

The mean of the error density for method="ke" or deamerKE. For other methods, mu=NULL.

sigma

The standard deviation (resp. scale parameter) of the error density for method="ke" or deamerKE with Gaussian noise (resp. Laplace noise). For other methods, sigma=NULL.

supp

The grid of values used for estimation.

m

The estimated parameter for adaptive model selection.

ahat

Values of the estimated projection coefficients using Fast Fourier Transform.

Generic function predict yields a vector of predictions.

Warning

Heteroscedastic errors are not supported in any of deamerKE, deamerSE, deamerRO.

Author(s)

Julien Stirnemann <j.stirnemann@gmail.com>

References

Stirnemann JJ, Comte F, Samson A. Density estimation of a biomedical variable subject to measurement error using an auxiliary set of replicate observations. Statistics in medicine. 2012 May 17 [Epub ahead of print]

Comte F, Lacour C. Data-driven density estimation in the presence of additive noise with unknown distribution. Journal of the Royal Statistical Society: Series B (Statistical Methodology). 2011 Sep 1;73(4):601-27.

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.

Comte F, Samson A, Stirnemann J. Deconvolution estimation of onset of pregnancy with replicate observations [Internet]. 2011 [cited 2011 Oct 25]. Available from: http://hal.archives-ouvertes.fr/hal-00588235_v2/

See Also

deamer, deamerKE, deamerRO, deamerSE

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
54
55
56
57
#this example based on simulated data presents each method implemented in deamer. 
#the deamer function is presented but the wrappers deamerKE, deamerRO
#and deamerSE would yield the same results.
 
set.seed(12345)
n=1000; M=500
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) # laplace noise
y <- x + e  # observations with additive noise

eps <- rlaplace(M, 0, 0.5) # a sample of pure errors for method="se"
# a 2-column matrix of replicate noisy observations for method="ro"
rep <- matrix(rep(rff(M),each=2)+rlaplace(2*M,0,0.5), byrow=TRUE, ncol=2)
 
#estimation with known error
# the same as deamerKE(y, noise.type="laplace", sigma=0.5)
est.ke <- deamer(y, noise.type="laplace", sigma=0.5, method="ke")  
#will generate a warning since we are assuming mu=0
est.ke

#estimation with an auxiliary sample of errors
# the same as deamerSE(y, errors=eps)
est.se <- deamer(y, errors=eps, method="se")
est.se

#estimation with replicate noisy observations
# the same as deamerRO(y, replicates=rep)
est.ro <- deamer(y, replicates=rep, method="ro")
est.ro

curve(f.true(x), from=-6, to=6,lwd=2, lty=2)
lines(est.ke, lwd=1, col="green3")
lines(est.se, lwd=1, col="blue2")
lines(est.ro, lwd=1, col="orange")
legend("topright", lty=c(2,1,1,1), col=c("black", "green3", "blue2","orange"), 
        legend=c("true density", "method='ke'", "method='se'", "method='ro'"),
        bty='n')
 
#compare predictions for each method for newx
newx=c(-2,0,2)
rbind(
      predict(est.ke, newdata=newx),
      predict(est.se, newdata=newx),
      predict(est.ro, newdata=newx)
      ) -> preds
dimnames(preds)<-list(c("ke","se","ro"),newx)
        #predictions are made at newdata
preds

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