This file contains 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 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 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 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 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 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 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 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 ![worldometer](https://www.worldometers.info/coronavirus/) and then makes a graph. | |
```{r} | |
library(WDI) | |
library(countrycode) |
This file contains 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(gghighlight) | |
library(tidyverse) | |
# load data | |
raw <- read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-03-03/game_goals.csv') | |
# 8 best scorers (there are 8 colors in scale_color_brewer Dark2) | |
best <- raw %>% | |
group_by(player) %>% | |
summarize(goals = sum(goals)) %>% |
This file contains 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(tidyverse) | |
example <- tibble(id = 1:500, | |
A = sample(TRUE:FALSE, 500, replace = TRUE), | |
B = sample(TRUE:FALSE, 500, replace = TRUE), | |
C = sample(TRUE:FALSE, 500, replace = TRUE), | |
D = sample(TRUE:FALSE, 500, replace = TRUE), | |
E = sample(TRUE:FALSE, 500, replace = TRUE), | |
F = sample(TRUE:FALSE, 500, replace = TRUE)) |