Learn R Programming

deamer (version 1.0)

deamerRO: Density estimation using an auxiliary sample of replicate noisy observations.

Description

deamerRO performs a deconvolution estimation of the density of a noisy variable ('y') under the hypothesis of an unknown density of the noise using an auxiliary sample of replicate observations ("RO" for "replicate observations"). Therefore deamerRO requires two samples: one with single noisy observations and another with replicate noisy observations (see details).

Usage

deamerRO(y, replicates, grid.length = 100, from, to, na.rm = FALSE)

Arguments

y
Numeric. The vector of noisy observations.
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).
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.

Value

  • an object of class 'deamer'

Warning

  • deamerROis not implemented for heteroscedastic errors.
  • UnlikedeamerKEanddeamerSE,deamerROassumes the errors are centered around 0.

Details

The model is defined as $y = x + e$, where $x$ and $e$ both have unknown densities. Replicate observations are defined as $$z_1 = x + e_1$$$$z_2 = x + e_2$$ The main underlying hypotheses are:
  1. Homoscedasticity of the errors.
  2. The errors$e_1$and$e_2$are independent.
  3. The samples are independent.
  4. Errors are symmetric, 0-mean variables.
  5. Errors$e$,$e_1$and$e_2$have the same distribution.

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, 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, deamerSE, deamer-class

Examples

Run this code
set.seed(123)
n=1000 #sample size of single noisy observtions
M=500 #sample size of replicate observations

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 <- rnorm(n,0,0.5)
y <- x + e

x. <- rff(M)

e1 <- rnorm(M,0,0.5)
e2 <- rnorm(M,0,0.5)
rep<-data.frame(y1=x.+e1, y2=x.+e2)

est<-deamerRO(y, replicates=rep)
est

plot(est, lwd=2)
curve(f.true(x), add=TRUE, lwd=2, lty=3)
lines(density(y), lwd=2, lty=4)
legend("topleft", bty="n", lty=c(1,3,4), lwd=2, legend=c("deamerRO", "true density", 
       "kernel density
of noisy obs."))

Run the code above in your browser using DataLab