RCA: Relational Class Analysis

Description Usage Arguments Details Author(s) References Examples

View source: R/RCA.R

Description

Relational Class Analysis (RCA) is a method for detecting heterogeneity in attitudinal data (as described in Goldberg A., 2011, Am. J. Soc, 116(5)).

The RCA function produces an object of class RCA. This object includes: (1) a vector of class membership —— $membership; (2) a list of modules —— $modules; and (3) the relationality matrix —— $R.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
RCA(matrix, max = NULL, min = NULL, num = 1000, 
  alpha = 0.05)

## S3 method for class 'RCA'
print(x, ...)

## S3 method for class 'RCA'
plot(x, module = NULL, colorblind = FALSE, 
  heatmap = TRUE, heat_labels = FALSE, 
  drop_neg_ties = TRUE, layout = layout.kamada.kawai, 
  edge_color = "gray", vertex_color = "white", 
  vertex_frame_color = "black", vertex_size = 20, 
  vertex_label_color = "black", vertex_label_cex = 0.8, 
  margin = 0, ...)

Arguments

matrix

a matrix of size m x n. Rows correspond to observations and columns correspond to variables.

max

either a single integer or a vector of length n. If an integer is specified, its value is used as the maximum for all variables in the matrix. If a vector is specified, then each element is used as the maximum value for each variable. The default value is NULL, in which case max is assumed to be the maximum of each variable in the input matrix.

min

either a single integer or a vector of length n. If an integer is specified, its value is used as the minimum for all variables in the matrix. If a vector is specified, then each element is used as the minimum value for each variable. The default value is NULL, in which case min is assumed to be the minimum of each variable in the input matrix.

num

the number of bootstrap samples to be used in testing for significant relationalities. The default is 1000.

alpha

a value between 0 and 1 specifying the significance level to be used in testing for significant relationalities. The default is 0.05.

x

an object of class RCA.

module

the module number to graph.

colorblind

change the graph color schemes to be colorblind friendly. Default is FALSE.

heatmap

choose which type of graph to produce. Default is TRUE for heatmap. FALSE produces an igraph.

heat_labels

add correlation labels to the heatmap. Default is FALSE.

drop_neg_ties

drop negative graph edges. Default is TRUE.

layout

choose a layout for plotting graphs. Default is layout.kamada.kawai. Additional layouts can be chosen from layout{igraph}.

edge_color

color of the graph edges. Default is gray.

vertex_color

color of the vertices. Default is white.

vertex_frame_color

color of the vertex frames. Default is black.

vertex_size

vertex frame size. Default is 20.

vertex_label_color

color of the vertex labels. Default is black.

vertex_label_cex

size of the vertex labels. Default is 0.8.

margin

adjust the margins of the graph. Default is 0. Negative values reduce the margins.

...

additional arguments

Details

RCA computes the relationality between all pairs of observations and partitions the sample into subgroups of schematically overlapping respondents such that those who subscribe to the same logic are clustered together. It accomplishes this by performing the following sequence:

1.) RCA computes a measure of relationality for each pair of observations in the data set, resulting in a complete, undirected, and weighted graph.

2.) Graph edges whose weights are statistically insignificant are removed. Remaining edges are transformed by their absolute value.

3.) RCA partitions the graph into subgroups of schematically similar observations using a graph-partitioning algorithm.

Author(s)

Amir Goldberg, Sarah K. Stein

Maintainer: Amir Goldberg <amirgo@stanford.edu>

References

Goldberg, Amir. "Mapping shared understandings using relational class analysis: the case of the cultural omnivore reexamined." American Journal of Sociology 116.5 (2011): 1397-1436.

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
27
28
29
# Test matrix
set.seed <- 2
matrix <- round(matrix(runif(100, min = 0, max = 6), 
  ncol = 5))

rca <- RCA(matrix)
rca <- RCA(matrix, max = rep(6, 5), min = rep(0, 5))
rca <- RCA(matrix, max = 6, min = 0)
rca <- RCA(matrix, num = 10000, alpha = 0.1)

