2015-12-08 62 views
1

我使用clmm()函數(從包)中提取z值來運行混合效應序邏輯迴歸和需要提取的B estimate參數爲RMem變量。如何從clmm輸出摘要

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-valuep-valueB estimateRMem變量?

謝謝!

+0

嘗試'摘要(otp)$係數[1,c(3,4)]' – DatamineR

+0

非常感謝您的快速響應!我沒有意識到summary(otp)$係數包含最後一行中的RMem(它在「係數」字段中報告)的z值和p值。 – user5656546

回答

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)