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) | |
######################################################################### | |
## Function to create prediction matrices from mgcv for glmmTMB | |
## from ?mgcv::smooth2random | |
######################################################################## | |
s2rPred <- function(sm,re,data) { | |
## Function to aid prediction from smooths represented as type==2 | |
## random effects. re must be the result of smooth2random(sm,...,type=2). |
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
#' @title Find the sections of a path that pass thorugh a restricted area | |
#' @description This function is used to identify sections of a path that pass through | |
#' restricted areas. the CTCRW model in crawl cannot actively steer paths away | |
#' from restricted areas as it knows nothing of spatial information. So, this function | |
#' will identify areas that for which the unrestrained path passes through these areas. | |
#' If the path/points end within the restricted area, those records will be removed. | |
#' The user can then use this information to adjust the path as desired. | |
#' @param xy A \code{SpatialPoints} object from the \code{sp} package or a | |
#' 2-column matrix of x and y locations | |
#' @param res_raster A \code{raster} object from the raster package that indicates |
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
### Load packages ### | |
# Must have 'marked' v >= 1.1.8 | |
library(marked) | |
# The splines package is only necessary for fitting b-spline curves used in the paper | |
# It is not required for the multivate models in the marked package | |
library(splines) | |
### Import and process data ### |
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(cowplot) | |
library(coda) | |
load("Sig_test_DJ.RData") | |
data = all_model | |
data$Year = factor(data$Year) | |
data = droplevels(data) | |
### Add beach variables | |
data$Beach4 = ifelse(data$Beach=="4", 1, 0) | |
data$Beach7 = ifelse(data$Beach=="7", 1, 0) |
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(rstan) | |
devtools::source_gist("8f675b9aa74ab9900fb4") | |
load("Sig_test_DJ.RData") | |
data = all_model | |
data$Year = factor(data$Year) | |
data = droplevels(data) | |
### Add beach variables | |
data$Beach4 = ifelse(data$Beach=="4", 1, 0) | |
data$Beach7 = ifelse(data$Beach=="7", 1, 0) |
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
### New growth function | |
logistic_growth = function(x, phi1, phi2, phi3){ | |
phi1/(1 + exp(-(x-phi2)/phi3)) | |
} | |
ll_logistic = function(par, y, xvar, phi1_dm, phi2_dm, phi3_dm, sigma_dm, sigma=1, predict=FALSE, scale=-2){ | |
n1 = ncol(phi1_dm) | |
n2 = ncol(phi2_dm) | |
n3 = ncol(phi3_dm) | |
if(!missing(sigma_dm)) n4 = ncol(sigma_dm) |
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
After you have installed gfortran from homebrew using | |
$ brew install gfortran | |
After installing R... add the following lines to ~/.R/Makevars | |
FC = /usr/local/bin/gfortran | |
F77 = /usr/local/bin/gfortran | |
FLIBS = -L/usr/local/Cellar/gcc/4.9.2_1/lib/gcc/4.9 -lgfortran -lquadmath -lm | |
and openblas using | |
$ brew install openblas |
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("marked") | |
#### Some preliminaries ### | |
ilogit = function(x){log(x/(1-x))} | |
min.adult.age=5 | |
additional.resight=3 | |
adult.age="stable" | |
set.seed(111) | |
n.rel.pup=c(138,57,38,250,rep(100,4)) |
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(sp) | |
library(rgdal) | |
library(raster) | |
library(gstat) | |
library(rgeos) | |
library(automap) | |
library(adehabitatHR) | |
source("stpp_rsf_helper.R") | |
# Read in telemtry |
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(sp) | |
library(rgdal) | |
library(raster) | |
library(gstat) | |
library(rgeos) | |
library(automap) | |
library(mgcv) | |
source("stpp_rsf_helper.R") | |
load("nfs_analysis/JAE_analysis_data_st.RData") | |
# load("stQuadList_countVersion.RData") |
NewerOlder