8.3 CA Analysis
CA and its inference analysis (boot, CI, TI, eigenvalue tests, scree) can be done by InPosition. Also, note that there are 2 ways to perform CA: symmetric and asymmetric (find definition above). We should perform both for either rows or columns or both. In the case of this sensory profile dataset where there is subjectivity to be balanced in both rows and columns, it is recommended that we do both tests (symmetry and asymmetry) for both rows and columns.
8.3.1 Run CA
We will perform CA in 2 ways: Symmetric and Asymmetric using epCA. Note that the results include multiple components like
“ExPosition.Data” - All ExPosition classes output (data, factor scores, contributions, etc…)
“Plotting.Data” - All ExPosition & prettyGraphs plotting data (constraints, colors, etc…)
For Inference Analysis we can use epCA.inference.battery() to obtain multiple result components.
In order to do epCA for rows instead of columns, we can simply transpose the data set as “t(data)”
SYMMETRIC CA
#Preliminary CA
epCA(wk1, symmetric = TRUE, graphs = FALSE)
resCA.sym <-
#Inference Battery for Columns (J)
epCA.inference.battery(wk1, symmetric = TRUE, graphs = FALSE)
resCAinf.sym.col <-
#Inference Battery for Rows (I)
epCA.inference.battery(t(wk1), symmetric = TRUE, graphs = FALSE) resCAinf.sym.row <-
ASYMMETRIC CA
#Preliminary CA
epCA(wk1, symmetric = FALSE, graphs = FALSE)
resCA.asym <- epCA(t(wk1), symmetric = FALSE, graphs = FALSE)
resCA.asym2 <-
#Inference Battery for Columns (J)
epCA.inference.battery(wk1, symmetric = FALSE, graphs = FALSE)
resCAinf.asym.col <-
#Inference Battery for Rows (I)
epCA.inference.battery(t(wk1), symmetric = FALSE, graphs = FALSE) resCAinf.asym.row <-
8.3.2 Scree Plot
Even with included permutation test, our scree plot does not show any significant component
#Symmetry
PlotScree(ev = resCA.sym$ExPosition.Data$eigs,
scree1 <-p.ev = resCAinf.sym.col$Inference.Data$components$p.vals,
title = "Explained Variance per Dimension + Permutation Test",
plotKaiser = TRUE,
color4Kaiser = "hotpink")
scree1 recordPlot()
scree1 <-
#Asymmetry
#scree2 <- PlotScree(ev = resCA.asym$ExPosition.Data$eigs,
# p.ev = resCAinf.asym.col$Inference.Data$components$p.vals,
# title = "Explained Variance per Dimension + Permutation Test (No Significant Component)")
#scree2
#scree2 <- recordPlot()
We see that there is no significant component for this dataset.
8.3.3 Permutation Test
Wanted to take a look into the eigenvalues to make sure that no component is actually significant.
Columns:
1
zeDim = prettyHist(
pH1 <-distribution = resCAinf.sym.col$Inference.Data$components$eigs.perm[,zeDim],
observed = resCAinf.sym.col$Fixed.Data$ExPosition.Data$eigs[zeDim],
xlim = c(0, 0.1), # needs to be set by hand
breaks = 10,
border = "white",
main = paste0("Permutation Test for Eigenvalue ",zeDim, " Sym Col"),
xlab = paste0("Eigenvalue ",zeDim),
ylab = "",
counts = FALSE,
cutoffs = c( 0.975),
observed.col = "hotpink"
)
recordPlot()
pH1 <-
2
zeDim = prettyHist(
pH2 <-distribution = resCAinf.sym.col$Inference.Data$components$eigs.perm[,zeDim],
observed = resCAinf.sym.col$Fixed.Data$ExPosition.Data$eigs[zeDim],
xlim = c(0, 0.1), # needs to be set by hand
breaks = 10,
border = "white",
main = paste0("Permutation Test for Eigenvalue ",zeDim, " Sym Col"),
xlab = paste0("Eigenvalue ",zeDim),
ylab = "",
counts = FALSE,
cutoffs = c( 0.975),
observed.col = "hotpink"
)
recordPlot()
pH2 <-
#Rows:
1
zeDim = prettyHist(
pH3 <-distribution = resCAinf.sym.row$Inference.Data$components$eigs.perm[,zeDim],
observed = resCAinf.sym.row$Fixed.Data$ExPosition.Data$eigs[zeDim],
xlim = c(0, 0.1), # needs to be set by hand
breaks = 10,
border = "white",
main = paste0("Permutation Test for Eigenvalue ",zeDim, " Sym Row"),
xlab = paste0("Eigenvalue ",zeDim),
ylab = "",
counts = FALSE,
cutoffs = c( 0.975),
observed.col = "hotpink"
)
recordPlot()
pH3 <-
2
zeDim = prettyHist(
pH4 <-distribution = resCAinf.asym.row$Inference.Data$components$eigs.perm[,zeDim],
observed = resCAinf.asym.row$Fixed.Data$ExPosition.Data$eigs[zeDim],
xlim = c(0, 0.1), # needs to be set by hand
breaks = 10,
border = "white",
main = paste0("Permutation Test for Eigenvalue ",zeDim, " Sym Row"),
xlab = paste0("Eigenvalue ",zeDim),
ylab = "",
counts = FALSE,
cutoffs = c( 0.975),
observed.col = "hotpink"
)
recordPlot() pH4 <-
8.3.4 Factor Scores
Set-Up:
Here we will list all of the components required to plot the Factor Scores and reassign to variables for easy handling.
#Factor scores needed
resCA.asym$ExPosition.Data$fj
Fj.a <- resCA.sym$ExPosition.Data$fi
Fi <- resCA.sym$ExPosition.Data$fj
Fj <-
# Asym map opposite row -col
resCA.asym2$ExPosition.Data$fj
t.Fj.a <- resCA.asym2$ExPosition.Data$fi
t.Fi <- resCA.asym2$ExPosition.Data$fj
t.Fj <-
# constraints -----
# first get the constraints correct
minmaxHelper(mat1 = Fi, mat2 = Fj)
constraints.sym <- minmaxHelper(mat1 = Fi, mat2 = Fj.a)
constraints.asym <- minmaxHelper(mat1 = t.Fi, mat2 = t.Fj.a)
constraints.asym2 <-
# Get some colors ----
prettyGraphsColorSelection(n.colors = nrow(Fi))
col.var <-
# baseMaps ----
colnames(Fi) <- paste("Dimension ", 1:ncol(Fi))
colnames(Fj) <- paste("Dimension ", 1:ncol(Fj))
colnames(Fj.a) <- paste("Dimension ", 1:ncol(Fj.a))
8.3.4.1 Asymmetric Factor Scores
Notes:
First, we will make an Asymmetric plot with Simplex (kind of like a Tolerance Interval for all variable - technically, it is flattening all dimentsion) so that we can compare col-to-row.
Interpretations:
We can interpret asymmetric plot by assessing the proximity (distance between) each data points (can be done for both rows and columns).
Some noticeable points of observation:
• We see that most observation cluster around center of gravity.
• Some observation also stay very near to components and can be broken into 3 main groups.
• Some of these observation groups are relatively close to some respective characteristics.
• For observations, we see small eigen values (this is because CA uses chi-square probability)
Asymmetric map with that makes Simplex polygon from column:
# Your asymmetric factor scores
createFactorMapIJ(Fi,
asymMap <-
Fj.a,constraints = constraints.asym,
col.labels.j = "darkgreen",
col.points.j = "darkgreen",
col.points.i = "hotpink")
# set drawing order, goal is to flatten the simplex:
c(5,8,13,4,2,6)
polygonorder <-
# Make the simplex visible
PTCA4CATA::ggdrawPolygon(Fj.a,
zePoly.J <-order2draw = polygonorder, # this parameter determines which point to draw first
color = 'darkgreen',
size = .2,
fill = 'darkgreen',
alpha = .05)
# Labels
createxyLabels(resCA = resCA.asym)
labels4CA <-
# Combine all elements you want to include in this plot
asymMap$baseMap + zePoly.J +
asymMap.simplex <- asymMap$I_points +
asymMap$J_labels +
asymMap$J_points +
labels4CA +
ggtitle('Asymmetric Map with Simplex (From Emotions')
asymMap.simplex
recordPlot() asymMap.simplex <-
Asymmetric map with that makes Simplex polygon from rows:
We prefer to draw asymmetric map from either rows or columns that have less levels. Here the rows have less levels
# Your asymmetric factor scores
createFactorMapIJ(t.Fi,
asymMap2 <-
t.Fj.a,constraints = constraints.asym2,
col.labels.j = "hotpink",
col.points.j = "hotpink",
col.points.i = "darkgreen")
# set drawing order, goal is to flatten the simplex:
c(1,7,6,3,2)
polygonorder2 <-
# Make the simplex visible
PTCA4CATA::ggdrawPolygon(t.Fj.a,
zePoly.J <-order2draw = polygonorder2, # this parameter determines which point to draw first
color = 'hotpink',
size = .2,
fill = 'hotpink',
alpha = .05)
# Labels
createxyLabels(resCA = resCA.asym)
labels4CA <-
# Combine all elements you want to include in this plot
asymMap2$baseMap + zePoly.J +
asymMap.simplex2 <- asymMap2$I_points +
asymMap2$J_labels +
asymMap2$J_points +
labels4CA +
ggtitle('Asymmetric Map with Simplex (From Products)')
asymMap.simplex2
recordPlot() asymMap.simplex2 <-
Let’s also check Dimension 3 and 4:
# Your asymmetric factor scores
createFactorMapIJ(t.Fi,
asymMap3 <-
t.Fj.a,col.labels.j = "hotpink",
col.points.j = "hotpink",
col.points.i = "darkgreen",
axis1 = 3,
axis2 = 4
)
# set drawing order, goal is to flatten the simplex:
c(5,7,4,3)
polygonorder3 <-
# Make the simplex visible
PTCA4CATA::ggdrawPolygon(t.Fj.a[,3:4],
zePoly.J.extra <-order2draw = polygonorder3, # this parameter determines which point to draw first
color = 'hotpink',
size = .2,
fill = 'hotpink',
alpha = .05)
# Labels
createxyLabels(resCA = resCA.asym, x_axis = 3, y_axis = 4)
labels4CA <-
# Combine all elements you want to include in this plot
asymMap3$baseMap + zePoly.J.extra +
asymMap.simplex3 <- asymMap3$I_points +
asymMap3$J_labels +
asymMap3$J_points +
labels4CA +
ggtitle('Asymmetric Map with Simplex (From Products) - D3 & D4')
asymMap.simplex3
recordPlot() asymMap.simplex3 <-
Asym for D1 and D3:
# Your asymmetric factor scores
createFactorMapIJ(t.Fi,
asymMap4 <-
t.Fj.a,col.labels.j = "hotpink",
col.points.j = "hotpink",
col.points.i = "darkgreen",
axis1 = 1,
axis2 = 3
)
# set drawing order, goal is to flatten the simplex:
c(3,5,7,2,1)
polygonorder4 <-
# Make the simplex visible
PTCA4CATA::ggdrawPolygon(t.Fj.a[,c(1,3)],
zePoly.J.extra <-order2draw = polygonorder4, # this parameter determines which point to draw first
color = 'hotpink',
size = .2,
fill = 'hotpink',
alpha = .05)
# Labels
createxyLabels(resCA = resCA.asym, x_axis = 1, y_axis = 3)
labels4CA <-
# Combine all elements you want to include in this plot
asymMap4$baseMap + zePoly.J.extra +
asymMap.simplex4 <- asymMap4$I_points +
asymMap4$J_labels +
asymMap4$J_points +
labels4CA +
ggtitle('Asymmetric Map with Simplex (From Products) - D1 & D3')
asymMap.simplex4
recordPlot() asymMap.simplex4 <-
8.3.4.2 Symmetric Factor Scores
Notes:
Since we have a relatively large number of rows and cols, it is a good idea to plot rows and cols separately. On the other hand, if we have a small number of rows and cols, we can do a biplot where 2 maps are on top of each other. Reason: since it is a symmetric map, we can put them on a same plane without issues.
# create symmetric Map:
createFactorMapIJ(Fi,
symMap <-
Fj,col.labels.j = "darkgreen",
col.points.j = "darkgreen",
col.points.i = "hotpink",
col.labels.i = "hotpink",
text.cex.i = 3,
text.cex.j = 3)
createxyLabels(resCA = resCA.asym)
labels4CA <-
# plot the row factor scores
symMap$baseMap +
symMap.row <- symMap$I_labels + symMap$I_points +
ggtitle('Symmetric: Row') +
labels4CA
# plot the columns factor scores with confidence intervals
symMap$baseMap +
symMap.col <- symMap$J_labels + symMap$J_points +
ggtitle('Symmetric: Column') +
labels4CA
grid.arrange(
sidebyside <-
symMap.row, symMap.col,ncol = 2,nrow = 1,
top = textGrob("Factor scores", gp = gpar(fontsize = 18, font = 3))
)
symMap$baseMap +
biplot <- symMap$I_labels + symMap$I_points +
symMap$J_labels + symMap$J_points +
ggtitle('Factor Scores Biplot (Rows and Cols)') +
labels4CA
sidebyside
## TableGrob (2 x 2) "arrange": 3 grobs
## z cells name grob
## 1 1 (2-2,1-1) arrange gtable[layout]
## 2 2 (2-2,2-2) arrange gtable[layout]
## 3 3 (1-1,1-2) arrange text[GRID.text.12558]
recordPlot()
sidebyside <-
symMap.row
recordPlot()
symMap.row <-
symMap.col
recordPlot()
symMap.col <-
biplot
recordPlot() biplot <-
Let’s also check Dimension 3 and 4:
# create symmetric Map:
createFactorMapIJ(Fi,
symMap <-
Fj,col.labels.j = "darkgreen",
col.points.j = "darkgreen",
col.points.i = "hotpink",
col.labels.i = "hotpink",
text.cex.i = 3,
text.cex.j = 3,
axis1 = 3,
axis2 = 4)
createxyLabels(resCA = resCA.asym, x_axis = 3, y_axis = 4)
labels4CA <-
# plot the row factor scores
symMap$baseMap +
symMap.row2 <- symMap$I_labels + symMap$I_points +
ggtitle('Symmetric: Row - D3 & D4') +
labels4CA
# plot the columns factor scores with confidence intervals
symMap$baseMap +
symMap.col2 <- symMap$J_labels + symMap$J_points +
ggtitle('Symmetric: Column - D3 & D4') +
labels4CA
grid.arrange(
sidebyside2 <-
symMap.row2, symMap.col2,ncol = 2,nrow = 1,
top = textGrob("Factor scores - D3 & D4", gp = gpar(fontsize = 18, font = 3))
)
symMap$baseMap +
biplot2 <- symMap$I_labels + symMap$I_points +
symMap$J_labels + symMap$J_points +
ggtitle('Factor Scores Biplot (Rows and Cols) - D3 & D4') +
labels4CA
sidebyside2
## TableGrob (2 x 2) "arrange": 3 grobs
## z cells name grob
## 1 1 (2-2,1-1) arrange gtable[layout]
## 2 2 (2-2,2-2) arrange gtable[layout]
## 3 3 (1-1,1-2) arrange text[GRID.text.13030]
recordPlot()
sidebyside2 <-
symMap.row2
recordPlot()
symMap.row <-
symMap.col2
recordPlot()
symMap.col2 <-
biplot2
recordPlot() biplot2 <-
Recolor to tell a story about products similarities (D1,2 - rows):
#color for product groups based on proximity
dplyr::recode(wk0$Products,
prod.color <-"Nutriday Bebible" = "firebrick1",
"Alquería Niños" = 'firebrick1',
"Yogo Yogo" = 'firebrick1',
"Seedy strawberry" = "thistle2",
"Jammy strawberry" = "turquoise3",
"Sweet strawberry" = "thistle2",
"Candied strawberry" = "turquoise3",
"Fruity strawberry"= "thistle2"
)
# create symmetric Map:
createFactorMapIJ(Fi,
symMap <-
Fj,col.points.i = prod.color,
col.labels.i = prod.color,
text.cex.i = 3,
text.cex.j = 3)
createxyLabels(resCA = resCA.asym)
labels4CA <-
# plot the row factor scores
symMap$baseMap +
symMap.row3 <- symMap$I_labels + symMap$I_points +
ggtitle('Symmetric: Row - Products Groups on Component 1') +
labels4CA
symMap.row3
recordPlot() symMap.row3 <-
Recolor to tell a story about positive vs negative emotions (D3,4 - columns):
#Recolor positive vs negative emotions:
dplyr::recode(colnames(wk0[,-1]),
emo.color <-"Happy" = "turquoise3",
"Pleasantly surprised" = "turquoise3",
"Refreshed" = "turquoise3",
"Calm" = "turquoise3",
"Comforted" = "turquoise3",
"Disgusted" = 'firebrick1',
"Energetic" = "turquoise3",
"Joy" = "turquoise3",
"Interested" = "turquoise3",
"Irritated" = 'firebrick1',
"Relaxed" = "turquoise3",
"Sad" = 'firebrick1',
"Well-being" = "turquoise3")
# create symmetric Map:
createFactorMapIJ(Fi,
symMap <-
Fj,col.labels.j = emo.color,
col.points.j = emo.color,
text.cex.i = 3,
text.cex.j = 3,
axis1 = 3,
axis2 = 4)
createxyLabels(resCA = resCA.asym, x_axis = 3, y_axis = 4)
labels4CA <-
# plot the columns factor scores with confidence intervals
symMap$baseMap +
symMap.col3 <- symMap$J_labels + symMap$J_points +
ggtitle('Symmetric: Column - D3 & D4 - Positive VS Negative Emotion') +
labels4CA
symMap.col3
recordPlot() symMap.col3 <-
8.3.4.3 Contributions and bootstrap ratios barplots
Contribution barplots:
Make the barplots:
resCA.sym$ExPosition.Data$ci * sign(resCA.sym$ExPosition.Data$fi)
signed.ctrI <- resCA.sym$ExPosition.Data$cj * sign(resCA.sym$ExPosition.Data$fj)
signed.ctrJ <-
#matching color scheme:
rep("darkseagreen",13)
sweet.col <- rep("hotpink",8)
sweet.row <-
# plot contributions of rows for component 1
.1 <- PrettyBarPlot2(signed.ctrI[,1],
ctrIthreshold = 1 / NROW(signed.ctrI),
font.size = 3,
color4bar = sweet.row,
ylab = 'Contributions',
ylim = c(1.2*min(signed.ctrI), 1.2*max(signed.ctrI))
+ ggtitle("Component 1", subtitle = 'rows')
)
# plot contributions of columns for component 1
.1 <- PrettyBarPlot2(signed.ctrJ[,1],
ctrJthreshold = 1 / NROW(signed.ctrJ),
font.size = 3,
color4bar = sweet.col,
ylab = 'Contributions',
ylim = c(1.2*min(signed.ctrJ), 1.2*max(signed.ctrJ))
+ ggtitle("", subtitle = 'columns')
)
# plot contributions of rows for component 2
.2 <- PrettyBarPlot2(signed.ctrI[,2],
ctrIthreshold = 1 / NROW(signed.ctrI),
font.size = 3,
color4bar = sweet.row,
ylab = 'Contributions',
ylim = c(1.2*min(signed.ctrI), 1.2*max(signed.ctrI))
+ ggtitle("Component 2", subtitle = 'rows')
)
# plot contributions of columns for component 2
.2 <- PrettyBarPlot2(signed.ctrJ[,2],
ctrJthreshold = 1 / NROW(signed.ctrJ),
font.size = 3,
color4bar = sweet.col,
ylab = 'Contributions',
ylim = c(1.2*min(signed.ctrJ), 1.2*max(signed.ctrJ))
+ ggtitle("", subtitle = 'columns') )
Combine them:
grid.arrange(
as.grob(ctrI.1),as.grob(ctrJ.1),as.grob(ctrI.2),as.grob(ctrJ.2),
ncol = 2,nrow = 2,
top = textGrob("Contributions", gp = gpar(fontsize = 18, font = 3))
)
recordPlot() Ctr.IJ <-
Bootstrap Ratio
resCAinf.sym.row$Inference.Data$fj.boots$tests$boot.ratios
BR.I <- resCAinf.sym.col$Inference.Data$fj.boots$tests$boot.ratios
BR.J <-
rep("hotpink",13)
sweet.row1 <-
1
laDim =
# Plot the bootstrap ratios for Dimension 1
PrettyBarPlot2(BR.I[,laDim],
ba001.BR1.I <-threshold = 2,
font.size = 3,
color4bar = sweet.row,
ylab = 'Bootstrap ratios'
#ylim = c(1.2*min(BR[,laDim]), 1.2*max(BR[,laDim]))
+ ggtitle(paste0('Component ', laDim), subtitle = 'rows')
)
PrettyBarPlot2(BR.J[,laDim],
ba002.BR1.J <-threshold = 2,
font.size = 3,
color4bar = sweet.col,
ylab = 'Bootstrap ratios'
#ylim = c(1.2*min(BR[,laDim]), 1.2*max(BR[,laDim]))
+ ggtitle("", subtitle = 'columns')
)
# Plot the bootstrap ratios for Dimension 2
2
laDim = PrettyBarPlot2(BR.I[,laDim],
ba003.BR2.I <-threshold = 2,
font.size = 3,
color4bar = sweet.row,
ylab = 'Bootstrap ratios'
#ylim = c(1.2*min(BR[,laDim]), 1.2*max(BR[,laDim]))
+ ggtitle(paste0('Component ', laDim), subtitle = 'rows')
)
PrettyBarPlot2(BR.J[,laDim],
ba004.BR2.J <-threshold = 2,
font.size = 3,
color4bar = sweet.col,
ylab = 'Bootstrap ratios'
#ylim = c(1.2*min(BR[,laDim]), 1.2*max(BR[,laDim]))
+ ggtitle("", subtitle = 'columns') )
Combine them:
grid.arrange(
as.grob(ba001.BR1.I),as.grob(ba002.BR1.J),as.grob(ba003.BR2.I),as.grob(ba004.BR2.J),
ncol = 2,nrow = 2,
top = textGrob("Bootstrap ratios", gp = gpar(fontsize = 18, font = 3))
)
recordPlot() # you need this line to be able to save them in the end BR.IJ <-
Combine them all:
grid.arrange(
as.grob(ctrI.1),as.grob(ctrJ.1),as.grob(ctrI.2),as.grob(ctrJ.2),as.grob(ba001.BR1.I),as.grob(ba002.BR1.J),as.grob(ba003.BR2.I),as.grob(ba004.BR2.J),
ncol = 4,nrow = 2,
top = textGrob("Contribution & Bootstrap Ratios", gp = gpar(fontsize = 18, font = 3))
)
recordPlot() combine <-
Repeat for Dimension 3 and 4:
Make the barplots:
resCA.sym$ExPosition.Data$ci * sign(resCA.sym$ExPosition.Data$fi)
signed.ctrI <- resCA.sym$ExPosition.Data$cj * sign(resCA.sym$ExPosition.Data$fj)
signed.ctrJ <-
#matching color scheme:
rep("darkseagreen",13)
sweet.col <- rep("hotpink",8)
sweet.row <-
# plot contributions of rows for component 1
.1 <- PrettyBarPlot2(signed.ctrI[,3],
ctrIthreshold = 1 / NROW(signed.ctrI),
font.size = 3,
color4bar = sweet.row,
ylab = 'Contributions',
ylim = c(1.2*min(signed.ctrI), 1.2*max(signed.ctrI))
+ ggtitle("Component 1", subtitle = 'rows')
)
# plot contributions of columns for component 1
.1 <- PrettyBarPlot2(signed.ctrJ[,3],
ctrJthreshold = 1 / NROW(signed.ctrJ),
font.size = 3,
color4bar = sweet.col,
ylab = 'Contributions',
ylim = c(1.2*min(signed.ctrJ), 1.2*max(signed.ctrJ))
+ ggtitle("", subtitle = 'columns')
)
# plot contributions of rows for component 2
.2 <- PrettyBarPlot2(signed.ctrI[,4],
ctrIthreshold = 1 / NROW(signed.ctrI),
font.size = 3,
color4bar = sweet.row,
ylab = 'Contributions',
ylim = c(1.2*min(signed.ctrI), 1.2*max(signed.ctrI))
+ ggtitle("Component 2", subtitle = 'rows')
)
# plot contributions of columns for component 2
.2 <- PrettyBarPlot2(signed.ctrJ[,4],
ctrJthreshold = 1 / NROW(signed.ctrJ),
font.size = 3,
color4bar = sweet.col,
ylab = 'Contributions',
ylim = c(1.2*min(signed.ctrJ), 1.2*max(signed.ctrJ))
+ ggtitle("", subtitle = 'columns') )
Combine them:
grid.arrange(
as.grob(ctrI.1),as.grob(ctrJ.1),as.grob(ctrI.2),as.grob(ctrJ.2),
ncol = 2,nrow = 2,
top = textGrob("Contributions", gp = gpar(fontsize = 18, font = 3))
)
recordPlot() Ctr.IJ <-
Bootstrap Ratio
resCAinf.sym.row$Inference.Data$fj.boots$tests$boot.ratios
BR.I <- resCAinf.sym.col$Inference.Data$fj.boots$tests$boot.ratios
BR.J <-
rep("hotpink",13)
sweet.row1 <-
3
laDim =
# Plot the bootstrap ratios for Dimension 1
PrettyBarPlot2(BR.I[,laDim],
ba001.BR1.I <-threshold = 2,
font.size = 3,
color4bar = sweet.row,
ylab = 'Bootstrap ratios'
#ylim = c(1.2*min(BR[,laDim]), 1.2*max(BR[,laDim]))
+ ggtitle(paste0('Component ', laDim), subtitle = 'rows')
)
PrettyBarPlot2(BR.J[,laDim],
ba002.BR1.J <-threshold = 2,
font.size = 3,
color4bar = sweet.col,
ylab = 'Bootstrap ratios'
#ylim = c(1.2*min(BR[,laDim]), 1.2*max(BR[,laDim]))
+ ggtitle("", subtitle = 'columns')
)
# Plot the bootstrap ratios for Dimension 2
4
laDim = PrettyBarPlot2(BR.I[,laDim],
ba003.BR2.I <-threshold = 2,
font.size = 3,
color4bar = sweet.row,
ylab = 'Bootstrap ratios'
#ylim = c(1.2*min(BR[,laDim]), 1.2*max(BR[,laDim]))
+ ggtitle(paste0('Component ', laDim), subtitle = 'rows')
)
PrettyBarPlot2(BR.J[,laDim],
ba004.BR2.J <-threshold = 2,
font.size = 3,
color4bar = sweet.col,
ylab = 'Bootstrap ratios'
#ylim = c(1.2*min(BR[,laDim]), 1.2*max(BR[,laDim]))
+ ggtitle("", subtitle = 'columns') )
Combine them:
grid.arrange(
as.grob(ba001.BR1.I),as.grob(ba002.BR1.J),as.grob(ba003.BR2.I),as.grob(ba004.BR2.J),
ncol = 2,nrow = 2,
top = textGrob("Bootstrap ratios", gp = gpar(fontsize = 18, font = 3))
)
recordPlot() # you need this line to be able to save them in the end BR.IJ <-
Combine them all:
grid.arrange(
as.grob(ctrI.1),as.grob(ctrJ.1),as.grob(ctrI.2),as.grob(ctrJ.2),as.grob(ba001.BR1.I),as.grob(ba002.BR1.J),as.grob(ba003.BR2.I),as.grob(ba004.BR2.J),
ncol = 4,nrow = 2,
top = textGrob("Contribution & Bootstrap Ratios", gp = gpar(fontsize = 18, font = 3))
)
recordPlot() combine <-