Save the summary of the parameters

281 views
Skip to first unread message

Lee Ang Ling

unread,
Jan 8, 2014, 9:00:39 PM1/8/14
to stan-...@googlegroups.com
In Rstan,  print  are defined to work with the samples, conduct model inference, and assess the convergence of the Markov chains. But, print can't save the results into a matrix table. Now, I'm using coda package to get the posterior mean, sd, R hat, and effective size. Does Rstan has the default function to do this job?

Thanks

Jiqiang Guo

unread,
Jan 9, 2014, 8:02:57 PM1/9/14
to stan-...@googlegroups.com
there is a function called summary, which is referred to in the help of function print. 



On Wed, Jan 8, 2014 at 9:00 PM, Lee Ang Ling <leean...@gmail.com> wrote:
In Rstan,  print  are defined to work with the samples, conduct model inference, and assess the convergence of the Markov chains. But, print can't save the results into a matrix table. Now, I'm using coda package to get the posterior mean, sd, R hat, and effective size. Does Rstan has the default function to do this job?

Thanks

--
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/groups/opt_out.

Lee Ang Ling

unread,
Jan 10, 2014, 11:57:44 AM1/10/14
to stan-...@googlegroups.com
Summary function not work, no result is returned.

Sergio Polini

unread,
Jan 10, 2014, 12:20:10 PM1/10/14
to stan-...@googlegroups.com
Il 10/01/2014 17:57, Lee Ang Ling ha scritto:
> Summary function not work, no result is returned.

Let's say that sf is your stanfit objeft. Try:

> sf.summ <- summary(sf)
> str(sf.summ)
> sf.summ$summary[1,1:10]

etc.

Sergio

>
> On Thursday, January 9, 2014 7:02:57 PM UTC-6, Jiqiang Guo wrote:
>
> there is a function called summary, which is referred to in the help
> of function print.
>
>
>
> On Wed, Jan 8, 2014 at 9:00 PM, Lee Ang Ling <leean...@gmail.com
> <javascript:>> wrote:
>
> In Rstan, *print * are defined to work with the samples, conduct
> model inference, and assess the convergence of the Markov
> chains. But, *print *can't save the results into a matrix table.
> Now, I'm using coda package to get the posterior mean, sd, R
> hat, and effective size. Does Rstan has the default function to
> do this job?
>
> Thanks
>
> --
> 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 <javascript:>.
> For more options, visit https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.

Bob Carpenter

unread,
Jan 10, 2014, 12:49:37 PM1/10/14
to stan-...@googlegroups.com
If you report a potential bug, it really helps us debug it
if you can post what you entered and what RStan returned.

Just saying it doesn't work doesn't give us much to go on.

- Bob


On 1/10/14, 5:57 PM, Lee Ang Ling wrote:
> Summary function not work, no result is returned.
>
> On Thursday, January 9, 2014 7:02:57 PM UTC-6, Jiqiang Guo wrote:
>
> there is a function called summary, which is referred to in the help of function print.
>
>
>
> On Wed, Jan 8, 2014 at 9:00 PM, Lee Ang Ling <leean...@gmail.com <javascript:>> wrote:
>
> In Rstan, *print * are defined to work with the samples, conduct model inference, and assess the convergence of
> the Markov chains. But, *print *can't save the results into a matrix table. Now, I'm using coda package to get
> the posterior mean, sd, R hat, and effective size. Does Rstan has the default function to do this job?
>
> Thanks
>
> --
> 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 <javascript:>.
> For more options, visit https://groups.google.com/groups/opt_out <https://groups.google.com/groups/opt_out>.

Sergio Polini

unread,
Jan 10, 2014, 1:04:54 PM1/10/14
to stan-...@googlegroups.com
Il 10/01/2014 18:49, Bob Carpenter ha scritto:
> If you report a potential bug, it really helps us debug it
> if you can post what you entered and what RStan returned.
>
> Just saying it doesn't work doesn't give us much to go on.

