【问题标题】:mgcv GAM with betarmgcv GAM 与 beta
【发布时间】:2020-03-21 06:26:59
【问题描述】:

有谁知道如何从模型输出(具有 beta 分布的 mgcv GAM)中获取拟合的 phi 参数?

参考提供的betar gam example

library(mgcv)
## Simulate some beta data...
set.seed(3);n<-400
dat <- gamSim(1,n=n)
mu <- binomial()$linkinv(dat$f/4-2)
phi <- .5
a <- mu*phi;b <- phi - a;
dat$y <- rbeta(n,a,b) 

bm <- gam(y~s(x0)+s(x1)+s(x2)+s(x3),family=betar(link="logit"),data=dat)

输出显示“家庭:Beta 回归”下的 phi 估计值

> bm

Family: Beta regression(0.491) 
Link function: logit 

Formula:
y ~ s(x0) + s(x1) + s(x2) + s(x3)

Estimated degrees of freedom:
1.73 1.63 5.62 1.00  total = 10.98 

【问题讨论】:

  • 嗨 Luis,我知道这是你第一次发帖。确保提供可重复的示例,而不仅仅是参考网页。这次我为你编辑了它,因为我对此有点熟悉。下次,请注意并写一个更明智的问题:)
  • 您能否添加一些代码来说明您是如何实现这一目标的?

标签: r gam mgcv


【解决方案1】:

在拟合过程中,gam 函数调用 betar(),然后估计称为 theta 的 phi 参数。我在下面引用了函数的描述:

说明:

 Family for use with ‘gam’ or ‘bam’, implementing regression for
 beta distributed data on (0,1). A linear predictor controls the
 mean, mu of the beta distribution, while the variance is then
 mu(1-mu)/(1+phi), with parameter phi being estimated during
 fitting, alongside the smoothing parameters.

用法:

 betar(theta = NULL, link = "logit",eps=.Machine$double.eps*100)
  Arguments:

 theta: the extra parameter (phi above).

使用您的示例,您只需要查看 gam 对象:

bm <- gam(y~s(x0)+s(x1)+s(x2)+s(x3),family=betar(link="logit"),data=dat)
exp(bm$family$getTheta())
[1] 0.4913482

【讨论】:

  • 我想这通常是正确的,额外的拟合参数列在这个“Theta”中。怎么知道参数是如何转换的(在上面的例子中是 exp)?我在 mgcv 文档中找不到这个。
  • 嘿@LuisMier-y-Teran,我查看了家庭的源代码,beta,github.com/cran/mgcv/blob/master/R/efam.r,你可以看到大部分时间,在他们将它输入到 beta 之前-二项分布,取指数。
  • +1 如果您查看getTheta 函数,您可以执行getTheta(trans = TRUE) 来实现与显式exp() 相同的事情——调用getTheta() 的结果。跨度>
  • 是的@ReinstateMonica-G.Simpson,你是对的。感谢您指出。
猜你喜欢
  • 2016-01-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-25
  • 1970-01-01
  • 2023-01-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多