SSM Analysis¶
circumplex.analysis.ssm_analyze
¶
Main SSM analysis function.
This module provides the primary user-facing function for performing Structural Summary Method (SSM) analysis on circumplex data.
| FUNCTION | DESCRIPTION |
|---|---|
ssm_analyze |
Perform Structural Summary Method (SSM) analysis on circumplex data. |
ssm_analyze
¶
ssm_analyze(data: DataFrame, scales: list[str] | list[int], angles: ndarray | list[float] | None = None, measures: list[str] | str | None = None, grouping: str | None = None, boots: int = 2000, interval: float = 0.95, measures_labels: list[str] | None = None, *, contrast: bool = False, listwise: bool = True, seed: int | None = None) -> SSM
Perform Structural Summary Method (SSM) analysis on circumplex data.
This is the main entry point for SSM analysis. It automatically determines
whether to perform mean-based or correlation-based analysis based on the
measures parameter, calculates SSM parameters, and computes bootstrap
confidence intervals.
| PARAMETER | DESCRIPTION |
|---|---|
data
|
DataFrame containing circumplex scale scores (and optionally measures and grouping variables)
TYPE:
|
scales
|
Column names or indices for circumplex scales. Must be ordered according
to their angular positions (matching the order in |
angles
|
Angular positions for the scales in degrees. If None, uses standard octant angles [90, 135, 180, 225, 270, 315, 360, 45]. Length must match the number of scales. |
measures
|
Column name(s) for external measure variable(s) to correlate with scales.
|
grouping
|
Column name for grouping variable. If None, treats all data as a single group. The variable will be converted to a categorical factor.
TYPE:
|
contrast
|
If True, calculates differences between groups or measures.
TYPE:
|
boots
|
Number of bootstrap resamples for confidence interval calculation. Default: 2000.
TYPE:
|
interval
|
Confidence level for bootstrap intervals (e.g., 0.95 for 95% CI). Default: 0.95.
TYPE:
|
listwise
|
Missing data handling:
TYPE:
|
measures_labels
|
Optional custom labels for measures (same length as measures). If None, uses the column names. |
seed
|
Random seed for reproducibility of bootstrap results. If None, results will vary across runs.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SSM
|
Dictionary containing:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
|
Examples:
Mean-based analysis (single group)
>>> from circumplex import ssm_analyze
>>> from circumplex.data import load_dataset
>>> aw2009 = load_dataset('aw2009')
>>> results = ssm_analyze(aw2009, scales=list(range(8)), seed=12345)
>>> print(results['results'][['Label', 'e_est', 'a_est', 'd_est']])
Label e_est a_est d_est
0 All 0.423 0.981 344.358
Mean-based analysis (multiple groups with contrast)
>>> jz2017 = load_dataset('jz2017')
>>> results = ssm_analyze(jz2017, scales=list(range(1, 9)),
... grouping='Gender', contrast=True, seed=12345)
>>> print(results['results'][['Label', 'e_est', 'a_est']])
Label e_est a_est
0 Female 0.635 0.158
1 Male 0.596 0.192
2 Male - Female -0.039 0.034
Correlation-based analysis (single measure)
>>> results = ssm_analyze(jz2017, scales=list(range(1, 9)),
... measures='PARPD', seed=12345)
>>> print(results['results'][['Label', 'e_est', 'a_est', 'd_est']])
Label e_est a_est d_est
0 PARPD 0.250 0.150 128.9
Correlation-based analysis (measure contrast)
>>> results = ssm_analyze(jz2017, scales=list(range(1, 9)),
... measures=['ASPD', 'NARPD'],
... contrast=True, seed=12345)
>>> print(results['results'][['Label', 'e_est', 'a_est']])
Label e_est a_est
0 ASPD 0.253 0.055
1 NARPD 0.311 0.203
2 NARPD - ASPD 0.058 0.148
Notes
This function is a Python port of ssm_analyze() from the R circumplex package (Zimmermann & Wright, 2017). It maintains numerical parity with the R implementation to at least 3 decimal places.
SSM Parameters:
- elevation (e): Mean of all scale scores
- x_value (x): Projection onto x-axis (cosine component)
- y_value (y): Projection onto y-axis (sine component)
- amplitude (a): Vector length (prototypicality)
- displacement (d): Angular position in degrees [0, 360)
- fit: Model fit (R²), proportion of variance explained
Bootstrap Confidence Intervals:
Uses percentile method with stratified sampling when groups are present. Displacement CIs use circular statistics to handle angular wrapping.
See Also
load_dataset : Load example datasets
OCTANTS :
Standard octant angles for 8-scale circumplex
References
Zimmermann, J., & Wright, A. G. C. (2017). Beyond description in interpersonal construct validation: Methodological advances in the circumplex Structural Summary Approach. Assessment, 24(1), 3-23. https://doi.org/10.1177/1073191115621795
Zimmermann, J., & Wright, A. G. C. (2017). The circumplex package [Computer software]. https://cran.r-project.org/package=circumplex
Source code in src/circumplex/analysis/ssm_analyze.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |