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
set.seed(13) | |
y <- rnorm(n=5, mean=1, sd=2/3) | |
n <- length(y) | |
s_sq <- sum((y-1)^2)/n | |
# weakly informative priors: | |
nu0 <- 1 | |
s0 <- 1 | |
post_nu <- nu0 + n | |
post_ssd <- (nu0 * s0^2 + n*s_sq)/2 | |
post_tau <- rgamma(10000, post_nu/2, post_ssd) |
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
set.seed(1234) | |
# Exercise 3.1: simple symmetric random walk on {0,1,2} | |
upd <- function(x, U) { | |
x + ifelse(x < 2 && U > 0.5, 1, 0) - ifelse(x > 0 && U <= 0.5, 1, 0) | |
} | |
x <- 1 | |
upd(x,0.25) | |
upd(x,0.75) |
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
# Piecewise basis functions: splines | |
# ch. 5 of ESL: Hastie, Tibshirani & Friedman (2009) | |
# one dimension (p=1) | |
x <- seq(-0.5,1,by=0.05)[-11] | |
y <- 2 - 5*exp(-8 * x^2) + rnorm(length(x), sd=0.5) | |
plot(x,y, ylim=range(-3,2,y)) | |
curve(2 - 5*exp(-8 * x^2), from=-0.5, to=1, n=length(x), col=4, add=T) | |
# kNN regression: piecewise constant |
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
functions { | |
vector ft(vector t, real r, real y0, real tC, real L) { | |
vector[num_elements(t)] mu; | |
vector[num_elements(t)] exprt; | |
exprt = exp(r*(t-tC)); | |
mu = y0*L*exprt ./ (L + y0*(exprt - 1)); | |
return mu; | |
} | |
vector dfdt(vector t, real r, real tC, real L) { |
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 downloaded from CovidBaseAU and Our World in Data, | |
# https://github.com/owid/covid-19-data/ | |
vax_aus <- read.csv("Australia.txt") | |
vax_aus$Date <- as.Date(vax_aus$date) | |
ix1 <- which.max(vax_aus$Date > "2021-05-02") - 1 | |
idx <- which.max(vax_aus$Date > "2021-07-02") - 1 | |
ix2 <- which.max(vax_aus$Date > "2021-09-02") - 1 | |
ix3 <- which.max(vax_aus$Date > "2021-11-02") - 1 | |
ix4 <- which.max(vax_aus$Date > "2021-10-02") - 1 | |
vax_aus$Date[idx] |
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(serrsBayes) | |
### read the data ---- | |
library(hyperSpec) | |
etoh <- read.spc("EtOH.spc") | |
plot(etoh) | |
wv <- wl(etoh) | |
i1 <- which.min(wv < 300) | |
i2 <- which.min(wv < 1800) |
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: "BayesComp 2023 abstract booklet" | |
format: pdf | |
editor: visual | |
params: | |
echo: FALSE | |
--- | |
```{r, echo=FALSE, eval=TRUE, results='hide'} | |
library(stringr) |