summary(rca)
print(rca)

rca$membership
rca$modules[[1]]$matrix
rca$R

# Heatmap
plot(rca, module = 1)
plot(rca, module = 1, colorblind = TRUE, 
  heat_labels = TRUE)

# IGraph
plot(rca, module = 1, heatmap = FALSE)
plot(rca, module = 1, heatmap = FALSE, 
  layout = layout.circle, edge_color = "red", 
  vertex_color = "gray", vertex_frame_color = "red", 
  vertex_size = 30, vertex_label_color= "red", 
  vertex_label_cex = 1, margin = 0.2)

Example output

Loading required package: igraph

Attaching package: 'igraph'

The following objects are masked from 'package:stats':

    decompose, spectrum

The following object is masked from 'package:base':

    union

Loading required package: gplots

Attaching package: 'gplots'

The following object is masked from 'package:stats':

    lowess

           Length Class  Mode   
membership  20    -none- numeric
modules      8    -none- list   
R          400    -none- numeric
RCA found 8 relational classes. Sizes: 4 1 1 2 4 1 4 3 
 [1] 1 2 3 4 1 5 7 5 6 4 5 1 7 8 5 8 7 8 1 7
     [,1] [,2] [,3] [,4] [,5]
[1,]    3    4    2    1    5
[2,]    2    2    4    4    1
[3,]    2    3    0    5    0
[4,]    2    2    2    4    1
            [,1] [,2] [,3]       [,4]       [,5]       [,6]      [,7]
 [1,]  0.0000000    0    0  0.0000000 -0.5722354  0.0000000 0.0000000
 [2,]  0.0000000    0    0  0.0000000  0.0000000  0.0000000 0.0000000
 [3,]  0.0000000    0    0  0.0000000  0.0000000  0.0000000 0.0000000
 [4,]  0.0000000    0    0  0.0000000  0.0000000  0.0000000 0.0000000
 [5,] -0.5722354    0    0  0.0000000  0.0000000  0.0000000 0.0000000
 [6,]  0.0000000    0    0  0.0000000  0.0000000  0.0000000 0.0000000
 [7,]  0.0000000    0    0  0.0000000  0.0000000  0.0000000 0.0000000
 [8,]  0.0000000    0    0  0.0000000  0.0000000  0.0000000 0.0000000
 [9,]  0.0000000    0    0  0.0000000  0.0000000  0.0000000 0.0000000
[10,]  0.0000000    0    0 -0.5855687  0.0000000  0.0000000 0.0000000
[11,]  0.0000000    0    0  0.0000000  0.0000000 -0.5122354 0.0000000
[12,]  0.0000000    0    0  0.0000000  0.0000000  0.0000000 0.0000000
[13,]  0.0000000    0    0  0.0000000  0.0000000  0.0000000 0.6677646
[14,]  0.0000000    0    0  0.0000000  0.0000000  0.0000000 0.0000000
[15,]  0.0000000    0    0  0.0000000  0.0000000  0.0000000 0.0000000
[16,]  0.0000000    0    0  0.0000000  0.0000000  0.0000000 0.0000000
[17,]  0.4744313    0    0  0.0000000  0.0000000  0.0000000 0.0000000
[18,]  0.4610980    0    0  0.0000000 -0.5255687  0.0000000 0.0000000
[19,] -0.6322354    0    0  0.0000000  0.6077646  0.0000000 0.0000000
[20,]  0.0000000    0    0  0.0000000  0.0000000  0.0000000 0.5677646
            [,8] [,9]      [,10]      [,11]     [,12]     [,13]      [,14]
 [1,]  0.0000000    0  0.0000000  0.0000000 0.0000000 0.0000000  0.0000000
 [2,]  0.0000000    0  0.0000000  0.0000000 0.0000000 0.0000000  0.0000000
 [3,]  0.0000000    0  0.0000000  0.0000000 0.0000000 0.0000000  0.0000000
 [4,]  0.0000000    0 -0.5855687  0.0000000 0.0000000 0.0000000  0.0000000
 [5,]  0.0000000    0  0.0000000  0.0000000 0.0000000 0.0000000  0.0000000
 [6,]  0.0000000    0  0.0000000 -0.5122354 0.0000000 0.0000000  0.0000000
 [7,]  0.0000000    0  0.0000000  0.0000000 0.0000000 0.6677646  0.0000000
 [8,]  0.0000000    0  0.0000000 -0.7255687 0.0000000 0.0000000  0.0000000
 [9,]  0.0000000    0  0.0000000  0.0000000 0.0000000 0.0000000  0.0000000
