implemented checks with 'performance' package

This commit is contained in:
Andreas Gammelgaard Damsbo 2024-11-29 14:30:02 +01:00
commit 3ce9902170
No known key found for this signature in database
13 changed files with 574 additions and 27 deletions

View file

@ -5,6 +5,6 @@ account: agdamsbo
server: shinyapps.io
hostUrl: https://api.shinyapps.io/v1
appId: 13276335
bundleId: 9426438
bundleId: 9433115
url: https://agdamsbo.shinyapps.io/webResearch/
version: 1

View file

@ -20,6 +20,8 @@ library(here)
library(broom)
library(broom.helpers)
library(REDCapCAST)
library(easystats)
library(patchwork)
# if (!requireNamespace("webResearch")) {
# devtools::install_github("agdamsbo/webResearch", quiet = TRUE, upgrade = "never")
# }
@ -68,7 +70,6 @@ server <- function(input, output, session) {
REDCapCAST::numchar2fct(.x)
)
})()
}
return(out)
})
@ -194,9 +195,20 @@ server <- function(input, output, session) {
)
})
# browser()
# check <- performance::check_model(purrr::pluck(models,"Multivariable") |>
# (\(x){
# class(x) <- class(x)[class(x) != "webresearch_model"]
# return(x)
# })())
check <- purrr::pluck(models, "Multivariable") |>
performance::check_model()
v$list <- list(
data = data,
check = check,
table1 = data |>
baseline_table(
fun.args =
@ -234,9 +246,27 @@ server <- function(input, output, session) {
v$list$table2 |>
gtsummary::as_gt()
)
output$check <- shiny::renderPlot({
p <- plot(check) +
patchwork::plot_annotation(title = "Multivariable regression model checks")
p
# Generate checks in one column
# layout <- sapply(seq_len(length(p)), \(.x){
# patchwork::area(.x, 1)
# })
#
# p + patchwork::plot_layout(design = Reduce(c, layout))
# patchwork::wrap_plots(ncol=1) +
# patchwork::plot_annotation(title = 'Multivariable regression model checks')
})
}
)
output$uploaded <- shiny::reactive({
if (is.null(v$ds)) {
"no"

View file

@ -17,8 +17,12 @@ panels <- list(
gt::gt_output(outputId = "table1")
),
bslib::nav_panel(
title = "Multivariable regression table",
title = "Regression table",
gt::gt_output(outputId = "table2")
),
bslib::nav_panel(
title = "Regression checks",
shiny::plotOutput(outputId = "check")
)
)
@ -193,7 +197,8 @@ ui <- bslib::page(
bslib::nav_spacer(),
panels[[1]],
panels[[2]],
panels[[3]]
panels[[3]],
panels[[4]]
# layout_columns(
# cards[[1]]

View file

@ -16,7 +16,9 @@ params:
web_data <- readr::read_rds(file = params$data.file)
library(gtsummary)
library(gt)
library(webResearch)
library(easystats)
library(patchwork)
# library(webResearch)
```
## Introduction
@ -25,7 +27,7 @@ Research should be free and open with easy access for all. The webResearch tool
## Methods
Analyses were conducted in R version `r paste(version["major"],version["minor"],sep=".")` using the web-based data analysis tool 'webResearcher' version `r packageVersion("webResearch")`.
Analyses were conducted in R version `r paste(version["major"],version["minor"],sep=".")`.
## Results
@ -48,3 +50,19 @@ web_data$table2
## Discussion
Good luck on your further work!
## Sensitivity
Here are the results from testing the regression model:
```{r}
#| label: tbl-checks
#| fig-cap: Regression analysis checks
#| fig-height: 8
#| fig-width: 6
#| fig-dpi: 600
plot(web_data$check)
```