You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

autoplot的scaling参数作用解析及Distance biplot绘制方法咨询

Understanding scaling in autoplot() for PCA Biplots (USArrests Example)

Great question—let's break down how ggfortify::autoplot() handles biplot scaling, especially compared to base R's biplot(), and how to get the exact Distance biplot (scaling = 1) you're looking for.

First, a quick recap of the two biplot types from Borcard et al. (2011):

  • Distance Biplot (scaling = 1): Prioritizes preserving the Euclidean distance between sample points (matching the standardized original data). Loading vectors show how variables contribute to the principal components.
  • Correlation Biplot (scaling = 2): Focuses on showing correlations between variables (via the angle between loading vectors) and approximating original variable values via the dot product of sample scores and loadings.

How Base R's biplot() Maps to These Types

Your base R examples are exactly right:

  • Distance biplot (scaling = 1):
    biplot(prcomp(USArrests, scale = TRUE), scale=0)
    
  • Correlation biplot (scaling = 2):
    biplot(prcomp(USArrests, scale = TRUE), pc.biplot=TRUE)
    

How autoplot() Matches (and Controls) These Biplots

The ggfortify::autoplot() function mirrors base R's parameter behavior directly—you just need to map the arguments correctly:

  1. Correlation Biplot (scaling = 2)
    Your first autoplot call uses pc.biplot=TRUE, which is exactly equivalent to the base R correlation biplot:

    ggplot2::autoplot(stats::prcomp(USArrests, scale=TRUE), pc.biplot=TRUE, label = TRUE, loadings.label = TRUE)
    

    This scales sample scores and loadings to emphasize variable correlations and approximate original variable values.

  2. Distance Biplot (scaling = 1)
    Yes! You absolutely can draw this with autoplot()—and you already did it in your second example:

    ggplot2::autoplot(stats::prcomp(USArrests, scale=TRUE), scale=0, label = TRUE, loadings.label = TRUE)
    

    This matches the base R scale=0 call, preserving sample distances (the core of a Distance biplot) while displaying loadings as variable contributions to principal components.

  3. Other scaling Values in autoplot()

    • scale=1: A middle-ground scaling that balances sample distance preservation and variable correlation visibility. Both samples and loadings are scaled to equalize their "weight" in the plot.
    • scale=2: Scales loadings to reflect the variance of original variables, while adjusting sample scores to align with this. This emphasizes variable magnitude alongside correlations.

Quick Cheat Sheet

Biplot TypeBase R biplot() Callautoplot() Equivalent
Distance (scaling=1)biplot(..., scale=0)autoplot(..., scale=0)
Correlation (scaling=2)biplot(..., pc.biplot=TRUE)autoplot(..., pc.biplot=TRUE)

内容的提问来源于stack exchange,提问作者H.F.S C.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 04:09:13