catplotmlx: Plot Categorical Longitudinal Data

Description Usage Arguments Details Value Examples

View source: R/catplotmlx.R

Description

Plot the empirical distribution of categorical longitudinal data.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
catplotmlx(
  r,
  col = NULL,
  breaks = NULL,
  plot = TRUE,
  color = "#194280",
  group = NULL,
  facet = TRUE,
  labels = NULL
)

Arguments

r

a data frame with a column id, a column time, a column with values and possibly Hk[ja column group.

col

a vector of 3 column numbers: (id, time/x, y. Default = c(1, 2,3).

breaks

one of:

  • a vector giving the breakpoints,

  • a single number giving the number of segments.

plot

if TRUE the empirical distribution is displayed, if FALSE the values are returned

color

a color to be used for the plots (default="#194280")

group

variable to be used for defining groups (by default, group is used when it exists)

facet

makes subplots for different groups if TRUE

labels

vector of strings

Details

See http://simulx.webpopix.org/mlxr/catplotmlx/ for more details.

Value

a ggplot object if plot=TRUE ; otherwise, a list with fields:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
## Not run: 
  catModel <- inlineModel("
  [LONGITUDINAL]
  input =  {a,b}
  EQUATION:
  lp1=a-b*t
  lp2=a-b*t/2
  DEFINITION:
  y = {type=categorical, categories={1,2,3}, 
  logit(P(y<=1))=lp1, logit(P(y<=2))=lp2}
  ")
  
  y.out  <- list(name='y', time=seq(0, 100, by=4))

  Ng  <- 1000
  g1 <- list(size=Ng, parameter=c(a=6,b=0.2))
  res <- simulx(model=catModel, output=y.out, group=g1)
  catplotmlx(res$y)
  catplotmlx(res$y, breaks=seq(-2,102,by=8), color="purple") 
  catplotmlx(res$y, breaks=5, color="#490917") 
  
  g2 <- list(size=Ng, parameter=c(a=10,b=0.2))
  res <- simulx(model=catModel, output=y.out, group=list(g1,g2))
  catplotmlx(res$y) 
  catplotmlx(res$y, group="none")
  
  g3 <- list(size=Ng, parameter=c(a=6,b=0.4))
  g4 <- list(size=Ng, parameter=c(a=10,b=0.4))
  res <- simulx(model=catModel, output=y.out, group=list(g1,g2,g3,g4))
  catplotmlx(res$y)
   
  cov <- data.frame(id=levels(res$y$id), a=rep(c(6,10,6,10),each=Ng), 
                    b=rep(c(0.2,0.2,0.4,0.4),each=Ng))
  catplotmlx(res$y, group=cov) 

## End(Not run)

mlxR documentation built on Jan. 19, 2021, 5:06 p.m.