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

如何在R中使用clm()获取p值?附VGAM包vglm()有序回归输出

Getting p-values with clm() for Partial Proportional Odds Ordinal Regression

Got it, let's walk through how to get p-values when using clm() (from the ordinal package) for an ordinal regression that relaxes the proportional odds assumption—just like you did with vglm() from VGAM.

Step 1: Fit the Partial Proportional Odds Model

First, make sure you have the ordinal package installed and loaded. To relax the proportional odds assumption for your PROXIMITY variable, you'll use the scale argument in clm()—this tells the model that PROXIMITY can have different coefficients across the response levels (instead of a single coefficient that applies to all levels, which is the default proportional odds setup).

Here's the code structure, assuming your response variable is named y and your dataset is your_data:

# Install if needed
install.packages("ordinal")
library(ordinal)

# Fit the partial proportional odds model
model <- clm(y ~ PROXIMITY, scale = ~ PROXIMITY, data = your_data)
  • The scale = ~ PROXIMITY part is key here—it's how you specify that PROXIMITY doesn't follow the proportional odds assumption. If you had other variables that should still follow the assumption, just leave them in the main formula (the y ~ ... part) and only include non-proportional variables in the scale formula.

Step 2: Extract p-values

To get the p-values (along with coefficients, standard errors, and z-values), just run summary() on your fitted model:

summary(model)

The output will look similar to what you got from vglm(), with two main sections:

  1. Threshold coefficients: These correspond to the intercepts ((Intercept):1, (Intercept):2 in your VGAM output) that define the boundaries between your 3 response levels.
  2. Coefficients: These are the coefficients for your PROXIMITY variable, with separate values for each response level (matching PROXIMITY2:1, PROXIMITY2:2, etc., from your VGAM results). The Pr(>|z|) column is exactly the p-value you're looking for.

For example, your summary output might look like this:

Threshold coefficients:
Estimate Std. Error z value Pr(>|z|)
y1|y2 0.502 0.541 0.928 0.354
y2|y3 -0.721 0.495 -1.457 0.145

Coefficients:
Estimate Std. Error z value Pr(>|z|)
PROXIMITY2 1.101 0.475 2.318 0.0205 *
PROXIMITY3 0.879 0.483 1.820 0.0688 .

Signif. codes: 0 ‘’ 0.001 ‘’ 0.01 ‘’ 0.05 ‘.’ 0.1 ‘ ’ 1

Step 3: Extract p-values Programatically (If Needed)

If you want to pull just the p-values into a vector for further analysis, you can use:

# Get all p-values (thresholds + coefficients)
p_values <- coef(summary(model))[, 4]

# Or just get p-values for the PROXIMITY coefficients
prox_p_values <- p_values[grepl("PROXIMITY", names(p_values))]

Quick Note on Model Alignment

The clm() partial proportional odds model works a bit differently under the hood than vglm(), but the core idea is the same: allowing PROXIMITY to have level-specific coefficients. You should see p-values that are consistent with what you got from VGAM once you set up the model correctly.

内容的提问来源于stack exchange,提问作者Amolly

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 09:30:53