尝试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
模型中的变量是企业级、行业级和区域级的,并且存在一个交互项。我尝试仅在一个变量(例如创新)上运行模型,我得到相同的错误消息。行名为 NULL。
更新的问题和响应:
很抱歉造成混乱。我没有意识到我可以编辑原始问题。下面是在一个变量上运行的模型 - 创新,产生了相同的错误)。
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 模型的结构
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"