Bob, summary works but ends with "invisible(ss)", so if you type:

> summary(sf)

it looks like as if it returns nothing.
I don't like those "invisible" (a matter of taste), but

> print(summary(sf))

or

> something <- summary(sf)
> str(summary)

work very well.

Cheers

Sergio

Lee Ang Ling

unread,
Jan 10, 2014, 1:08:31 PM1/10/14
to stan-...@googlegroups.com
Hi Bob,

I'm sorry for the confusing. What I really mean is that the summary function didn't return any result to me.

Here is the logs:
 fit <- stan(model_code = schools_code, data = schools_dat,
+             iter = 1000, chains = 2)

TRANSLATING MODEL 'schools_code' FROM Stan CODE TO C++ CODE NOW.
COMPILING THE C++ CODE FOR MODEL 'schools_code' NOW.
/home/llin/Rlibs/rstan/include//stansrc/stan/agrad/rev/var_stack.hpp:49: warning: âvoid stan::agrad::free_memory()â defined but not used
SAMPLING FOR MODEL 'schools_code' NOW (CHAIN 1).
Iteration: 1000 / 1000 [100%]  (Sampling)
Elapsed Time: 0.01 seconds (Warm-up)
              0.01 seconds (Sampling)
              0.02 seconds (Total)

SAMPLING FOR MODEL 'schools_code' NOW (CHAIN 2).
Iteration: 1000 / 1000 [100%]  (Sampling)
Elapsed Time: 0.02 seconds (Warm-up)
              0.01 seconds (Sampling)
              0.03 seconds (Total)

> fit2 <- stan(fit = fit, data = schools_dat, iter = 10000, chains = 4)
SAMPLING FOR MODEL 'schools_code' NOW (CHAIN 1).
Iteration: 10000 / 10000 [100%]  (Sampling)
Elapsed Time: 0.11 seconds (Warm-up)
              0.11 seconds (Sampling)
              0.22 seconds (Total)

SAMPLING FOR MODEL 'schools_code' NOW (CHAIN 2).
Iteration: 10000 / 10000 [100%]  (Sampling)
Elapsed Time: 0.13 seconds (Warm-up)
              0.1 seconds (Sampling)
              0.23 seconds (Total)



> summary(fit2)
(nothing returned)

Thanks


To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to a topic in the Google Groups "stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/2tqMrAnlM4I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+unsubscribe@googlegroups.com.

Lee Ang Ling

unread,
Jan 10, 2014, 1:11:33 PM1/10/14
to stan-...@googlegroups.com
Hi Sergio,

It works. Thank you.

lee




--
You received this message because you are subscribed to a topic in the Google Groups "stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/2tqMrAnlM4I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+unsubscribe@googlegroups.com.

Bob Carpenter

unread,
Jan 10, 2014, 1:50:41 PM1/10/14
to stan-...@googlegroups.com
That is confusing. Especially given the doc, which says summary
"summarizes". I think we should either (a) have it print by
default (perhaps with a flag to turn it off), or (b) change the
doc to make it clear that there's no output by default.

- Bob

Sergio Polini

unread,
Jan 10, 2014, 4:20:26 PM1/10/14
to stan-...@googlegroups.com
Il 10/01/2014 19:50, Bob Carpenter ha scritto:
> That is confusing. Especially given the doc, which says summary
> "summarizes". I think we should either (a) have it print by
> default (perhaps with a flag to turn it off), or (b) change the
> doc to make it clear that there's no output by default.

Other functions that return "invisible" results:

get_stancode() perhaps confusing but wise
get_stanmodel() perhaps confusing but wise
get_inits() why?
get_posterior_mean() why?
get_logposterior() perhaps confusing but wise
get_adaptation_info() why?

As to get_sampler_params(), please see
https://groups.google.com/d/msg/stan-users/Nn2I9gvbSmY/6hxe4fEpOvIJ.

Cheers

Sergio

Reply all
Reply to author
Forward
0 new messages