Another version of this gist with figures included is on Rpubs
Recently I was trying to put confidence intervals on a regression line, and I got some excellent advice from @davidjayharris on Twitter, who suggested the below method in an excellent
info <- function(x, a, b) { | |
a * (exp(a * (x - b))) / (exp(a * b) + exp(a * x)) ^ 2 | |
} |
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) |
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) |
library(brms) | |
library(tidyverse) | |
# we're going to have 5 animals | |
nspp <- 5 | |
# in 100 sites | |
nsites <- 100 | |
#abilities are between -1 and 1, from a normal distribution: | |
thetas <- rnorm(nspp, 0, 1.2) |
#!/bin/bash | |
# Usage: mkproj [projectname] | |
# projectname defaults to name of current directory | |
template="Version: 1.0\nRestoreWorkspace: Default\nSaveWorkspace: Default\nAlwaysSaveHistory: Default\n\nEnableCodeIndexing: Yes\nUseSpacesForTab: Yes\nNumSpacesForTab: 4\nEncoding: UTF-8\n\nRnwWeave: knitr\nLaTeX: pdfLaTeX" | |
wd=$(basename `pwd`) | |
if [ -z $1 ]; then |
library(pageviews) | |
require(lubridate) | |
today <- pageview_timestamps() | |
earlysept <- pageview_timestamps(lubridate::ymd("2017-09-01")) | |
korsmit <- pageviews::article_pageviews("en.wikipedia", "Roy_Kortsmit", start = earlysept, end = today) | |
korsmit %>% | |
ggplot(aes(x = date, y = views)) + theme_minimal() + geom_line() + geom_point() + | |
labs(title = "Roy Kortsmit wikipedia pageviews", subtitle = "Before and after he made 4 saves in 5s.") |
Another version of this gist with figures included is on Rpubs
Recently I was trying to put confidence intervals on a regression line, and I got some excellent advice from @davidjayharris on Twitter, who suggested the below method in an excellent
I hereby claim:
To claim this, I am signing this object:
rmax <- function(rm, baserate){ | |
force(rm) | |
force(baserate) | |
function(x) { | |
rm * x / ( | |
(rm / baserate) + x | |
) | |
} | |
} |