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
| # https://frbcesab.github.io/rwosstarter/ | |
| remotes::install_github("frbcesab/rwosstarter") | |
| library(rwosstarter) | |
| # Use the function rwosstarter::wos_search() to get the total number of references that match the Web of Science query. | |
| ?rwosstarter::wos_search() | |
| ## Search in TOPIC an exact expression ---- | |
| query <- "TS=\"salmo salar\"" |
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(spatstat) | |
| #------- HOMOGENEOUS | |
| # spatial point pattern from a homogeneous Poisson process with intensity lambda = 100 | |
| # in the window A = [0,1]x[0k2] which has area |A| = 2 | |
| phom <- rpoispp(lambda = 100, | |
| win = owin(xrange = c(0, 1), yrange = c(0, 2))) | |
| phom$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
| # Kod modifierad från Rafael Irizarry | |
| # https://simplystatistics.org/2017/08/08/code-for-my-educational-gifs/ | |
| library(dplyr) | |
| library(magick) | |
| library(ggplot2) | |
| theme_set(theme_minimal()) | |
| # Simulera data. | |
| N <- 100 | |
| Sigma <- matrix(c(1, 0.75, 0.75, 1), 2, 2) * 1.5 |
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
| # AUTHOR: Shade Wilson | |
| # EMAIL: [email protected] | |
| # DESCRIPTION: The following function is a simulation of the random walk phenomena. | |
| # It uses the runif() funtion to return a uniform random number from 0 to 1, which is then | |
| # scaled up to between 0 and 2pi. The number is then used as an angle, and the coordinate | |
| # changes are calculated using the sin and cos values. random_walk() has three optional | |
| # arguments: time, gradient, and step_size. | |
| # The time argument specifies how many points you want | |
| # to create, or more generally, how long you want the simulation to run. There's a 1:1 ratio of |
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) | |
| url <- "https://www.metoffice.gov.uk/hadobs/hadcet/data/legacy/cetdl1772on.dat" | |
| df_raw <- read_tsv(url, col_names = FALSE) | |
| div_10 <- function(...){ | |
| .../10 | |
| } |
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
| # libraries needed | |
| library(tidyverse) | |
| library(viridis) | |
| library(gganimate) | |
| library(wbstats) | |
| # rosling chart in one command | |
| # pull the country data down from the World Bank - three indicators |
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(glmmTMB) | |
| library(mgcv) | |
| library(magrittr) | |
| ## Continuous covariate | |
| x <- seq(1,10, length=100) | |
| ## Set up penalized thin-plate regression spline for x | |
| sm <- mgcv::smoothCon(s(x), data=as.data.frame(x))[[1]] | |
| ## null space columns |
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
| # The purpose of thise script is to generate a list of formula combinations, | |
| # which can later be used for model fitting using unmarked::pcountOpen | |
| library(tidyverse) | |
| lambda_opts <- c("1","NorthCove") | |
| gamma_opts <- c("1","NorthCove","Year") | |
| omega_opts <- c("1","NorthCove","Year") | |
| detec_opts <- c("1","NorthCove","Year") | |
| param_list <- list(lambda_opts, gamma_opts, omega_opts, detec_opts) |
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
| ################################################ | |
| ## Functions for derivatives of GAM(M) models ## | |
| ################################################ | |
| Deriv <- function(mod, n = 200, eps = 1e-7, newdata, term) { | |
| if(inherits(mod, "gamm")) | |
| mod <- mod$gam | |
| m.terms <- attr(terms(mod), "term.labels") | |
| if(missing(newdata)) { | |
| newD <- sapply(model.frame(mod)[, m.terms, drop = FALSE], | |
| function(x) seq(min(x), max(x), length = 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
| # Bioeconomic model from Milner-Gulland & Rowcliffe, p. 163-... | |
| # define constants | |
| K = 1000 # carrying capacity | |
| r = 0.2 # intrinsic rate of increase | |
| P = 105 # price | |
| a = 200 # constant for cost calculation | |
| b = 0.2 # constant for cost calculation | |
| s = 10 # SD of the distribution for the cost | |
| N1 = 500 # initial pop size |
NewerOlder