sdcTools / sdcMicro

sdcMicro
http://sdctools.github.io/sdcMicro/
79 stars 23 forks source link

Default value additive noise and definition of noise (alpha) #77

Closed thijsbenschop closed 8 years ago

thijsbenschop commented 8 years ago

Hi,

while using the additive noise option in the addNoise function, I came up with two question:

Thanks!

# Test additive noise
library(sdcMicro)

set.seed(2352)
dataIllus <- cbind(c(rnorm(1000, 1, 0.5)), c(rnorm(1000, 1, 0.5)))

dataNoise <- addNoise(dataIllus) # default value 150
var(dataNoise$x)   # variance as expected 0.25
var(dataNoise$xm)  # variance not (1 + alpha) * variance, 150 seems very large

dataNoise2 <- addNoise(dataIllus, noise = 0.5)
var(dataNoise2$x)  # 
var(dataNoise2$xm) # 

# Seems alpha to sd and not var, in literature var
var(dataNoise2$xm)[1,1] / var(dataNoise2$x)[1,1] # 1 + alpha^2
sqrt(var(dataNoise2$xm)[1,1]) / sqrt(var(dataNoise2$x)[1,1])

var(dataNoise2$xm)[2,2] / var(dataNoise2$x)[2,2] # 1 + alpha^2
sqrt(var(dataNoise2$xm)[2,2]) / sqrt(var(dataNoise2$x)[2,2])
bernhard-da commented 8 years ago

for the additive-noise method we changed x + rnorm(N, 0, noise * sd(x, na.rm=TRUE)) to x + rnorm(N, 0, noise/100 * sd(x, na.rm=TRUE)) where x is the numeric data vector.