楼主: dxystata
2994 2

[问答] 如何增加一行 [推广有奖]

版主

已卖:302份资源

大师

37%

还不是VIP/贵宾

-

TA的文库  其他...

Software

中英文Ebook

R学习

威望
2
论坛币
183395 个
通用积分
15333.1475
学术水平
208 点
热心指数
271 点
信用等级
174 点
经验
298627 点
帖子
5586
精华
1
在线时间
13632 小时
注册时间
2006-6-21
最后登录
2025-12-22

初级学术勋章 初级热心勋章 中级热心勋章 初级信用勋章

楼主
dxystata 发表于 2013-4-27 09:45:39 |AI写论文
100论坛币
  1. mydata <- read.csv("http://www.ats.ucla.edu/stat/data/binary.csv")
  2. library(foreign)
  3. write.dta(mydata,"e:/abc.dta")
  4. head(mydata)
  5. mydata$rank <- factor(mydata$rank)
  6. regress.out<- glm(admit ~ gre + gpa + rank, data = mydata, family = "binomial")
  7. usual.output <-summary(regress.out)
  8. usual.output

  9. 输出的结果中Coefficients:
  10.              Estimate Std. Error z value Pr(>|z|)   
  11. (Intercept) -3.989979   1.139951  -3.500 0.000465 ***
  12. gre          0.002264   0.001094   2.070 0.038465 *  
  13. gpa          0.804038   0.331819   2.423 0.015388 *  
  14. rank2       -0.675443   0.316490  -2.134 0.032829 *  
  15. rank3       -1.340204   0.345306  -3.881 0.000104 ***
  16. rank4       -1.551464   0.417832  -3.713 0.000205 ***


  17. 把系数转成成数据框后,如何为多分类自变量多增加一行
  18. Coefficients:
  19.              Estimate Std. Error z value Pr(>|z|)   
  20. (Intercept) -3.989979   1.139951  -3.500 0.000465 ***
  21. gre          0.002264   0.001094   2.070 0.038465 *  
  22. gpa          0.804038   0.331819   2.423 0.015388 *  
  23. rank1        0
  24. rank2       -0.675443   0.316490  -2.134 0.032829 *  
  25. rank3       -1.340204   0.345306  -3.881 0.000104 ***
  26. rank4       -1.551464   0.417832  -3.713 0.000205 ***
  27. 谢谢!
复制代码

关键词:Data 如何 gpa gre library foreign

沙发
ntsean 发表于 2013-4-27 10:49:30
x <- rbind(usual.output$coefficients[1:3, ], c(0, rep(NA, 3)), usual.output$coefficients[-(1:3), ])
                rownames(x)[4] <- "rank1"
               
                printCoefmat(x, na.print="")
已有 1 人评分学术水平 热心指数 收起 理由
qoiqpwqr + 1 + 1 热心帮助其他会员

总评分: 学术水平 + 1  热心指数 + 1   查看全部评分

藤椅
dxystata 发表于 2013-4-27 12:17:16
ntsean 发表于 2013-4-27 10:49
x
如果有多个多分类的自变量,如何自动实现呢?

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-31 05:38