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) | |
| library(gapminder) | |
| library(broom) | |
| library(ggplot2) | |
| life_exp_mods <- gapminder %>% | |
| #do this for each country | |
| group_by(country) %>% | |
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) | |
| library(ggplot2) | |
| library(visreg) | |
| #some fake data | |
| set.seed(35) | |
| my_data <- data.frame(x1 = runif(100,-50,50), x2 = runif(100, -50, 50)) %>% | |
| mutate(y = rnorm(100, 0.001*x2*(x1 - x1^2), 100)) | |
| #let's see that 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
| Traceback (most recent call last): | |
| File "/usr/local/bin/gdal_polygonize.py", line 36, in <module> | |
| import gdal, ogr, osr | |
| File "/Library/Frameworks/GDAL.framework/Versions/1.11/Python/2.7/site-packages/gdal.py", line 2, in <module> | |
| from osgeo.gdal import deprecation_warn | |
| File "/Library/Frameworks/GDAL.framework/Versions/1.11/Python/2.7/site-packages/osgeo/__init__.py", line 21, in <module> | |
| _gdal = swig_import_helper() | |
| File "/Library/Frameworks/GDAL.framework/Versions/1.11/Python/2.7/site-packages/osgeo/__init__.py", line 17, in swig_import_helper | |
| _mod = imp.load_module('_gdal', fp, pathname, description) | |
| ImportError: dlopen(/Library/Frameworks/GDAL.framework/Versions/1.11/Python/2.7/site-packages/osgeo/_gdal.so, 2): Symbol not found: _GTIFAllocDefn |
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 | |
| ########### | |
| library(sp) | |
| library(rgdal) | |
| library(rgeos) | |
| library(raster) | |
| library(tidyverse) | |
| library(spdplyr) |
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) | |
| library(broom) | |
| library(sp) | |
| library(spdplyr) | |
| library(ggplot2) | |
| library(rgdal) | |
| library(raster) | |
| library(rgeos) | |
| library(lubridate) |
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) | |
| library(broom) | |
| library(sp) | |
| library(spdplyr) | |
| library(ggplot2) | |
| library(ggmap) | |
| library(rgdal) | |
| library(raster) | |
| #read in spatialPolygonsDataFrame (shapefile) |
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: "Bayesian SEM with BRMS" | |
| author: "Jarrett Byrnes" | |
| date: "12/20/2017" | |
| output: html_document | |
| --- | |
| ```{r setup, include=FALSE} | |
| #http://sites.tufts.edu/emotiononthebrain/2017/08/12/blog-posting-from-r-markdown-to-wordpress/ | |
| knitr::opts_chunk$set(echo = TRUE) |
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
| #from rethinking library for numerically stable log sums | |
| log_sum_exp <- function (x) { | |
| xmax <- max(x) | |
| xsum <- sum(exp(x - xmax)) | |
| xmax + log(xsum) | |
| } | |
| #function for WAIC from an LM | |
| waic.lm <- function(mod, n.sims=1e3){ |
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(rethinking) | |
| #make a multivariate vector with known correlation | |
| sigma_mat <- matrix(c(1,.3, 0.2, | |
| 0.3, 1, 0.4, | |
| 0.2, 0.4, 1), nrow=3) | |
| z <- rmvnorm(1, c(0,0, 0), sigma_mat) | |
| z_2 <- z[2] | |
| z[2] <- NA |
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
| kelp_mod_noyear <- alist( | |
| kelp_s ~ dnorm(mu, sigma), | |
| mu <- a[time_idx], | |
| a[time_idx] ~ GPL2( Dmat , etasq , rhosq , delta_sq), | |
| sigma ~ dcauchy(0,5), | |
| etasq ~ dcauchy(0,2), | |
| delta_sq ~ dcauchy(0,2), |