library(tidyverse)
#> Warning: package 'tibble' was built under R version 4.0.2
#> Warning: package 'tidyr' was built under R version 4.0.2
#> Warning: package 'dplyr' was built under R version 4.0.2
tibble(x = 0:42,
y1 = pbinom(x, 42, 0.3),
y2 = 1-pbeta(0.3, x+1, 42-x)) %>%
ggplot(aes(x = x, y = y1)) +
geom_point(col = "green", size = 3) +
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(shiny) | |
library(bslib) | |
library(thematic) | |
library(ggplot2) | |
thematic::thematic_shiny(font = "auto") | |
# take a vector, make a histogram |
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: "Exploring observations" | |
author: "Andrew, based on Tim's lecture!" | |
date: "18/05/2020" | |
output: html_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = 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
m <- 0.086 | |
o <- (1-m)/m | |
curve((sqrt(o) - sqrt(o^-1)) / sqrt(x^2 - x + 1), xlim = c(0,50)) | |
abline(h = 1/3) |
library(tidyverse)
cv <- 2.5
sigma = seq(0.2,5,by = 0.2)
list(mean = sigma / cv, sd = sigma) %>% transpose %>%
set_names(., nm = map_chr(., lift_dl(paste, sep="_"))) %>%
map(lift_dl(partial, .f = dnorm)) %>%
map_df(~ tibble(x = seq(-2,3.5,0.01),
y = .x(x)), .id = "mean_sd") %>%
ggplot(aes(x = x, ymax = y, ymin = 0, fill = mean_sd)) + geom_ribbon() +
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
pwr <- function(S, a, mu = 0.086, phi=240){ | |
D <- S * (S - 1) | |
2 * (D + 1) * (D/(phi + 1) + 1) * mu * ( 1 - mu) + ( a * mu + mu) * (1 - a * mu - mu) * (2.8)^2 / ((D + 1)*a*mu)^2 | |
} | |
pwr(6, 0.10) | |
curve(pwr(x, 0.4), xlim = c(3,30)) | |
curve(pwr(x, 0.2), xlim = c(3,30), log = "y") |
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
using Plots | |
# a vector of r values | |
Rs=collect(0.1:0.001:3) | |
T = 5000 | |
N=zeros(length(Rs), T) | |
#Set t0 values to 1 | |
N[:,1] .= 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
info <- function(x, a, b) { | |
a * (exp(a * (x - b))) / (exp(a * b) + exp(a * x)) ^ 2 | |
} |
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(tidyverse) | |
set.seed(4812) | |
islands <- data_frame(area = | |
# runif(35, min = 0, max = 29) | |
rlnorm(35, meanlog = log(5), sdlog = log(3)) | |
) | |
dragon_response <- function(b0, b1){ | |
force(b0) | |
force(b1) |
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
simulate_one_cardoso <- function(.cardoso_island = cardoso_island){ | |
spp_names <- unique(.cardoso_island$morphospecies) | |
nspp <- length(spp_names) | |
bromeliad_names <- unique(.cardoso_island$Bromeliad) | |
nbrom <- length(bromeliad_names) | |
# simulate from the parameters: | |
b_intercept <- rnorm(1, 1, 0.2) |
NewerOlder