On Fri, Jun 22, 2012 at 5:13 AM, Mohan Radhakrishnan <mohanr at fss.co.in>
wrote:> Hi,
>
>
>
> ? ? ?Is there a way to calculate variance directly by specifying
> confidence interval using R ? I am specifically asking because I wanted
> to investigate how this could be useful for project schedule variance
> calculation.
This question seems -- to me -- to be somewhat ill-specified. At
first, there's some ambiguity about what exactly a confidence interval
is and means (a trickier question than most people realize) or how it
should be constructed, which is almost always done by knowing the
distribution of the underlying thing [intentionally vague].
I'll go out on a limb and guess that you're really thinking of
something more like this:
http://www.johndcook.com/quantiles_parameters.pdf
>
>
>
> Moreover I am interested in using R for monte carlo simulation as well
> and any simple examples would help. I read that project schedules would
> benefit from this.
>
>
This seems an entirely different question. And MC simulation is a
massive field, but here's a very trivial example you can think
through.
What is the variance of the sample median of a draw of 50 samples from
a N(0, 5) distribution? In a one liner,
set.seed(1)
system.time(x1 <- var(replicate(1e4, median(rnorm(50, 0, 5)))))
More efficiently,
set.seed(1)
library("matrixStats")
system.time(x2 <- var(colMedians(matrix(rnorm(50*1e4, 0, 5), ncol = 1e4))))
identical(x1, x2)
Best,
Michael
>
> Thanks,
>
> Mohan
>
>
>
> DISCLAIMER:\ ===============...{{dropped:31}}
>
> ______________________________________________
> 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.