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(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.
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
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) |
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(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", { |
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
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", |
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
--- | |
title: "Test new version of `modelsummary`" | |
author: "Vincent Arel-Bundock" | |
date: "2020-05-26" | |
output: pdf_document | |
header-includes: | |
- \usepackage{booktabs} | |
- \usepackage{threeparttable} | |
--- |
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
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 |
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(lfe) | |
library(lme4) | |
library(MASS) | |
library(tidyverse) | |
library(modelsummary) | |
set.seed(290653) | |
sim <- function(Nobs = 100, Ngrp = 50, cor_x_u = .6, x_sd = .2, y_sd = 1, ...) { | |
group <- mvrnorm(Ngrp, c(0, 0), matrix(c(1, cor_x_u, cor_x_u, 1), ncol = 2)) %>% | |
data.frame %>% setNames(c('U', 'Ucor')) %>% |
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(lme4) | |
library(gt) | |
library(modelsummary) | |
library(tidyverse) | |
# y dependent variable | |
# x regressor varies at the county-year level | |
# z regressor varies at the county level | |
url <- 'https://vincentarelbundock.github.io/Rdatasets/csv/plm/Crime.csv' |
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
--- | |
title: "COVID-19 Worldometer data" | |
output: html_notebook | |
--- | |
This notebook pulls a table with useful information out of  and then makes a graph. | |
```{r} | |
library(WDI) | |
library(countrycode) |