你能在pystan或pymc3中使用样本权重吗?

2024-06-12 06:22:37 发布

您现在位置:Python中文网/ 问答频道 /正文

如果我观察到的数据集具有权重(例如跟踪多重性),是否可以将其提供给pystan或pymc3,类似于rstanarm包中的函数签名(http://mc-stan.org/rstanarm/reference/stan_glm.html):

stan_glm(formula, family = gaussian(), data, weights, subset,
  na.action = NULL, offset = NULL, model = TRUE, x = FALSE, y = TRUE,
  contrasts = NULL, ..., prior = normal(), prior_intercept = normal(),
  prior_aux = exponential(), prior_PD = FALSE, algorithm = c("sampling",
  "optimizing", "meanfield", "fullrank"), adapt_delta = NULL, QR = FALSE,
  sparse = FALSE)

Tags: 数据函数falsetruehttpnull权重normal
1条回答
网友
1楼 · 发布于 2024-06-12 06:22:37

使用Stan(在其任何接口中,包括PyStan),您可以在模型中引入权重。例如,在一个线性回归中,例如,用y[i] ~ normal(mu[i], sigma)代替target += weight[i] * normal_lpdf(y[i] | mu[i], sigma)。在

如果权重为正,这将为您提供指定良好的密度。我们倾向于使用生成性方法。在

相关问题 更多 >