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
## Spatio-temporal point process RSF helper functions | |
### | |
### Create spatial polygons object from a SpatialPoints object | |
### | |
voronoiPoly <- function(layer){ | |
require(deldir) | |
require(sp) | |
crds <- layer@coords | |
z <- deldir(crds[,1], crds[,2], rw=as.vector(t(bbox(layer)))) |
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(sp) | |
library(rgdal) | |
library(RColorBrewer) | |
library(spdep) | |
library(INLA) | |
library(grid) | |
library(gridExtra) | |
Greys <- colorRampPalette(brewer.pal(9,"Greys")) | |
#source("stpp_rsf_helper.R") | |
load("nfs_analysis/JAE_analysis_data_spatial.RData") |
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(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") |
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(sp) | |
library(rgdal) | |
library(raster) | |
library(gstat) | |
library(rgeos) | |
library(automap) | |
library(adehabitatHR) | |
source("stpp_rsf_helper.R") | |
# Read in telemtry |
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("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 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 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 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 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 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 ### |
OlderNewer