Learn R Programming

RCA (version 2.0)

RCA-package: Relational Class Analysis

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

RCA(matrix, max = NULL, min = NULL, num = 1000, alpha = 0.05)
"print"(x, ...)
"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.

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

Run this code
# 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)

Run the code above in your browser using DataLab