[#6612] Add a parameter to erase short gaps

2019-01-31 15:07
Submitted by:
Elie Chosson (elichos)
Assigned to:
Gilbert Ritschard (gritschard)
Add a parameter to erase short gaps

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: = a numeric value indicating the minimum numbers of consecutive missing values that can be considered as "true" 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...


Message  ↓
Date: 2019-02-04 16:46
Sender: Gilbert Ritschard

Thank you for your proposition.
We will test it before possibly incorporate it in the development version of TraMineR.


Date: 2019-02-01 08:24
Sender: Elie Chosson

I'v updated my previous version for taking into account the trajectories with no gaps state ( length(mm) ==0 ).
I upload a new file with the modifications.

Attached Files:

Size Name Date By Download
3 KiBTraMineR._trunc_modif_for_gap.R2019-01-31 15:07elichosTraMineR._trunc_modif_for_gap.R
8 KiBseqdef_modgap.R2019-01-31 15:07elichosseqdef_modgap.R
1 KiBseqprep_modgap.R2019-01-31 15:07elichosseqprep_modgap.R
3 KiBTraMineR_trunc_modif_for_gap.R2019-02-01 08:24elichosTraMineR_trunc_modif_for_gap.R


Field Old Value Date By
assigned_tonone2019-02-04 16:46gritschard
File Added5176: TraMineR_trunc_modif_for_gap.R2019-02-01 08:24elichos
File Added5174: seqdef_modgap.R2019-01-31 15:07elichos
File Added5175: seqprep_modgap.R2019-01-31 15:07elichos
File Added5173: TraMineR._trunc_modif_for_gap.R2019-01-31 15:07elichos
Thanks to:
Vienna University of Economics and Business Powered By FusionForge