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 { | |
int N; | |
int M; | |
real<lower=0> Y[N]; | |
} | |
parameters { | |
real<lower=0> mu; | |
real<lower=0> phi; | |
real<lower=1, upper=2> theta; |
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
# Distance sampling model with data augmentation. | |
# Based on section 8.3.1 of the Applied Hierarchical Modeling book by Royle and Kery | |
library(rstan) | |
B <- 50 | |
# note that I'm dividing by 10 and adding 1e-6 to put this on a manageable | |
# scale and prevent values == 0 | |
d_obs <- c(71.93, 26.05, 58.47, 92.35, 163.83, 84.52, 163.83, 157.33, |
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) | |
library(gganimate) | |
library(mgcv) | |
library(mvtnorm) | |
# Fit a GAM to the data | |
mod <- gam(hp ~ s(mpg), data=mtcars, method="REML") | |
# Get the linear prediction matrix | |
newdat = 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(emoGG) | |
library(ggplot2) | |
#use subsetting to display different emojis for different factor levels | |
ggplot(mtcars, aes(wt, mpg))+ | |
geom_emoji(data = mtcars[mtcars$am==1, ], emoji = "1f697") + | |
geom_emoji(data = mtcars[mtcars$am==0, ], emoji = "1f68c") |
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: Back to basics: High quality plots using base R graphics | |
### An interactive tutorial for the Davis R Users Group meeting on April 24, 2015 | |
### | |
### Date created: 20150418 | |
### Last updated: 20150423 | |
### | |
### Author: Michael Koontz | |
### Email: mikoontz@gmail.com | |
### Twitter: @michaeljkoontz | |
### |
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
require(quantmod) | |
require(fAssets) | |
#get asian currency data from the FED FRED data series | |
getSymbols("DEXKOUS",src="FRED") #load Korea | |
getSymbols("DEXMAUS",src="FRED") #load Malaysia | |
getSymbols("DEXSIUS",src="FRED") #load Singapore | |
getSymbols("DEXTAUS",src="FRED") #load Taiwan | |
getSymbols("DEXCHUS",src="FRED") #load China | |
getSymbols("DEXJPUS",src="FRED") #load Japan |