rblimp: Wrapper functions to provide Blimp functions in R

View source: R/rblimp.R

rblimpR Documentation

Wrapper functions to provide Blimp functions in R

Description

rblimp will generate the input, run the script, and load most the saved data into an R object. rblimp_fcs is used to specify the FCS command in Blimp. rblimp_syntax will generate the Blimp syntax file only.

Usage

rblimp(
  model,
  data,
  burn = 10000,
  iter = 10000,
  seed,
  thin,
  nimps,
  latent,
  randomeffect,
  parameters,
  clusterid,
  timeid,
  weight,
  ordinal,
  nominal,
  count,
  center,
  chains,
  simple,
  waldtest,
  options,
  transform,
  dropout,
  filter,
  fixed,
  output,
  tmpfolder,
  add_save = TRUE,
  print_output = TRUE,
  nopowershell = FALSE
)

rblimp_fcs(
  variables,
  data,
  burn = 10000,
  iter = 10000,
  seed,
  thin,
  nimps,
  clusterid,
  ordinal,
  nominal,
  chains,
  options,
  transform,
  fixed,
  output,
  tmpfolder,
  add_save = TRUE,
  print_output = TRUE,
  nopowershell = FALSE
)

rblimp_syntax(
  model,
  data,
  burn,
  iter,
  seed,
  thin,
  nimps,
  latent,
  randomeffect,
  parameters,
  clusterid,
  timeid,
  weight,
  ordinal,
  nominal,
  count,
  transform,
  dropout,
  filter,
  fixed,
  center,
  chains,
  simple,
  waldtest,
  options,
  save,
  output
)

Arguments

model

a character string or vector/list of character strings. Specifies Blimp's MODEL command. See details.

data

a data.frame or a SIMULATE object. If a data.frame, the data set used by Blimp. If a SIMULATE object (created with SIMULATE()), Blimp will generate simulated data instead of using existing data

burn

an integer. The number of burn-in iterations to be run

iter

an integer. The number of post burn-in iterations to be run

seed

a positive integer. The seeding value for Blimp's pseudo random number generator

thin

an integer. The thinning interval for imputations only.

nimps

an integer. The number of imputations to save.

latent

a character string, formula, or vector/list of character strings. Specifies Blimp's LATENT command. See details.

randomeffect

a character string or vector/list of character strings. Specifies Blimp's RANDOMEFFECTS command.

parameters

a character string or vector/list of character strings. Specifies Blimp's MODEL command. See details.

clusterid

a character string, formula, or vector/list of character strings. Specifies Blimp's CLUSTERID command. See details.

timeid

a character string, formula, or vector/list of character strings. Specifies Blimp's TIMEID command. See details.

weight

a character string, formula, or vector/list of character strings. Specifies Blimp's WEIGHT command. See details.

ordinal

a character string, formula, or vector/list of character strings. Specifies Blimp's ORDINAL command. See details.

nominal

a character string, formula, or vector/list of character strings. Specifies Blimp's NOMINAL command. See details.

count

a character string, formula, or vector/list of character strings. Specifies Blimp's COUNT command. See details.

center

a character string, formula, or vector/list of character strings. Specifies Blimp's CENTER command. See details.

chains

an integer, character string, or vector/list of character strings. Specifies Blimp's CHAINS command.

simple

a character string or vector/list of character strings. Specifies Blimp's SIMPLE command. See details.

waldtest

a character string or vector/list of character strings. Specifies Blimp's WALDTEST command. See details.

options

a character string or vector/list of character strings. Specifies Blimp's OPTIONS command.

transform

a character string or vector/list of character strings. Specifies Blimp's TRANSFORM command.

dropout

a character string, formula, or vector/list of character strings. Specifies Blimp's DROPOUT command. See details.

filter

a character string. Specifies Blimp's FILTER command.

fixed

a character string, formula, or vector/list of character strings. Specifies Blimp's FIXED command. See details.

output

a character string or vector/list of character strings. Specifies Blimp's OUTPUT command

tmpfolder

a character string. If specified rblimp will use the given file path as a temporary directory instead of creating one with tempdir

add_save

a single logical value or a list of logical values. If TRUE then saveLatent, saveResidual, and savePredicted will be included in OPTIONS command. Otherwise, it will be coerced to a list. The elements of the list should labeled latent, residual, and predicted each containing a single logical value that can be used to toggle on or off them individually. Missing elements will be defaulted to TRUE.

print_output

The type of output printed to the console. 'iteration' or logical TRUE is only iteration history, 'none' or logical FALSE suppresses all output to console, and 'all' prints all output to console.

nopowershell

Windows only. Uses cmd.exe with some limited functions (instead of powershell).

variables

list of variables to be included in FCS procedure

save

Specify SAVE command for blimp syntax

Details

The above functions require knowledge of specifying Blimp commands. Blimp's syntax commands are documented in the Blimp User Manual

By default, these commands can be inputted as character strings that will be used to generate the syntax. For multiple lined commands, you can wrap multiple strings into a character vector or a list. The appropriate semicolons will be specified, so they are not required in any character strings. If specifying a character vector or a list for the model, providing names to each element will be used as blocks in Blimp's model syntax. Similarly, specifying named elements can be used for the center command to specify if you would like centering within a cluster or grand mean centering. This also works for the latent input when requesting latent variables at a specific cluster identifier. See the Blimp User Manual for more details about types of centering and specifying latent variables.

In addition, R's formula syntax can be used to specify lists of variables in place of character strings. For example, specifying the CLUSTERID command with the variable id can be specified as ~ id as opposed to a character string. Similarly, + can be used to specify multiple variables. For example, to specify two variables as ordinal the formula would be: ~ x1 + x2. Finally, this can also be used to specify centering and latent variables. For example, to center x1 and x2 within cluster we can specify: cwc ~ x1 + x2.

Running rblimp will also check if blimp is up to date. See details in rblimp_source for more information.

Value

blimp_obj

See Also

  • SIMULATE() for creating simulated data to fit within rblimp()

  • rblimp_sim() for generating simulated datasets

Examples


# Generate Data with `rblimp_sim`
mydata <- rblimp_sim(
    c(
        'f ~ normal(0, 1)',
        'x1:x5 ~ normal(f, 1)',
        'y ~ normal(10 + 0.3*f, 1 - .3^2)'
     ),
     n = 500,
     seed = 19723,
     variables = c('y', 'x1:x5')
)

# Fit SEM Model
model <- rblimp(
    list(
        structure = 'y ~ f',
        measurement = 'f -> x1:x5'
    ),
    mydata,
    seed = 3927,
    latent = ~ f
)

# View results
summary(model)


rblimp documentation built on May 18, 2026, 9:07 a.m.