全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
7333 8
2012-03-23
悬赏 10 个论坛币 已解决

R中的显著性标志为:


Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 而且0.1那个标志都看不出来。


而在经济学中通常所使用的显著性表示为0.01 ‘***’ 0.05 ‘**’ 0.1 ‘*’


如何将显示结果直接输出为这种形式呢,比如lm回归结果如何更改?


另外查询到summary.lm命令输出结果的时候用到printCoefmat命令,我对程序中显著性标志进行了更改,可是为什么没有作用呢


谢谢啦~~

最佳答案

epoh 查看完整内容

printCoefmat.R 单独使用function printCoefmat(),可以改过来 然summary()->summary.lm()->printCoefmat(),还是呼叫到旧function 先供老兄参考. ########## ctl
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2012-3-23 17:35:44
printCoefmat.R
   
printCoefmat.rar
大小:(1.4 KB)

 马上下载

本附件包括:

  • printCoefmat.R


单独使用function printCoefmat(),可以改过来
然summary()->summary.lm()->printCoefmat(),还是呼叫到旧function
先供老兄参考.
##########
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- gl(2,10,20, labels=c("Ctl","Trt"))
weight <- c(ctl, trt)
lm.D9 <- lm(weight ~ group)
source("printCoefmat.R")
summary(lm.D9)

Call:
lm(formula = weight ~ group)

Residuals:
    Min      1Q  Median      3Q     Max
-1.0710 -0.4938  0.0685  0.2462  1.3690

Coefficients:
            Estimate Std. Error t value Pr(>|t|)   
(Intercept)   5.0320     0.2202  22.850 9.55e-15 ***
groupTrt     -0.3710     0.3114  -1.191    0.249   
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.6964 on 18 degrees of freedom
Multiple R-squared: 0.07308,    Adjusted R-squared: 0.02158
F-statistic: 1.419 on 1 and 18 DF,  p-value: 0.249

printCoefmat(summary(lm.D9)$coefficients)
            Estimate Std. Error t value  Pr(>|t|)      
(Intercept)  5.03200    0.22022 22.8501 9.547e-15 *****
groupTrt    -0.37100    0.31143 -1.1913     0.249 *   
---
Signif. codes:  0 ‘*****’ 0.001 ‘****’ 0.01 ‘***’ 0.05 ‘**’ 0.1 ‘*’ 1
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-3-24 22:07:34
epoh 发表于 2012-3-24 21:39
printCoefmat.R
   
单独使用function printCoefmat(),可以改过来
呵呵,epoh兄出手,果然不同凡响
我尝试更改了几次printCoefmat函数,一直没试验成功,
原来这样可以搞定,
如果能够更改R的内部函数或者能让summary调用新的函数就好了
呵呵,不过还是十分感谢epoh兄!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-3-24 22:13:34
epoh 发表于 2012-3-24 21:39
printCoefmat.R
   
单独使用function printCoefmat(),可以改过来
大神啊
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-3-25 07:19:53
kk22boy 发表于 2012-3-24 22:07
呵呵,epoh兄出手,果然不同凡响
我尝试更改了几次printCoefmat函数,一直没试验成功,
原来这样可以搞 ...
針對lm object,修改如下:
lm.R
  
lm.rar
大小:(10.07 KB)

 马上下载

本附件包括:

  • lm.R


########
source("lm.R")
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- gl(2,10,20, labels=c("Ctl","Trt"))
weight <- c(ctl, trt)
lm.D9 <- lm(weight ~ group)
summary(lm.D9)

Call:
lm(formula = weight ~ group)

Residuals:
    Min      1Q  Median      3Q     Max
-1.0710 -0.4938  0.0685  0.2462  1.3690

Coefficients:
            Estimate Std. Error t value Pr(>|t|)      
(Intercept)   5.0320     0.2202  22.850 9.55e-15 *****
groupTrt     -0.3710     0.3114  -1.191    0.249 *   
---
Signif. codes:  0 ‘*****’ 0.001 ‘****’ 0.01 ‘***’ 0.05 ‘**’ 0.1 ‘*’ 1

Residual standard error: 0.6964 on 18 degrees of freedom
Multiple R-squared: 0.07308,    Adjusted R-squared: 0.02158
F-statistic: 1.419 on 1 and 18 DF,  p-value: 0.249

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-3-25 09:22:37
epoh 发表于 2012-3-25 07:19
針對lm object,修改如下:
lm.R
呵呵,epoh兄起的真早,
好勤快~~
谢谢epoh兄~~
这个程序好像只能用于lm回归,对其他的像plm、glm回归好像就不能用了
如果能修改summary函数,可以直接使用的话,效果可能会更好,呵呵
其实前边epoh兄给的那个printCoefmat函数就已经把问题很好的解决了
呵呵,得好好向epoh兄学习那股钻研劲
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群