ggadd_partial: Main and partial effect of a supplementary variable

View source: R/ggadd_partial.R

ggadd_partialR Documentation

Main and partial effect of a supplementary variable

Description

Adds the main and partial effects of a supplementary variable to a MCA cloud of individuals, with one or more supplementary partialled out

Usage

ggadd_partial(p, resmca, var, controls, excl = NULL,
axes = c(1,2), col = "black", textsize = 4, lines = TRUE, dashes = TRUE, 
legend = "right", force = 1, max.overlaps = Inf)

Arguments

p

ggplot2 object with the cloud of variables or the cloud of individuals

resmca

object created with MCA, speMCA, csMCA, wcMCA, bcMCA, stMCA or multiMCA function

var

factor. The categorical supplementary variable.

controls

data frame of supplementary variables to be partialled out (i.e. control variables)

excl

character vector of categories from the var to exclude from the plot. If NULL (default), all the supplementary categories are plotted.

axes

numeric vector of length 2, specifying the components (axes) to plot. Default is c(1,2).

col

the color for the labels and lines. Default is "black".

textsize

size of the labels of categories. Default is 4.

lines

logical. Whether to add colored lines between the points of the categories of v1. Default is TRUE.

dashes

logical. Whether to add gray dashed lines between the points of the categories of v2. Default is TRUE.

legend

the position of legends ("none", "left", "right", "bottom", "top", or two-element numeric vector). Default is right.

force

force of repulsion between overlapping text labels. Defaults to 1. If 0, labels are not repelled at all.

max.overlaps

exclude text labels that overlap too many things. Defaults to Inf, which means no labels are excluded.

Value

a ggplot2 object

Note

The partial effects of the supplementary variable are computed with the Average Marginal Effects of a linear regression, with individual coordinates as dependent variable, and the supplementary and control variables as independent variables.

Author(s)

Nicolas Robette

References

Le Roux B. and Rouanet H., Multiple Correspondence Analysis, SAGE, Series: Quantitative Applications in the Social Sciences, Volume 163, CA:Thousand Oaks (2010).

Le Roux B. and Rouanet H., Geometric Data Analysis: From Correspondence Analysis to Stuctured Data Analysis, Kluwer Academic Publishers, Dordrecht (June 2004).

See Also

ggcloud_variables, ggadd_supvar, ggadd_supvars, ggadd_interaction

Examples

# specific MCA of Taste example data set
data(Taste)
junk <- c("FrenchPop.NA", "Rap.NA", "Rock.NA", "Jazz.NA", "Classical.NA",
          "Comedy.NA", "Crime.NA", "Animation.NA", "SciFi.NA", "Love.NA", 
          "Musical.NA")
mca <- speMCA(Taste[,1:11], excl = junk)
# effect of education,
# with age partialled out (partial effect) or not (main effect)
p <- ggcloud_indiv(mca, col = "grey95")
ggadd_partial(p, mca, Taste$Educ, Taste$Age)

GDAtools documentation built on June 8, 2025, 10:08 a.m.