Description Details Author(s) References Examples
This package is used to estimate the density approximant of the original data, in the meanwhile to produce synthetic data of the original data, based on noise multiplied data.
Package: | MaskDensity14 |
Type: | Package |
Version: | 1.0 |
Date: | 2015-04-20 |
License: | GPL-2 |
~~ An overview of how to use the package, including the most important ~~ ~~ functions ~~
Mark and Yan-Xia
Maintainer: Yan-Xia Lin <yanxia@uow.edu.au> ~~ The author and/or maintainer of the package ~~
no reference
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 | # Example for continuous data
# Data provider would have the real data, in this case we are just simulating some continuous data:
set.seed(123)
n=10000
rmulti<-function(n,mean,sd,p)
{
x<-rnorm(n,0,1)
k<- length(mean)
u<-sample(1:k, size=n, prob=p, replace=TRUE)
for(i in 1:k)
x[u==i]<-mean[i]+sd[i]*x[u==i]
return(x)
}
y<-rmulti(n=10000, mean=c(30,50),sd=c(4,2), p=c(0.3,0.7))
# y is a sample drawn from Y
noise <- rmulti(n=10000, mean=c(80,100), sd=c(5,3), p=c(0.6,0.4))
# noise is a sample drawn from C
# Data provider now masks the real data created above:
library(MaskDensity14)
ymask<- mask(y, noisefile="noise.bin", a1=min(y), b1=max(y), noise)
write(ymask$ystar, "ystar.dat")
# Data user unmasks the masked data:
library(MaskDensity14)
ystar<-scan("ystar.dat")
y1<-unmask(ystar, noisefile="noise.bin")
plot(density(y1$unmaskedVariable), main="density(ymask)", xlab="y")
# Example for categorical data
# Data provider would have the real data, in this case we are just simulating some categorical data:
set.seed(124)
n<-2000
a<-170
b<-80
y<-rbinom(n, 1, 0.1)+1
noise<-(a+b)/2+ sqrt(1+(a-b)^2/4)*rnorm(n, 0,1)
noise<-abs(noise)
# Data provider now masks the real data created above:
library(MaskDensity14)
ymask<-mask(factor(y), noisefile="noise.bin", noise, a1=0,b1=3)
# using factor(y) because y is a categorical variable
write(ymask$ystar, "ystar.dat")
# Data user unmasks the masked data:
library(MaskDensity14)
ystar<-scan("ystar.dat")
y1 <- unmask(ystar, noisefile="noise.bin")
unmaskY<-y1$unmaskedVariable # synthetic data
mass_function<-y1$prob # estimated mass function
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.