【问题标题】:Random effects specification in gamlss in RR中gamlss中的随机效应规范
【发布时间】:2021-10-20 15:08:51
【问题描述】:

我想使用 gamlss 包来拟合模型,从而受益于该包中更多可用的发行版。但是,我正在努力正确指定我的随机效应,或者至少我认为这是一个错误,因为如果我将 lmer 模型的输出与高斯分布进行比较,而 gamlss 模型与高斯分布的输出不同。如果比较没有随机效应的 lm 模型和具有高斯分布且没有随机效应的 gamlss 模型,输出是相似的。

很遗憾,我无法共享我的数据来复制它。 这是我的代码:

df <- subset.data.frame(GFW_food_agg, GFW_food_agg$fourC_area_perc < 200, select = c("ISO3", "Year", "Forest_loss_annual_perc_boxcox", "fourC_area_perc", "Pop_Dens_km2", "Pop_Growth_perc", "GDP_Capita_current_USD", "GDP_Capita_growth_perc", 
                                                                                     "GDP_AgrForFis_percGDP", "Gini_2008_2018", "Arable_land_perc", "Forest_loss_annual_perc_previous_year", "Forest_extent_2000_perc"))
fourC <- lmer(Forest_loss_annual_perc_boxcox ~ fourC_area_perc + Pop_Dens_km2 + Pop_Growth_perc + GDP_Capita_current_USD + 
              GDP_Capita_growth_perc + GDP_AgrForFis_percGDP + Gini_2008_2018 + Arable_land_perc + Forest_extent_2000_perc + (1|ISO3) + (1|Year), 
            data = df)
summary(fourC)
resid_panel(fourC)


df <- subset.data.frame(GFW_food_agg, GFW_food_agg$fourC_area_perc < 200, select = c("ISO3", "Year", "Forest_loss_annual_perc_boxcox", "fourC_area_perc", "Pop_Dens_km2", "Pop_Growth_perc", "GDP_Capita_current_USD", "GDP_Capita_growth_perc", 
                                                                                     "GDP_AgrForFis_percGDP", "Gini_2008_2018", "Arable_land_perc", "Forest_loss_annual_perc_previous_year", "Forest_extent_2000_perc"))
df <- na.omit(df)
df$ISO3 <- as.factor(df$ISO3)
df$Year <- as.factor(df$Year)
fourC <- gamlss(Forest_loss_annual_perc_boxcox ~ fourC_area_perc + Pop_Dens_km2 + Pop_Growth_perc + GDP_Capita_current_USD + 
                  GDP_Capita_growth_perc + GDP_AgrForFis_percGDP + Gini_2008_2018 + Arable_land_perc + Forest_extent_2000_perc + random(ISO3) + random(Year), 
                data = df, family = NO, control = gamlss.control(n.cyc = 200))
summary(fourC)
plot(fourC)

如何在 gamlss 中指定随机效应与 lmer 中的随机效应相似?

如果我指定随机效果而不是使用

re(random = ~1|ISO3) + re(random = ~1|Year)

我收到以下错误: model.frame.default 中的错误(公式 = Forest_loss_annual_perc_boxcox ~ : 可变长度不同(为 're(random = ~1 | ISO3)' 找到)

【问题讨论】:

    标签: r random lme4 mixed-models gamlss


    【解决方案1】:

    我发现 +re(random=~1|x) 规范与我的 GAMLSS 配合得很好。您是否仔细检查过 NA 是否已从您的数据集中删除?有时 na.omit 无法正常工作。

    查看与您的错误相同的线程,但在 GAM 中。您可以尝试使用该代码删除您的 NA

    Error in model.frame.default: variable lengths differ

    【讨论】:

      猜你喜欢
      • 2018-07-05
      • 1970-01-01
      • 2015-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-13
      • 2020-06-30
      相关资源
      最近更新 更多