如何解决使用r-mice时池函数导致估算数据出错
R的新手,对于任何误解,我们深表歉意。
我正在尝试对估算数据进行线性回归。我已经用完整的案例进行了线性回归,但想比较估算模型。
我正在使用鼠标,并已创建估算的数据:
imp_data2 <- mice(data,m=5,maxit=20,meth='pmm',seed=12345)
然后:
# Stack imputed datasets in long format,exclude the original data
impdat <- complete(imp_data2,action="long",include = FALSE)
然后我指定了模型:
model1 <-with(data = impdat,exp = lm(nat11 ~ sex + AGE + (fasbathroom+fasbedroom+fascomputers+
fasdishwash+fasfamcar+fasholidays)))
但是当我尝试使用pool()函数给出模型摘要时:
summary(pool(model1))
我得到一些奇怪的错误代码,但我找不到任何可以帮助的东西。我可以使用summary(model1),它可以正常工作,但无法获得汇总模型的摘要。有什么建议吗?
我得到的错误是:
Error: No tidy method for objects of class qr
In addition: Warning messages:
1: In get.dfcom(object,dfcom) : Infinite sample size assumed.
2: 'tidy.numeric' is deprecated.
See help("Deprecated")
3: 'tidy.numeric' is deprecated.
See help("Deprecated")
4: 'tidy.numeric' is deprecated.
See help("Deprecated")
5: 'tidy.numeric' is deprecated.
See help("Deprecated")
6: 'tidy.numeric' is deprecated.
See help("Deprecated")
7: 'tidy.numeric' is deprecated.
See help("Deprecated")
编辑
如果有帮助,我使用了traceback()函数。输出为:
12: stop("No tidy method for objects of class ",class(x)[1],call. = FALSE)
11: tidy.default(X[[i]],...)
10: FUN(X[[i]],...)
9: lapply(fitlist,tidy,effects = "fixed",parametric = TRUE,...)
8: eval(lhs,parent,parent)
7: eval(lhs,parent)
6: lapply(fitlist,...) %>%
bind_rows()
5: summary.mira(fitlist,type = "tidy",exponentiate = FALSE)`
4: summary(fitlist,exponentiate = FALSE)
3: pool.fitlist(getfit(object),dfcom = dfcom)
2: pool(model1)
1: summary(pool(model1))
如果我输入
str(complete(imp_data2,action=1))
输出如下:
'data.frame': 5286 obs. of 45 variables:
`$ AGE : num 11.6 12 12.3 11.2 12 ...`
`$ sex : num 1 1 1 2 2 1 1 2 2 2 ...`
..- attr(*,"value.labels")= Named chr [1:2] "2" "1"
.. ..- attr(*,"names")= chr [1:2] "female" "male"
$ grade : num 1 1 1 1 1 1 1 1 1 1 ...
..- attr(*,"value.labels")= Named chr [1:3] "3" "2" "1"
.. ..- attr(*,"names")= chr [1:3] "Country specific grade (15 year old)" "Country specific grade (13 year old)" "Country specific grade (11 year old)"
$ fasfamcar : num 3 3 3 2 3 3 3 2 3 3 ...
..- attr(*,"names")= chr [1:3] "Yes,two or more" "Yes,one" "No"
$ fasbedroom : num 1 2 2 2 1 2 2 2 2 2 ...
..- attr(*,"names")= chr [1:2] "Yes" "No"
$ fascomputers : num 4 3 4 4 4 4 4 4 4 4 ...
..- attr(*,"value.labels")= Named chr [1:4] "4" "3" "2" "1"
.. ..- attr(*,"names")= chr [1:4] "More than two" "Two" "One" "None"
$ fasbathroom : num 4 4 3 4 3 4 4 3 4 4 ...
..- attr(*,"names")= chr [1:4] "More than two" "Two" "One" "None"
$ fasdishwash : num 2 2 1 2 2 2 2 2 2 2 ...
..- attr(*,"names")= chr [1:2] "Yes" "No"
$ fasholidays : num 4 4 3 3 1 4 4 2 2 2 ...
..- attr(*,"names")= chr [1:4] "More than twice" "Twice" "Once" "Not at all"
$ health : num 1 1 2 2 2 1 1 1 2 1 ...
..- attr(*,"names")= chr [1:4] "Poor" "Fair" "Good" "Excellent"
$ lifesat : num 9 8 9 7 8 10 10 10 8 9 ...
..- attr(*,"value.labels")= Named chr [1:11] "10" "9" "8" "7" ...
.. ..- attr(*,"names")= chr [1:11] "10 Best possible life" "9" "8" "7" ...
$ feellow : num 5 5 4 4 5 5 5 5 4 4 ...
..- attr(*,"value.labels")= Named chr [1:5] "5" "4" "3" "2" ...
.. ..- attr(*,"names")= chr [1:5] "Rarely or never" "About every month" "About every week" "More than once a week" ...
$ irritable : num 5 5 4 4 3 3 5 5 5 4 ...
..- attr(*,"names")= chr [1:5] "Rarely or never" "About every month" "About every week" "More than once a week" ...
$ nervous : num 4 1 4 3 4 3 5 4 4 4 ...
..- attr(*,"names")= chr [1:5] "Rarely or never" "About every month" "About every week" "More than once a week" ...
$ sleepdifficulty : num 5 5 1 4 5 5 5 5 4 4 ...
..- attr(*,"names")= chr [1:5] "Rarely or never" "About every month" "About every week" "More than once a week" ...
$ fmeal : num 1 1 2 1 2 1 2 2 4 2 ...
..- attr(*,"names")= chr [1:5] "Never" "Less often" "About once a week" "Most days" ...
$ smok30d_2 : num 1 1 1 1 1 1 1 1 1 1 ...
..- attr(*,"value.labels")= Named chr [1:7] "7" "6" "5" "4" ...
.. ..- attr(*,"names")= chr [1:7] "30 days (or more)" "20-29 days" "10-19 days" "6-9 days" ...
$ drunk30d : num 1 1 1 1 1 1 1 1 1 1 ...
..- attr(*,"names")= chr [1:5] "Yes,more than 10 times" "Yes,4-10 times" "Yes,2-3 times" "Yes,once" ...
$ likeschool : num 1 1 1 1 1 2 1 1 2 2 ...
..- attr(*,"names")= chr [1:4] "I don't like it at all" "I don't like it very much" "I like it a bit" "I like it a lot"
$ schoolpressure : num 2 1 4 1 1 3 1 2 3 2 ...
..- attr(*,"names")= chr [1:4] "A lot" "Some" "A little" "Not at all"
$ studtogether : num 2 2 3 2 2 2 2 2 2 2 ...
..- attr(*,"names")= chr [1:5] "Strongly disagree" "Disagree" "Neither agree nor disagree" "Agree" ...
$ studhelpful : num 1 2 3 1 1 2 2 2 1 3 ...
..- attr(*,"names")= chr [1:5] "Strongly disagree" "Disagree" "Neither agree nor disagree" "Agree" ...
$ studaccept : num 2 3 2 2 2 1 1 2 1 2 ...
..- attr(*,"names")= chr [1:5] "Strongly disagree" "Disagree" "Neither agree nor disagree" "Agree" ...
$ teacheraccept : num 1 1 2 1 1 1 1 1 1 2 ...
..- attr(*,"names")= chr [1:5] "Strongly disagree" "Disagree" "Neither agree nor disagree" "Agree" ...
$ teachercare : num 1 1 3 1 3 1 1 2 2 2 ...
..- attr(*,"names")= chr [1:5] "Strongly disagree" "Disagree" "Neither agree nor disagree" "Agree" ...
$ teachertrust : num 1 1 3 1 2 1 1 2 2 2 ...
..- attr(*,"names")= chr [1:5] "Strongly disagree" "Disagree" "Neither agree nor disagree" "Agree" ...
$ beenbullied : num 1 3 1 2 1 1 1 1 1 2 ...
..- attr(*,"names")= chr [1:5] "Several times a week" "About once a week" "2 or 3 times a month" "It has happened once or twice" ...
$ cbeenbullied : num 1 1 1 1 1 1 1 1 1 1 ...
..- attr(*,"names")= chr [1:5] "Several times a week" "About once a week" "2 or 3 times a month" "It has happened once or twice" ...
$ fight12m : num 1 1 2 1 1 1 1 1 1 1 ...
..- attr(*,"names")= chr [1:5] "4 times or more" "3 times" "2 times" "1 time" ...
$ friendhelp : num 7 7 4 5 7 5 2 7 7 7 ...
..- attr(*,"names")= chr [1:7] "Very strongly agree" "6" "5" "4" ...
$ friendcounton : num 7 6 4 5 7 5 1 7 7 7 ...
..- attr(*,"names")= chr [1:7] "Very strongly agree" "6" "5" "4" ...
$ friendshare : num 7 5 3 5 7 5 1 7 7 7 ...
..- attr(*,"names")= chr [1:7] "Very strongly agree" "6" "5" "4" ...
$ friendtalk : num 7 4 3 5 6 2 1 7 7 7 ...
..- attr(*,"names")= chr [1:7] "Very strongly agree" "6" "5" "4" ...
$ hadsex : num 2 2 2 2 2 1 2 2 2 2 ...
..- attr(*,"names")= chr [1:2] "No" "Yes"
$ agesex : num 1 3 5 1 5 4 3 3 4 5 ...
..- attr(*,"value.labels")= Named chr [1:6] "6" "5" "4" "3" ...
.. ..- attr(*,"names")= chr [1:6] "16 years old and older" "15 years old" "14 years old" "13 years old" ...
$ contraceptcondom: num 2 2 1 3 1 2 1 1 1 3 ...
..- attr(*,"names")= chr [1:3] "Don't know" "No" "Yes"
$ contraceptpill : num 3 3 3 3 3 3 2 3 2 3 ...
..- attr(*,"names")= chr [1:3] "Don't know" "No" "Yes"
$ motherhome1 : num 1 1 1 1 1 1 1 1 1 1 ...
..- attr(*,"names")= chr [1:2] "No" "Yes"
$ fatherhome1 : num 2 1 2 1 1 1 1 1 1 1 ...
..- attr(*,"names")= chr [1:2] "No" "Yes"
$ talkfather : num 1 1 2 2 2 2 2 2 2 2 ...
..- attr(*,"names")= chr [1:5] "Don't have or see this person" "Very difficult" "Difficult" "Easy" ...
$ talkmother : num 1 1 1 2 2 2 2 1 2 1 ...
..- attr(*,"names")= chr [1:5] "Don't have or see this person" "Very difficult" "Difficult" "Easy" ...
$ famhelp : num 7 7 5 6 7 7 1 7 7 7 ...
..- attr(*,"names")= chr [1:7] "Very strongly agree" "6" "5" "4" ...
$ famsup : num 7 7 5 6 7 7 1 7 7 7 ...
..- attr(*,"names")= chr [1:7] "Very strongly agree" "6" "5" "4" ...
$ famtalk : num 7 7 6 6 7 6 1 7 7 7 ...
..- attr(*,"names")= chr [1:7] "Very strongly agree" "6" "5" "4" ...
$ nat11 : num 2 2 3 2 1 2 2 2 2 2 ...
..- attr(*,"names")= chr [1:5] "Always" "Often" "Sometimes" "Hardly ever" ...
- attr(*,"variable.labels")= Named chr(0)
..- attr(*,"names")= chr(0)
- attr(*,"codepage")= int 65001
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。