[10,]  0.0000000    0  0.0000000  0.0000000 0.0000000 0.0000000  0.0000000
[11,] -0.7255687    0  0.0000000  0.0000000 0.0000000 0.0000000  0.0000000
[12,]  0.0000000    0  0.0000000  0.0000000 0.0000000 0.0000000  0.0000000
[13,]  0.0000000    0  0.0000000  0.0000000 0.0000000 0.0000000  0.0000000
[14,]  0.0000000    0  0.0000000  0.0000000 0.0000000 0.0000000  0.0000000
[15,]  0.0000000    0  0.0000000 -0.5589020 0.0000000 0.0000000  0.0000000
[16,]  0.0000000    0  0.0000000  0.0000000 0.0000000 0.0000000  0.5877646
[17,]  0.0000000    0  0.0000000  0.0000000 0.0000000 0.0000000  0.0000000
[18,]  0.0000000    0  0.0000000  0.0000000 0.0000000 0.0000000 -0.5589020
[19,]  0.0000000    0  0.0000000  0.0000000 0.4744313 0.0000000  0.0000000
[20,]  0.0000000    0  0.0000000  0.0000000 0.0000000 0.0000000  0.0000000
          [,15]     [,16]      [,17]      [,18]      [,19]     [,20]
 [1,]  0.000000 0.0000000  0.4744313  0.4610980 -0.6322354 0.0000000
 [2,]  0.000000 0.0000000  0.0000000  0.0000000  0.0000000 0.0000000
 [3,]  0.000000 0.0000000  0.0000000  0.0000000  0.0000000 0.0000000
 [4,]  0.000000 0.0000000  0.0000000  0.0000000  0.0000000 0.0000000
 [5,]  0.000000 0.0000000  0.0000000 -0.5255687  0.6077646 0.0000000
 [6,]  0.000000 0.0000000  0.0000000  0.0000000  0.0000000 0.0000000
 [7,]  0.000000 0.0000000  0.0000000  0.0000000  0.0000000 0.5677646
 [8,]  0.000000 0.0000000  0.0000000  0.0000000  0.0000000 0.0000000
 [9,]  0.000000 0.0000000  0.0000000  0.0000000  0.0000000 0.0000000
[10,]  0.000000 0.0000000  0.0000000  0.0000000  0.0000000 0.0000000
[11,] -0.558902 0.0000000  0.0000000  0.0000000  0.0000000 0.0000000
[12,]  0.000000 0.0000000  0.0000000  0.0000000  0.4744313 0.0000000
[13,]  0.000000 0.0000000  0.0000000  0.0000000  0.0000000 0.0000000
[14,]  0.000000 0.5877646  0.0000000 -0.5589020  0.0000000 0.0000000
[15,]  0.000000 0.0000000  0.0000000  0.0000000  0.0000000 0.0000000
[16,]  0.000000 0.0000000  0.0000000  0.0000000  0.0000000 0.0000000
[17,]  0.000000 0.0000000  0.0000000  0.0000000 -0.5322354 0.8344313
[18,]  0.000000 0.0000000  0.0000000  0.0000000  0.0000000 0.0000000
[19,]  0.000000 0.0000000 -0.5322354  0.0000000  0.0000000 0.0000000
[20,]  0.000000 0.0000000  0.8344313  0.0000000  0.0000000 0.0000000

RCA documentation built on May 2, 2019, 7:27 a.m.

Related to RCA in RCA...