% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/MCseqReplicate.R
\name{MCseqReplicate}
\alias{MCseqReplicate}
\title{Generate R altered sequence data sets.}
\usage{
MCseqReplicate(
  seqdata,
  J = 1,
  R = 20,
  silent = FALSE,
  unique = FALSE,
  model = "keep.dss",
  jfixed = FALSE,
  kchanges = NULL,
  include.obs = FALSE
)
}
\arguments{
\item{seqdata}{A state sequence \code{stslist} object as generated by \code{\link[TraMineR]{seqdef}}.}

\item{J}{Integer or vector of positive numbers. If an integer, maximal timing error (number of unit periods around first state of new spell. Default is \code{J=1}. If a vector, weights of the timing errors \code{k = -K, -(K-1), ..., K-1, K}, where \code{2K + 1} is the length of \code{J}. The vector length must be odd.}

\item{R}{Integer. Number of random replicated sequence data. Default is \code{R=10}. The weights are internally normalized to sum to 1.}

\item{silent}{Logical. Should waiting and timing messages be hidden?}

\item{unique}{Logical. Should only unique sequences be replicated? Default is \code{FALSE}. If \code{TRUE} weights will reflect the multiple occurrences of each original unique sequence.}

\item{model}{String. Time alteration model. One of \code{"keep.dss"} (default), \code{"indep"} (suppress spells erased by move of transition), and \code{"relative"} (keep time until next transitions unchanged).}

\item{jfixed}{Logical. Should same error j be applied to all transitions in a sequence? Default is \code{FALSE}.}

\item{kchanges}{Integer, string, or \code{NULL}. If integer, number of transitions whose time can potentially be altered in each sequence. If \code{"rand"}, the number of potential changes is randomly selected for each sequence. If \code{NULL} (default), all transitions can potentially be altered.}

\item{include.obs}{logical. Should the observed sequence data be added as last element.}
}
\value{
List of R altered \code{stslist} objects plus observed sequence object as last element when \code{include.obs=TRUE}.
}
\description{
R \code{stslist} state sequence objects are generated by applying the chosen timing error model to the provided state sequence object.
}
\details{
This function is handy for testing how outcome of a sequence analysis may vary with timing errors in the reported sequences.

Use the vector form of \code{J} to specify the probability distribution of the timing error. See function \code{\link{MCpj}} to generate a probability vector that complies with expected mean timing errors.
}
\examples{
## mini test data, 6 sequences of length 4, 4 unique sequences
exdata <- read.table(text="
                a a b b
                a a b b
                b b a a
                a c c b
                b b a c
                b b a c
                ")
weights=rep(1, nrow(exdata))
s.exdata <- seqdef(exdata, weights = weights, id=paste("id",1:nrow(exdata), sep=""))

## 3 altered sequence datasets
(altseq.list <- MCseqReplicate(s.exdata, J=1, R=3))

## list of dissimilarity matrices
suppressMessages(dist.list <- lapply(altseq.list, seqdist, method="LCS", full.matrix=FALSE))
dist.list

## Can also be obtained with MCdisslist, which offers option use.udiss;
## use.udiss=TRUE is faster when number of unique merged replicated
## sequences is less than n*sqrt(R).
suppressMessages(dist.list <- MCdisslist(altseq.list, method="LCS", use.udiss=TRUE))

## Replication based on expected left and right non-zero errors of 1.1
##  and assuming a 0.5 probability of no error
Pj <- MCpj(Emean=1.1, pzero=.5)
(altseq2.list <- MCseqReplicate(s.exdata, J=Pj, R=3))
}
\references{
Ritschard, G. and Liao, T.F. (2026). Assessing the Impact of Timing Errors in Sequence Analysis. \emph{International Journal of Social Research Methodology}. Forthcoming
}
\seealso{
\code{\link{MCpj}}
}
\author{
Gilbert Ritschard
}
