Why are the results of `turbn` and `turb2n` `NaN` in TraMineR `seqindic` function for every single sequence of the data?

47 Views Asked by At

I am using TraMineR package to analyze sequence data. I have a large dataset of sequences, and I am trying to calculate the normalized turbulence using the seqindic() function in TraMineR.

However, when I run seqindic() on my data, the results of both turbn and turb2n are NaN for every single sequence in the data.

Can anyone suggest what might be causing this issue and how to fix it? I would greatly appreciate any help or suggestions. Thank you.

It's worth noting that the results of the function on several other indicators, including the standard deviations, were correctly calculated. So, how does it happen that normalized turbulence produces NaN values?

1

There are 1 best solutions below

3
Gilbert On

The example you provide in the comment works fine. In the script below, we first transform the sequence data given in SPS format into STS format, then create the state sequence object using the alphabet argument to provide the full alphabet because only 5 of the 25 tokens of the alphabet occur in the sequence.

library(TraMineR)
alph <- c(0, 4, 16, 20, 32, 48, 52, 
          60, 84, 92, 116, 124, 126, 
          127, 252, 254, 255, 276, 348, 
          380, 476, 508, 509, 510, 511)
data.sps <-  "(126,27)-(124,16)-(60,30)-(52,17)-(0,73)"
data.sts <- seqformat(data.sps, from="SPS", to="STS")
s <- seqdef(data.sts, alphabet=alph)
seqindic(s, indic=c("turb", "turb2", "turbn", "turb2n"))

#         Turb      Turbn    Turb2     Turb2n
# [1] 8.186515 0.04436121 6.750483 0.03546431

Edit

However, when the number of susbsequences of the DSS exceeds the greatest double value allowed on your system (.Machine$double.xmax), the maximum possible value of the turbulence cannot be computed and, as a result, the normalization cannot be applied.