我使用clmm()函数(来自序号包)运行混合效应序数logistic回归,并需要提取RMem变量的B estimate参数。
otp <- summary(clmm(Rank ~ RMem + (1|sbj.ID), data = brands))
> otp
Cumulative Link Mixed Model fitted with the Laplace approximation
formula: as.factor(Rank) ~ RMem + (1 | sbj.ID)
data: dataset
link threshold nobs logLik AIC niter max.grad cond.H
logit flexible 1921 -5433.43 10908.87 5152(10419) 1.02e-02 1.2e+03
Random effects:
Groups Name Variance Std.Dev.
sbj.ID (Intercept) 0.04227 0.2056
Number of groups: sbj.ID 107
Coefficients:
Estimate Std. Error z value Pr(>|z|)
RM -2.3087 0.1129 -20.46 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Threshold coefficients:
Estimate Std. Error z value
1|2 -4.43967 0.13667 -32.485
2|3 -3.63258 0.11504 -31.576
...
19|20 2.36590 0.11028 21.454str(otp)只返回$beta属性的一个条目(对于我感兴趣的RMem变量)
> str(otp)
...
$ beta : Named num -2.31
..- attr(*, "names")= chr "RMem"
...unlist()函数也只显示估计值。您能告诉我如何提取z-value和p-value用于RMem变量的B estimate吗?
谢谢!
发布于 2015-12-08 23:27:00
因此,我不能使用clmm调用完美地复制,因为这对我来说是新的,但是摘要函数看起来是返回相同类型的项,所以这应该适用于一些所需的替换:
##with the mtcars dataset
data(mtcars)
glm1<-summary(glm(mpg~cyl+disp+hp,data=mtcars))
glm1$coefficients[,'t value'] #change to z value
glm1$coefficients[,'Pr(>|t|)'] #this will return your t-values - you need to change "t" to "z"
##as a data.frame from a function##
getCoefs<-function(summaryModel){
sumResults<-data.frame(coefs=names(summaryModel$coefficients[,'t value']),
t=summaryModel$coefficients[,'t value'],
prT=summaryModel$coefficients[,'Pr(>|t|)'])
return(sumResults)
}
sumResults<-getCoefs(glm1)https://stackoverflow.com/questions/34167843
复制相似问题