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(mgcv) | |
set.seed(2) ## simulate some data... | |
dat <- gamSim(1,n=400,dist="normal",scale=2) | |
b <- gam(y~s(x1), data=dat, fit=FALSE) | |
newpred <- data.frame(x1=seq(0, 10, length.out=100)) | |
# Lp for the data | |
lp_data <- PredictMat(b$smooth[[1]], dat) |
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
# Tax data from NYT article | |
# data scraped from https://www.nytimes.com/interactive/2019/10/06/opinion/income-tax-rate-wealthy.html | |
# load data scraped from SVG | |
tax <- readLines("taxdat.dat") | |
taxy <- c() | |
for(i in 1:length(tax)){ |
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
# generate some relaxing cloudy sky squares | |
# | |
# David Lawrence Miller (2019) | |
library(INLA) | |
library(ggplot2) | |
## function to simulate spatial fields | |
simdat <- function(n, seed, prior.range = c(5, .05), | |
prior.sigma = c(.05, .05)){ |
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
# data digitized from https://twitter.com/nberpubs/status/1062080096549261312 | |
# thanks @tpoi and co! https://cran.r-project.org/web/packages/digitize/index.html | |
# load the above data | |
dat <- read.csv("nber.csv") | |
# it's ya boi, mgcv | |
library(mgcv) | |
# fit the next stupidest model |
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
tax_rate | tax_rev | |
---|---|---|
0.07357329 | -0.0567062 | |
8.81285407 | 2.4505785 | |
12.84385295 | 3.5807126 | |
16.23680790 | 2.1860302 | |
19.18260073 | 2.4643621 | |
19.29050823 | 1.9514672 | |
18.45218145 | 1.2480201 | |
26.73285538 | 1.5886201 | |
22.37159417 | 3.3657369 |
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
Hat | Season | Episode | |
---|---|---|---|
Thick | 6 | 9 | |
Wet To Activate | 4 | 3 | |
Ho Ho Horny | 2 | 9 | |
Horny | 3 | 1 | |
Horny | 3 | 1 | |
Rods | 1 | 9 | |
Feet | 6 | 6 | |
Feet | 6 | 7 | |
Squeeze It | 1 | 15 |
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
# average predictions | |
library(Distance) | |
library(dsm) | |
# download data from http://workshops.distancesampling.org/stand-intermed-2018/practicals/spermwhale.RData | |
load("spermwhale.RData") | |
# make sure we get the same results every time | |
set.seed(123) |
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
# little animation to illustrate uncertainty in a density map | |
library(dsm) | |
library(mvtnorm) | |
library(ggplot2) | |
library(animation) | |
library(viridis) | |
library(cowplot) | |
set.seed(1997) |
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
### | |
n <- 200 | |
add_layer <- function(coords=data.frame(x=0, y=0), layer=0){ | |
so_rad <- seq(0, 2*pi-0.1, len=n) | |
if(layer==0){ | |
lens0 <- 0.1*runif(1, 0.1, 1) |