首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用摘要提取R中的选定输出

使用摘要提取R中的选定输出
EN

Stack Overflow用户
提问于 2021-11-23 20:00:25
回答 1查看 137关注 0票数 1

使用摘要提取R中的选定输出

代码语言:javascript
复制
model <- glm(am ~ disp + hp, data=mtcars, family=binomial)
T1<-summary(model)
T1

,这是我得到的输出

代码语言:javascript
复制
 Call:
    glm(formula = am ~ disp + hp, family = binomial, data = mtcars)
    
    Deviance Residuals: 
        Min       1Q   Median       3Q      Max  
    -1.9665  -0.3090  -0.0017   0.3934   1.3682  
    
    Coefficients:
                Estimate Std. Error z value Pr(>|z|)  
    (Intercept)  1.40342    1.36757   1.026   0.3048  
    disp        -0.09518    0.04800  -1.983   0.0474 *
    hp           0.12170    0.06777   1.796   0.0725 .
    ---
    Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
    
    (Dispersion parameter for binomial family taken to be 1)
    
    Null deviance: 43.230  on 31  degrees of freedom
    Residual deviance: 16.713  on 29  degrees of freedom
    AIC: 22.713
    
    Number of Fisher Scoring iterations: 8

我只想提取系数和零偏差,如下所示,我如何做到这一点,我尝试使用$coefficeint,但它只显示系数值?

代码语言:javascript
复制
Coefficients:
(Intercept)        disp          hp 
1.40342203   -0.09517972      0.12170173 

Null deviance: 43.230  on 31  degrees of freedom
Residual deviance: 16.713  on 29  degrees of freedom
AIC: 22.713
EN

回答 1

Stack Overflow用户

发布于 2021-11-23 20:07:20

更新:尝试如下:

代码语言:javascript
复制
  coef(model)
  model$coefficients
  model$null.deviance
  model$deviance
  model$aic

如果您输入T1$,则会出现一个窗口,您可以选择所需的任何内容。

代码语言:javascript
复制
  T1$null.deviance    
  T1$coefficients
代码语言:javascript
复制
>   T1$null.deviance        
[1] 43.22973
>   T1$coefficients
               Estimate Std. Error   z value   Pr(>|z|)
(Intercept)  1.40342203 1.36756660  1.026218 0.30478864
disp        -0.09517972 0.04800283 -1.982794 0.04739044
hp           0.12170173 0.06777320  1.795721 0.07253897
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70087119

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档