ctModelLatex: Generate and optionally compile latex equation of subject...

View source: R/ctModelLatex.R

ctModelLatexR Documentation

Generate and optionally compile latex equation of subject level ctsem model.

Description

Generate and optionally compile latex equation of subject level ctsem model.

Usage

ctModelLatex(
  x,
  matrixnames = TRUE,
  digits = 3,
  linearise = class(x) %in% "ctStanFit",
  textsize = "normalsize",
  folder = tempdir(),
  filename = paste0("ctsemTex", as.numeric(Sys.time())),
  tex = TRUE,
  equationonly = FALSE,
  compile = TRUE,
  open = TRUE,
  includeNote = TRUE,
  minimal = FALSE
)

Arguments

x

ctsem model object or ctStanFit object.

matrixnames

Logical. If TRUE, includes ctsem matrix names such as DRIFT and DIFFUSION under the matrices.

digits

Precision of decimals for numeric values.

linearise

Logical. Show the linearised normal approximation for subject parameters and covariate effects, or the raw parameters?

textsize

Standard latex text sizes – tiny scriptsize footnotesize small normalsize large Large LARGE huge Huge. Useful if output overflows page.

folder

Character string specifying folder to save to, defaults to temporary directory, use "./" for working directory.

filename

filename, without suffix, to output .tex and .pdf files too.

tex

Save .tex file? Otherwise latex is simply returned within R as a string.

equationonly

Logical. If TRUE, output is only the latex relevant to the equation, not a compileable document.

compile

Compile to .pdf? (Depends on tex = TRUE)

open

Open after compiling? (Depends on compile = TRUE)

includeNote

Include text describing matrix transformations and subject notation? triangular matrices (which results in a covariance or Cholesky matrix) is shown – the latter is a more direct representation of the model, while the former is often simpler to convey.

minimal

if TRUE, outputs reduced form version displaying matrix dimensions and equation structure only.

Value

character string of latex code. Side effects include saving a .tex, .pdf, and displaying the pdf.

Examples

ctmodel <- ctModel(type='stanct', 
n.latent=2, n.manifest=1, 
manifestNames='sunspots', 
latentNames=c('ss_level', 'ss_velocity'),
LAMBDA=matrix(c( 1, 'ma1' ), nrow=1, ncol=2),
DRIFT=matrix(c(0, 1,   'a21', 'a22'), nrow=2, ncol=2, byrow=TRUE),
MANIFESTMEANS=matrix(c('m1'), nrow=1, ncol=1),
CINT=matrix(c(0, 0), nrow=2, ncol=1),
DIFFUSION=matrix(c(
  0, 0,
  0, "diffusion"), ncol=2, nrow=2, byrow=TRUE))
  
l=ctModelLatex(ctmodel,compile=FALSE, open=FALSE)
cat(l)

ctsem documentation built on Sept. 11, 2024, 9:06 p.m.