Specifying Markov data objects
Description
Markovdata creates an object of class md
, to be used
by fitdmm
.
Usage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23  markovdata(dat, itemtypes, nitems = length(itemtypes), ntimes =
length(as.matrix(dat))/nitems, replicates = rep(1,
length(ntimes)), inames = NULL, dname = NULL, xm =
NA)
## S3 method for class 'md'
summary(object, ...)
## S3 method for class 'md'
plot(x, nitems = 1:(min(5, dim(x)[2])),
nind = 1:(min(5,length(attributes(x)$ntimes))),...)
## S3 method for class 'md'
print(x, ...)
dname(object)
ntimes(object)
itemtypes(object)
replicates(object)
ncov(object)
inames(object)
nitems(object)
ind(object)

Arguments
dat 
An R object to be coerced to markovdata, a data frame or matrix. 
itemtypes 
A vector providing the types of measurement with possible values ‘continuous’, ‘categorical’, and ‘covariate’. This is mainly only used to rearrange the data when there are covariates in such a way that the covariate is in the last column. Only one covariate is supported in estimation of models. 
ntimes 
The number of repeated measurements, ie the length of the time series (this may be a vector containing the lengths of independent realiazations). It defaults the number of rows of the data frame or data matrix. 
replicates 
Using this argument case weights can be provided.
This is particularly usefull in eg latent class analysis with
categorical variables when there usually are huge numbers of
replicates, ie identical response patterns. 
inames 
The names of items. These default to the column names of matrices or dataframes. 
dname 
The name of the dataset, used in summary, print and plot functions. 
xm 

object,x 
An object of class 
... 
Further arguments passed on to plot and summary. 
nitems,nind 
In the plot function, these arguments control which data are to be plotted, ie nitems indicates a range of items, and nind a range of realizations, respectively. 
Details
The function markovdata
coerces a given data frame or matrix to be
an object of class md
such that it can be used in
fitdmm
. The md
object has its own summary,
print and plot methods.
The functions dname, itemtypes, ntimes, and replicates retrieve the
respective attributes with these names; similarly ncov, nitems,
inames
, and ind
retrieve the number of covariates, the number of
items (the number of columns of the data), the column names and the number
of ind
ependent realizations respectively.
Value
An md
object is a
matrix of dimensions sum(ntimes) by nitems, containing the
measured variables and covariates rearranged such that the
covariate appears in the last column. The column names are
inames
and the matrix has three further attributes:
dname 
The name of the data set. 
itemtypes 
See above. 
ntimes 
See above. This will be a vector computed as ntimes=rep(ntimes,nreal). 
replicates 
The number of replications of each case, used as weigths in computing the log likelihood. 
Author(s)
Ingmar Visser i.visser@uva.nl
See Also
dmm
, depmix
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16  x=rnorm(100,10,2)
y=ifelse(runif(100)<0.5,0,1)
z=matrix(c(x,y),100,2)
md=markovdata(z,itemtypes=c("cont","cat"))
summary(md)
data(speed)
summary(speed)
plot(speed,nind=2)
# split the data into three data sets
# (to perform multi group analysis)
r1=markovdata(dat=speed[1:168,],item=itemtypes(speed))
r2=markovdata(dat=speed[169:302,],item=itemtypes(speed))
r3=markovdata(dat=speed[303:439,],item=itemtypes(speed))
summary(r2)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker. Vote for new features on Trello.