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

Stan多项式回归模型:标准化与原尺度参数转换正确性问询

验证二元二次贝叶斯多项式回归的参数转换公式与Stan代码正确性

Great question—let's break down the verification of your parameter transformation formulas and Stan implementation step by step.

1. Variable Transformation Basics

First, recall your standardized variable definitions:
$$x_{1,\text{std}} = \frac{x_1 - \bar{x}1}{s_1}, \quad x{2,\text{std}} = \frac{x_2 - \bar{x}_2}{s_2}$$
Where $\bar{x}_1 = \text{mean}(x_1)$, $s_1 = \text{sd}(x_1)$, and similarly for $x_2$. The inverse transformations are:
$$x_1 = \bar{x}1 + s_1 x{1,\text{std}}, \quad x_2 = \bar{x}2 + s_2 x{2,\text{std}}$$

2. Derive the Parameter Mapping

Your original model's mean function is:
$$\mu_i = \alpha + \beta_1 x_{i1} + \beta_2 x_{i2} + \beta_3 x_{i1}^2 + \beta_4 x_{i2}^2 + \beta_5 x_{i1}x_{i2}$$
Substitute $x_1$ and $x_2$ with their standardized forms, then expand and group terms by powers of $x_{1,\text{std}}$ and $x_{2,\text{std}}$. This lets us equate coefficients to the standardized model's mean function:
$$\mu_i = \alpha_{\text{std}} + \beta_{1,\text{std}}x_{1,\text{std},i} + \beta_{2,\text{std}}x_{2,\text{std},i} + \beta_{3,\text{std}}x_{1,\text{std},i}^2 + \beta_{4,\text{std}}x_{2,\text{std},i}^2 + \beta_{5,\text{std}}x_{1,\text{std},i}x_{2,\text{std},i}$$

Key Coefficient Equivalences:

  • Quadratic & Cross Terms: These map directly because the standardized variable's square/cross product scales predictably:
    $$\beta_3 = \frac{\beta_{3,\text{std}}}{s_1^2}, \quad \beta_4 = \frac{\beta_{4,\text{std}}}{s_2^2}, \quad \beta_5 = \frac{\beta_{5,\text{std}}}{s_1 s_2}$$
  • Linear Terms: The linear coefficients in the original model account for the centering of the standardized variables. Substituting the quadratic/cross term mappings gives:
    $$\beta_1 = \frac{\beta_{1,\text{std}}}{s_1} - 2\frac{\beta_{3,\text{std}} \bar{x}1}{s_1^2} - \frac{\beta{5,\text{std}} \bar{x}2}{s_1 s_2}$$
    $$\beta_2 = \frac{\beta
    {2,\text{std}}}{s_2} - 2\frac{\beta_{4,\text{std}} \bar{x}2}{s_2^2} - \frac{\beta{5,\text{std}} \bar{x}_1}{s_1 s_2}$$
  • Intercept: The intercept adjusts for all constant terms introduced by centering. Substituting all other mapped parameters gives:
    $$\alpha = \alpha_{\text{std}} - \frac{\beta_{1,\text{std}} \bar{x}1}{s_1} - \frac{\beta{2,\text{std}} \bar{x}2}{s_2} + \frac{\beta{3,\text{std}} \bar{x}12}{s_12} + \frac{\beta{4,\text{std}} \bar{x}22}{s_22} + \frac{\beta{5,\text{std}} \bar{x}_1 \bar{x}_2}{s_1 s_2}$$

3. Verify Stan Code Implementation

Looking at the generated quantities block in your Stan code:

generated quantities {
 real alpha;
 real beta1;
 real beta2;
 real beta3;
 real beta4;
 real beta5;
 alpha = alpha_std - beta1_std*bar_x1/x1_sd - beta2_std*bar_x2/x2_sd + (beta3_std*bar_x1^2)/x1_sd^2 + (beta4_std*bar_x2^2)/x2_sd^2 + (beta5_std*bar_x2*bar_x1)/(x1_sd*x2_sd);
 beta1 = beta1_std/x1_sd - 2*beta3_std*bar_x1/x1_sd^2 - beta5_std*bar_x2/(x1_sd*x2_sd);
 beta2 = beta2_std/x2_sd - 2*beta4_std*bar_x2/x2_sd^2 - beta5_std*bar_x1/(x1_sd*x2_sd);
 beta3 = beta3_std/x1_sd^2;
 beta4 = beta4_std/x2_sd^2;
 beta5 = beta5_std/(x1_sd*x2_sd);
}

This code exactly matches the derived transformation formulas. Every term aligns with the algebraic mapping we worked through, with bar_x1/x1_sd corresponding to $\bar{x}_1$/$s_1$, and so on.

Conclusion

Both your parameter transformation formulas and Stan code implementation are correct. The mapping properly accounts for the centering and scaling of your predictor variables, ensuring you recover interpretable coefficients on the original variable scale from the standardized model fits.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.28 04:16:33