TraMineR (version 2.2-0.1)

seqipos: Proportion of positive spells or states per sequence

Description

Indicators for the underlaying binary sequences of positive and negative states. Possible indicators are the proportion of positive states within each sequence, i.e. of positive spells if computed on the sequences of distinct successive states (DSS), objective volatility of the binary sequences, and capacity to integrate a positive state.

Usage

seqipos(seqdata, dss=NULL, pos.states=NULL, neg.states=NULL, index="share",
     pow=1, w=.5, with.missing=FALSE)

Arguments

seqdata

a state sequence object (stslist) as returned by seqdef.

dss

logical. Should the proportion be computed inside the DSS sequences? Defaults to TRUE when index="share" and to FALSE otherwise.

pos.states

vector of positive states.

neg.states

vector of negative states.

index

character string. One of "share" (proportion of positive states or spells), "volatility" (objective volatility), or "integration" (capacity to integrate a positive state). See Details. Default is "share".

pow

real. Exponent passed to seqintegration. Only used when index="integration". Default is 1.

w

real in range [0,1]. Relative weight of proportion of visited states in volatility (see seqivolatility). Only used when index="volatility". Default is .5.

with.missing

logical: should non-void missing values be treated as a regular state? If FALSE (default) missing values are ignored.

Value

A numeric vector with - when index="share", the proportion of positive states (or spells) within each sequence; - when index="volatility", the objective volatility of the sequences; - when index="integration", the index of integration into a positive state. The binary sequence as an attribute sbinary.

Details

The function transforms the provided state sequences into binary sequence of positive and negative states. When dss = TRUE, the count of positive and negative elements give the number of positive and negative spells. The binary state sequence object is returned as an attribute.

When neg.states=NULL, states not listed on the pos.states argument are considered as negative and conversely when pos.states=NULL. When with.missing=TRUE, the missing state nr will be considered as positive if included in the pos.states list or as negative if in neg.states. When with.missing=FALSE (default) missing states are ignored. However, when missing values appear within a spell, such as in AA*ABB, the DSS sequence will have two consecutive occurrences of the spell. For the example we would have AAB, i.e. if A is positive and B negative, a proportion of 2/3 of positive spells.

When both pos.states and neg.states are provided, states of the alphabet (including the nr code when with.missing=TRUE) that belong nor to pos.states nor to neg.states are ignored.

For index="share", letting \(npos\) be the number of positive states and \(nneg\) the number of negative states in the sequence, the function returns the value of \(npos/(npos + nneg)\) for each sequence. With dss=TRUE, this is the normative volatility of Brzinsky-Fay.

For index="volatility", the function returns the objective volatility of the binary sequences. See seqivolatility.

For index="integration", the function returns the index of integrative potential for the positive state. See seqintegration.

See Also

seqindic

Examples

Run this code
# NOT RUN {
data(ex1)
sx <- seqdef(ex1[,1:13], right="DEL")
nr <- attr(sx,'nr') ## code for missing values

seqipos(sx, pos.states=c("A","B"))
seqipos(sx, pos.states=c("A","B"), with.missing=TRUE)

## ignoring state "D"
seqipos(sx, pos.states=c("A","B"), neg.states=c("C",nr), with.missing=TRUE)

seqipos(sx, pos.states=c("A","B"), dss=FALSE)
seqipos(sx, pos.states=c("A","B",nr), dss=FALSE, with.missing=TRUE)

seqipos(sx, pos.states=c("A","B"), index="volatility")
seqipos(sx, pos.states=c("A","B"), index="integration")

## retrieving the binary sequences
ip <- seqipos(sx, pos.states=c("A","B"))
attr(ip,"sbinary")
ip <- seqipos(sx, pos.states=c("A","B"), with.missing=TRUE)
attr(ip,"sbinary")

# }

Run the code above in your browser using DataCamp Workspace