为geeglm()

问题描述 投票:0回答:2

你能帮我弄清楚为什么我会遇到错误吗?

在本质上,我的数据看起来像这样:

> attributes(compl)$names [1] "UserID" "compl_bin" "Sex.x" "PHQ_base" "PHQ_Surv1" "PHQ_Surv2" "PHQ_Surv3" [8] "PHQ_Surv4" "EFE" "Neuro" "Intervention.x" "depr0" "error1_1.x" "error1_2.x" [15] "error1_3.x" "error1_4.x" "stress0" "stress1" "stress2" "stress3" "stress4" [22] "hours1" "hours2" "hours3" "hours4" "subject"
首先,我重塑了我的数据以为geeglm做准备:

compl$subject <- factor(rownames(compl)) nobs <- nrow(compl) compl_long <- reshape(compl, idvar = "subject", varying = list(c("PHQ_Surv1", "PHQ_Surv2" , "PHQ_Surv3", "PHQ_Surv4"), c("error1_1.x", "error1_2.x", "error1_3.x", "error1_4.x"), c("stress1", "stress2", "stress3", "stress4"), c("hours1", "hours2", "hours3", "hours4")), v.names = c("PHQ", "error", "stress", "hours"), times = c("1", "2", "3", "4"), direction = "long")
-(编辑注:不确定下一个输出是什么...)

[1] "UserID" "compl_bin" "Sex.x" "PHQ_base" "EFE" "Neuro" "Intervention.x" [8] "depr0" "stress0" "subject" "time" "PHQ" "error" "stress" [15] "hours"
然后我使用geeglm函数:

library(geepack) geeSand=(geeglm(PHQ~as.factor(compl_bin) + Neuro+PHQ_base+as.factor(depr0) + EFE+as.factor(Sex.x) + as.factor(error)+stress+hours, family = poisson, data=compl_long, id=subject, corst="exchangeable"))
我正在遇到错误:

"Error in geese.fit(xx, yy, id, offset, soffset, w, waves = waves, zsca, : nrow(zsca) and length(y) not match"

如果我删除变量为factor(error)和小时,则geeglm不会抱怨,我正在获取输出。该函数与错误和小时变量无效。我检查所有变量的长度,它们相等。你能帮我弄清楚怎么了吗?

thound,谢谢!

found以下网址:

Https://stat..ch/pipermail/r-help/2008-october/178337.html
r
2个回答
3
投票

我很确定这是Geese()中的一个错误,应该报告给 这 Geepack的维护者。 问题在于缺少的治疗 值 如果看

dim(na.omit(dat[,c("id","score","chem","time")]))
得到44。 在geese.fit()ZSCA中设置等于矩阵(1,n,1),其中n为n 等于 长度(ID)。 但是id的长度为46,而响应却是

修剪 通过消除任何数据的所有行,以下到44 变量 涉及的缺失。 因此问题
问题的解决方案需要通过
重写一些代码 geepack的维护者

GEEGLM的文档专门说

“ na.Action没有采取任何措施。实际上Geeglm仅适用于完整的数据。”

如果在任何行中都有任何NA,则该函数将不起作用。显然,尝试弄清楚为什么缺少数据并找到它们或算上数据。如果是不可能的,则在任何列中使用任何NA排除所有行的快速方法是:

data= na.omit(mydata)

在您的情况下会是
data= na.omit(compl_long)

0
投票
希望它有帮助

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.