Skip to content

Instantly share code, notes, and snippets.

@WardBrian
WardBrian / analysis.R
Last active April 9, 2025 16:12
Lotka-Volterra
# code adapted from https://github.com/stan-dev/example-models/blob/master/knitr/lotka-volterra/lotka-volterra-predator-prey.Rmd
library(posterior)
library(reshape2)
library(ggplot2)
lynx_hare_df <-
read.csv("https://raw.githubusercontent.com/stan-dev/example-models/refs/heads/master/knitr/lotka-volterra/hudson-bay-lynx-hare.csv",
comment.char="#")
@WardBrian
WardBrian / analysis.R
Last active February 4, 2025 16:56
Disease Transmission
# posterior predictive check using the pred_cases generated quantity
install.packages("bayesplot")
library(posterior)
library(ggplot2)
# load from data
d <- jsonlite::read_json('./data.json')
cases <- unlist(d$cases)
n_days <- d$n_days
@WardBrian
WardBrian / analysis.R
Last active March 18, 2025 18:43
Linear Regression
install.packages("ggplot2")
library(posterior)
library(ggplot2)
# load data from data.json
data <- jsonlite::read_json("./data.json")
x <- unlist(data$x)
y <- unlist(data$y)
# posterior predictive check
#include <stdexcept>
#include <iostream>
void maybe_throw(int should_throw) {
if (should_throw)
throw std::domain_error("exception in C++: dummy");
}
extern "C" int some_fn(int should_throw) {
try {
/**
* Demonstration of `scalar_type_t`, `base_type_t`, and `value_type_t`, for
* examples where they do the same thing and examples where they differ.
*
* Place in math repo directory and compile with:
make -f make/standalone test_types
*/
#include <stan/math/prim.hpp>
#include <stan/math/prim/fun/typedefs.hpp>
@WardBrian
WardBrian / CustomFunctions.psm1
Last active June 24, 2020 22:15
Brian's Powershell Customization
<#
.Synopsis
Opens explorer in the current working directory
#>
Function Start-FileExplorer {
Start-Process explorer.exe .
}
<#
.Synopsis