TraMineR Using Weights
I am still new to TraMineR
; so 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 results with poll weights and nominal weights. I can import data into R and run sequence plots with the data as is, but I cannot run it with weights. I've included my syntax on how I created state sequence objects (pretty naive) and two sequence examples. How do I write the syntax for using weights? Thanks to
Data file DISDATAC
; Survey scales: 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")
source to share
It's hard to be sure without a sample of your data to reproduce, but it looks like you need to provide a column weights
in a function seqdef
. If you do this, the construction functions TraMineR
respect the default weight.
If you do help for seqIplot
, you can go to the help page, which discusses weights. Here's the key section from the help for seqIplot
:
If the weights were specified at creation
seqdata
, the weighted frequencies will be returned toseqtab
as the default is the optionweighted=TRUE
. See Examples belowseqtab
and theplot.stslist.freq
man 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
that creates an object seqdata
for plotting. Help for seqdef
describes the argument weights
:
weights
an optional numeric vector containing weights to be considered for plotting and statistical functions, when applicable.
The help also has an example of how to enter weights in seqdef
.
source to share