This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #' Calculate Relative Measurement Uncertainty (RMU) from an rvar | |
| #' | |
| #' This function takes a vector of `rvar`s (one for each subject) and estimates | |
| #' the reliability of the posteriors using the Relative Measurement Uncertainty (RMU) | |
| #' method, as described by Bignardi et al. (2024). It is designed to be robust | |
| #' to the common case where the underlying array of a vector rvar from a model | |
| #' has a trailing dimension of 1 (e.g., [draws, subjects, 1]). | |
| #' | |
| #' @param intercepts_rvar A vector `rvar` object from the `posterior` package. | |
| #' Each element of the vector represents the posterior distribution for a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pacman::p_load(pacman, tidyverse, rio, magrittr, janitor, ggdist, distributional) | |
| tibble::tribble( | |
| ~Kön, ~Ålder, ~Kapital.Medel, ~Kapital.Median, ~Månadssparande.Medel, ~Månadssparande.Median, | |
| "Kvinna", 18L, 66660L, 10750L, 2440L, 550L, | |
| "Kvinna", 19L, 66510L, 12810L, 4570L, 1700L, | |
| "Kvinna", 20L, 71230L, 17110L, 4730L, 2000L, | |
| "Kvinna", 21L, 72470L, 16100L, 4110L, 1500L, | |
| "Kvinna", 22L, 71510L, 15910L, 3710L, 1400L, | |
| "Kvinna", 23L, 78860L, 16720L, 3590L, 1500L, | |
| "Kvinna", 24L, 78820L, 16570L, 3750L, 1500L, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <!-- Vibe coded with Gemini 2.5 Pro --> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Interactive Confusion Matrix</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <style> | |
| body { |
We can't make this file beautiful and searchable because it's too large.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| atc,sv1,sv2,sv3,sv4,sv5 | |
| A,Matsmältningsorgan och ämnesomsättning,,,, | |
| A01,Matsmältningsorgan och ämnesomsättning,Medel vid mun- och tandsjukdomar,,, | |
| A01A,Matsmältningsorgan och ämnesomsättning,Medel vid mun- och tandsjukdomar,Medel vid mun- och tandsjukdomar,, | |
| A01AA,Matsmältningsorgan och ämnesomsättning,Medel vid mun- och tandsjukdomar,Medel vid mun- och tandsjukdomar,Medel mot karies, | |
| A01AA01,Matsmältningsorgan och ämnesomsättning,Medel vid mun- och tandsjukdomar,Medel vid mun- och tandsjukdomar,Medel mot karies,Natriumfluorid | |
| A01AA02,Matsmältningsorgan och ämnesomsättning,Medel vid mun- och tandsjukdomar,Medel vid mun- och tandsjukdomar,Medel mot karies,Natriummonofluorofosfat | |
| A01AA03,Matsmältningsorgan och ämnesomsättning,Medel vid mun- och tandsjukdomar,Medel vid mun- och tandsjukdomar,Medel mot karies,Olaflur | |
| A01AA04,Matsmältningsorgan och ämnesomsättning,Medel vid mun- och tandsjukdomar,Medel vid mun- och tandsjukdomar,Medel mot karies,Tennfluorid | |
| A01AA30,Matsmältningsorgan och ämnesomsättning,Medel vid |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Third order Delta method | |
| bias_adj <- function(mu, sigma, fun){ | |
| first_deriv <- pracma::fderiv(fun, mu) | |
| second_deriv <- pracma::fderiv(fun, mu, n = 2) | |
| third_deriv <- pracma::fderiv(fun, mu, n = 3) | |
| moment1 <- fun(mu)+ # first order | |
| 1/2*second_deriv*sigma^2 # second order | |
| # the third order part evaluates to zero due to symmetry | |
| moment2 <- sqrt((first_deriv*sigma)^2+ # first order |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Workaround for Chromium Issue 468227 - fixes download functionality in Chrome-based browsers | |
| downloadButton <- function(...) { | |
| tag <- shiny::downloadButton(...) | |
| tag$attribs$download <- NULL | |
| tag | |
| } | |
| # Load required packages | |
| library(shiny) # Core Shiny functionality | |
| library(DT) # For interactive data tables |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(shiny) | |
| library(bslib) | |
| library(readxl) | |
| library(FactoMineR) | |
| library(factoextra) | |
| library(DT) | |
| library(dplyr) | |
| library(data.table) | |
| ui <- page_sidebar( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(cmdstanr) | |
| library(brms) | |
| brm_pathfinder_inits <- function(..., psis_resample=TRUE, max_lbfgs_iters = 2500, history_size = 100){ | |
| brm(empty = T, ...) -> | |
| brm_empty | |
| cmdstanr::write_stan_file(brm_empty$model) %>% | |
| cmdstan_model(cpp_options = list(stan_threads = TRUE)) -> | |
| model_cmdstan |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(duckdb) | |
| library(DBI) | |
| library(dbplyr) | |
| duckdb_write_parquet <- function(tbl_obj, filename){ | |
| library(tictoc) | |
| library(glue) | |
| tbl_object$src$con -> con | |
| con %>% dbExecute("SET autoinstall_known_extensions=1;") | |
| con %>% dbExecute("SET autoload_known_extensions=1;") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef DIRICHLET_RNG_WRAPPER_HPP | |
| #define DIRICHLET_RNG_WRAPPER_HPP | |
| #include <stan/math.hpp> | |
| #include <boost/random/mersenne_twister.hpp> | |
| #include <chrono> | |
| #include <Eigen/Dense> | |
| #include <iostream> | |
| // Declare an integer to keep track of the iteration count |
NewerOlder