Last chance! 50% off unlimited learning
Sale ends in
A common class for representing data. No matter the actual representation of data, the important characteristics are contained in a graphical metadata object.
newgmData(varNames,
varTypes=rep(validVarTypes()[1],length(varNames)),
nLevels=NULL,
latent=NULL,
valueLabels=NULL,
observations=NULL,
description=NULL,
shortNames=NULL
)
An object of class gmData
holds information about the data
and can be retrieved and changed by accessor functions.
Objects can be created by calls of the form
newgmData(
varNames, varTypes, nLevels, latent, valueLabels,
observations, description)
.
More often, gmData objects will be created from a data.frame or table.
A gmData
object contains the abstraction of data into a
meta data object including variable names and types etc. However, the
actual data might not be present or may be represented by a reference
to data, such as a database file. Also, it may be possible to work
without data, which may be valuable if the point of interest is in the
model alone. Separating the specification of the
variables from data has the benefit, that some properties of a model can be
investigated without any reference to data, for example
decomposability and collapsibility.
a vector of strings with names of variables.
a vector of strings with values from
validVarTypes
giving the types of the variables;
typical types are "Discrete","Ordinal","Continuous", but others can
be defined. The types can be abbreviated.
a numeric vector with integer values for discrete or ordinal variables giving the number of levels.
a vector of strings with names of the latent variables.
a list of vectors of strings with names of the levels for each discrete or ordinal variable.
an object containing the observations, eg. a dataframe or a table.
a string describing the origin of the data.
a vector of strings giving a short name of each variable.
Søren Højsgaard, sorenh@math.aau.dk,
Claus Dethlefsen, dethlef@math.aau.dk
If neither nLevels nor valueLabels are given, then all categorical variables are assumed to be binary. If valueLabels are given then nLevels are infered from these. valueLabels / nLevels are recycled if necessary.
demo(gmData)
vn <- c("a","b","c","d")
z<-newgmData(vn,varTypes=c("dis","dis","con","con"))
summary(z)
z<-newgmData(vn,varTypes=c("dis","dis","con","con"),nLevels=c(4,3,NA,NA))
summary(z)
z<-newgmData(vn,varTypes=c("dis","dis","con","con"),nLevels=c(4,NA,NA,NA))
summary(z)
z<-newgmData(vn,varTypes=c("dis","dis","ord","con"),valueLabels=list("a"=1:2, "b"=1:4))
summary(z)
ccnames <- c("asia", "smoke", "tub", "lung", "bronc", "either", "xray", "dysp")
gmd <- newgmData(ccnames,valueLabels=c("yes","no"), description="Chest clinic")
summary(gmd)
data(mathmark)
as.gmData(mathmark)
data(HairEyeColor)
as.gmData(HairEyeColor)
Run the code above in your browser using DataLab