createPartialFactorScoresMap: Create a 'ggplot2' map for partial factor scores (for...

View source: R/createMap4PartialFS.R

createPartialFactorScoresMapR Documentation

Create a ggplot2 map for partial factor scores (for PTCA4CATA, ordistatis) to be added to the main map of the factor scores.

Description

createPartialFactorScoresMap: Creates a map for partial factor scores for blocks of data (e.g., for PTCA4CATA or distatis) to be added to the main map of the factor scores (created for example by createFactorMap). The partial factor scores are colored by Blocks and by Items (i.e. observations). The data are 1) an I Items by J factors/dimensions data set storing the main factor scores (factorScores), and 2) an I Items by J factors/dimensions by K Blocks storing the partial factor scores. The resulting map connects the partial factor scores to their respective main factor scores.

Usage

createPartialFactorScoresMap(
  factorScores,
  partialFactorScores,
  axis1 = 1,
  axis2 = 2,
  colors4Items = NULL,
  colors4Blocks = NULL,
  names4Partial = NULL,
  alpha.lines = 0.5,
  size.lines = 0.75,
  type.lines = 1,
  arrow.length = 0,
  alpha.points = 0.7,
  shape.points = 23,
  size.points = 1,
  alpha.labels = 0.7,
  font.labels = "plain",
  family.labels = "sans",
  size.labels = 2
)

Arguments

factorScores

an I Items by J factors/dimensions data set storing the main factor scores.

partialFactorScores

an I Items by J factors/dimensions by K Blocks storing the partial factor scores. Needs to have numbers of Items as factorScores.

axis1

(Default: 1) the horizontal dimension of the map.

axis2

(Default: 2) the vertical dimension of the map.

colors4Items

(Default: NULL) color name(s) for the Items, can be one element or a I by 1 vector of color names. If NULL (defaults), prettyGraphsColorSelection() is used to select the colors.

colors4Blocks

(Default: NULL) color name(s) for the Blocks, can be one element or a K by 1 vector of color names. If NULL (defaults), prettyGraphsColorSelection() is used to select the colors.

names4Partial

a vector for (preferably short) names of the Blocks. If NULL (default), the names are obtained from the third dimension of partialFactorScores; if the third dimension of partialFactorScores is NULL, then block are names from 1 to K.

alpha.lines

(Default: 0.5) transparency parameter for the lines, should be between 0 (complety transparent) and 1 (no transparent).

size.lines

(Default: 0.75) thickness of the lines connecting the partial factor scores to their main scores.

type.lines

(Default: 1) the type (from 1 to 6) of the lines connecting the partial factor scores to their main scores.

arrow.length

(Default: 0) the length in cm. of the arrow point toward the factor scores.

alpha.points

(Default: 0.7) transparency parameter for the points, should be between 0 (complety transparent) and 1 (no transparent).

shape.points

(Default: 23) the pch for the shape (from 1 to 25). Default (23) is the diamond.

size.points

(Default: 1) the size of the points.

alpha.labels

(Default: 0.7) transparency parameter for the labels, should be between 0 (complety transparent) and 1 (no transparent).

font.labels

(Default: 'plain') the font for the labels, can be "plain", "bold", "italic"

family.labels

(Default: 'sans') the family of the fontn used, this set depends upon the set of font installed, the three save choices (always installed) are 'sans','serif','mono'.

size.labels

(Default: 2) the size of the labels.

Details

The maps show the connections from the partial factor scores to the main factor scores (which are baycentric to their respective partial factor scores). The map obtained should be added to a main map (of the main factor scores) that should be created prior to adding the map of the partial factor scores. Because the partial factor scores have a larger variance than the main factor scores, the dimension (i.e. the constraints) of the map should be computed (with minmaxHelper4Partial()) before creating the main of the main factor scores (see example).

Value

a list with 1) $mapColByItems: the Partial Factor Score Map Colored by Items; 2) $mapColByBlocks: the Partial Factor Score Map Colored by Blocks; 3) $linesColByItems: the Lines Colored by Items; 4) $pointsColByItems: Points Colored by Items; 5) $labelsColByItems: the Labels Colored by Items; 6) $linesColByBlocks: the Lines Colored by Blocks; 7) $pointsColByBlocks: the Points Colored by Blocks; and 8) #'$labelsColByBlocks: the Labels Colored by Blocks.

Important_Note

When creating multiple layers graphs because of the way ggplot2 create graphs all the the matrices/dataframe should all the have the same column names [e.g., colnames() equal to c("Dimension 1", "Dimension 2")]. When it is not the case, some strange and cryptic error may be produced (e.g., "cannot find Dimension").

Author(s)

Herve Abdi

See Also

minmaxHelper4Partial createFactorMap DistatisR

Examples

## Not run: 
# fS are factor scores and pFS are partial factor scores
# first get the constraints
constraint4PFS <- minmaxHelper4Partial(fS, pFS)
# Get the background map
BaseMap.FS <- createFactorMap(X = fS ,
                              constraints = constraint4PFS)
# Create the map of the partial factor scores
map4pFS <- createPartialFactorScoresMap(fS, pFS)
map_FS_pFS <- BaseMap.FS + map4pFS
# To print the Map:
print(map_FS_pFS )

## End(Not run)

HerveAbdi/PTCA4CATA documentation built on July 17, 2022, 5:41 a.m.