[R] conditions simpler way

Prof Brian Ripley ripley at stats.ox.ac.uk
Sun Jun 5 10:42:28 CEST 2011


To drop the burnin period

xx <- x1$x[-seq_len(burnin)]

And it sounds like you want

mean(xx > -1 & xx < 2]

but your code and description differ.

On Sun, 5 Jun 2011, Kehl Dániel wrote:

> Dear All,
>
> I have a MCMC result in x1. I was wondering if there is a simpler, more 
> elegant way of evaluating the estimate of an integral then this (I am pretty 
> sure there is):
> Also if I want to count the x's say -1<x<2 but not the ones in the burn in 
> period.
>
> [code]
> z <- -2
> burnin <- 2000
> int1 <- 
> length(x1$x[(burnin+1):length(x1$x)][x1$x[(burnin+1):length(x1$x)]<z])/(length(x1$x)-burnin)
> [\code]
>
> Thank you:
> Daniel
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


More information about the R-help mailing list