Skip to content

Instantly share code, notes, and snippets.

View vincentarelbundock's full-sized avatar

Vincent Arel-Bundock vincentarelbundock

View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>tinytable_c80pijf8rq8f225cdrn6</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<script type="text/x-mathjax-config">
@vincentarelbundock
vincentarelbundock / maringe_2020.R
Last active December 9, 2023 02:50
Maringe et al. 2020
# Downloads data here:
# https://academic.oup.com/ije/article/49/5/1719/5835351#226179197
#############################################################################
# TRIAL EMULATION: SURGERY WITHIN 6 MONTHS AMONG OLDER LUNG CANCER PATIENTS
# Author: Clemence Leyrat (from Camille Maringe's Stata code)
# Refactored by Vincent Arel-Bundock on 2023-12-08
# Example of examining a continuous x categorical interaction using emmeans,
# and an attempt at doing the same using marginaleffects.
# Author: Cameron Patrick <cameron.patrick@unimelb.edu.au>
library(tidyverse)
library(emmeans)
library(marginaleffects)
# use the mtcars data, set up am as a factor
data(mtcars)
``` r
library(marginaleffects)
library(modelsummary)
set.seed(20220722)
S <- diag(3)
S[1,2] <- S[2,1] <- 0.6
S[1,3] <- S[3,1] <- 0.6
data <- MASS::mvrnorm(1000, rep(0, 3), S) |>
as.data.frame() |>
@vincentarelbundock
vincentarelbundock / bboot_vab.R
Last active February 7, 2022 21:38
Bayesian bootstrap in `R` with `update()`
library(fixest)
library(data.table)
library(insight)
bboot_vab <- function(model, reps = 1e3, conf.level = .95, cluster = NULL) {
data <- insight::get_data(model)
setDT(data)
if (!is.null(cluster)) {
if (anyNA(data[[cluster]])) {
stop("The cluster variable cannot include missing values.")
# French Accents
name: french-finnish-accents
parent: default
matches:
- trigger: "e''"
replace: "é"
- trigger: "e``"
@vincentarelbundock
vincentarelbundock / modelsummary.ipynb
Last active April 20, 2021 14:28
`modelsummary` regression tables in a Jupyter notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vincentarelbundock
vincentarelbundock / rdrobus_modelsummary.R
Created September 21, 2020 16:58
rdrobust & modelsummary
library(rdrobust)
library(modelsummary)
tidy.rdrobust <- function(object, ...){
ret <- data.frame(term = row.names(object$coef),
estimate = object$coef[, 1],
std.error = object$se[, 1],
statistic = object$z[, 1],
p.value = object$pv[, 1],
conf.low = object$ci[,1],
library(data.table)
library(tidyverse)
library(microbenchmark)
make_tibble <- function(...) {
treated_units <- sample(1:20000, 4000)
# year fixed effects
year <- tibble(
year = 1981:2010,
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.