cluster: Extract clustered subsets

Description Usage Arguments Details Value Author(s) References Examples

View source: R/cluster.Simpson.R

Description

After running a Simpsons, the function 'cluster' extracts desired clusters from "Simpsons" object.

Usage

1
cluster(x, clusters)

Arguments

x

Object of class Simpson

clusters

Define which clusters should be returned. Can range from 1 to maximum number of clusters detected in the Simpsons analysis.

Details

Returns list

Value

Returns list

Author(s)

Rogier Kievit <rogierkievit@gmail.com> & Sacha Epskamp <mail@sachaepskamp.com>

References

Kievit, R.A., Frankenhuis, W. E. , Waldorp, L. J. & Borsboom, D. (in preparation). Simpson's Paradox in Psychological Science: A Practical Guide. http://rogierkievit.com/simpsonsparadox.html

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
## Not run: 
#example 2. Here we estimate the relationship between 'Coffee' and #'Neuroticism'. 
#As opposed to example 1, we have not measured any possible clustering #identifiers 
#such as gender, so we want to estimate whether there is evidence for #clustering based 
#only on the data we measured: Coffee and Neuroticism.

#generating data 
Coffee1=rnorm(100,100,15)
Neuroticism1=(Coffee1*.8)+rnorm(100,15,8)
g1=cbind(Coffee1, Neuroticism1)
Coffee2=rnorm(100,170,15)
Neuroticism2=(300-(Coffee2*.8)+rnorm(100,15,8))
g2=cbind(Coffee2, Neuroticism2)
Coffee3=rnorm(100,140,15)
Neuroticism3=(200-(Coffee3*.8)+rnorm(100,15,8))
g3=cbind(Coffee3, Neuroticism3)
data2=data.frame(rbind(g1,g2,g3))
colnames(data2) <- c("Coffee","Neuroticism")

example2=Simpsons(Coffee,Neuroticism,data=data2) 
cluster(example2,2) #extracts data belonging to cluster 2
cluster(example2,c(1,3) #extracts all datapoints belonging to clusters 1 and 3

## End(Not run)

Simpsons documentation built on May 1, 2019, 10:08 p.m.

Related to cluster in Simpsons...