Skip to content

Instantly share code, notes, and snippets.

Avatar

Vincent Arel-Bundock vincentarelbundock

View GitHub Profile
View gist:06ea0cc1d3c6807370f17a5c3c7abecf
# French Accents
name: french-finnish-accents
parent: default
matches:
- trigger: "e''"
replace: "é"
- trigger: "e``"
@vincentarelbundock
vincentarelbundock / modelsummary.ipynb
Last active Apr 20, 2021
`modelsummary` regression tables in a Jupyter notebook
View modelsummary.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View rdrobus_modelsummary.R
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],
View gist:3ff82c86191bf7dfcaa9a4e4cbb47d6e
library(data.table)
library(tidyverse)
library(microbenchmark)
make_tibble <- function(...) {
treated_units <- sample(1:20000, 4000)
# year fixed effects
year <- tibble(
year = 1981:2010,
View test.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View gist:8d2e6ad7c13057d910bf13694d39c871
remotes::install_github('vincentarelbundock/modelsummary')
library(modelsummary)
models <- list()
models[['OLS']] <- lm(mpg ~ factor(cyl), mtcars)
models[['Logit']] <- glm(am ~ factor(cyl), mtcars, family = binomial)
make_rows <- function(models) {
rows <- data.frame(term = 'factor(cyl)4', section = 'middle', position = 3)
View gist:40f53604ec843972b489c877cb1f0203
library(testthat)
library(mice)
context("pool.r.squared")
data(nhanes)
imp <- mice::mice(nhanes, maxit = 2, m = 2, seed = 1, print = FALSE)
fit_mira <- with(data = imp, exp = lm(chl ~ age + bmi))
test_that("r.squared", {
View margins.fixest.R
url <- 'https://raw.githubusercontent.com/leeper/margins/master/R/find_terms_in_model.R'
source(url)
#' @rdname prediction
#' @export
prediction.fixest <-
function(model,
data = find_data(model, parent.frame()),
at = NULL,
type = "response",
View gist:a2de4446f3a5ac9b374136d9992b4705
---
title: "Test new version of `modelsummary`"
author: "Vincent Arel-Bundock"
date: "2020-05-26"
output: pdf_document
header-includes:
- \usepackage{booktabs}
- \usepackage{threeparttable}
---
View gist:4e06ed1b0deb4259ad1a0b70379f91e3
draw_plot <- function(funs = list('S' = function(x) x, 'D' = function(x) 100 - x),
xlim = c(0, 100)) {
# data.frame of 1000 points to trace smooth functions
dat <- tibble(x = seq(xlim[1], xlim[2], length.out = 1000),
y1 = funs[[1]](x),
y2 = funs[[2]](x))
# find equilibrium and add it to data.frame