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
| data { | |
| int N; | |
| int M; | |
| real<lower=0> Y[N]; | |
| } | |
| parameters { | |
| real<lower=0> mu; | |
| real<lower=0> phi; | |
| real<lower=1, upper=2> theta; |
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
| # Distance sampling model with data augmentation. | |
| # Based on section 8.3.1 of the Applied Hierarchical Modeling book by Royle and Kery | |
| library(rstan) | |
| B <- 50 | |
| # note that I'm dividing by 10 and adding 1e-6 to put this on a manageable | |
| # scale and prevent values == 0 | |
| d_obs <- c(71.93, 26.05, 58.47, 92.35, 163.83, 84.52, 163.83, 157.33, |
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: "Surface temperatures of albatross eggs and nests" | |
| author: Philipp H. Boersch-Supan^A,B,C^, Leah R. Johnson^D^, Richard A. Phillips^E^, | |
| Sadie J. Ryan^A,B^ | |
| date: '' | |
| output: | |
| word_document: | |
| keep_md: yes | |
| reference_docx: marine_ornithology_style_ref.docx | |
| pdf_document: |
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(gganimate) | |
| library(mgcv) | |
| library(mvtnorm) | |
| # Fit a GAM to the data | |
| mod <- gam(hp ~ s(mpg), data=mtcars, method="REML") | |
| # Get the linear prediction matrix | |
| newdat = data.frame( |
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(dplyr) | |
| system.time(df3 <- left_join(select(df1, lat, lon, id, time_hour), | |
| select(df2, lat, lon, var1, var2, time_words), | |
| by = c('lat', 'lon', 'time_hour' = 'time_words') | |
| ) | |
| ) | |
| #21.37 seconds |
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
| require(dplyr) | |
| nuts1 <- readr::read_csv('NUTS1_kmsq.csv') | |
| nuts1 %>% group_by(ONEKMREF) %>% summarise(biggest_area = max(kmsq_Area), biggest_area_index = which.max(kmsq_Area), biggest_area_name = Region_name[biggest_area_index] ) -> solution_df | |
| #check for areas with multiple regions | |
| nuts1 %>% group_by(ONEKMREF) %>% summarise(n_rows = n()) %>% arrange(desc(n_rows)) %>% head() |
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: "Academic moves" | |
| author: "Philipp Boersch-Supan" | |
| date: "2018-02-17" | |
| output: | |
| html_document: | |
| keep_md: yes | |
| --- | |
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
| gc() | |
| #devtools::install_github("pboesu/rucrdtw", ref = "expose_distance_calculations") | |
| library(rucrdtw) | |
| set.seed(12444) | |
| x = rnorm(10^4) | |
| y = rnorm(10^4) | |
| gctorture(on = TRUE) | |
| for (i in 1:(2*10^3)) { |
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
| Warning: Function cummax has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict. | |
| >> edit ths_ds1.dat | |
| >> [t,s]=ldf('ths_ds1.dat'); | |
| clf | |
| plot(t,s,'o') | |
| xlabel('Time in seconds') | |
| ylabel('Drawdown in meters') | |
| title('The Fetter data set') | |
| >> diagnostic(t,s) | |
| Attempted to access Dk(:,2); index out of bounds because |
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
| #!/bin/bash | |
| # This map is a quick and dirty adaptation of GMT EXAMPLE 25 | |
| # (using GMT 5.4.0_r17345) | |
| # Purpose: Display distribution of antipode types around NZ | |
| # GMT modules: gmtset, grdlandmask, grdmath, grd2xyz, gmtmath, grdimage, pscoast, pslegend | |
| # Unix progs: cat | |
| # | |
| # Create D minutes global grid with -1 over oceans and +1 over land | |
| D=10 | |
| gmt grdlandmask -Rg -I${D}m -Dc -A500 -N-1/1/1/1/1 -r -Gwetdry.nc |
NewerOlder