如何读取R 的sumary()结果
思路
step 1: sum = summary(model)
step 2: sum有好多属性,直接根据属性名称引用(\()即可, 如:
+ > sum\)call 返回 model 使用的模型语句
+ > sum\(coefficients; 返回一个列表,可以继续引用,如下
+ > sum\)coefficients[1 : 12]; 返回一个列表的一个切片,还可以继续切片
+ > sum$coefficients[1 : 12][2]; 返回一个列表的一个切片的第二个元素
下面是一些 测试代码,未整理,可以大致学习一下
用'demo()'来看一些示范程序,用'help()'来阅读在线帮助文件,或
用'help.start()'通过HTML浏览器来看帮助文件。
用'q()'退出R.
[Workspace loaded from ~/.RData]
> y=c(53,434,111,38,108,48)
> x1=c(1,2,3,1,2,3)
> x2=c(1,2,1,2,1,2)
> log.glm <-glm(y~x1+x2,family = possion(link=log))
Error in possion(link = log) : 没有"possion"这个函数
> log.glm <-glm(y~x1+x2,family = possion(link=log),data=(y,x1,x2))
错误: 意外的',' in "log.glm <-glm(y~x1+x2,family = possion(link=log),data=(y,"
> dataframe <-data.frame(y,x1,x2)
> head(dataframe)
y x1 x2
1 53 1 1
2 434 2 2
3 111 3 1
4 38 1 2
5 108 2 1
6 48 3 2
> log.glm <-glm(y~x1+x2,family = possion(link=log),data=data.frame(y,x1,x2))
Error in possion(link = log) : 没有"possion"这个函数
> log.glm <-glm(y~x1+x2,family = poisson(link=log),data=data.frame(y,x1,x2))
> summary(log.glm)
Call:
glm(formula = y ~ x1 + x2, family = poisson(link = log), data = data.frame(y,
x1, x2))
Deviance Residuals:
1 2 3 4 5 6
-3.1382 16.6806 0.8189 -11.0398 1.8210 -12.6942
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 3.59532 0.15792 22.767 < 2e-16 ***
x1 0.12915 0.04370 2.955 0.00312 **
x2 0.64803 0.07483 8.660 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for poisson family taken to be 1)
Null deviance: 662.84 on 5 degrees of freedom
Residual deviance: 575.10 on 3 degrees of freedom
AIC: 619.08
Number of Fisher Scoring iterations: 5
> log.glm.x1
错误: 找不到对象'log.glm.x1'
>
>
>
>
>
>
> summary(log.glm)
Call:
glm(formula = y ~ x1 + x2, family = poisson(link = log), data = data.frame(y,
x1, x2))
Deviance Residuals:
1 2 3 4 5 6
-3.1382 16.6806 0.8189 -11.0398 1.8210 -12.6942
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 3.59532 0.15792 22.767 < 2e-16 ***
x1 0.12915 0.04370 2.955 0.00312 **
x2 0.64803 0.07483 8.660 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for poisson family taken to be 1)
Null deviance: 662.84 on 5 degrees of freedom
Residual deviance: 575.10 on 3 degrees of freedom
AIC: 619.08
Number of Fisher Scoring iterations: 5
> log.glm.x1
错误: 找不到对象'log.glm.x1'
> help("glm")
> anova(log.glm)
Analysis of Deviance Table
Model: poisson, link: log
Response: y
Terms added sequentially (first to last)
Df Deviance Resid. Df Resid. Dev
NULL 5 662.84
x1 1 8.770 4 654.07
x2 1 78.978 3 575.10
> ano= anova(log.glm)
> ano[1]
Df
NULL
x1 1
x2 1
> ano[2]
Deviance
NULL
x1 8.770
x2 78.978
> ano[3]
Resid. Df
NULL 5
x1 4
x2 3
> sum= summary(log.glm)
> sum
Call:
glm(formula = y ~ x1 + x2, family = poisson(link = log), data = data.frame(y,
x1, x2))
Deviance Residuals:
1 2 3 4 5 6
-3.1382 16.6806 0.8189 -11.0398 1.8210 -12.6942
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 3.59532 0.15792 22.767 < 2e-16 ***
x1 0.12915 0.04370 2.955 0.00312 **
x2 0.64803 0.07483 8.660 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for poisson family taken to be 1)
Null deviance: 662.84 on 5 degrees of freedom
Residual deviance: 575.10 on 3 degrees of freedom
AIC: 619.08
Number of Fisher Scoring iterations: 5
> sum[1]
$call
glm(formula = y ~ x1 + x2, family = poisson(link = log), data = data.frame(y,
x1, x2))
> sum[1,1]
Error in sum[1, 1] : 量度数目不对
> sum[2]
$terms
y ~ x1 + x2
attr(,"variables")
list(y, x1, x2)
attr(,"factors")
x1 x2
y 0 0
x1 1 0
x2 0 1
attr(,"term.labels")
[1] "x1" "x2"
attr(,"order")
[1] 1 1
attr(,"intercept")
[1] 1
attr(,"response")
[1] 1
attr(,".Environment")
<environment: R_GlobalEnv>
attr(,"predvars")
list(y, x1, x2)
attr(,"dataClasses")
y x1 x2
"numeric" "numeric" "numeric"
> sum[3]
$family
Family: poisson
Link function: log
> sum[4]
$deviance
[1] 575.0954
> sum[4,1]
Error in sum[4, 1] : 量度数目不对
> sum
Call:
glm(formula = y ~ x1 + x2, family = poisson(link = log), data = data.frame(y,
x1, x2))
Deviance Residuals:
1 2 3 4 5 6
-3.1382 16.6806 0.8189 -11.0398 1.8210 -12.6942
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 3.59532 0.15792 22.767 < 2e-16 ***
x1 0.12915 0.04370 2.955 0.00312 **
x2 0.64803 0.07483 8.660 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for poisson family taken to be 1)
Null deviance: 662.84 on 5 degrees of freedom
Residual deviance: 575.10 on 3 degrees of freedom
AIC: 619.08
Number of Fisher Scoring iterations: 5
> sum[5]
$aic
[1] 619.0808
> sum[6]
$contrasts
NULL
> sum[8]
$null.deviance
[1] 662.8432
> sum[9]
$df.null
[1] 5
> sum[10]
$iter
[1] 5
> sum$aic
[1] 619.0808
> sum$null.deviance
[1] 662.8432
> sum$residual.deviance
NULL
> sum$residual.devianc
NULL
> sum[11]
$deviance.resid
1 2 3 4 5 6
-3.1382350 16.6805594 0.8189003 -11.0397892 1.8209720 -12.6941833
> summary.aov()
Error in summary.aov() : 缺少参数"object",也没有缺省值
> sum
Call:
glm(formula = y ~ x1 + x2, family = poisson(link = log), data = data.frame(y,
x1, x2))
Deviance Residuals:
1 2 3 4 5 6
-3.1382 16.6806 0.8189 -11.0398 1.8210 -12.6942
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 3.59532 0.15792 22.767 < 2e-16 ***
x1 0.12915 0.04370 2.955 0.00312 **
x2 0.64803 0.07483 8.660 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for poisson family taken to be 1)
Null deviance: 662.84 on 5 degrees of freedom
Residual deviance: 575.10 on 3 degrees of freedom
AIC: 619.08
Number of Fisher Scoring iterations: 5
> sum$coefficients
Estimate Std. Error z value Pr(>|z|)
(Intercept) 3.5953201 0.15791713 22.767132 9.709542e-115
x1 0.1291456 0.04370053 2.955240 3.124256e-03
x2 0.6480267 0.07482977 8.660013 4.717107e-18
> sum$coefficients[4]
[1] 0.1579171
> sum$coefficients[5]
[1] 0.04370053
> sum$coefficients[6]
[1] 0.07482977
> sum$coefficients[1]
[1] 3.59532
> sum$coefficients[1..2]
错误: unexpected numeric constant in "sum$coefficients[1..2"
> sum$coefficients[1:2]
[1] 3.5953201 0.1291456
> sum$coefficients[1:5]
[1] 3.59532005 0.12914558 0.64802675 0.15791713 0.04370053
> sum$coefficients[11:12]
[1] 3.124256e-03 4.717107e-18
> sum$coefficients[11:12][1]
[1] 0.003124256
> sum$coefficients[11:12][2]
[1] 4.717107e-18
如何读取R 的sumary()结果的更多相关文章
- R语言基础
一.扩展包的基本操作语句R安装好之后,默认自带了"stats" "graphics" "grDevices" "utils&qu ...
- R语言︱文件读入、读出一些方法罗列(批量xlsx文件、数据库、文本txt、文件夹)
笔者寄语:小规模的读取数据的方法较为简单并且多样,但是,批量读取目前看到有以下几种方法:xlsx包.RODBC包.批量转化成csv后读入. R语言中还有一些其他较为普遍的读入,比如代码包,R文件,工作 ...
- R语言手册
在R的官方教程里是这么给R下注解的:一个数据分析和图形显示的程序设计环境(A system for data analysis and visualization which is built bas ...
- 让R与Python共舞
转载:http://ices01.sinaapp.com/?p=129 R(又称R语言)是一款开源的跨平台的数值统计和数值图形化展现 工具.通俗点说,R是用来做统计和画图的.R拥有自己的脚本 ...
- Android小例子:使用反射机制来读取图片制作一个图片浏览器
效果图: 工程文件夹: 该例子可供于新手参考练习,如果有哪里不对的地方,望指正>-< <黑幕下的人> java代码(MainActivity.java): package co ...
- ArcGIS二次开发之读取遥感图像像素值的做法
作者:朱金灿 来源:http://blog.csdn.net/clever101 首先是读取遥感图像的R.G.B波段数据的做法.读取R.G.B波段数据的像素值主要通过IRaster接口的Read方法在 ...
- go语言学习笔记---读取文件io/ioutil 包
io/ioutil 包几个函数方法 名称 作用 备注 ReadAll 读取数据,返回读到的字节 slice 1 ReadDir 读取一个目录,返回目录入口数组 []os.FileInfo, 2 Re ...
- GO 文件读取常用的方法
方式1: 一行一行的方式读取 其中常用的方法就有:ReadString,ReadLine,ReadBytes ReadLine 返回单个行,不包括行尾字节,就是说,返回的内容不包括\n或者\r\n,返 ...
- [高性能MYSQL 读后随笔] 关于事务的隔离级别(一)
一.锁的种类 MySQL中锁的种类很多,有常见的表锁和行锁,也有新加入的Metadata Lock等等,表锁是对一整张表加锁,虽然可分为读锁和写锁,但毕竟是锁住整张表,会导致并发能力下降,一般是做dd ...
随机推荐
- PHP响应码和HTTP请求方法
HTTP请求报文由请求行(request line).请求头部(header).空行和请求数据4个部分组成,格式如下 可见请求行由请求方法字段.URL字段和HTTP协议版本字段3个字段组成,它们用空格 ...
- 20165304第4次实验《Android程序设计》实验报告
一.实验报告封面 课程:Java程序设计 班级:1653班 姓名:李松杨 学号:20165304 指导教师:娄嘉鹏 实验日期:2018年5月14日 实验时间:15:35 - 17:15 实验序号:实验 ...
- install oracle 12c on redhat
---恢复内容开始--- 1. 确定VM的硬盘空间是否够 df- h, 硬盘空间free disk 15G 比较稳妥 2. 确定好网络,需要remote connect ifconfig 3. ...
- c++冒号作用
转自http://www.360doc.com/content/13/0605/11/3373961_290615318.shtml 1.冒号(:)用法 (1)表示机构内位域的定义(即该变量占几个bi ...
- 2、python的变量
1.什么是变量 变量>顾名思义变化的量,量是一种表示一种状态的方式,而且可以变 2.为什么要用变量 程序的执行是一直处于一种变化状态的,我们可以用变量表示表示程序进行中的状态,并将它记录下来 3 ...
- 关于echarts图表在tab页中width:100%失效的问题
https://www.cnblogs.com/tongrenlu/p/9268250.html
- 大数据入门到精通6---spark rdd reduce by key 的使用方法
1.前期数据准备(同之前的章节) val collegesRdd= sc.textFile("/user/hdfs/CollegeNavigator.csv")val header ...
- as3.0 嵌入字体的用法
var txt:TextField = new TextField();//创建文本 txt.embedFonts=true;//确定嵌入字体 var font:Font=new MyFont();/ ...
- 视频和swf的相对路径加载,卸载
package com{ import flash.display.MovieClip; import flash.net.NetConnection; import flash.net.NetStr ...
- TypeError: while_loop() got an unexpected keyword argument 'maximum_iterations'
错误: TypeError: while_loop() got an unexpected keyword argument 'maximum_iterations' 参照https://blog.c ...