visW {DrBats}R Documentation

Plot the estimates for the latent factors

Description

Plot the estimates for the latent factors

Usage

visW(mcmc.output, Y, D, chain = 1, factors = c(1, 2))

Arguments

mcmc.output

an mcmc list as produced by clean.mcmc

Y

the matrix of data

D

the number of latent factors

chain

the chain to plot (default = 1)

factors

a vector indicating the factors to plot (default = c(1, 2))

Value

res.W a data frame containing the estimates for the factors, and their lower and upper bounds

Inertia the percentage of total inertia captured by each of the factors

Author(s)

Gabrielle Weinrott

Examples

data("toydata")
data("stanfit")
codafit <- coda.obj(stanfit) ## convert to mcmc.list
W.res <- visW(codafit, Y = toydata$Y.simul$Y, D = toydata$wlu$D,
chain = 1, factors = c(1, 2))

## plot the results

data <- data.frame(time = rep(1:9, 2), W.res$res.W)
ggplot2::ggplot() +
  ggplot2::geom_step(data = data, ggplot2::aes(x = time, y = Estimation, colour = Factor)) +
  ggplot2::geom_step(data = data, ggplot2::aes(x = time, y = Lower.est, colour = Factor),
  linetype = "longdash") +
  ggplot2::geom_step(data = data, ggplot2::aes(x = time, y = Upper.est, colour = Factor),
  linetype = "longdash")


[Package DrBats version 0.1.6 Index]