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

Description Usage Arguments Value Examples

View source: R/simLP.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
simLP(n = 100, nl = 2, 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:

data

an ( n*(nl+np) \times 3) data matrix.

class

length-n*(nl+np) vector for class label.

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
26
## test for visualization
set.seed(10)
tester = simLP(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(mfrow=c(2,2), no.readonly=TRUE)
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
opar <- par(no.readonly=TRUE)
require(scatterplot3d)
scatterplot3d::scatterplot3d(x=data, pch=19, cex.symbols=0.5, color=label)
par(opar)

## End(Not run)

kyoustat/Rsubclust documentation built on Feb. 22, 2020, 12:20 a.m.