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

## ----setup, eval=FALSE--------------------------------------------------------
# devtools::install_github("KevinHZhao/TriLLIEM")

## ----load_package-------------------------------------------------------------
library(TriLLIEM)

## ----simplesim----------------------------------------------------------------
set.seed(123) # setting random seed for reproducibility
matdat <- 
  simulateData(
    nCases = 1000,
    maf = 0.3,
    mtCoef = c(1,1,1),
    S = c(1, 1.2, 1.2^2)
  )

## ----complexsim---------------------------------------------------------------
impdat <-
  simulateData(
    nCases = 2000,
    nControl = 1000,
    maf = 0.3,
    S = c(1, 1.2, 1.2^2),
    V = c(1, 1.5, 1.5^2),
    mtCoef = c(0.5, 0.5, 0.5),
    Im = 1.4,
    propE = 0.3,
    Einteraction = "Im"
  )

## ----simpleres----------------------------------------------------------------
matres <-
  TriLLIEM(
    mtmodel = "HWE",
    effects = c("M"),
    dat = matdat
  )

## ----simpleinterp-------------------------------------------------------------
matres |> summary() |> coef()

## ----complexres---------------------------------------------------------------
impres <-
  TriLLIEM(
    mtmodel = "MaS",
    effects = c("M", "Im", "E:Im"),
    dat = impdat,
    includeE = TRUE,
    includeD = TRUE
  )
impres |> summary() |> coef()

## ----complexres_strat---------------------------------------------------------
impres_strat <-
  TriLLIEM(
    mtmodel = "MaS",
    effects = c("M", "Im", "E:Im"),
    dat = impdat,
    includeE = TRUE,
    Estrat = TRUE,
    includeD = TRUE
  )
impres_strat |> summary() |> coef()

## ----model_compare_fit--------------------------------------------------------
model_1 <- TriLLIEM(dat = example_dat4R, effects = c("C", "M"))
model_2 <- TriLLIEM(dat = example_dat4R, effects = c("C", "M", "Im"))

## ----model_anova--------------------------------------------------------------
anova(model_1, model_2)

