Learn R Programming

flps (version 0.1.0)

runFLPS: Conduct fully latent principal stratification

Description

Conduct fully latent principal stratification

Usage

runFLPS(
  inp_data = NULL,
  custom_data = NULL,
  custom_stan = NULL,
  outcome = NULL,
  group = NULL,
  covariate = NULL,
  lv_model = NULL,
  lv_type = NULL,
  priors_input = NULL,
  stan_options = list(),
  ...
)

Value

an object of class flps which contains a stanfit object.

call

argument calls

inp_data

A given data frame

flps_model

a Stan syntax used in [rstan::stan()]

flps_data

a list of data used in [rstan::stan()]

flps_fit

stanfit

time

a numeric of timing

Arguments

inp_data

A matrix or a data frame

custom_data

A list. should be provided with custom_stan.

custom_stan

A string. should be provided with custom_data.

outcome

A character indicating the name of an outcome variable

group

A character indicating the name of a treatment/control group variable

covariate

A character indicating the names of covariate variables

lv_model

A description of the latent variable model, which is similar to the lavaan model syntax.

  • =~ : Specify the association between factors and indicators (e.g., F1 =~ v1 + v2 + v3).

  • + : Specify a series of indicators

lv_type

A character indicating the type of latent variable models

priors_input

A list of priors. Otherwise, the default priors are used (N(0, 5). It takes three parameter names including tau0, tau1, and omega, which are the difference between groups, the principal effects, and the effect of latent factors on the outcome. If added, the length of tau1 and omega must be matched with the number of factors. Examples of How to specify priors as follows:

  • list(tau0 = c(0, 1), tau1 = c(0.5, 1)) : The first element is the mean and the second is the variance of normal priors.

  • list(tau1 = list(c(0.5, 1), c(-0.4, 1)) : If there's two factors.

stan_options

A list containing [rstan::stan()] options, using 'name = value'.

...

Additional arguments for latent variable models information (e.g., nclass = 2).

See Also

[rstan::stan()]

Examples

Run this code
# \donttest{
inp_data <- flps::makeInpData(
  N       = 200,
  R2Y     = 0.2,
  R2eta   = 0.5,
  omega   = 0.2,
  tau0    = 0.23,
  tau1    = -0.16,
  betaL   = 0.1,
  betaY   = 0.2,
  lambda  = 0.8,
  nitem    = 10,
  nfac    = 1,
  lvmodel = 'rasch' )

res <- runFLPS(
   inp_data = inp_data,
   outcome = "Y",
   group = "Z",
   covariate = c("X1"),
   lv_type = "rasch",
   lv_model = "F =~ v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8 + v9 + v10",
   stan_options = list(iter = 1000, warmup = 500, cores = 1, chains = 2)
   )
# }

Run the code above in your browser using DataLab