首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用stargazer和coxph - Survival数据出错

使用stargazer和coxph - Survival数据出错
EN

Stack Overflow用户
提问于 2013-02-22 19:09:48
回答 1查看 1.2K关注 0票数 2

当我尝试在coxph (生存)中使用stargazer::stargazer时,我得到了以下错误:

代码语言:javascript
复制
> summary(firm.survcox)
> stargazer(firm.survcox) 
> firm.survcox #only partial results are included for brevity 
Call: coxph(formula = Surv(Duration, Event, type = "right") ~ Innovation + Avg_Wage) 
coef exp(coef) se(coef) z p 
Innovation -0.87680 0.4161 0.008040 -109.051 0.0e+00 
Prior_Experience:Age -0.01297 0.9871 0.004174 -3.107 1.9e-03 
Likelihood ratio test=131885 on 23 df, p=0 n= 535416, 
number of events= 203037 (1060020 observations deleted due to missingness) 

Error in .get.standard.errors.1(object.name, user.given) : 
  subscript out of bounds

模型中的变量是公司、行业和地区级别的变量,并且只有一个交互项。我尝试只在一个变量上运行模型(例如,Innovation),但得到了相同的错误消息。行名为空。

更新的问题和回答:

很抱歉给你带来了混乱。我没有意识到我可以编辑原始问题。下面是运行在一个变量上的模型-创新,产生了相同的错误)。

代码语言:javascript
复制
Call: coxph(formula = Surv(Duration, Event, type = "right") ~ Innovation) 
coef exp(coef) se(coef) z p 
Innovation -0.87680 0.4161 0.008040 -109.051 0.0e+00 
Likelihood ratio test=131885 on 23 df, p=0 n= 535416, 
number of events= 203037 (1060020 observations deleted due to missingness) 

stargazer(firm.survcox)
Error in .get.standard.errors.1(object.name, user.given) : 
  subscript out of bounds

Cox模型的结构

代码语言:javascript
复制
str(firm.survcox)

    List of 18
    $ coefficients     : Named num -0.772
    ..- attr(*, "names")= chr "Innovation"
    $ var              : num [1, 1] 3.91e-05
    $ loglik           : num [1:2] -5583174 -5573640
    $ score            : num 16015
    $ iter             : int 4
    $ linear.predictors: num [1:1595436] 0.0807 0.0807 0.0807 -0.6915 0.0807 ...
    $ residuals        : Named num [1:1595436] 0.925 0.976 -0.516 0.888 0.976 ...
     ..- attr(*, "names")= chr [1:1595436] "1" "2" "3" "4" ...
    $ means            : Named num 0.104
      ..- attr(*, "names")= chr "Innovation"
    $ concordance      : Named num [1:5] 5.20e+10 1.97e+10 3.67e+11 1.14e+10 2.49e+08
    ..- attr(*, "names")= chr [1:5] "concordant" "discordant" "tied.risk" "tied.time"..
   $ method           : chr "efron"
   $ n                : int 1595436
   $ nevent           : num 404033
   $ terms            :Classes 'terms', 'formula' length 3 Surv(Duration, Event, type =  
       "right") ~ Innovation
    .. ..- attr(*, "variables")= language list(Surv(Duration, Event, type = "right"),      
       Innovation)
     .. ..- attr(*, "factors")= int [1:2, 1] 0 1
     .. .. ..- attr(*, "dimnames")=List of 2
     .. .. .. ..$ : chr [1:2] "Surv(Duration, Event, type = \"right\")" "Innovation"
     .. .. .. ..$ : chr "Innovation"
     .. ..- attr(*, "term.labels")= chr "Innovation"
    .. ..- attr(*, "specials")=Dotted pair list of 3

    .. .. ..$ strata : NULL   .. .. ..$ cluster: NULL   .. .. ..$ tt     : NULL   ..-    
    attr(*, "order")= int 1   .. ..- attr(*, "intercept")= int 1   .. ..- attr(*, 
    "response")= int 1   .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv>    .. ..- 

    attr(*, "predvars")= language list(Surv(Duration, Event, type = "right"), 
   Innovation)   .. ..- attr(*, "dataClasses")= Named chr [1:2] "nmatrix.2" "numeric"    
   .. .. ..- attr(*, "names")= chr [1:2] "Surv(Duration, Event, type = \"right\")" 
  "Innovation"  
   $ assign     :List of 1   ..$ Innovation: num 1  
   $ wald.test        : Named num 15249   ..- attr(*, "names")= chr "Innovation"  
   $ y                : Surv [1:1595436, 1:2]  2   1  10+  5   1  10+ 10+  6   8+  8+  
    ...   ..- attr(*, "dimnames")=List of 2   .. ..$ : chr [1:1595436] "1" "2" "3" "4"     
   $ : chr [1:2] "time" "status"   ..- attr(*, "type")= chr "right"  $ formula          
     :Class 'formula' length 3 Surv(Duration, Event, type = "right") ~ Innovation   ..    
   attr(*, ".Environment")=<environment: R_GlobalEnv>   $ call             : language 
   coxph(formula = Surv(Duration, Event, type = "right") ~ Innovation)

    - attr(*, "class")= chr "coxph"
EN

回答 1

Stack Overflow用户

发布于 2013-02-23 01:27:26

在你的评论中张贴的材料(我将其添加到问题中并应用了代码块格式化功能,这是你应该做的)没有真正的意义。列出的"Prior_Experience:Age“和”Surv“系数与调用中的公式"formula = Surv(Duration,Event,type = "right") ~ Innovation + Avg_Wage)”不匹配。在这个过程中,这个物体似乎受到了一些损坏。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15022800

复制
相关文章

相似问题

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