Analysing output from cmdSTAN in R

473 views
Skip to first unread message

midy...@gmail.com

unread,
Mar 24, 2014, 11:03:00 PM3/24/14
to stan-...@googlegroups.com

Hi STAN Users,

Thanks in advance.

May I request you to assist me for the following please.

I am new to cmdSTAN.

I’ve compiled one example program in \stan-2.2.0\src\models\basic_estimators\bernoulli.stan and I’ve run the program using the following command:

stan-2.2.0>bernoulli sample data file=bernoulli.data.R

As a result, I can see an outfile file, output.csv,  in \stan-2.2.0\src\models\basic_estimators

How can I use this file in R to get some statistics for parameter theta and the response variable y? I am interested to get the statistics like in the WinBUGS / openBUGS.

Once again, thank you very much for the time you have given.

Regards,

Deb

Bob Carpenter

unread,
Mar 24, 2014, 11:21:00 PM3/24/14
to stan-...@googlegroups.com
If you're going to use R, I'd suggest just using RStan
directly in R. It has a range of output analysis tools
you can use. Here's a link:

http://mc-stan.org/rstan.html

- Bob
> --
> You received this message because you are subscribed to the Google Groups "stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Daniel Lee

unread,
Mar 25, 2014, 12:13:24 AM3/25/14
to stan-...@googlegroups.com
I second Bob's advice, but if you insist on using CmdStan and using R only for analysis, you can easily read the output files as csv files with '#' as a comment character. For example, this will provide a histogram and summary statistics about the theta parameter:

samples <- read.csv('output.csv', comment.char='#')
hist(samples$theta)
summary(samples$theta)


If you're using RStan, you can also read in the output files using the read_stan_csv() function.



Daniel

Reply all
Reply to author
Forward
0 new messages