## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(dtametaTMB)


## -----------------------------------------------------------------------------
#| echo: TRUE

data("HPV")
head(HPV)


## -----------------------------------------------------------------------------
#| echo: TRUE

HPV$Test <- factor(HPV$Test,levels = c("HC2", "CC", "LBC"))
levels(HPV$Test)


## -----------------------------------------------------------------------------
#| echo: TRUE

nyaga <- fitNyaga(data = HPV,
                  TP = TP,
                  FP = FP,
                  FN = FN,
                  TN = TN,
                  study = StudyID,
                  test = Test)
nyaga
summary(nyaga)


## -----------------------------------------------------------------------------
#| echo: TRUE
#| fig.height: 8
#| fig.width: 10

plot(nyaga,size="se_revman",nudge_legend = -0.25)


## -----------------------------------------------------------------------------
#| echo: TRUE
#| eval: FALSE
#| fig.height: 11
#| fig.width: 13

# forest(nyaga,order = "test")


## -----------------------------------------------------------------------------
#| echo: TRUE

nyaga_common_sens <- fitNyaga(data = HPV,
                              TP = TP,
                              FP = FP,
                              FN = FN,
                              TN = TN,
                              study = StudyID,
                              test = Test,
                              sensspec_constrain = "sens")

nyaga_common_sens


## -----------------------------------------------------------------------------
#| echo: TRUE

nyaga_common_spec <- fitNyaga(data = HPV,
                              TP = TP,
                              FP = FP,
                              FN = FN,
                              TN = TN,
                              study = StudyID,
                              test = Test,
                              sensspec_constrain = "spec")

nyaga_common_spec


## -----------------------------------------------------------------------------
#| echo: TRUE

nyaga_common_both <- fitNyaga(data = HPV,
                              TP = TP,
                              FP = FP,
                              FN = FN,
                              TN = TN,
                              study = StudyID,
                              test = Test,
                              sensspec_constrain = c("sens","spec"))

nyaga_common_both


## -----------------------------------------------------------------------------
#| echo: TRUE

anova(nyaga_common_sens,nyaga)
anova(nyaga_common_spec,nyaga)
anova(nyaga_common_both,nyaga)

