# How does the TraMiner Package Calculate Standard Error Using Weighted Data?

The TraMiner Package includes an option to include sampling weights in the analysis. However, I haven't found any discussion in the package documentation (or associated user manual) of how standard errors are calculated in the presence of sampling weights - such as the calculation of the standard error of the mean for the number of times that a state appears in each sequence.

I assume that some version of the Horvitz-Thompson variance estimator is used, assuming non-uniform first-order inclusion probabilities in a non-stratified, non-clustered probabilistic sample. However, I would like to know what assumptions are made about second-order inclusion probabilities - in practice, are finite population corrections introduced (e.g. treating the finite population size as the sum of the weights) or not?

Apologies if this is documented somewhere that I haven't found. If TraMiner's SE calculations rely on some other package's facilities I would be happy to be directed to those so that I can consult their documentation. Thank you in advance for any assistance with this.

When sequence weights are provided, all outcome of TraMineR account for those weights. This means that all means, proportions, and other statistics are obtained by weighting the importance of each sequence. This is also true for the standard deviations of the mean time spent in the different state from which the standard errors (SE) are derived.
TraMineR computes the standard deviation $$s$$ of the times $$t_i$$ spent in a state $$j$$ as the square root of
$$s^2 = \frac{V_1}{V_1^2 - V_2} \sum_i w_i (t_i - \bar t)^2$$
where $$\bar t$$ is the weighted mean, $$V_1$$ the sum of the weights $$w_i$$, and $$V_2$$ the sum of the squared weights. The standard error of the weighted mean is
$$SE = \sqrt{s^2/V_1}$$