I've tried to make a short summary of what I'm trying to do but it wasn't clear at all, so sorry for the length of the post.
I'm currently trying to study the length of sick leaves in administrations and so i have a database where have been put the lengths, dates, and other infos for thousands of leaves.
I'm a complete beginner in that type of analysis. First of all, I'm studying the percentage of sick days that happens beyond the x-th day of a sick leave*. I've used the survival analysis package (survival) to simplify my work but this package is focused specifically on survival analysis and the ratio that i study isn't the survival ratio. So i'm looking for a package or a method that could help with what i'm actually looking at.
*The actual ratio that I'm studying is the number of sick leave's days that happened after the x-th day divided by the total number of sick leave's days. (For instance if i have 3 leaves that are 2, 8 and 10 days long : the ratio for day 5 is (3+5)/(2+8+10)=0,4)
The data that i have is a dataframe where in each line I have a single sick leave with pretty much any information that could be useful in a statistical analysis BUT I'm not supposed to use every piece of information. I'm supposed to study this in order to help for the pricing of contracts and the only variables that are communicated to them (and therefore are relevant in my work) are :
-the type of contract (there are two types : I(mostly part-time workers) or C(full-time)),
-the type of sick leaves (3 types : Ordinary(short <1 year), Rare(<3 year), very Life threatening(<5years))
-I also have the amount of deductible days in the contract of the person who had a sick day (to know wheter or not deductible days induce a bias)
-A few other things (I'll go into details if it is necessary)
-Also my data was censored so I have a column with 0s for censored data and 1s for data that isn't.
The only thing that has been taken into account for the censoring is this : the last time the dataframe has been updated was the 31/12/2013 any sick leaves that was still going on at that time has been considered censored. To be more accurate, what I have is the date on the medical report that allowed the sick leave so for instance I can have a sick leave where the end date is 25/02/2014 but it is not the actual end of the sick leave cause afterward it might have been extended so I put it has been censored at the 25/02/2014.
First of all in order to correct censoring I used the survival package like so :
s <- Surv(time2013,event2013) fKM <- survfit(s ~ 1,data=mydata) res <- summary( fKM)
Afterwards I only considered the results that were given to me by the survival model.
What I've been asked to do was to determine what variable had enough influence. (I haven't been told what enough actually was so what I did so far, was to say if, for instance, when I compare sick leaves where the work contract was : I(part-time) with C(full-time), if I have more than ~4-5% of difference in my ratios then the variable had an influence and so I divided the population in two categories that i studied separately.)
The problem I have now is to find a statistical way to tell if a variable has enough influence, so I have the following plot (the two types of contract) I've said that there was enough difference so that when pricing the contracts they should price their insurance differently for each type of contract. Red is I(part time), Black is C(full time) the plot tells me that full-time workers have slightly longer ordinary(<1 year) leaves.
What i would like to do now is find a way(most likely with an algorithm or another package) to measure the difference between those two plots. In order, to be able for instance to compare this difference with the difference there is in rare leaves(<3 years). So that I can know if a difference is significant by comparing it to the other differences.
If you think another approach would be more useful I have no problem with this, comparing the differences was just what seemed the most intuitive analysis to me.
Considering the Cox model, unless I'm making an error, I don't think (I might be wrong) that it is working in my situation because of the results that I get.
For instance I have two situations ; the first one here is the plot of the ratio I'm studying (not the ratio that the cox model is using, I didn't want to put too many images the post is already too long) for a population that is divided in 2 groups (Red is full-time workers and Black is part-time workers). I apply "coxph" I get a coefficient for the type of contract of 0.223 which is interpreted, if I understood correctly, as : "full-time workers have longer sick leaves", which we don't really see on the plot of the percentages of days beyond the x-th day :
But on another situation where I have this plot :
When I use "coxph" I get a coefficient of 0.2175 which is basically, giving me the same conlusion. But intuitively i would have said that in the first situation the differences were insignificant and in the second they were meaningful. That's why I haven't used "coxph". Maybe you can find an issue in the code that i used :
mydata_MO$SI_DUREE_ARR is the length of the sick leaves;
mydata_MO$NON_CENSURE is 0 for censored data and 1 for not censored data;
IND_AG_CONTRAT is 1 for full-time, 0 for part-time
timeMO<-mydata_MO$SI_DUREE_ARR eventMO<-mydata_MO$NON_CENSURE coxph.fit <- coxph(Surv(timeMO,eventMO) ~ IND_AG_CONTRAT, data=mydata_MO) summary(coxph.fit)
Sadly, I can not share the data, but what i believe is the issue is that both cases are very similar except that there are a few extremely long leaves in the second case that are not in the first situation which is why there is such a big difference on the graphs.