Skip to content

Nathaniel-Haines/cmdstanr-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

cmdstanr-docker

This repository contains a docker image for cmdstanr version 0.4.0. It also contains R version 4.1.0

Installation

The image is hosted on dockerhub here. Therefore, with docker already installed,you can pull the image to your local machine using the following command:

docker pull nathanielhaines/cmdstanr

Running the image

Once the image is installed, you can open a bash terminal using the following command:

docker run -it nathanielhaines/cmdstanr

Testing the installation

From the terminal, you can run the following example code to see cmdstanr in action:

Rscript cmdstanr-example.R

This will run the following R code:

# Load cmdstanr
library(cmdstanr)

# Get the compiled stan file for this example
file <- file.path(cmdstan_path(), "examples", "bernoulli", "bernoulli.stan")
mod <- cmdstan_model(file)

# Create some fake data and fit the model
data_list <- list(N = 10, y = c(0,1,0,0,0,0,0,0,0,1))

fit <- mod$sample(
  data = data_list,
  seed = 123,
  chains = 4,
  parallel_chains = 4,
  refresh = 500
)

# Summarize the results
fit$summary()

About

docker image for cmdstanr

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published