Skip to main content

Profile Analysis via Multidimensional Scaling

Project description

pams-kim

Profile Analysis via Multidimensional Scaling (PAMS)

Python port of the R pams package (CRAN, Kim & Kim 2026).

PyPI License: MIT Tests CRAN


Overview

PAMS identifies population-level core response profiles from cross-sectional or longitudinal person-score data using nonmetric multidimensional scaling (SMACOF algorithm). Each person profile is decomposed into:

  • Level component: person mean across subscales
  • Pattern component: ipsatized subscores (within-person variation)

PAMS fits a nonmetric MDS solution to the J x J inter-variable distance matrix, bootstraps the solution to generate empirical sampling distributions, and computes BCa confidence intervals for each core profile coordinate.

Key features:

  • Nonmetric MDS via SMACOF (de Leeuw & Mair, 2009) or classical metric MDS
  • BCa bootstrap CIs for core profile coordinates
  • Person-level weights, R-squared, and profile correlations
  • Optional individual bootstrap CIs for selected participants
  • Longitudinal support (time-ordered subscale columns)

References: Kim & Kim (2024) doi:10.20982/tqmp.20.3.p230


Installation

pip install pams-kim

Requirements: Python >= 3.9, numpy >= 1.24, scipy >= 1.10, scikit-learn >= 1.3


Quick start

import numpy as np
from pams import BootSmacof

# Toy example (matches R PAMS documentation)
rng = np.random.default_rng(42)
toy_data = rng.normal(10, 2, (50, 5))

result = BootSmacof(
    testdata    = toy_data,
    participant = [0, 1, 2],   # row indices for individual CIs
    mds         = "smacof",
    type        = "ordinal",
    distance    = "euclid",
    nprofile    = 2,
    direction   = [1, 1],
    cl          = 0.95,
    nBoot       = 2000,
    testname    = ["S1", "S2", "S3", "S4", "S5"],
)

print(f"Stress: {result['MDS']['stress']:.4f}")
print(f"Mean R2: {result['WeightmeanR2']:.3f}")
print(result["MDSsummary"][0].round(3))  # Core Profile 1 with BCa CIs

Output fields

result["MDS"] # dict with conf (J x K) and stress result["MDSsummary"] # list of K DataFrames -- BCa CIs per core profile result["MDSprofile"] # list of K arrays (nBoot, J) -- bootstrap distributions result["stresssummary"] # one-row DataFrame of bootstrap stress result["MDSR2"] # (K,) R² confirming non-collinearity of core profiles result["Weight"] # (n, 2K+2) person weights, level, R², correlations result["WeightmeanR2"] # mean person R² across all persons result["WeightB"] # bootstrap weight summary for participants result["PcorrB"] # bootstrap partial correlations for participants


Lower-level functions

from pams import (
    intervar_distance,  # J x J inter-variable distance matrix
    smacof_mds,         # SMACOF nonmetric MDS
    classical_mds,      # Torgerson classical metric MDS
    apply_direction,    # sign flipping for core profiles
)

R package

CRAN: https://cran.r-project.org/package=pams GitHub: https://github.com/sekangakim/pams


Citation

Kim, S.-K., & Kim, D. (2024). Utility of profile analysis via multidimensional scaling in R for the study of person response profiles in cross-sectional and longitudinal data. The Quantitative Methods for Psychology, 20(3), 230-247. doi:10.20982/tqmp.20.3.p230


License

MIT

Authors

Se-Kang Kim, Ph.D. -- se-kang.kim@bcm.edu Baylor College of Medicine / Texas Children's Hospital

Donghoh Kim, Ph.D.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pams_kim-0.1.0.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pams_kim-0.1.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file pams_kim-0.1.0.tar.gz.

File metadata

  • Download URL: pams_kim-0.1.0.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for pams_kim-0.1.0.tar.gz
Algorithm Hash digest
SHA256 369dbb7775cfacb64d23568456cd2e21e8352aae0051e5e13df04c5dfdcfface
MD5 5870f930d494bf932c556a5cd275b089
BLAKE2b-256 0f58cb0978de18fd8f20d635dbcd7a8130ca2f3061d49c2f9c2750baad2e0c77

See more details on using hashes here.

File details

Details for the file pams_kim-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pams_kim-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for pams_kim-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d73362f5adf5f8ed751f1e0d711ecd75bfe505772b24a665c9ce9e6472c391c6
MD5 5445414a8e28322e3ee9f69402301406
BLAKE2b-256 136388245e42b752337b00d45f185281df5017226cff97bd567d79cf327df68d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page