我正在使用clmm()
函数(来自序数包)来运行混合效果序数逻辑回归,需要为B estimate
提取RMem
的参数变量。
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.454
str(otp)
只返回$beta
属性的一个条目(我感兴趣的RMem
变量)
> str(otp)
...
$ beta : Named num -2.31
..- attr(*, "names")= chr "RMem"
...
unlist()
函数也只显示估算值。您能否告诉我如何为z-value
变量的p-value
提取B estimate
和RMem
?
谢谢!
答案 0 :(得分:0)
所以我无法使用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)