Skip to content

Instantly share code, notes, and snippets.

View mpettis's full-sized avatar

Matt Pettis mpettis

  • Personal
  • Minneapolis, MN
View GitHub Profile
(require '[clara.rules :as r])
;;;; Define 3 rules, where the "priority" order is r1, r2, r3, where the highest priority is first
;;;; and the rest is in descending order of priority.
;;;; :type :rule/result "syntetic" fact is used to hold the final changes that can be queried out
;;;; from a session after `r/fire-rules` via `r/query` on the `find-results` query.
;;;; A namespace qualified keyword is used to avoid collision with externally given :type of
;;;; "real" facts.
@mpettis
mpettis / comparing-polynomial-models-covid.R
Created May 5, 2020 21:03 — forked from dgrtwo/comparing-polynomial-models-covid.R
Comparing the CEA's "cubic model" to quadratic and quartic models
library(tidyverse)
library(broom)
US <- read_csv("https://raw.githubusercontent.com/nytimes/covid-19-data/master/us.csv") %>%
mutate(new_deaths = deaths - lag(deaths)) %>%
filter(date >= "2020-02-26")
models <- tibble(degrees = 2:4) %>%
mutate(model = map(degrees, ~ lm(log(new_deaths + 1) ~ poly(date, .), data = US)))