## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----setup--------------------------------------------------------------------
library(lasars)

## ----data---------------------------------------------------------------------
head(example_lasars_data)

## ----run_lasars---------------------------------------------------------------
result <- run_lasars(data = example_lasars_data,
                     resp_opts = 5, 
                     est_directPref = TRUE,
                     subject_colname = "subject", 
                     response_colname = "response", 
                     latentState_colname = "subscale", 
                     direction_colname = "reverse",
                     rev_score_id = 'TRUE',
                     iterations = 100, #Optional - speed up vignette
                     particles = 15 #Optional - speed up vignette
                     )

## ----model_output-------------------------------------------------------------
subject_level_ests <-  result$samples$alpha[,,]
group_level_ests <- result$samples$theta_mu[,]
covariance_mtx_ests <- result$samples$theta_sig[,,]

## ----mle_method---------------------------------------------------------------
mle_result <- run_lasars(data = example_lasars_data,
                     resp_opts = 5, 
                     est_directPref = TRUE,
                     subject_colname = "subject", 
                     response_colname = "response", 
                     latentState_colname = "subscale", 
                     direction_colname = "reverse",
                     rev_score_id = 'TRUE',
                     sampling_method = 'mle')
head(mle_result)

## ----run_latstat, eval = FALSE------------------------------------------------
# latstat_result <- run_latstat(data = example_lasars_data,
#                               resp_opts = 5,
#                               subject_colname = "subject",
#                               response_colname = "response",
#                               latentState_colname = "subscale",
#                               direction_colname = "reverse",
#                               rev_score_id = "TRUE")

## ----make_priors--------------------------------------------------------------
test_priors <- make_priors(data = example_lasars_data, 
                           resp_opts = 5, 
                           latentState_colname = "subscale",
                           est_directPref = TRUE, 
                           mu_prior = 0.5,
                           centrePref_prior = 0.3)

test_priors

## ----prior_output, eval = FALSE-----------------------------------------------
# testing_priors_result <- run_lasars(data = example_lasars_data,
#                      resp_opts = 5,
#                      est_directPref = TRUE,
#                      subject_colname = "subject",
#                      response_colname = "response",
#                      latentState_colname = "subscale",
#                      direction_colname = "reverse",
#                      rev_score_id = 'TRUE',
#                      priors = test_priors)

## ----gen_pp_data--------------------------------------------------------------
pp_data <- gen_pp_data(sampled = result)

head(pp_data)

## ----echo=FALSE---------------------------------------------------------------
sessionInfo()

