The GVARCLUS Procedure
Example 12.1 Analyzing United States Senate Voting Data
This example analyzes United States Senate voting records data from the 106th Congress 1999–2000. The data set contains 100 variables, which correspond to 100 senators. Each of the 542 samples is a bill that was put to a vote. The votes are recorded as 0 for a No vote and 1 for a Yes vote.
Download the Senate data set to the Work library from the Github repository: https://github.com/sassoftware/sas-viya-machine-learning/tree/master/data/senate. You can then load the Work.Senate data set into your CAS session by naming your CAS engine libref in the first statement of the following DATA step:
data mycas.senate;
set work.senate;
run;
These statements assume that your CAS engine libref is named mycas, but you can substitute any appropriately defined CAS engine libref.
The following statements invoke the GVARCLUS procedure:
proc gvarclus data=mycas.senate rho=0.8 maxstep=5 outtree=mycas.tree
outedge=mycas.edge outvert=mycas.vert;
input _ALL_/LEVEL=NOMINAL;
run;
By specifying the MAXSTEP= option to be more than 1, you can let PROC GVARCLUS perform variable clustering at multiple values, which decrease at each step. RHO=0.8 specifies the initial
value for step 1, and then
is
for step 2,
for step 3, and so on. The regularization parameter
controls the sparsity of the estimation of the inverse covariance matrix at each step, and a sequence of steps yields a hierarchical structure of clustering. The hierarchies provided by PROC GVARCLUS are interpretable with tree output. The OUTTREE= option saves the tree to a CAS table, and you can plot the dendrogram using the SAS Graph Template language (GTL). PROC GVARCLUS also outputs the edge and vertex information for representing the partial correlations in an undirected graph. The OUTEDGE= option saves the edges in the network to a CAS table named
mycas.edge, and the OUTVERT= option saves the vertices and their sizes in the network to CAS table named mycas.vert.
The following statements download the tree table to the Work library:
data work.tree (drop = last);
set mycas.tree;
last = scan(_CHILD_, -1);
if last=0 then delete;
run;
The following code uses the DENDROGRAM statement in GTL to define the parent node, child node, and the height in the dendrogram. The dendrogram is then plotted using the SGRENDER procedure.
proc template;
define statgraph dendrogram;
begingraph;
layout overlay/ yaxisopts=(linearopts=(viewmax=0.1));
dendrogram nodeID=_CHILD_ parentID=_PARENT_ clusterheight=_HEIGHT_;
endlayout;
endgraph;
end;run;
ods graphics /width =2300px;
proc sgrender data=work.tree1 template=dendrogram;
run;
Output 12.1.1 shows that there are two large clusters in the dendrogram. All the Democratic Senate votes are united and in one cluster. Most of the Republican Senate votes are in the other cluster, but there are some small cliques.
Output 12.1.1: Senate Voting Records from the 106th Congress
