Package 'circumplex'

Title: Analysis and Visualization of Circular Data
Description: Circumplex models, which organize constructs in a circle around two underlying dimensions, are popular for studying interpersonal functioning, mood/affect, and vocational preferences/environments. This package provides tools for analyzing and visualizing circular data, including scoring functions for relevant instruments and a generalization of the bootstrapped structural summary method from Zimmermann & Wright (2017) <doi:10.1177/1073191115621795> and functions for creating publication-ready tables and figures from the results.
Authors: Jeffrey Girard [aut, cre] (ORCID: <https://orcid.org/0000-0002-7359-3746>), Johannes Zimmermann [aut] (ORCID: <https://orcid.org/0000-0001-6975-2356>), Aidan Wright [aut] (ORCID: <https://orcid.org/0000-0002-2369-0601>)
Maintainer: Jeffrey Girard <[email protected]>
License: GPL-3
Version: 1.2.0.9999
Built: 2026-07-03 15:13:21 UTC
Source: https://github.com/jmgirard/circumplex

Help Index


Display the anchors of a circumplex instrument

Description

Display the anchors of a circumplex instrument including the total number of anchors and each anchor's numerical value and text label. Anchors are the response options that respondants select from (e.g., 0 = No, 1 = Yes).

Usage

anchors(x)

Arguments

x

Required. An object of the instrument class.

Value

The same input object. Prints text to console.

See Also

Other instrument functions: instruments(), items(), norms(), scales()

Examples

anchors(csip)

Standardized octant scores on hypothetical circumplex scales

Description

A small example dataset containing standardized scores on eight hypothetical circumplex scales. Taken from Wright, Pincus, Conroy, & Hilsenroth (2009).

Usage

aw2009

Format

A data frame with 5 observations and 8 variables:

PA

circumplex scale at 90 degrees

BC

circumplex scale at 135 degrees

DE

circumplex scale at 180 degrees

FG

circumplex scale at 225 degrees

HI

circumplex scale at 270 degrees

JK

circumplex scale at 315 degrees

LM

circumplex scale at 360 degrees

NO

circumplex scale at 45 degrees

Source

doi:10.1080/00223890902935696


Draw SSM confidence-region arcs in circumplex space

Description

A ggplot2 layer that draws, for each profile, the wedge spanning its amplitude confidence interval (radially) and its displacement confidence interval (angularly), on the canvas produced by ggcircumplex(). The amplitude/displacement-to-canvas transform – including the wrap-around when a displacement interval crosses the 0/360 degree boundary – is handled internally, so the bounds are supplied directly in SSM units.

Usage

geom_ssm_arc(
  mapping = NULL,
  data = NULL,
  stat = StatSsmArc,
  position = "identity",
  ...,
  amax = 0.5,
  n = 360,
  na.rm = TRUE,
  show.legend = NA,
  inherit.aes = TRUE
)

Arguments

mapping, data, stat, position, show.legend, inherit.aes, ...

Standard ggplot2 layer arguments. mapping must supply the amplitude_min, amplitude_max, displacement_min, and displacement_max aesthetics.

amax

A single positive number giving the amplitude represented by the canvas's outer ring; must match the amax used for ggcircumplex() (default = 0.5).

n

The number of points used to draw each arc's curved edges (default = 360).

na.rm

Ignored; profiles with a missing displacement or amplitude bound (degenerate profiles) are always dropped.

Value

A ggplot2 layer.

See Also

ggcircumplex(), geom_ssm_point()

Examples

data("jz2017")
res <- ssm_analyze(jz2017, scales = 2:9, measures = "NARPD")
amax <- 0.5
ggcircumplex(octants(), amax = amax) +
  geom_ssm_arc(
    data = res$results,
    mapping = ggplot2::aes(
      amplitude_min = a_lci, amplitude_max = a_uci,
      displacement_min = d_lci, displacement_max = d_uci
    ),
    amax = amax, alpha = 0.4
  )

Draw SSM profile points in circumplex space

Description

A ggplot2 layer that places a point for each profile at its amplitude and displacement, on the canvas produced by ggcircumplex(). The amplitude/displacement-to-canvas transform is handled internally, so the amplitude and displacement aesthetics are supplied directly in SSM units (amplitude in the score metric, displacement in degrees).

Usage

geom_ssm_point(
  mapping = NULL,
  data = NULL,
  stat = "identity",
  position = "identity",
  ...,
  amax = 0.5,
  na.rm = TRUE,
  show.legend = NA,
  inherit.aes = TRUE
)

Arguments

mapping, data, stat, position, show.legend, inherit.aes, ...

Standard ggplot2 layer arguments. mapping must supply the amplitude and displacement aesthetics.

amax

A single positive number giving the amplitude represented by the canvas's outer ring; must match the amax used for ggcircumplex() so the points align with the amplitude gridlines (default = 0.5).

na.rm

Ignored; profiles with a missing displacement or amplitude (degenerate profiles) are always dropped, since they have no location.

Value

A ggplot2 layer.

See Also

ggcircumplex(), geom_ssm_arc()

Examples

data("jz2017")
res <- ssm_analyze(jz2017, scales = 2:9, measures = "NARPD")
amax <- 0.5
ggcircumplex(octants(), amax = amax) +
  geom_ssm_point(
    data = res$results,
    mapping = ggplot2::aes(amplitude = a_est, displacement = d_est),
    amax = amax
  )

Create a circumplex plotting canvas

Description

Build an empty circular canvas – the amplitude rings, displacement spokes, and scale labels that circumplex figures are drawn on – as a ggplot2 object. Additional layers (points, arcs, annotations) can be added to it with +, so it serves as the reusable foundation for custom circumplex visualizations. The package's own ssm_plot_circle() draws on the same canvas.

Usage

ggcircumplex(
  angles = octants(),
  labels = NULL,
  amax = 0.5,
  font_size = 12,
  instrument = NULL
)

Arguments

angles

Optional. A numeric vector of the angular position (in degrees) of each circumplex scale, going counterclockwise from the right (default = octants()). Ignored if instrument is supplied.

labels

Optional. Either NULL or a character vector of text labels to draw around the circle, one per angle and in the same order (default = NULL, which draws the numeric angles). If instrument is supplied, NULL uses the instrument's scale abbreviations.

amax

Optional. A single positive number giving the amplitude at the outer ring, which sets the amplitude-axis labels; the center of the circle is fixed at amplitude 0 (default = 0.5).

font_size

Optional. A single positive number giving the size (in pt) of the scale and amplitude labels (default = 12).

instrument

Optional. Either NULL or a circumplex_instrument object (see instrument()). When supplied, the scale angles and (unless labels is given) the scale abbreviations are taken from the instrument (default = NULL).

Value

A ggplot2 object containing the empty circumplex canvas.

See Also

ssm_plot_circle(), which draws SSM results on this canvas.

Examples

# A default octant canvas
ggcircumplex()

# Label the scales with their circumplex pole abbreviations
ggcircumplex(octants(), labels = PANO())

# Derive the angles and labels from a circumplex instrument
ggcircumplex(instrument = csip)

Format and render data frame as HTML table

Description

Format a data frame as an HTML table and render it to the web viewer.

Usage

html_render(df, caption = NULL, align = "l", ...)

Arguments

df

A data frame to be rendered as an HTML table.

caption

A string to be displayed above the table.

align

A string indicating the alignment of the cells (default = "l").

...

Other arguments to pass to htmlTable.

Value

HTML syntax for the df table.

See Also

Other table functions: ssm_table()


List all available instruments

Description

The circumplex package includes information about numerous circumplex instruments including instructions for scoring and standardizing items. Individual instruments can be loaded using the instrument function.

Usage

instruments()

See Also

Other instrument functions: anchors(), items(), norms(), scales()

Examples

instruments()

Ipsatize circumplex items using deviation scoring across variables

Description

Rescore each circumplex item using deviation scoring across variables. In other words, subtract each observation's mean response from each response. This effectively removes the presence of a general factor, which can make certain circumplex fit analyses more powerful.

Usage

ipsatize(data, items, na.rm = TRUE, prefix = "", suffix = "_i", append = TRUE)

Arguments

data

Required. A data frame or matrix containing at least circumplex scales.

items

Required. A character vector containing the column names, or a numeric vector containing column indexes, of item variables in data to be ipsatized.

na.rm

Optional. A logical that determines whether missing values should be ignored during the calculation of the mean during ipsatization (default = TRUE).

prefix

Optional. A string that will be added to the start of each items name in the output (default = "").

suffix

Optional. A string that will be added to the end of each items name in the output (default = "_i").

append

Optional. A logical that determines whether to append the ipsatized scores to data in the output or just return the ipsatized scores alone (default = TRUE).

Value

A data frame that matches data except that the variables specified in items have been rescored using ipsatization.

See Also

Other tidying functions: norm_standardize(), score(), self_standardize()

Examples

data("raw_iipsc")
ipsatize(raw_iipsc, items = 1:32)
ipsatize(raw_iipsc, items = sprintf("IIP%02d", 1:32))

Display the items of a circumplex instrument

Description

Display the items of a circumplex instrument including the total number of items and each item's number and text. The item ordering/numbering displayed here is the same ordering/numbering assumed by the score() function.

Usage

items(x)

Arguments

x

Required. An object of the instrument class.

Value

The same input object. Prints text to console.

See Also

Other instrument functions: anchors(), instruments(), norms(), scales()

Examples

items(csip)

Raw octant scores on real circumplex scales with covariates

Description

A large example dataset containing gender, raw mean scores on the Inventory of Interpersonal Problems - Short Circumplex (IIP-SC), and raw sum scores on the Personality Diagnostic Questionnaire - 4th Edition Plus (PDQ-4+).

Usage

jz2017

Format

A data frame with 1166 observations and 19 variables:

Gender

Self-reported Gender

PA

Domineering Problems (IIP-SC) 90 degrees

BC

Vindictive Problems (IIP-SC) 135 degrees

DE

Cold Problems (IIP-SC) 180 degrees

FG

Socially Avoidant Problems (IIP-SC) 225 degrees

HI

Nonassertive Problems(IIP-SC) 270 degrees

JK

Easily Exploited Problems (IIP-SC) 315 degrees

LM

Overly Nurturant Problems (IIP-SC) 360 degrees

NO

Intrusive Problems (IIP-SC) 45 degrees

PARPD

Paranoid PD Symptoms (PDQ-4+)

SCZPD

Schizoid PD Symptoms (PDQ-4+)

SZTPD

Schizotypal PD Symptoms (PDQ-4+)

ASPD

Antisocial PD Symptoms (PDQ-4+)

BORPD

Borderline PD Symptoms (PDQ-4+)

HISPD

Histrionic PD Symptoms (PDQ-4+)

NARPD

Narcissistic PD Symptoms (PDQ-4+)

AVPD

Avoidant PD Symptoms (PDQ-4+)

DPNPD

Dependent PD Symptoms (PDQ-4+)

OCPD

Obsessive-Compulsive PD Symptoms (PDQ-4+)

Source

doi:10.1177/1073191115621795


Standardize circumplex scales using normative data

Description

Take in a data frame containing circumplex scales, angle definitions for each scale, and normative data (from the package or custom) and return that same data frame with each specified circumplex scale transformed into standard scores (i.e., z-scores) based on comparison to the normative data.

Usage

norm_standardize(
  data,
  scales,
  angles = octants(),
  instrument,
  sample = 1,
  prefix = "",
  suffix = "_z",
  append = TRUE
)

Arguments

data

Required. A data frame or matrix containing at least circumplex scales.

scales

Required. A character vector containing the column names, or a numeric vector containing the column indexes, for the variables (scale scores) to be standardized.

angles

Required. A numeric vector containing the angular displacement of each circumplex scale included in scales (in degrees). Can use the octants(), poles(), or quadrants() convenience functions. Each angle is matched to the instrument's normative data by angular position, so 0 and 360 degrees are treated as the same angle; an angle with no matching normative row (or with more than one) produces an informative error.

instrument

Required. An instrument object from the package. To see the available circumplex instruments, see instruments().

sample

Required. An integer corresponding to the normative sample to use in standardizing the scale scores (default = 1). See ?norms to see the normative samples available for an instrument.

prefix

Optional. A string to include at the beginning of the newly calculated scale variables' names, before the scale name and suffix (default = "").

suffix

Optional. A string to include at the end of the newly calculated scale variables' names, after the scale name and prefix (default = "_z").

append

Optional. A logical that determines whether the calculated standardized scores should be added as columns to data in the output or the standardized scores alone should be output (default = TRUE).

Value

A data frame that contains the norm-standardized versions of scales.

See Also

Other tidying functions: ipsatize(), score(), self_standardize()

Examples

data("jz2017")
norm_standardize(jz2017, scales = 2:9, instrument = iipsc, sample = 1)

Display the norms for a circumplex instrument

Description

Display the norms for a circumplex instrument including the total number of normative data sets available and each data set's number, sample size, population, and source reference and hyperlink. If another normative data set exists that is not yet included in the package, please let us know.

Usage

norms(x)

Arguments

x

Required. An object of the instrument class.

Value

The same input object. Prints text to console.

See Also

Other instrument functions: anchors(), instruments(), items(), scales()

Examples

norms(csip)

Angular displacements for octant circumplex scales

Description

Return a vector of angular displacements, in degrees, for eight equally spaced circumplex scales corresponding to the circumplex octants. Can be passed to the angles parameter of other functions in this package.

Usage

octants()

Value

A numeric vector with eight elements, each corresponding to the angular displacement (in degrees) of a subscale, in the following order: PA, BC, DE, FG, HI, JK, LM, NO.

Examples

octants()

Two-letter abbreviations for octant circumplex scales

Description

Return a vector of abbreviations for octant circumplex scales, from PA to NO.

Usage

PANO(case = "upper")

Arguments

case

An optional string the determines whether the abbreviations should be in uppercase or lowercase. (default = "upper")

Value

A character vector with eight elements, each corresponding to the abbreviation of an octant subscale: PA, BC, DE, FG, HI, JK, LM, NO.

Examples

PANO()
PANO(case = "lower")

Angular displacements for pole circumplex scales

Description

Return a vector of angular displacements, in degrees, for four equally spaced circumplex scales corresponding to the circumplex poles. Can be passed to the angles parameter of other functions in this package.

Usage

poles()

Value

A numeric vector with four elements, each corresponding to the angular displacement (in degrees) of a subscale, in the following order: PA, DE, HI, LM.

Examples

poles()

Angular displacements for quadrant circumplex scales

Description

Return a vector of angular displacements, in degrees, for four equally spaced circumplex scales corresponding to the circumplex quadrants. Can be passed to the angles parameter of other functions in this package.

Usage

quadrants()

Value

A numeric vector with eight elements, each corresponding to the angular displacement (in degrees) of a subscale, in the following order: BC, FG, JK, NO.

Examples

quadrants()

Raw item responses on real circumplex scales

Description

A small example dataset containing raw item responses on the Inventory of Interpersonal Problems, Short Circumplex (IIP-SC). This data set is useful for testing functions that operate on item-level data.

Usage

raw_iipsc

Format

A data frame with 10 observations and 32 variables.


Angle-labeled x-axis scale for circumplex plots

Description

A ggplot2 continuous position scale for the angle axis of a linear circumplex plot, such as the score-by-angle curve drawn by ssm_plot_curve(). It places axis breaks at the circumplex scale angles and labels them, by default, with their angular position in degrees. Custom text labels or a circumplex_instrument can be supplied instead, using the same conventions as ggcircumplex(), so the linear axis and the circular canvas label their scales consistently.

Usage

scale_x_circumplex(angles = octants(), labels = NULL, instrument = NULL, ...)

Arguments

angles

Optional. A numeric vector of the angular position (in degrees) of each circumplex scale (default = octants()). Ignored if instrument is supplied.

labels

Optional. Either NULL or a character vector of axis labels, one per angle and in the same order (default = NULL, which labels each break with its angle in degrees, or with the instrument's scale abbreviations when instrument is supplied).

instrument

Optional. Either NULL or a circumplex_instrument object (see instrument()) from which to take the scale angles and (unless labels is given) abbreviations (default = NULL).

...

Additional arguments passed to ggplot2::scale_x_continuous(), such as name or limits.

Value

A ggplot2 scale object that can be added to a plot with +.

See Also

ggcircumplex()

Examples

# Degree-labeled angle axis
scale_x_circumplex(octants())

# Label the axis with an instrument's scale abbreviations
scale_x_circumplex(instrument = csip)

Display the scales of a circumplex instrument

Description

Display the scales of a circumplex instrument including the total number of scales and each scale's abbreviation, hypothetical angle, and text label.

Usage

scales(x, items = FALSE)

Arguments

x

Required. An object of the instrument class.

items

Optional. A logical determining whether the items for each scale should be displayed below its other information (default = FALSE).

Value

The same input object. Prints text to console.

See Also

Other instrument functions: anchors(), instruments(), items(), norms()

Examples

scales(csip)
scales(csip, items = TRUE)

Score circumplex scales from item responses

Description

Calculate mean scores on circumplex scales from item responses by using a set of scoring instructions, which may be loaded from the package or created as a custom data frame.

Usage

score(
  data,
  items,
  instrument,
  na.rm = TRUE,
  prefix = "",
  suffix = "",
  append = TRUE
)

Arguments

data

Required. A data frame or matrix containing at least circumplex scales.

items

Required. The variable names or column numbers for the variables in .data that contain all the circumplex items from a single circumplex measure, in ascending order from item 1 to item N.

instrument

Required. An instrument object from the package. To see the available circumplex instruments, use instruments().

na.rm

Optional. A logical that determines if missing values should be omitted from the calculation of scores (default = TRUE). When set to TRUE, scales with missing data are essentially calculated with mean imputation.

prefix

Optional. A string to include at the beginning of the newly calculated scale variables' names, before Abbrev from key and suffix (default = "").

suffix

Optional. A string to include at the end of the newly calculated scale variables' names, after Abbrev from key and prefix (default = "").

append

Optional. A logical that determines whether the calculated score variables will be appended to data or returned on their own (default = TRUE).

Value

A data frame that matches .data except that new variables are appended that contain mean scores on each variable included in key.

See Also

Other tidying functions: ipsatize(), norm_standardize(), self_standardize()

Examples

data("raw_iipsc")
score(raw_iipsc, items = 1:32, instrument = iipsc, prefix = "IIPSC_")

Standardize circumplex scales using sample data

Description

Take in a data frame containing circumplex scales (or items) and return that same data frame with each specified variable transformed into standard scores (i.e., z-scores) based on observed means and SDs.

Usage

self_standardize(
  data,
  scales,
  na.rm = TRUE,
  prefix = "",
  suffix = "_z",
  append = TRUE
)

Arguments

data

Required. A data frame or matrix containing at least circumplex scales.

scales

Required. A character vector containing the column names, or a numeric vector containing the column indexes, for the variables (scale scores) to be standardized.

na.rm

Optional. A logical that determines whether to remove missing values from scales when calculating the means and SDs used for standardization (default = TRUE).

prefix

Optional. A string to include at the beginning of the newly calculated scale variables' names, before the scale name and suffix (default = "").

suffix

Optional. A string to include at the end of the newly calculated scale variables' names, after the scale name and prefix (default = "_z").

append

Optional. A logical that determines whether the calculated standardized scores should be added as columns to data in the output or the standardized scores alone should be output (default = TRUE).

Value

A data frame that contains the self-standardized versions of scales.

See Also

Other tidying functions: ipsatize(), norm_standardize(), score()

Examples

self_standardize(aw2009, scales = 1:8)

Perform analyses using the Structural Summary Method

Description

Calculate SSM parameters with confidence intervals (bootstrapped by default, or Monte Carlo via method) for a variety of different analysis types. Depending on what arguments are supplied, either mean-based or correlation-based analyses will be performed, one or more groups will be used to stratify the data, and contrasts between groups or measures will be calculated.

Usage

ssm_analyze(
  data,
  scales,
  angles = octants(),
  measures = NULL,
  grouping = NULL,
  contrast = FALSE,
  boots = 2000,
  interval = 0.95,
  listwise = TRUE,
  measures_labels = NULL,
  parallel = "no",
  ncpus = 1,
  method = "bootstrap"
)

Arguments

data

Required. A data frame or matrix containing at least circumplex scales.

scales

Required. A character vector of column names, or a numeric vector of column indexes, from data that contains the circumplex scale scores to be analyzed.

angles

Optional. A numeric vector containing the angular displacement of each circumplex scale included in scales (in degrees). (default = octants()). The closed-form SSM estimator used here equals the ordinary-least-squares cosine fit only when angles are equally spaced around the circle (e.g., octants at 45-degree intervals); for unequally spaced angles it is the conventional Gurtman estimator, not a least-squares fit.

measures

Optional. Either NULL or a character vector of column names from data that contains one or more variables to be correlated with the circumplex scales and analyzed using correlation-based SSM analyses.

grouping

Optional. Either NULL or a string that contains the column name from data of the variable that indicates the group membership of each observation.

contrast

Optional. A logical indicating whether to output the difference between two measures' or two groups' SSM parameters. Can only be set to TRUE when there are exactly two measures and one group, one measure and two groups, or no measures and two groups (default = FALSE). The contrast is always the second level minus the first. For two groups, this is the second level of grouping alphabetically, unless grouping is already a factor with an explicit level order, in which case that order is used. For two measures, this is simply the second entry of measures as given (no reordering). The direction is shown in the result's Label (e.g., "Male - Female").

boots

Optional. A single positive whole number indicating how many bootstrap resamples (or, when method = "montecarlo", Monte Carlo draws) to use when estimating the confidence intervals (default = 2000).

interval

Optional. A single positive number between 0 and 1 (exclusive) that indicates what confidence level to use when estimating the confidence intervals (default = 0.95).

listwise

Optional. A logical indicating whether missing values should be handled by listwise deletion (TRUE) or pairwise deletion (FALSE). Note that pairwise deletion may result in different missing data patterns in each bootstrap resample and is slower to compute (default = TRUE).

measures_labels

Optional. Either NULL or a character vector providing a label for each measure provided in measures (in the same order) to appear in the results as well as tables and plots derived from the results.

parallel

Optional. A string indicating whether to distribute the bootstrap computation across multiple CPU cores: "no" (default), "multicore" (process forking; available on macOS and Linux, ignored on Windows), or "snow" (a local PSOCK cluster; available on all platforms). Passed to boot. Because the bootstrap resample indices are drawn in the main R process before any work is distributed, results for a given set.seed() are identical regardless of the parallel and ncpus settings.

ncpus

Optional. A single positive whole number indicating how many CPU cores to use when parallel is not "no" (default = 1).

method

Optional. A string indicating how to estimate the confidence intervals: "bootstrap" (default) resamples the data, whereas "montecarlo" draws parameter replicates from the asymptotic sampling distribution of the group mean vector (mean-based analyses) or the measure-scale correlation vector (correlation-based analyses) – a multivariate normal with empirically estimated covariance – and propagates them through the SSM parameter transformation. The Monte Carlo method is much faster for large samples but relies on the asymptotic normality of the means or correlations, so prefer the bootstrap for small samples; it also requires listwise-complete data. Correlations are drawn jointly across measures within each group on the Fisher z scale and back-transformed. The parallel and ncpus arguments apply only to the bootstrap.

Value

A list containing the results and description of the analysis.

results

A data frame with the SSM parameter estimates

details

A list with the number of bootstrap resamples or Monte Carlo draws (boots), the confidence interval percentage level (interval), the angular displacement of scales (angles), and the interval estimation method (method)

call

A language object containing the function call that created this object

scores

A data frame containing the mean scale scores

type

A string indicating what type of SSM analysis was done

The profile displacement parameter is reported in the half-open interval ⁠[0, 360)⁠ degrees. A profile that peaks exactly at the 0/360 degree boundary is reported as approximately 360 (equivalently 0, the same direction); which of the two appears is a floating-point detail and both denote the same pole. Contrast displacements are instead reported as a signed difference in ⁠(-180, 180]⁠ degrees (see the "Contrast" block in the printed output).

Degenerate profiles (flat or zero-amplitude) have undefined displacement (and fit, if flat), which is reported as NA with a warning. Bootstrap resamples that produce degenerate profiles (e.g., a resampled measure with zero variance) are excluded from the confidence intervals with a warning reporting how many were dropped; the intervals are then conditional on estimability.

[0, 360)⁠degrees. A profile that peaks exactly at the 0/360 degree boundary is reported as approximately 360 (equivalently 0, the same direction); which of the two appears is a floating-point detail and both denote the same pole. Contrast displacements are instead reported as a signed difference in⁠(-180, 180]: R:0,%20360)%60%20degrees.%20A%20profile%20that%20peaks%20exactly%20at%20the%200/360%20degree%0A%20%20boundary%20is%20reported%20as%20approximately%20360%20(equivalently%200,%20the%20same%0A%20%20direction);%20which%20of%20the%20two%20appears%20is%20a%20floating-point%20detail%20and%20both%0A%20%20denote%20the%20same%20pole.%20Contrast%20displacements%20are%20instead%20reported%20as%20a%0A%20%20signed%20difference%20in%20%60(-180,%20180

Reproducibility

This is the only function in the package that consumes R's random number stream (ssm_score()/ssm_parameters() and the tidying functions are deterministic). Call set.seed() immediately before ssm_analyze() for reproducible confidence intervals:

  • Bootstrap (method = "bootstrap", the default): the same seed gives byte-identical results, regardless of the parallel/ncpus settings (see their descriptions below), because boot::boot() draws all resample indices from the seed before any work is parallelized.

  • Monte Carlo (method = "montecarlo"): the same seed gives byte-identical results. Adding a group or measure, or reordering scales/measures, changes the random draw sequence, so results are reproducible for a fixed call but will not match after such structural edits even with the same seed.

  • The two methods are not expected to agree numerically for the same seed – they consume the random stream in unrelated ways. Their statistical agreement (validated on real data; see vignette("introduction-to-ssm-analysis")) is a separate property from RNG reproducibility.

  • Increasing boots changes the CI by design (more resamples/draws should tighten Monte Carlo error), so results are not expected to be stable across different boots values, only within a fixed call.

See Also

Other ssm functions: ssm_parameters(), ssm_score(), ssm_table()

Other analysis functions: ssm_parameters(), ssm_score()

Examples

# Load example data
data("jz2017")

# Single-group mean-based SSM
ssm_analyze(
  jz2017,
  scales = c("PA", "BC", "DE", "FG", "HI", "JK", "LM", "NO")
)

# Single-group correlation-based SSM
ssm_analyze(
  jz2017,
  scales = c("PA", "BC", "DE", "FG", "HI", "JK", "LM", "NO"),
  measures = c("NARPD", "ASPD")
)

# Monte Carlo confidence intervals (faster for large samples)
ssm_analyze(
  jz2017,
  scales = c("PA", "BC", "DE", "FG", "HI", "JK", "LM", "NO"),
  method = "montecarlo"
)

# Multiple-group mean-based SSM
ssm_analyze(
  jz2017,
  scales = c("PA", "BC", "DE", "FG", "HI", "JK", "LM", "NO"),
  grouping = "Gender"
)

# Multiple-group mean-based SSM with contrast
ssm_analyze(
  jz2017,
  scales = c("PA", "BC", "DE", "FG", "HI", "JK", "LM", "NO"),
  grouping = "Gender",
  contrast = TRUE
)

# Single-group correlation-based SSM with contrast
ssm_analyze(
  jz2017,
  scales = c("PA", "BC", "DE", "FG", "HI", "JK", "LM", "NO"),
  measures = c("NARPD", "ASPD"),
  contrast = TRUE
)

# Multiple-group correlation-based SSM
ssm_analyze(
  jz2017,
  scales = c("PA", "BC", "DE", "FG", "HI", "JK", "LM", "NO"),
  measures = "NARPD",
  grouping = "Gender"
)

# Multiple-group correlation-based SSM with contrast
ssm_analyze(
  jz2017,
  scales = c("PA", "BC", "DE", "FG", "HI", "JK", "LM", "NO"),
  measures = "NARPD",
  grouping = "Gender",
  contrast = TRUE
)

Calculate Structural Summary Method parameters for a set of scores

Description

Calculate SSM parameters (without confidence intervals) for a set of scores and generate a data frame with customizable labels for each parameter value. This function requires the input to be a numeric vector (or coercable to one) and returns only the parameters. See ssm_score() for a similar function that calculates SSM parameters for each row of a data frame.

Usage

ssm_parameters(
  scores,
  angles = octants(),
  prefix = "",
  suffix = "",
  e_label = "Elev",
  x_label = "Xval",
  y_label = "Yval",
  a_label = "Ampl",
  d_label = "Disp",
  f_label = "Fit"
)

Arguments

scores

Required. A numeric vector (or single row data frame) containing one score for each of a set of circumplex scales.

angles

Required. A numeric vector containing the angular displacement of each circumplex scale included in scores (in degrees).

prefix

Optional. A string to append to the beginning of all of the SSM parameters' variable names (default = "").

suffix

Optional. A string to append to the end of all of the SSM parameters' variable names (default = "").

e_label

Optional. A string representing the variable name of the SSM elevation parameter (default = "Elev").

x_label

Optional. A string representing the variable name of the SSM x-value parameter (default = "Xval").

y_label

Optional. A string representing the variable name of the SSM y-value parameter (default = "Yval").

a_label

Optional. A string representing the variable name of the SSM amplitude parameter (default = "Ampl").

d_label

Optional. A string representing the variable name of the SSM displacement parameter (default = "Disp").

f_label

Optional. A string representing the variable name of the SSM fit or R-squared value (default = "Fit").

Value

A data frame containing the SSM parameters calculated from scores. For degenerate profiles the undefined parameters are returned as NA with a warning: a flat profile (zero variance) has undefined displacement and fit, and a profile with real variance but zero amplitude (i.e., no first-harmonic component) has undefined displacement and a fit of 0. Note that this applies only to amplitudes that are zero up to machine precision; small real amplitudes are always estimated, and their uncertainty is expressed through confidence intervals (see ssm_analyze()).

See Also

Other ssm functions: ssm_analyze(), ssm_score(), ssm_table()

Other analysis functions: ssm_analyze(), ssm_score()

Examples

# Manually enter octant scores
scores <- c(0.55, 0.58, 0.62, 0.76, 1.21, 1.21, 1.48, 0.90)
ssm_parameters(scores)

# Customize several of the labels
ssm_parameters(scores, x_label = "LOV", y_label = "DOM")

# Add a prefix to all labels
ssm_parameters(scores, prefix = "IIP_")

Create a Circular Plot of SSM Results

Description

Take in the results of a Structural Summary Method analysis and plot the point and interval estimate for each row (e.g., group or measure) in a circular space quantified by displacement and amplitude.

Usage

ssm_plot_circle(
  ssm_object,
  amax = NULL,
  legend_font_size = 12,
  scale_font_size = 12,
  drop_lowfit = FALSE,
  repel = FALSE,
  angle_labels = NULL,
  palette = "Set2",
  vary_shapes = FALSE,
  ...
)

Arguments

ssm_object

Required. The output of ssm_analyze().

amax

A positive real number corresponding to the radius of the circle. It is used to scale the amplitude values and will determine which amplitude labels are drawn.

legend_font_size

A positive real number corresponding to the size (in pt) of the text labels in the legend (default = 12).

scale_font_size

A positive real number corresponding to the size (in pt) of the text labels for the amplitude and displacement scales (default = 12).

drop_lowfit

A logical determining whether profiles with low model fit (<.70) should be omitted or plotted with dashed borders (default = FALSE).

repel

An experimental argument for plotting text labels instead of colors.

angle_labels

A character vector specifying text labels to plot around the circle for each scale. Can also specify NULL to default to numerical angle labels or a vector of empty strings ("") to hide the labels. If not NULL, must have the same length and ordering as the angles argument to ssm_analyze(). (default = NULL)

palette

A string corresponding to the palette to be used from ColorBrewer for the color and fill aesthetics. If set to NULL, all points will appear blue and no legend will be there (useful for showing the coverage of a high number of variables).

vary_shapes

A logical determining whether profiles should each get their own shape or vary only by fill color. This only works when the number of profiles is five or less. (default = FALSE)

...

Not used. Supplying an unrecognized argument produces a warning.

Value

A ggplot variable containing a completed circular plot.

Examples

data("jz2017")
res <- ssm_analyze(
  jz2017,
  scales = 2:9,
  measures = c("NARPD", "ASPD")
)
ssm_plot_circle(res)

Create a Difference Plot of SSM Contrast Results

Description

Take in the results of a Structural Summary Method analysis with pairwise contrasts and plot the point and interval estimates for each parameter's contrast (e.g., between groups or measures).

Usage

ssm_plot_contrast(
  ssm_object,
  drop_xy = FALSE,
  sig_color = "#fc8d62",
  ns_color = "white",
  linesize = 1.25,
  fontsize = 12,
  ...
)

Arguments

ssm_object

Required. The results output of ssm_analyze().

drop_xy

A logical determining whether the X-Value and Y-Value parameters should be removed from the plot (default = FALSE).

sig_color

Optional. A string corresponding to the color to use to denote significant contrasts (default = "#fc8d62").

ns_color

Optional. A string corresponding to the color to use to denote non-significant contrasts (default = "white").

linesize

Optional. A positive number corresponding to the size of the point range elements in mm (default = 1.5).

fontsize

Optional. A positive number corresponding to the size of the axis labels, numbers, and facet headings in pt (default = 12).

...

Not used. Supplying an unrecognized argument produces a warning.

Value

A ggplot variable containing difference point-ranges faceted by SSM parameter. An interval that does not contain the value of zero has p<.05.

Examples

data("jz2017")
res <- ssm_analyze(
  jz2017,
  scales = 2:9,
  measures = c("NARPD", "ASPD"),
  contrast = TRUE
)
ssm_plot_contrast(res)

Create a Curve Plot of SSM Results

Description

Take in the results of a Structural Summary Method analysis and plot the scores by angle and the estimated SSM curve.

Usage

ssm_plot_curve(
  ssm_object,
  angle_labels = NULL,
  base_size = 11,
  drop_lowfit = FALSE,
  ...
)

Arguments

ssm_object

Required. The results output of ssm_analyze().

angle_labels

Optional. Either NULL or a character vector that determines the x-axis labels. If NULL, the labels will be the angle numbers. If a character vector, must be the same length and in the same order as the angles argument to ssm_analyze() (default = NULL).

base_size

Optional. A positive number corresponding to the base font size in pts (default = 11).

drop_lowfit

Optional. A logical indicating whether to omit profiles with low fit (<.70) or include them with dashed lines (default = FALSE).

...

Not used. Supplying an unrecognized argument produces a warning.

Value

A ggplot object depicting the SSM curve(s) of each profile.

Examples

data("jz2017")
res <- ssm_analyze(
  jz2017,
  scales = 2:9,
  measures = 10:13
)
ssm_plot_curve(res)
ssm_plot_curve(res, angle_labels = PANO())

Calculate SSM parameters by row and add results as new columns

Description

Calculate the SSM parameters for each row of a data frame and add the results as additional columns. This can be useful when the SSM is being used for the description or visualization of individual data points rather than for statistical inference on groups of data points.

Usage

ssm_score(data, scales, angles = octants(), append = TRUE, ...)

Arguments

data

Required. A data frame or matrix containing at least circumplex scales.

scales

Required. The variable names or column numbers for the variables in .data that contain circumplex scales to be analyzed.

angles

Required. A numeric vector containing the angular displacement of each circumplex scale included in scales (in degrees).

append

Optional. A logical indicating whether to append the output to data or simply return the output (default = "TRUE").

...

Optional. Additional named arguments passed to ssm_parameters(), such as prefix and suffix; each must be a single string. Unnamed or non-scalar arguments raise an error.

Value

A data frame containing .data plus six additional columns containing the SSM parameters (calculated rowwise).

See Also

Other ssm functions: ssm_analyze(), ssm_parameters(), ssm_table()

Other analysis functions: ssm_analyze(), ssm_parameters()

Examples

data("aw2009")
ssm_score(
  aw2009,
  scales = c("PA", "BC", "DE", "FG", "HI", "JK", "LM", "NO")
)

Create HTML table from SSM results or contrasts

Description

Take in the results of an SSM analysis and return an HTML table with the desired formatting.

Usage

ssm_table(ssm_object, caption = NULL, drop_xy = FALSE, render = TRUE)

Arguments

ssm_object

Required. The results output of ssm_analyze().

caption

A string to be displayed above the table (default = NULL).

drop_xy

A logical indicating whether the x-value and y-value parameters should be omitted from the output (default = FALSE).

render

A logical indicating whether the table should be displayed in the RStudio viewer or web browser (default = TRUE).

Value

A data frame containing the information for the HTML table. As a side-effect, may also output the HTML table to the web viewer.

See Also

Other ssm functions: ssm_analyze(), ssm_parameters(), ssm_score()

Other table functions: html_render()

Examples

# Load example data
data("jz2017")

# Create table of profile results
res <- ssm_analyze(
  jz2017,
  scales = 2:9,
  measures = c("NARPD", "ASPD")
)
ssm_table(res)

# Create table of contrast results
res <- ssm_analyze(
  jz2017,
  scales = 2:9,
  measures = c("NARPD", "ASPD"), 
  contrast = TRUE
)
ssm_table(res)