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<lower = 1> N_D; | |
int<lower = 1> N_ind; | |
real B; | |
int <lower = 1, upper = N_D> D_class[N_ind]; | |
real<lower = 0, upper = B> Delta; // Width of distance bins | |
vector<lower = 0, upper = B>[N_D] Midpt; // Interval mid-points | |
} | |
transformed data { | |
vector<lower = 0, upper = 1>[N_D] pi = 2 * Midpt / square(B) * Delta; |
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<lower = 1> N_ind; // Number of individuals | |
int<lower = 1> N_z; // Number of augment observed data | |
int<lower = 0, upper = 1> Y[N_ind + N_z]; // Augumented inds. have y=0 by | |
// definition | |
int<lower = 1> N_D; | |
real B; | |
int <lower = 1, upper = N_D> D_class[N_ind]; | |
real<lower = 0, upper = B> Delta; // Width of distance bins | |
vector<lower = 0, upper = B>[N_D] Midpt; // Interval mid-points |
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<lower = 1> N_sites; | |
int<lower = 0> N_ind; | |
int<lower = 0> N_z; | |
real<lower = 0> B; | |
vector[N_sites] Habitat; | |
vector[N_sites] Wind; | |
int<lower = 0, upper = 1> Y[N_ind + N_z]; | |
vector<lower = 0, upper = B>[N_ind] D; | |
int<lower = 1, upper = N_sites> Site[N_ind]; |
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<lower = 1> N_sites; | |
int<lower = 0> N_ind; | |
int<lower = 0> N_z; | |
int<lower = 1> N_D; | |
real<lower = 0> B; | |
real<lower = 0> Delta; | |
vector<lower = 0, upper = B>[N_D] Midpt; | |
vector[N_sites] Habitat; | |
vector[N_sites] Wind; |
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(ggplot2) | |
library(sf) | |
library(ggspatial) | |
# Data source: http://www.pref.hokkaido.lg.jp/sr/srk/OPD.htm | |
# CC-BY 北海道水産林務部林務局森林計画課 | |
houkai <- read_sf("山腹崩壊.shp", options = "ENCODING=CP932") | |
sum(st_area(houkai)) |
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(GGally) | |
sc <- 4 | |
ht <- 3 | |
wd <- 4 | |
set.seed(101) | |
N <- 100 | |
X <- rnorm(N, 0, 1) | |
Y <- rnorm(N, 0, 1) |
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(rstan) | |
options(mc.cores = parallel::detectCores()) | |
rstan_options(auto_write = TRUE) | |
set.seed(105) | |
N <- 100 | |
X <- rnorm(N, 0, 1) | |
Y <- rnorm(N, 0, 1) | |
Z <- rnorm(N, 0, 1) |
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-mixture model with 2 replicated observations | |
* | |
* References | |
* Dennis et al. (2015) Computational aspects of N-mixture models. | |
* Biometrics 71:237--246. DOI:10.1111/biom.12246 | |
* Stan users mailing list | |
* https://groups.google.com/forum/#!topic/stan-users/9mMsp1oB69g | |
*/ |
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: "Rounding" | |
output: html_notebook | |
--- | |
```{r} | |
library(rstan) | |
options(mc.cores = parallel::detectCores()) | |
rstan_options(auto_write = TRUE) | |
``` |
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(coda) | |
library(readr) | |
read_cmdstan <- function(files) { | |
m <- lapply(files, function(f) { | |
d <- read_csv(f, comment = "#") | |
as.mcmc(d) | |
}) | |
as.mcmc.list(m) | |
} |