r betareg predict(...) 等同于 GLM predict(....)

r betareg predict(...) equivalent to the GLM predict(....)

上下文: 使用 betareg package to reproduce this example

我认为归结为 betareg 等同于 GLM predict(...)

# Generate data
mydata <- data.frame(Ft = c(1, 6, 11, 16, 21, 2, 7, 12, 17, 22, 3, 8, 
                            13, 18, 23, 4, 9, 14, 19, 5, 10, 15, 20),
                     Temp = c(66, 72, 70, 75, 75, 70, 73, 78, 70, 76, 69, 70, 
                              67, 81, 58, 68, 57, 53, 76, 67, 63, 67, 79),
                     TD = c(0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 
                            0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0))

# Run logistic regression model
model <- glm(TD ~ Temp, data=mydata, family=binomial(link="logit"))

# Create a temporary data frame of hypothetical values
temp.data <- data.frame(Temp = seq(53, 81, 0.5))

# Predict the fitted values given the model and hypothetical data
predicted.data <- as.data.frame(predict(model, newdata = temp.data, 
                                        type="link", se=TRUE))

glimpse(predicted.data)

  Observations: 57
  Variables: 3
  $ fit            <dbl> 2.73827620, 2.62219483, 2.50611346, 2.39003209, 2.27395072, 2.15786934, 2.0...
  $ se.fit         <dbl> 1.7132157, 1.6620929, 1.6111659, 1.5604536, 1.5099778, 1.4597631, 1.4098372...
  $ residual.scale <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...

AFAICT betareg 函数 predict(...) 不会生成在图表中显示置信区间功能区所需的 se.fit 值。

有谁知道如何在这个例子中模仿 GLM predict(...)

OK,这个"answer"确定问题是non-trivial,并指向部分解决方案。

  1. zoib 包:该包提供 se 值,但仅用于示例数据。未实施基于新数据的预测值的 SE 估计。当我有机会时,我会效仿。

  2. betareg 包:以下论文的附录 B 包含所需的公式。 Ferrari, S.L.P., and Cribari-Neto, F. (2004)。 Beta Regression for Modeling Rates and Proportions。应用统计学杂志, 31(7), 799–815 似乎没有标准的计算。预测值的误差已在 betareg 包中实现。

很高兴接受纠正。

我已经使用了包 'effects' 和函数 allEffects()

BetaReg <- betareg(Value~x, data = Data)
Effects <- as.data.frame(allEffects(BetaReg, xlevels=list(x=BetaReg$x)))$x
Effects

我认为它是正确的(在图表上看起来是正确的):)