3

I am still new to TraMineR; therefore, my problem might be very simple for most of you. I am working on some sequence plots with my data and would like to see the results with the survey weights and nominal weights. I am able to import data into R and run sequence plots with the data as is, but am unable to run it with weights. I have included my syntax on how I created the state sequence objects (pretty naïve) and a two sequence plot examples. How do I write syntax to use weights? Thanks

Data file: DISDATAC; Survey weights: WTSURVY; Nominal weights: NORMWEIGHTS

DISDATAC<-read.spss("/Users/tac0432/Desktop/DISDATAC.sav",to.data.frame=TRUE,use.value.labels=TRUE,)
DISDATAC.shortlab <- c("2yr", "4yr", "Gov","Bus","UeL")
DISDATAC.lab <- c("2year college or Other School System", " 4year college or Medical Institution", " Government","Business/Industry","Unemployed or Not in the labor force")
DISDATAC.seq <- seqdef(DISDATAC, 09:12, states = DISDATAC.shortlab, labels = DISDATAC.lab)
DISDATAC.seq[1:20, 1:4] ; print(DISDATAC.seq[1:20, ], format = "SPS"); alphabet(DISDATAC.seq)
stlab(DISDATAC.seq)

Sequence Plot Syntax examples
seqIplot(DISDATAW.seq, border = NA, group = DISDATAW$NMRMEMG, sortv = "from.start")
seqIplot(DISDATAW.seq, border = NA, group = DISDATAW$GENDER:DISDATAW$NMRMEMG, sortv = "from.start")

1 Answer 1

3

Hard to be certain without a sample of your data to play with, but it looks like you need to provide a column of weights in the seqdef function. If you do that, the TraMineR plotting functions account for the weights by default.

If you follow the help for seqIplot, you can get to the help page that discusses weights. Here's the key section from the help for seqIplot:

If weights have been specified when creating seqdata, weighted frequencies will be returned by seqtab since the default option is weighted=TRUE. See examples below, the seqtab and plot.stslist.freq manual pages for a complete list of optional arguments and Müller et al., (2008) for a description of sequence frequency plots.

So we need to look at the function seqdef, which creates the seqdata object for plotting. The help for seqdef describes the weights argument:

weights optional numerical vector containing weights, which are accounted for by plotting and statistical functions when applicable.

The help also has an example of how to specify the weights in seqdef.

Not the answer you're looking for? Browse other questions tagged or ask your own question.