Created
July 7, 2011 21:27
-
-
Save cboettig/1070581 to your computer and use it in GitHub Desktop.
Segue with custom packages
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(segue) | |
setCredentials(getOption("amazon_key"), getOption("amazon_secret")) | |
require(mcmcTools) | |
X <- rnorm(20, 2, 5) | |
loglik <- function(pars){ | |
sum( dnorm(X, mean=pars[1], sd=pars[2], log=TRUE) ) | |
} | |
prior <- function(pars){ | |
1/pars[2]^2 | |
} | |
pars <- list(c(mu=1,sigma=2), c(mu=1,sigma=2)) | |
# make sure local method works | |
local <- lapply(as.list(1,2), function(i) mcmcmc_fn(pars, loglik, prior)) | |
# launch cluster with packages, objects, evrything we will need | |
# include a CRAN package for demo purposes | |
myCluster <- createCluster(numInstances=2, cranPackages=c("sde"), rObjectsOnNodes=list(X=X,pars=pars,prior=prior,loglik=loglik), sourcePackagesToInstall=c("/home/cboettig/Documents/ucdavis/research/code/mcmcTools_0.0-1.tar.gz")) | |
# run the method on the cloud | |
cloud <- emrlapply(myCluster, as.list(1,2), function(i) mcmcmc_fn(pars, loglik, prior)) | |
# check that everything worked without error: | |
cloud | |
# stop the cluster to make sure we're not being billed. | |
stopCluster(myCluster) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment