Probabilistic models applied in survival analysis I am trying to fit some probabilistic models for a survival analysis, that is, considering a parametric approach (I tried to fit the cox regression model, but the proportional hazards assumption was violated).
My problem consists in analyzing the time until response to a certain information requested by an individual as a function of a variable that defines the means by which such information was requested, where I have the following variables:
Dados: https://drive.google.com/file/d/1b6g4kxNoBMOLHNGyhG2Ylx-PprKFP4wF/view?usp=sharing

*

*Data_Registro: It informs the date that the requester requested the information;

*Data_Limite: It informs the maximum date that the responsible body needs to answer the requester;

*Data_Resposta: It informs the date that the requester got the answer;

*Origem_Solicitação: A qualitative variable indicating the means of requesting the information;

*Tipo_Resposta: Informs the type of answer that the requester obtained, where the blank space " " indicates that the answer has not yet been answered, that is, it is in process (however, this blank field has been replaced by the date (09/07/2021) (d/m/y), as this is the date that the data was downloaded from the public information site.).

With this information, I initially had the following question.
How could I define the variable that will determine the censorship? I initially thought of using as a basis the Tipo_Resposta variable , All the information that obtained answers would be = 1 and those that are still in process, that is, the " ", would be = 0. However, with the Data_Registro, Data_Limite and Data_Resposta variables  could some other kind of censorship be defined? Perhaps more coherent? Since the Data_Limite variable informs the maximum date that the responsible body needs to answer the requester, however, it is observed that many requested information allow a longer time than the recommended one.
Based on what was said before, I followed the modeling, that is, I considered the variable Status that will define censorship as: all the information that obtained answers would be = 1 and the ones that are still in process, that is, the " ", would be = 0.
When analyzing the graph of the survival curves, the following behavior is noted:

As such, I have initiated the modeling process under the parametric approach, where the following models are being considered:
library(flexsurv)
# exponencial
fit_exp <- flexsurvreg(Surv(TempoDias, Status) ~ Origem_Solicitacao, dist='exponential', data = dados)
fit_exp

# lognorm
fit_log <- flexsurvreg(Surv(TempoDias, Status) ~ Origem_Solicitacao, dist='lognorm', data = dados)
fit_log

# weibull
fit_wei <- flexsurvreg(Surv(TempoDias, Status) ~ Origem_Solicitacao, dist='weibull', data = dados)
fit_wei

# modelo gama
fit_gamma <- flexsurvreg(Surv(TempoDias, Status) ~ Origem_Solicitacao, dist = 'gamma', data = dados)
fit_gamma

# modelo generalizado (gama generalizada)
fit_gammagen <- flexsurvreg(Surv(TempoDias, Status) ~ Origem_Solicitacao, dist = 'gengamma', data = dados)
fit_gammagen


However, I am encountering the following error:
Error in (function (formula, data, weights, subset, na.action, dist = "weibull",  : 
  Invalid survival times for this distribution

In order to try to solve this, I tried to modify the statements of the Origem_Solicitação variable,  storing them in a new variable called Origem_Solicitação3, which were regrouped in Presential and Non-Presential (although I don't think it would be important to me that such a modification be made, since there are levels within Origem_Solicitação which are fundamental for this application, but I see that there are few observations in most of them and if such a modification is necessary, I agree). Having done this, I performed the survival curves again:

And I tried resetting the above templates, however, the error still persists. Is the error due to some misspecification in the models considered? The censoring that was set wrong? Lack of observations in the levels? Any plausible explanation or suggestion of what could be done?


initially thought of using as a basis the Tipo_Resposta variable , All the information that obtained answers would be = 1 and those that are still in process, that is, the " ", would be = 0.

If you only know that the time to get an answer is at least as long as you have data for, you indicate that time as right censored (often 0 in R). That seems consistent with what you did.
This sounds, however, like you have different types of responses that might best be handled as different event types. If that's the case, then (in R, at least) instead of 0/1 censored/event coding you should use a categorical event marker with "censored" as the reference level. It sounds like only one type of response will occur in response to any request, so this would be a fairly straightforward competing risks model.

with the Data_Registro, Data_Limite and Data_Resposta variables could some other kind of censorship be defined?

Censoring should be defined as above, for cases in which you only have a lower limit for the time between request and response. Presumably, Tempo = Data_Resposta - Data_Registro, where for censored cases Data_Resposta is the data download date (09/07/2021).
Data_Limite, might be handled as a predictor variable in your model. If I understand correctly, Data_Limite is the date some legally mandated number of days after Data_Registro (even if the "mandate" often isn't met). If I were a public servant with one answer expected in 3 days and another in 30, I suspect that I would attend to the former before I got around to the latter and that I would put off responding to the latter if another request with a 3-day expectation soon came in. So that mandated date difference would probably be an important predictor.

Is the error due to some misspecification in the models considered? The censoring that was set wrong? Lack of observations in the levels? Any plausible explanation or suggestion of what could be done?

It looks like some of your Tempo values equal 0. If that's the case, such data will probably not work with a parametric model.* A work-around is to add a small positive Tempo value to those 0 values. Having small numbers of events doesn't help but that usually ends up with warnings about convergence or large errors in coefficient estimates rather a refusal to undertake the analysis that you report. Make sure that censoring is specified in the way I indicated at the beginning. There might also be problems with having no cases in the Presencial group after 25 days; check that by limiting analysis to cases with event/censoring times no longer than that.

I am trying to fit some probabilistic models for a survival analysis, that is, considering a parametric approach (I tried to fit the cox regression model, but the proportional hazards assumption was violated).

I don't think that a parametric model, at least of these types, will solve your problem. The long plateau in the green curve in your last display suggests that you have a type of "cure" model in which some cases never experience the "event." These accelerated failure time models can be thought of as covariates compressing or expanding the time axis, while I can't see any way that you could compress the time axis for the green curve to match the blue curve in that last display. Furthermore, the exponential and Weibull models expect proportional hazards, so if a Cox model failed a proportional hazards test they wouldn't be expected to work well, either.
A simple Kaplan-Meier analysis would certainly document the significance of the difference between those last two survival curves, and I see the plateau in the green curve as being a potentially important substantive finding.

*Whether it should be allowed to work for a Cox model is questionable, although I vaguely remember some years ago having some 0 values for event times that coxph() didn't complain about.
