implemented checks with 'performance' package

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

View file

@ -29,7 +29,12 @@ Imports:
broom.helpers,
cardx,
parameters,
DT
DT,
performance,
ggiraph,
qqplotr,
see,
patchwork
Suggests:
styler,
devtools,

View file

@ -1,7 +1,7 @@
# Generated by roxygen2: do not edit by hand
S3method(regression_table,default)
S3method(regression_table,list)
S3method(regression_table,webresearch_model)
export(argsstring2list)
export(baseline_table)
export(default_format_arguments)

View file

@ -112,7 +112,6 @@ regression_model <- function(data,
# Recreating the call
# out$call <- match.call(definition=eval(parse(text=fun)), call(fun, data = 'data',formula = as.formula(formula.str),args.list))
class(out) <- c("webresearch_model", class(out))
return(out)
}
@ -202,3 +201,19 @@ regression_model_uv <- function(data,
return(out)
}
#' Easy saving png
#'
#' @param data plot
#' @param ... passed to 'png()'
#' @param filename filename
#'
#' @return NULL
#' @export
#'
save_png <- function(data, filename,...) {
png(filename = filename,...)
data
dev.off()
}

View file

@ -79,7 +79,7 @@ regression_table.list <- function(x, ...) {
#' @rdname regression_table
#' @export
regression_table.webresearch_model <- function(x, ..., args.list = NULL, fun = "gtsummary::tbl_regression") {
regression_table.default <- function(x, ..., args.list = NULL, fun = "gtsummary::tbl_regression") {
# Stripping custom class
class(x) <- class(x)[class(x) != "webresearch_model"]

View file

@ -19,7 +19,6 @@ shiny_webResearch <- function(data = NULL, ...) {
G <- .GlobalEnv
if (!is.null(data) && is.data.frame(data)) {
assign("webResearch_data", data, envir = G)
}

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)
```

View file

@ -49,7 +49,7 @@ gtsummary::trial |>
formula.str = "{outcome.str}~.",
args.list = NULL
)
gtsummary::trial |> regression_model(
ls <- gtsummary::trial |> regression_model(
outcome.str = "trt",
auto.mode = FALSE,
fun = "stats::glm",

View file

@ -3,14 +3,14 @@
\name{regression_table}
\alias{regression_table}
\alias{regression_table.list}
\alias{regression_table.webresearch_model}
\alias{regression_table.default}
\title{Create table of regression model}
\usage{
regression_table(x, ...)
\method{regression_table}{list}(x, ...)
\method{regression_table}{webresearch_model}(x, ..., args.list = NULL, fun = "gtsummary::tbl_regression")
\method{regression_table}{default}(x, ..., args.list = NULL, fun = "gtsummary::tbl_regression")
}
\arguments{
\item{x}{regression model}

BIN
myplot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 KiB

495
renv.lock
View file

@ -9,6 +9,16 @@
]
},
"Packages": {
"DEoptimR": {
"Package": "DEoptimR",
"Version": "1.1-3-1",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"stats"
],
"Hash": "53a0299b56b4cbe418b12e3b65587211"
},
"DT": {
"Package": "DT",
"Version": "0.33",
@ -41,6 +51,23 @@
],
"Hash": "0cafd6f0500e5deba33be22c46bf6055"
},
"Matrix": {
"Package": "Matrix",
"Version": "1.7-1",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"grDevices",
"graphics",
"grid",
"lattice",
"methods",
"stats",
"utils"
],
"Hash": "5122bb14d8736372411f955e1b16bc8a"
},
"PKI": {
"Package": "PKI",
"Version": "0.1-14",
@ -307,6 +334,17 @@
],
"Hash": "b299c6741ca9746fb227debcb0f9fb6c"
},
"caTools": {
"Package": "caTools",
"Version": "1.18.3",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"bitops"
],
"Hash": "ab79c733080d83b4ad8a2cc33c1ef393"
},
"cachem": {
"Package": "cachem",
"Version": "1.1.0",
@ -320,7 +358,7 @@
},
"cards": {
"Package": "cards",
"Version": "0.3.0",
"Version": "0.4.0",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
@ -332,11 +370,11 @@
"tidyr",
"tidyselect"
],
"Hash": "2147e8448f4eb87197520fc1710855c7"
"Hash": "2cd0d1966092de416f9b7fa1e88b6132"
},
"cardx": {
"Package": "cardx",
"Version": "0.2.1",
"Version": "0.2.2",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
@ -349,7 +387,7 @@
"rlang",
"tidyr"
],
"Hash": "e5458dd65b0602136b16aed802d3bd50"
"Hash": "21f5ce5381d529b08783dca434af3003"
},
"cellranger": {
"Package": "cellranger",
@ -396,6 +434,16 @@
],
"Hash": "3f038e5ac7f41d4ac41ce658c85e3042"
},
"codetools": {
"Package": "codetools",
"Version": "0.2-20",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R"
],
"Hash": "61e097f35917d342622f21cdc79c256e"
},
"colorspace": {
"Package": "colorspace",
"Version": "2.1-1",
@ -417,6 +465,22 @@
"Repository": "CRAN",
"Hash": "14eb0596f987c71535d07c3aff814742"
},
"correlation": {
"Package": "correlation",
"Version": "0.8.6",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"bayestestR",
"datasets",
"datawizard",
"insight",
"parameters",
"stats"
],
"Hash": "8b6512d8f60685736ee3bafdc292190d"
},
"cpp11": {
"Package": "cpp11",
"Version": "0.5.0",
@ -486,6 +550,20 @@
],
"Hash": "33698c4b3127fc9f506654607fb73676"
},
"doParallel": {
"Package": "doParallel",
"Version": "1.0.17",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"foreach",
"iterators",
"parallel",
"utils"
],
"Hash": "451e5edf411987991ab6a5410c45011f"
},
"dplyr": {
"Package": "dplyr",
"Version": "1.1.4",
@ -509,6 +587,45 @@
],
"Hash": "fedd9d00c2944ff00a0e2696ccf048ec"
},
"easystats": {
"Package": "easystats",
"Version": "0.7.3",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"bayestestR",
"correlation",
"datawizard",
"effectsize",
"insight",
"modelbased",
"parameters",
"performance",
"report",
"see",
"tools",
"utils"
],
"Hash": "57b5affd63511e4bf93efc3e077e9241"
},
"effectsize": {
"Package": "effectsize",
"Version": "0.8.9",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"bayestestR",
"datawizard",
"insight",
"parameters",
"performance",
"stats",
"utils"
],
"Hash": "7aceb5e07b6d48171c6b56714cc305ea"
},
"evaluate": {
"Package": "evaluate",
"Version": "1.0.1",
@ -583,6 +700,19 @@
],
"Hash": "1a0a9a3d5083d0d573c4214576f1e690"
},
"foreach": {
"Package": "foreach",
"Version": "1.5.2",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"codetools",
"iterators",
"utils"
],
"Hash": "618609b42c9406731ead03adf5379850"
},
"fs": {
"Package": "fs",
"Version": "1.6.5",
@ -605,6 +735,52 @@
],
"Hash": "15e9634c0fcd294799e9b2e929ed1b86"
},
"ggiraph": {
"Package": "ggiraph",
"Version": "0.8.11",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"Rcpp",
"cli",
"ggplot2",
"grid",
"htmltools",
"htmlwidgets",
"purrr",
"rlang",
"stats",
"systemfonts",
"uuid",
"vctrs"
],
"Hash": "14b3b3b923944afb9542dbef4c68bf4b"
},
"ggplot2": {
"Package": "ggplot2",
"Version": "3.5.1",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"MASS",
"R",
"cli",
"glue",
"grDevices",
"grid",
"gtable",
"isoband",
"lifecycle",
"mgcv",
"rlang",
"scales",
"stats",
"tibble",
"vctrs",
"withr"
],
"Hash": "44c6a2f8202d5b7e878ea274b1092426"
},
"glue": {
"Package": "glue",
"Version": "1.8.0",
@ -646,6 +822,22 @@
],
"Hash": "3170d1f0f45e531c241179ab57cd30bd"
},
"gtable": {
"Package": "gtable",
"Version": "0.3.6",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"cli",
"glue",
"grid",
"lifecycle",
"rlang",
"stats"
],
"Hash": "de949855009e2d4d0e52a844e30617ae"
},
"gtsummary": {
"Package": "gtsummary",
"Version": "2.0.3",
@ -795,6 +987,28 @@
],
"Hash": "bee0c3abb5eea6c4170ea2a7c334893f"
},
"isoband": {
"Package": "isoband",
"Version": "0.2.7",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"grid",
"utils"
],
"Hash": "0080607b4a1a7b28979aecef976d8bc2"
},
"iterators": {
"Package": "iterators",
"Version": "1.0.14",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"utils"
],
"Hash": "8954069286b4b2b0d023d1b288dce978"
},
"jquerylib": {
"Package": "jquerylib",
"Version": "0.1.4",
@ -892,14 +1106,29 @@
},
"later": {
"Package": "later",
"Version": "1.3.2",
"Version": "1.4.1",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"Rcpp",
"rlang"
],
"Hash": "a3e051d405326b8b0012377434c62b37"
"Hash": "501744395cac0bab0fbcfab9375ae92c"
},
"lattice": {
"Package": "lattice",
"Version": "0.22-6",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"grDevices",
"graphics",
"grid",
"stats",
"utils"
],
"Hash": "cc5ac1ba4c238c7ca9fa6a87ca11a7e2"
},
"lazyeval": {
"Package": "lazyeval",
@ -958,6 +1187,23 @@
],
"Hash": "e2817ccf4a065c5d9d7f2cfbe7c1d78c"
},
"mgcv": {
"Package": "mgcv",
"Version": "1.9-1",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"Matrix",
"R",
"graphics",
"methods",
"nlme",
"splines",
"stats",
"utils"
],
"Hash": "110ee9d83b496279960e162ac97764ce"
},
"mime": {
"Package": "mime",
"Version": "0.12",
@ -980,6 +1226,25 @@
],
"Hash": "ab9d0930bfa21e98aec9d07f0c43cc89"
},
"modelbased": {
"Package": "modelbased",
"Version": "0.8.9",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"bayestestR",
"datawizard",
"effectsize",
"graphics",
"insight",
"parameters",
"performance",
"stats",
"utils"
],
"Hash": "f519814037d08eee1343c2e7b5992cc4"
},
"munsell": {
"Package": "munsell",
"Version": "0.5.1",
@ -991,6 +1256,40 @@
],
"Hash": "4fd8900853b746af55b81fda99da7695"
},
"nlme": {
"Package": "nlme",
"Version": "3.1-166",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"graphics",
"lattice",
"stats",
"utils"
],
"Hash": "ccbb8846be320b627e6aa2b4616a2ded"
},
"opdisDownsampling": {
"Package": "opdisDownsampling",
"Version": "1.0.1",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"caTools",
"doParallel",
"foreach",
"graphics",
"methods",
"parallel",
"pbmcapply",
"pracma",
"stats",
"twosamples"
],
"Hash": "44d781d040b35c3c72eb46dfa64d2eff"
},
"openssl": {
"Package": "openssl",
"Version": "2.2.2",
@ -1032,7 +1331,7 @@
},
"parameters": {
"Package": "parameters",
"Version": "0.23.0",
"Version": "0.24.0",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
@ -1045,7 +1344,52 @@
"stats",
"utils"
],
"Hash": "518970426f8042a2b27c3415da881674"
"Hash": "42e4417823caf935fcc47a88ad4706e7"
},
"patchwork": {
"Package": "patchwork",
"Version": "1.3.0",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"cli",
"farver",
"ggplot2",
"grDevices",
"graphics",
"grid",
"gtable",
"rlang",
"stats",
"utils"
],
"Hash": "e23fb9ecb1258207bcb763d78d513439"
},
"pbmcapply": {
"Package": "pbmcapply",
"Version": "1.5.1",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"parallel",
"utils"
],
"Hash": "bf173fb42b60f8f404f7a9f9c3f95d0d"
},
"performance": {
"Package": "performance",
"Version": "0.12.4",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"bayestestR",
"datawizard",
"insight",
"stats",
"utils"
],
"Hash": "64e61921ea6b2a4d76c81290d5ecce25"
},
"pillar": {
"Package": "pillar",
@ -1074,6 +1418,20 @@
],
"Hash": "01f28d4278f15c76cddbea05899c5d6f"
},
"pracma": {
"Package": "pracma",
"Version": "2.4.4",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"grDevices",
"graphics",
"stats",
"utils"
],
"Hash": "44bc172d47d1ea0a638d9f299e321203"
},
"prettyunits": {
"Package": "prettyunits",
"Version": "1.2.0",
@ -1113,7 +1471,7 @@
},
"promises": {
"Package": "promises",
"Version": "1.3.0",
"Version": "1.3.2",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
@ -1125,7 +1483,7 @@
"rlang",
"stats"
],
"Hash": "434cd5388a3979e74be5c219bcd6e77d"
"Hash": "c84fd4f75ea1f5434735e08b7f50fbca"
},
"ps": {
"Package": "ps",
@ -1153,6 +1511,35 @@
],
"Hash": "1cba04a4e9414bdefc9dcaa99649a8dc"
},
"qqconf": {
"Package": "qqconf",
"Version": "1.3.2",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"MASS",
"R",
"Rcpp",
"robustbase"
],
"Hash": "0a813d2f61e344db1e587f6195314e1d"
},
"qqplotr": {
"Package": "qqplotr",
"Version": "0.0.6",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"MASS",
"R",
"dplyr",
"ggplot2",
"opdisDownsampling",
"qqconf",
"robustbase"
],
"Hash": "a22b3777f51fd005a7cd4c2bccc385ae"
},
"quarto": {
"Package": "quarto",
"Version": "1.4.4",
@ -1266,6 +1653,25 @@
],
"Hash": "47623f66b4e80b3b0587bc5d7b309888"
},
"report": {
"Package": "report",
"Version": "0.5.9",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"bayestestR",
"datawizard",
"effectsize",
"insight",
"parameters",
"performance",
"stats",
"tools",
"utils"
],
"Hash": "244b87e40159d58b8c84cb019e5bd16c"
},
"rlang": {
"Package": "rlang",
"Version": "1.1.4",
@ -1300,6 +1706,21 @@
],
"Hash": "df99277f63d01c34e95e3d2f06a79736"
},
"robustbase": {
"Package": "robustbase",
"Version": "0.99-4-1",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"DEoptimR",
"R",
"graphics",
"methods",
"stats",
"utils"
],
"Hash": "c4aa31d38787b63bddb050b175f52e3d"
},
"rprojroot": {
"Package": "rprojroot",
"Version": "2.0.4",
@ -1374,6 +1795,28 @@
],
"Hash": "c19df082ba346b0ffa6f833e92de34d1"
},
"see": {
"Package": "see",
"Version": "0.9.0",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"bayestestR",
"correlation",
"datawizard",
"effectsize",
"ggplot2",
"grDevices",
"graphics",
"insight",
"modelbased",
"parameters",
"performance",
"stats"
],
"Hash": "743de04e180938d89e913f392dc9a104"
},
"shiny": {
"Package": "shiny",
"Version": "1.9.1",
@ -1461,6 +1904,18 @@
"Repository": "CRAN",
"Hash": "de342ebfebdbf40477d0758d05426646"
},
"systemfonts": {
"Package": "systemfonts",
"Version": "1.1.0",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"cpp11",
"lifecycle"
],
"Hash": "213b6b8ed5afbf934843e6c3b090d418"
},
"tibble": {
"Package": "tibble",
"Version": "3.2.1",
@ -1529,6 +1984,16 @@
],
"Hash": "3ec7e3ddcacc2d34a9046941222bf94d"
},
"twosamples": {
"Package": "twosamples",
"Version": "2.0.1",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"cpp11"
],
"Hash": "cc7d944f8cf4a557decafe1dc95531de"
},
"tzdb": {
"Package": "tzdb",
"Version": "0.4.0",
@ -1550,6 +2015,16 @@
],
"Hash": "62b65c52671e6665f803ff02954446e9"
},
"uuid": {
"Package": "uuid",
"Version": "1.2-1",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R"
],
"Hash": "34e965e62a41fcafb1ca60e9b142085b"
},
"vctrs": {
"Package": "vctrs",
"Version": "0.6.5",