Skip to content

Instantly share code, notes, and snippets.

@mike-lawrence
mike-lawrence / rstan_parallel.R
Created October 9, 2012 22:58
Parallel computation of chains for rstan using doMC
library(rstan)
library(plyr)
library(doMC)
options(cores=4) #set this appropriate to your system
registerDoMC()
#This example assumes you have the rats.txt and rats.stan example files in your working directory
# rats.txt: http://wiki.stan.googlecode.com/git/rstangettingstarted/rats.txt
# rats.stan: http://stan.googlecode.com/git/src/models/bugs_examples/vol1/rats/rats.stan
@fonnesbeck
fonnesbeck / kernel_regression.py
Created April 3, 2014 11:23
Kernel regression using Theano
"""
Implementation of kernel regression:
"""
from pylearn.old_dataset.learner import OfflineLearningAlgorithm
from theano import tensor as T
from theano.tensor.nnet import prepend_1_to_each_row
from theano.scalar import as_scalar
from common.autoname import AutoName
import theano
@jrnold
jrnold / locallevel.stan
Created October 1, 2014 15:46
local level model in Stan reparameterized using Matt's trick
// Local Level model in Stan
// parameterized using Matt's Trick
data {
int n;
vector[n] y;
real<lower=0> theta1_mean;
real<lower=0> theta1_sd;
}
parameters {
real<lower=0> sigma_v;
# Some fake data
library(dplyr); library(rstan)
# Write out the data generation with known parameters
# Set the number of individuals
n_ind <- 50