2

I'm stumped here and hoping that someone can help me out.

I'm running a crude Cox PH model for a dichotomous predictor ("base_factor") and time of death. The modelruns without errors and the results can be displayed with summary(), as well as knitted to html in rmd.

factor_cox <- coxph(Surv(time, dead) ~ base_factor, data=t0)
tab_model(factor_cox) 

However, when attempting to use sjPlot::tab_model to create a results table, I keep getting the error:

"Error in data.frame(..., stringsAsFactors = FALSE) : arguments imply differing number of rows: 0, 1"

This error does not appear in tab_model for adjusted models for the same survival object and predictor with added covariates, just for this crude model.

I'd like to use sjPlot for this, but unless I can figure this out I'll have to use another function for my table (stargazer, for example, works fine).

thelatemail
  • 91,185
  • 12
  • 128
  • 188
  • 1
    Without being able to see the data, it looks like the code is trying to create a `data.frame` with an object that is missing. E.g., `data.frame(a=NULL,b=1)` gives the same error. Can you double check that you are referencing the correct variable names in your `coxph` line? – thelatemail Jan 30 '20 at 21:54
  • I am certain that I am referencing the correct data. What makes this frustrating is that the model results from the same code can be displayed with no problem using summary(), coef(), or packages like stargazer. Not sure why this issue is occurring specifically with tab_model and why it does not occur when I run an adjusted model like: ``` factor_cox <- coxph(Surv(time, dead) ~ base_factor + covar, data=t0) ``` – West_End_Line Jan 30 '20 at 21:59
  • Can you step through the debugger to find the exact line where it breaks? That might help you pinpoint the problem. E.g. `debugonce(tab_model)` then run `tab_model(factor_cox)` and go line by line until it falls over. – thelatemail Jan 30 '20 at 22:11
  • 1
    Are there any missing values in the data? If so, adding , `na.action="na.exclude"` into `coxph()` might solve the problem. – dcarlson Jan 30 '20 at 22:18
  • @dcarlson, this is what I was thinking initially. There are no NA's in the data, however, and even adding na.action="na.exclude" to coxph() just to be certain makes no difference – West_End_Line Jan 30 '20 at 22:25
  • @latemail, thanks I went through the debugger. It breaks on a big line of code from lines 103 - 348. – West_End_Line Jan 30 '20 at 22:26
  • Do you have a reproducible example? sjPlot uses [`parameters::model_parameters()`](https://easystats.github.io/parameters/reference/model_parameters.html) to extract the coefficients etc., and this function in turn calls `standard_error()`, `ci()`, `p_value()` (from _parameters_) and `get_parameters()` and `get_statistic()` (from _insight_). I think one of these functions does not work properly with your model. A reprex would help me debugging this issue - you could also file an issue here: https://github.com/easystats/parameters/issues – Daniel Feb 01 '20 at 11:07
  • @Daniel @West_End_Line Did anyone find a solution to this issue? I'm having the same issue now running the `lmer` package to create a mixed model. – Ben Apr 28 '20 at 18:32
  • I'm not sure, I can't do much without a reproducible example that helps me tracking down the error. You may file an issue here: https://github.com/strengejacke/sjPlot/issues – Daniel Apr 29 '20 at 12:18

0 Answers0