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 |
This file has been truncated, but you can view the full file.
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> | |
<html lang="en"><head> | |
<script>/*! | |
* clipboard.js v2.0.11 | |
* https://clipboardjs.com/ | |
* | |
* Licensed MIT © Zeno Rocha | |
*/ | |
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ClipboardJS=e():t.ClipboardJS=e()}(this,function(){return n={686:function(t,e,n){"use strict";n.d(e,{default:function(){return b}});var e=n(279),i=n.n(e),e=n(370),u=n.n(e),e=n(817),r=n.n(e);function c(t){try{return document.execCommand(t)}catch(t){return}}var a=function(t){t=r()(t);return c("cut"),t};function o(t,e){var n,o,t=(n=t,o="rtl"===document.documentElement.getAttribute("dir"),(t=document.createElement("textarea")).style.fontSize="12pt",t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[o?"right":"left"]="-9999px",o=window.pageYOffset||document.documentElement.scrollTop,t.style.top="".concat(o,"px"),t.setAttribute("readonly",""),t.value=n,t);return e.contain |
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
if(!("pak" %in% as.data.frame(installed.packages())$Package)){install.packages("pak")} | |
require(pak) | |
pkg_load <- function(...) { | |
if(!("pak" %in% as.data.frame(installed.packages())$Package)){install.packages("pak")} | |
pack <- sapply(match.call(), as.character)[-1] | |
pack[!(pack %in% as.data.frame(installed.packages())$Package)] -> to_install | |
if(length(to_install) > 0) pak(to_install) else "" | |
lapply(X = pack, FUN = function(x){tryCatch(require(x, character.only = T), error = function(e){NULL})}) -> X |
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(qs) | |
`%q>%` <- function(lhs, rhs){as.character(substitute(rhs)) -> name | |
qcache(substitute(lhs), name = name) -> value | |
assign(x = name, value = value, envir = .GlobalEnv)} |
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
county_code,county_name,county_name_long,municipality_code,municipality_name,municipality_name_long,regso_code,regso_name,deso,valdeltagande | |
01,Stockholm,Stockholms län,0114,Upplands Väsby,Upplands Väsby kommun,0114R001,Bollstanäs,0114C1010,0.88 | |
01,Stockholm,Stockholms län,0114,Upplands Väsby,Upplands Väsby kommun,0114R001,Bollstanäs,0114C1030,0.88 | |
01,Stockholm,Stockholms län,0114,Upplands Väsby,Upplands Väsby kommun,0114R001,Bollstanäs,0114C1050,0.91 | |
01,Stockholm,Stockholms län,0114,Upplands Väsby,Upplands Väsby kommun,0114R002,Hammarby-Vaxmyra,0114C1180,0.84 | |
01,Stockholm,Stockholms län,0114,Upplands Väsby,Upplands Väsby kommun,0114R002,Hammarby-Vaxmyra,0114C1220,0.72 | |
01,Stockholm,Stockholms län,0114,Upplands Väsby,Upplands Väsby kommun,0114R003,Odenslunda norra-Frestaby-Ekeby,0114C1100,0.83 | |
01,Stockholm,Stockholms län,0114,Upplands Väsby,Upplands Väsby kommun,0114R003,Odenslunda norra-Frestaby-Ekeby,0114C1140,0.9 | |
01,Stockholm,Stockholms län,0114,Upplands Väsby,Upplands Väsby kommun,0114R004,Odenslunda södra |
NewerOlder