This file contains hidden or 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<lower=1> n_site; | |
int<lower=1> n_distance_bins; | |
vector[n_distance_bins + 1] bin_breakpoints; | |
array[n_site, n_distance_bins] int y; | |
array[n_site] int n_obs; | |
} | |
transformed data { | |
real max_distance = max(bin_breakpoints); |
This file contains hidden or 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(forcats) | |
library(ggplot2) | |
library(testthat) | |
path <- testthat_example("success") | |
l <- test_file(path, reporter = "list") | |
l %>% | |
as.data.frame() %>% | |
ggplot(aes(y = fct_reorder(test, real), x = real)) + |
This file contains hidden or 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(sf) | |
library(here) | |
library(brms) | |
library(lubridate) | |
library(reshape2) | |
# Get ecoregion data ------------------------------------------------------ | |
download.file("ftp://newftp.epa.gov/EPADataCommons/ORD/Ecoregions/us/us_eco_l4.zip", | |
destfile = "ecoregions.zip") |
This file contains hidden or 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, |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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(reshape2) | |
library(pbapply) | |
n_samples <- 100 | |
n_wavelength <- 400 | |
wavelengths <- matrix(nrow = n_samples, ncol = n_wavelength) | |
reflectances <- matrix(nrow = n_samples, ncol = n_wavelength) | |
for (i in 1:n_samples) { |
This file contains hidden or 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(lme4) | |
# adapted from ?predict.merMod | |
gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 |herd), | |
cbpp, | |
binomial) | |
# add some new levels to herd, which is a random effect | |
newdata <- with(cbpp, | |
expand.grid(period=unique(period), |
This file contains hidden or 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(rstan) | |
options(mc.cores = parallel::detectCores()) | |
rstan_options(auto_write = TRUE) | |
psi <- .2 | |
theta <- .3 | |
p <- .5 | |
nsite <- 100 | |
ntime <- 4 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder