# \donttest{
require(datanugget)
#4-dim small example with cluster stuctures in V3 and V4
X = cbind.data.frame(V1 = rnorm(5*10^4,mean = 5,sd = 2),
V2 = rnorm(5*10^4,mean = 5,sd = 1),
V3 = c(rnorm(3*10^4,sd = 0.3),
rnorm(2*10^4,mean = 2, sd = 0.3)),
V4 = c(rnorm(1*10^4,mean = -8, sd = 1),
rnorm(3*10^4,mean = 0,sd = 1),
rnorm(1*10^4,mean = 7, sd = 1.5)))
#perform 2-dim Projection Pursuit for the big data
#based on Hole index for data nuggets
res = PPnugg(X, index = "Hole", dim = 2, R = 5000, DN.num1 = 1*10^4, DN.num2 = 2000,
no.cores = 2, tempMin = 0.05, maxiter = 1000, tol = 1e-4)
#data nuggets created and refined from the standardized raw data
nugg = res$DN$`Data Nuggets`
#data nugget assignments of each observation in the raw data
nugg_assign = res$DN$`Data Nugget Assignments`
#plot projected data nuggets
plotNugg(res$nuggproj,nugg$Weight,qt = 0.8)
#plot the corresponding projected raw big data
plot(res$dataproj,cex = 0.5,main = "Projected Raw Data")
#plot the estimated density of the projected data
image(res$density)
#plot loadings of original variables
#V3 and V4 have large loadings, same as the simulation setting.
plotLoadings(res$loadings)
#perform 1-dim Projection Pursuit for the big data
#based on Natural Hermite index for data nuggets
res = PPnugg(X, index = "NH", dim = 1, R = 5000, DN.num1 = 1*10^4, DN.num2 = 2000,
no.cores = 2, tempMin = 0.05, maxiter = 1000, tol = 1e-5)
#data nuggets created and refined from the standardized raw data
nugg = res$DN$`Data Nuggets`
#data nugget assignments of each observation in the raw data
nugg_assign = res$DN$`Data Nugget Assignments`
#plot projected data nuggets
plotNugg(res$nuggproj,nugg$Weight,qt = 0.8,hist = TRUE)
#plot the corresponding projected raw big data
hist(res$dataproj,breaks = 100)
# }
Run the code above in your browser using DataLab