genLP: Generate Line and Plane Example with Fixed Number of...

Description Usage Arguments Value Examples

View source: R/data_genLP.R

Description

This function generates a toy example of 'line and plane' data in R^3 that data are generated from a mixture of lines (one-dimensional) planes (two-dimensional). The number of line- and plane-components are explicitly set by the user for flexible testing.

Usage

1
genLP(n = 100, nl = 1, np = 1, iso.var = 0.1)

Arguments

n

the number of data points for each line and plane.

nl

the number of line components.

np

the number of plane components.

iso.var

degree of isotropic variance.

Value

a named list containing with m = n\times(nl+np):

data

an (m\times 3) data matrix.

class

length-m vector for class label.

dimension

length-m vector of corresponding dimension from which an observation is created.

Examples

 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
## test for visualization
set.seed(10)
tester = genLP(n=100, nl=1, np=2, iso.var=0.1)
data   = tester$data
label  = tester$class

## do PCA for data reduction
proj = base::eigen(stats::cov(data))$vectors[,1:2]
dat2 = data%*%proj

## visualize
opar <- par(no.readonly=TRUE)
par(mfrow=c(2,2), pty="s")
plot(dat2[,1],dat2[,2],pch=19,cex=0.5,col=label,main="PCA")
plot(data[,1],data[,2],pch=19,cex=0.5,col=label,main="Axis 1 vs 2")
plot(data[,1],data[,3],pch=19,cex=0.5,col=label,main="Axis 1 vs 3")
plot(data[,2],data[,3],pch=19,cex=0.5,col=label,main="Axis 2 vs 3")
par(opar)

## Not run: 
## visualize in 3d
x11()
scatterplot3d::scatterplot3d(x=data, pch=19, cex.symbols=0.5, color=label)

## End(Not run)

T4cluster documentation built on Aug. 16, 2021, 9:07 a.m.