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
| # Moment match for the beta distribution. | |
| params_from_moments <- function(mu, sigma) { | |
| alpha <- (mu^2 - mu^3 - mu * sigma^2) / sigma^2 | |
| beta <- (mu - 2 * mu^2 + mu^3 - sigma^2 + mu * sigma^2) / sigma^2 | |
| c(alpha = alpha, beta = beta) | |
| } | |
| moments_from_params <- function(alpha, beta) { | |
| mu <- alpha / (alpha + beta) | |
| sigma <- sqrt((alpha * beta) / ((alpha + beta)^2 * (alpha + beta + 1))) | |
| c(mu = mu, sigma = sigma) |
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
| img_date | centered_doy | ndvi_flt | year_index | centered_decade | |
|---|---|---|---|---|---|
| 2000-02-18 | -133.5 | 0.1774 | 1 | -0.851 | |
| 2000-03-05 | -117.5 | 0.2836 | 1 | -0.851 | |
| 2000-03-21 | -101.5 | 0.27 | 1 | -0.851 | |
| 2000-04-22 | -69.5 | 0.3241 | 1 | -0.851 | |
| 2000-05-08 | -53.5 | 0.585 | 1 | -0.851 | |
| 2000-05-24 | -37.5 | 0.7536 | 1 | -0.851 | |
| 2000-06-09 | -21.5 | 0.8622 | 1 | -0.851 | |
| 2000-06-25 | -5.5 | 0.8507 | 1 | -0.851 | |
| 2000-07-11 | 10.5 | 0.862 | 1 | -0.851 |
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) | |
| plus_minus <- function(x, scalar) c(x-scalar, x, x+scalar) | |
| scenarios <- expand.grid( | |
| b0 = 2.86 %>% plus_minus(1), # intercept | |
| b1 = -.28 %>% plus_minus(.5) # the effect of translocation | |
| ) %>% mutate(scenario = 1:n()) |
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
| biv_dist_plot <- function(df, x=NULL, y=NULL, bins=50) { | |
| library(ggplot2) | |
| library(gridExtra) | |
| h_top <- ggplot(data=df, aes_string(x=x)) + | |
| geom_histogram(aes(y=..density..), fill = "white", color = "black", bins=bins) + | |
| stat_density(colour = "blue", geom="line", size = 1, position="identity", | |
| show.legend=FALSE) + | |
| theme(axis.title.x = element_blank()) |
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; | |
| int<lower = 1> p; | |
| matrix[n, p] X; | |
| int<lower = 0> y[n]; | |
| int<lower = 1> m; | |
| int<lower = 1, upper = n> n_each[m]; | |
| int<lower = 1, upper = n> idx[m, 2]; // start and stop indices for plots | |
| matrix<lower = 0>[n, n] D; | |
| } |