## ----eval=FALSE---------------------------------------------------------------
# install.packages("GMLTM")

## ----eval=FALSE---------------------------------------------------------------
# # Example Q matrix: 5 items, 3 rules
# Q <- matrix(c(1,0,1,
#               0,1,1,
#               1,1,0,
#               1,0,0,
#               0,1,0), nrow = 5, byrow = TRUE)
# 
# # Group rules into 2 components
# components <- list(comp1 = c(1, 2), comp2 = 3)

## ----eval=FALSE---------------------------------------------------------------
# library(GMLTM)
# data(analogy)
# 
# Q <- matrix(...)  # define your Q matrix (items x rules)
# 
# fit <- LLTM(analogy, Q,
#             iters = 2000, iter_warmup = 500, chains = 2)
# 
# fit$EAP$eta      # rule difficulty estimates
# fit$EAP$beta     # item difficulty estimates
# reliability(fit) # marginal reliability
# ppchecks(fit)    # posterior predictive check plot

## ----eval=FALSE---------------------------------------------------------------
# components <- list(global = c(1, 2, 3), local = c(4, 5))
# 
# fit <- GMLTM(analogy, Q, components,
#              iters = 2000, iter_warmup = 500, chains = 2)
# 
# fit$EAP$eta      # rule difficulties per component
# fit$EAP$alpha    # item discriminations per component
# fit$EAP$guessing # item guessing parameters
# reliability(fit) # marginal reliability per component

## ----eval=FALSE---------------------------------------------------------------
# # More diffuse prior on rule difficulties
# fit_diffuse <- LLTM(analogy, Q,
#                     priors = list(eta = list(sigma = 3)))
# 
# # Moderately informative prior for guessing in GMLTM
# fit_gmltm <- GMLTM(analogy, Q, components,
#                    priors = list(c = list(shape1 = 2, shape2 = 10)))
# 
# # Uniform prior for guessing (least informative)
# fit_uniform_c <- GMLTM(analogy, Q, components,
#                        priors = list(c = list(shape1 = 1, shape2 = 1)))

## ----eval=FALSE---------------------------------------------------------------
# # Fit two models with different priors
# fit1 <- GMLTM(analogy, Q, components, iters = 2000, iter_warmup = 500)
# fit2 <- GMLTM(analogy, Q, components,
#               priors = list(c = list(shape1 = 1, shape2 = 1)),
#               iters = 2000, iter_warmup = 500)
# 
# # Compare with LOO
# result <- compute_model_validation(list(fit1, fit2))
# print(result$Summary)

## ----eval=FALSE---------------------------------------------------------------
# priors = list(
#   parameter_name = list(hyperparameter1 = value, hyperparameter2 = value)
# )

## ----eval=FALSE---------------------------------------------------------------
# library(GMLTM)
# data(analogy)
# 
# # Default priors (weakly informative)
# fit_default <- LLTM(analogy, Q,
#                     iters = 2000, iter_warmup = 500, chains = 2)
# 
# # More diffuse prior on rule difficulties (eta)
# fit_diffuse <- LLTM(analogy, Q,
#                     iters = 2000, iter_warmup = 500, chains = 2,
#                     priors = list(eta = list(mu = 0, sigma = 3)))
# 
# # Informative prior centered on positive difficulty
# fit_informed <- LLTM(analogy, Q,
#                      iters = 2000, iter_warmup = 500, chains = 2,
#                      priors = list(eta = list(mu = 1, sigma = 0.5)))

## ----eval=FALSE---------------------------------------------------------------
# components <- list(global = c(1, 2, 3), local = c(4, 5))
# 
# # Wider prior for discrimination
# fit_mltm <- MLTM(analogy, Q, components,
#                  iters = 2000, iter_warmup = 500, chains = 2,
#                  priors = list(
#                    theta = list(mu = 0, sigma = 1),
#                    alpha = list(sigma = 2)
#                  ))

## ----eval=FALSE---------------------------------------------------------------
# # Default: Beta(3,20) -- conservative guessing prior
# fit_gmltm <- GMLTM(analogy, Q, components,
#                    iters = 2000, iter_warmup = 500, chains = 2)
# 
# # Uniform prior for guessing -- no prior assumption
# fit_uniform_c <- GMLTM(analogy, Q, components,
#                        iters = 2000, iter_warmup = 500, chains = 2,
#                        priors = list(c = list(shape1 = 1, shape2 = 1)))
# 
# # Moderately informative prior
# fit_moderate_c <- GMLTM(analogy, Q, components,
#                         iters = 2000, iter_warmup = 500, chains = 2,
#                         priors = list(c = list(shape1 = 2, shape2 = 10)))

## ----eval=FALSE---------------------------------------------------------------
# # Conservative priors
# fit_conservative <- LLTM(analogy, Q, chains = 2, iters = 2000,
#                          priors = list(eta = list(sigma = 1)))
# 
# # Diffuse priors
# fit_diffuse <- LLTM(analogy, Q, chains = 2, iters = 2000,
#                     priors = list(eta = list(sigma = 5)))
# 
# # Compare eta estimates
# cbind(
#   conservative = fit_conservative$EAP$eta,
#   diffuse      = fit_diffuse$EAP$eta
# )

## ----eval=FALSE---------------------------------------------------------------
# fit_gmltm1_style <- GMLTM(analogy, Q, components,
#   priors = list(
#     theta = list(mu = 0, sigma = 2),
#     eta   = list(mu = 0, sigma = 2),
#     c     = list(shape1 = 2, shape2 = 5)
#   ))

## ----eval=FALSE---------------------------------------------------------------
# fit_gmltm2_style <- GMLTM(analogy, Q, components,
#   priors = list(
#     theta = list(mu = 0, sigma = 5),
#     eta   = list(mu = 0, sigma = 5),
#     c     = list(shape1 = 1, shape2 = 1)
#   ))

