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?