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

如何用glmmTMB包优化时间混合GLMM模型的最大值计算?

优化glmmTMB混合模型求最大值的方法探讨

我希望找到更优方法,使用glmmTMB包计算以月份(mes)为时间变量的混合GLM模型的最大值,但不确定当前方法是否最优。

当前使用的代码如下:

# 加载包
library(glmmTMB)
library(tidyverse)
library(inflection)
library(ggeffects)
theme_set(theme_bw())

# 读取数据集
d <- read.csv("https://raw.githubusercontent.com/Leprechault/trash/main/p_lineares.csv", h=T)

# 构建最优GLMM(对比过poisson、nbinom2、ziGamma等模型后选择)
m.c <- glmmTMB(N ~ poly(mes,2) + poly(prec,2) + (1 | mes), data = d,
               family = "nbinom1",
               ziformula = ~ 1)

# 使用bede方法(二分极值距离估计法)寻找拐点最大值
ds_F <- cbind(x=d$mes,y=exp(predict(m.c)))
ds_F <- as.data.frame(ds_F)
bb <- bede(ds_F$x, ds_F$y, 1)
bb$iplast

# 可视化结果
ggpredict(m.c, terms = "mes [all]") %>% 
  plot(add.data = TRUE) + 
  geom_vline(xintercept = bb$iplast, colour="red", linetype = "longdash") + 
  labs(
    title = " ",
    x     = "Meses",
    y     = "Insects counts"
  )

目前通过上述代码实现了模型拟合、最大值拐点计算及可视化,但希望能得到更高效或更严谨的最优值计算方法。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.22 16:55:41