Does seqistatd command calculate the standard error of time spent in each state?

StackOverflow https://stackoverflow.com/questions/17195153

  •  01-06-2022
  •  | 
  •  

Domanda

I'm using the R packages TraMineR to compute and analyze the event state sequences. My alphabet consists of 7 states. I used the seqistatd command to calculare the mean time spent in each state for a number of subpopulation I'm interest in (for example women with different educational level). However, I would like to add the information about the standard error or the standard deviation of the mean time spent in each state. Is it possible to do that within the seqistatd line command or do I have to compute somehow the estimation on my own? Thank you.

È stato utile?

Soluzione

No, the function seqistatd does return the time in each state for each individual sequence. It is easy however to compute the mean time and variance by groups with the apply function. I illustrate below with an example using the biofamdata provided by TraMineR.

library(TraMineR)
data(biofam)
bf.seq <- seqdef(biofam[,10:25])

bf.ldist <- seqistatd(bf.seq)
sel <- (biofam$sex == "man")

## Mean and variance of time in each state for men
(meant <- apply(bf.ldist[sel,], 2, mean, na.rm=TRUE))
(vart <- apply(bf.ldist[sel,], 2, var, na.rm=TRUE))
## and for women
(meant <- apply(bf.ldist[!sel,], 2, mean, na.rm=TRUE))
(vart <- apply(bf.ldist[!sel,], 2, var, na.rm=TRUE))
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top