Skip to content

Instantly share code, notes, and snippets.

View mbjoseph's full-sized avatar

Max Joseph mbjoseph

View GitHub Profile
@mbjoseph
mbjoseph / community_occ.R
Created January 23, 2013 04:22
Dynamic community occupancy model in R and JAGS example
# Multi-species dynamic occupancy model with R and JAGS
# Written by Max Joseph
# maxwell.b.joseph@colorado.edu
# see http://www.colorado.edu/eeb/gradstudents/joseph/community_occ.html
# for details
# convenience functions
logit <- function(x) {
log(x/(1 - x))
}
---
title: "Coloring lidar point clouds with RGB imagery in R"
author: "Max Joseph"
date: "June 30, 2016"
output:
html_document:
keep_md: true
---
```{r setup, echo = FALSE}
@mbjoseph
mbjoseph / template.Rmd
Created August 22, 2016 19:53
A R markdown beamer template that doesn't suck that much.
---
title: "Your title here"
subtitle: a clever subtitle
author: "Your name"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output:
beamer_presentation:
latex_engine: xelatex
fonttheme: "structurebold"
header-includes:
@mbjoseph
mbjoseph / lm_segs.stan
Last active September 12, 2016 04:38
Piecewise regression w/ unknown breakpoint in Stan
data {
int<lower=1> n;
vector[n] x;
vector[n] y;
}
parameters {
real alpha;
vector[2] beta;
real<lower=0> sigma;
# Importing data from USDA into large data file ---------------------------
library(stringr)
library(dplyr)
path_to_data <- "~/Desktop/ams_cattle_data/"
data_files <- list.files(path = path_to_data, pattern = "cattle",
full.names = TRUE)
# Define helper functions -------------------------------------------------
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mbjoseph
mbjoseph / small-sample-weibull.R
Created November 22, 2016 20:47
Exploring how sample size affects the estimates of Weibull shape and scale parameters
# Script to evaluate small sample behavior of Weibull parameter MLEs --------
library(fitdistrplus)
library(dplyr)
library(tidyr)
library(gridExtra)
library(parallel)
library(ggplot2)
library(viridis)
@mbjoseph
mbjoseph / parallel-loop-unroll.R
Last active December 9, 2016 17:38
How to unroll a nested for-loop in R so that it can be run in parallel
library(parallel)
# Create matrix to store result -------------------------------------------
M <- 4
N <- 6
A <- matrix(0, nrow = M, ncol = N)
list <- list(3, 4, 6)
# Serial version ----------------------------------------------------------
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mbjoseph
mbjoseph / modis.py
Created June 13, 2016 17:28
Python script to grab modus data
#===============================================================================
# Date: May 22, 2016
# Author: Lindy Nelson
# Purpose: This script downloads monthly MODIS burn data from
#
#
# FTP Server: fuoco.geog.umd.edu
#
#