Detailed description |
For my specifics needs i try to add a parameter in the seqdef() function.
The goal is to handling in different ways the gaps, based on their durations.
For example, I use seqdef() on low quality data sets that describe for each month if individuals receive an allocation or not. Du to administrative issues and the low quality of data, I don't want to consider gaps of one month or two month like true gaps.
I can deal with this issue by using apply() functions applied on my data in long format, but now i'v to use big data (more than 900 000 rows in long format), and this old method is very too long.
So, I'v modified the TraMineR.trunc() function (and also the seqdef and seqprep functions for taking into account the changes in TraMineR.trunc). I add two parameters:
minimal.gap = a numeric value indicating the minimum numbers of consecutive missing values that can be considered as "true" gap.
regle.pour.faux.gap = "before" or "after", indicating if the falses gap states are re-coded based on the previous non-NA value, or based on the next non-NA value. Other rules can be imagined here.
The core of my modifications are on the TraMineR_trunc_modgap.R file, lines 19 to 48 and lines 64 to 83. I'm not an R expert, and i'm sure that my solution is verbose and not at all optimal. But this work on my datas.
I'm not sure that other TraMineR users can be interested by this issue and my solution. Tell me if you are!
Thank you for your precious functions... |
|