mimR-ReadingData {mimR}R Documentation

Creation of gmData objects

Description

Different methods for creation of gmData objects. Depending on taste gmData can be taken as meaning 'graphical model data' or 'graphical meta data'

Usage

gmData(name, letter = NULL, factor = rep(FALSE,
length(name)), vallabels=NULL, data=NULL)
as.gmData (data, letter=NULL)
description(x)
"description<-"(tmp, value)
latent(x)
"latent<-"(tmp, value)
vallabels(x)
"vallabels<-"(tmp, value)
observations(x)
"observations<-"(tmp, value)

Arguments

name ~~Describe name here~~
factor ~~Describe factor here~~
data a dataframe
letter A specification of letters which can subsequently be used as short hand for the variable names
x A gmData object
tmp A gmData object
value The value to entered into the object
vallabels A list containing labels of the levels of the discrete variables (not currently used)

Details

as.mimData is just a wrapper for as.gmData (kept in the package for historical reasons). as.mimData only works for data frames.

Value

A dataframe containing the link between the names in the dataframe and the names (and labels) and the coding of factors in MIM

WARNING

If only a subset of a dataframe is used, then it may be necessary to recode the levels of factors in the dataframe. Otherwise one can end up with slices of the table in MIM with no observations in it. The easiest way to recode the levels is to use the function 'factor()', see examples below.

Note

Before using mimR, make sure that the MIM program is runnning.

Author(s)

Søren Højsgaard, sorenh@agrsci.dk

References

David Edwards, An Introduction to Graphical Modelling, Second Edition, Springer Verlag, 2000

See Also

mim.cmd

Examples

# A meta data object (without data)
gmd.rats.nodata  <-  gmData(c("Sex","Drug","W1","W2"),
    factor=c(2,3,FALSE,FALSE),
    vallabels=list("Sex"=c("M","F"), "Drug"=c("D1","D2","D3")))

# Note care should be taken to be consistent when specifying vallabels manually:

#This works
nt1  <-  gmData(c("Sex","Drug","W1","W2"),factor=c(2,3,FALSE,FALSE))
vallabels(nt1)

#This works
nt12  <-  gmData(c("Sex","Drug","W1","W2"),factor=c(2,3,FALSE,FALSE), vallabels=list("Sex"=c(1,2), "Drug"=c(1,2,3)))
vallabels(nt1)

## Not run: 
#This will not work
nt1  <-  gmData(c("Sex","Drug","W1","W2"),factor=c(2,3,FALSE,FALSE), vallabels=list("Sex"=c(1,2,3), "Drug"=c(1,2,3)))
vallabels(nt1)

#This will not work
nt1  <-  gmData(c("Sex","Drug","W1","W2"),factor=c(2,3,FALSE,FALSE), vallabels=list("Sex"=c(1,2,3)))
vallabels(nt1)
## End(Not run)

data(rats)

#NOTE: This works, but it should not because names in 'data' is not checked for consistency with what is specified
nt1  <-  gmData(c("Sex","Drug","W1","W2"),factor=c(2,3,FALSE,FALSE), vallabels=list("Sex"=c(1,2), "Drug"=c(1,2,3)), data=rats)
vallabels(nt1)

# Sending a data frame to MIM
gm.rats <- as.gmData(rats)
toMIM(gm.rats)

[Package mimR version 1.2.4 Index]