rm(list=ls()) ### To clear namespace
library(knitr)

# opts_chunk$set(fig.width=12, fig.height=8, fig.path='Figs/',
#                echo=TRUE, warning=FALSE, message=FALSE)
opts_chunk$set(fig.width= 7, fig.height= 5,
               echo=TRUE, warning=FALSE, message=FALSE)

Error Distribution Specification in KDDE

Recall that kernel deconvolution density estimators (KDDE).

Assessing Error distribution

library(kerdec)

error <- rlaplace(150)

ks.test(error, plaplace)


ks.test(error, rlaplace(200))


## -------------------------------------------------------------------

library(kerdec)
library(dplyr)
library(purrr)
library(tidyr)
library(ggplot2)

##
alp <- 5; bet <- 7
n <- 250
m <- 200
X <- rgamma(n, alp, bet)
eps <- rlaplace(m, sd = sd(X))
Y <- X + rlaplace(n, sd = sd(X))

qplot(X, geom = "density")

data_frame(original = X, contaminated = Y) %>%
    gather(sample, value) %>%
    ggplot(aes(value)) +
    geom_density(aes(color = sample))

kerdec_dens(Y, error_dist = "laplace", error_scale_par = sd(X))


gbasulto/kerdec documentation built on June 5, 2019, 10:58 a.m.