[英]How to add random and/or fixed effects into cloglog regression in R
更新关于固定效应的一个变量的处理问题我计划在 R 中运行阻塞回归,并使用随机和/或固定效应来检查未观察到的异质性。 现在我还没有找到任何关于如何在 R 中执行此操作的信息,只有一个 function 在 Stata 中。 有人熟悉这个吗? 我有一个我想输入的变量邮政编码,这个变量由 205 个级别组成,我有点不知道该怎么做。
这是我的堵塞回归的一个例子:
model_simple <- as.formula("completion_yesno ~ ac + ov + UCRate + FirstWeek + LastWeek + DayofWeekSu + DayofWeekMo + DayofWeekTu + DayofWeekWe + DayofWeekTh + DayofWeekFr + MonthofYearJan + MonthofYearFeb + MonthofYearMar + MonthofYearApr +MonthofYearMay+ MonthofYearJun + MonthofYearJul + MonthofYearAug + MonthofYearSep + MonthofYearOct + MonthofYearNov")
clog_simple1 = glm(model_simple,data=cllw,family = binomial(link = cloglog))
summary(clog_simple1)
我尝试使用来自 package glmmML package 的 glmmboost function 输入固定效果
> model_simple <- as.formula("completion_yesno ~ ac + ov +
> UCRate + FirstWeek + LastWeek + DayofWeekSu + DayofWeekMo
> + DayofWeekTu + DayofWeekWe + DayofWeekTh + DayofWeekFr + MonthofYearJan + MonthofYearFeb + MonthofYearMar + MonthofYearApr
> +MonthofYearMay+ MonthofYearJun + MonthofYearJul + MonthofYearAug + MonthofYearSep + MonthofYearOct + MonthofYearNov") clog_fe <-
> glmmboot(model_simple, data=cllw,family = binomial(link = cloglog),
> cluster = zip, boot = 5000) summary(clog_fe)
function 只是运行,似乎永远不会产生结果。 我对每一个小费都感到困惑和高兴。
您可以将固定效果 model 与标准glm
function 配合使用。 您只需要按兴趣级别创建一个虚拟对象。 例如,这种风味的东西:
model_FE <- as.formula("completion_yesno ~ factor(groupvar) + ac + ov + UCRate + FirstWeek + LastWeek + DayofWeekSu + DayofWeekMo + DayofWeekTu + DayofWeekWe + DayofWeekTh + DayofWeekFr + MonthofYearJan + MonthofYearFeb + MonthofYearMar + MonthofYearApr +MonthofYearMay+ MonthofYearJun + MonthofYearJul + MonthofYearAug + MonthofYearSep + MonthofYearOct + MonthofYearNov")
glm(model_simple,data=cllw,family = binomial(link = cloglog))
factor(group)
将创建 K-1(或 K,如果您想在没有截距的情况下拟合 model)系数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.