简体   繁体   English

使用观星仪和Coxph时出错-生存数据

[英]Error using stargazer and coxph - Survival Data

I get the following error when trying to use stargazer::stargazer with the coxph (Survival): 尝试将stargazer::stargazer与coxph(Survival)结合使用时出现以下错误:

> 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

Variables in the model are firm-, industry-, and region-level, and there is one interaction term. 模型中的变量是公司,行业和区域级别的,并且存在一个交互项。 I try running the model on only one variable (Eg Innovation), and I get the same error message. 我尝试仅在一个变量上运行模型(例如Innovation),并且得到相同的错误消息。 Rownames are NULL. 行名为NULL。

Updated Question and Response: 更新的问题和答案:

Sorry about the confusion. 对不起,我很困惑。 I did not realize I could edit the original question. 我没有意识到我可以编辑原始问题。 Below is the model run on one variable - innovation, with the same error produced). 以下是在一个变量(创新)上运行的模型,并产生了相同的错误)。

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

Structure of the Cox Model Cox模型的结构

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"

The material posted in your comment (which I added to the question and applied the code block formatting function as you should have done) doesn't really make sense. 发表在您的评论中的材料(我已经将其添加到问题中,并且按照您应该做的那样应用了代码块格式化功能)实际上没有任何意义。 The coefficients listed "Innovation" and "Prior_Experience:Age" do not match the formula in the call: "formula = Surv(Duration, Event, type = "right") ~ Innovation + Avg_Wage)". 列出的系数“ Innovation”和“ Prior_Experience:Age”与调用中的公式不匹配:“公式= Surv(持续时间,事件,类型=“正确”)〜Innovation + Avg_Wage)”。 There seems to have been some mangling of the object along the way. 在此过程中似乎对对象进行了一些处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 coxph() 中的“termlabels”错误 function 生存 package - 'termlabels' error in coxph() function of survival package 在 R 中使用 coxph(生存包)对分层变量进行模型诊断时出错 - Error when model diagnostics on stratified variable with coxph (survival package) in R survfit.coxph ; 使用 newdata 和 ID 选项预测生存 - survfit.coxph ; Predicting Survival using newdata and ID option 使用 CoxPH 预测和绘制生存曲线 - Predicting and Plotting Survival Curve with the CoxPH 使用Ze1e1d3d40573127E9EE0480CAF1283D6Z ZEFE90A8E604A7C88D03A67F67F6B78ZB78Z'SERVIVAL of ZE1E1E1E1D3D40127E9E9E9E9EE9E9EENEENEENENENENES FELS.COXPH' - Using 'predict.coxph' from the R package 'survival' in own R package 使用stargazer获取lfe并获得错误 - Using stargazer for lfe and getting error R生存分析coxph调用多列 - R survival analysis coxph call multiple column 在生存分析中计算AIC(survfit / coxph) - Compute AIC in Survival Analysis (survfit/coxph) 使用&#39;生存&#39;包中的&#39;tmerge&#39;为生存数据添加时变协变量 - Adding time varying covariates to survival data using 'tmerge' in 'survival' package 使用pryr或其他tidyverse工具修复surviving()环境“ is.data.frame中的错误”错误 - Fix survival() environment “Error in is.data.frame” error using pryr or other tidyverse tools
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM