Olena,
From my understanding, your interpretation of rexp is
correct. It simulates n times the exponential distribution.
For the Vectorize question, take a look on pg19 of Patrick's primer.
He solves for E[x] of a beta distribution
If we wanted to calc the Var(beta distribution).. You can easily manipulate the function
to solve for E[x^2]
...and then subsequently calc, Var = E[x^2] - E[x]^2
You can try something similar w/r to the Exp. Distr
slight change to your function:
lambda*e^(-lambda*x)? --> lambda*exp(-lambda*x)
Best.
________________________________________
From: gov2001-l-bounces at
lists.fas.harvard.edu [gov2001-l-bounces at
lists.fas.harvard.edu] On Behalf Of Olena Ageyeva [eageeva at
hotmail.com]
Sent: Thursday, February 19, 2009 11:37 AM
To: gov2001-l at
lists.fas.harvard.edu
Subject: [gov2001-l] (no subject)
Thank your for your help. The examples were extremely helpful!
Can anyone explain me how rexp(n, rate) works? Is rate equal to lambda? Is that
simulation for the function: lambda*e^(-lambda*x)?
Also, do I use a right formula for variance? I get an error when I try to Vectorize() it.
Without vectorizing everything works fine.
Var<-function(x,lambda){E((x-E(x,lambda))^2,lambda)}
Var.x<-integrate(Vectorize(Var),lambda,lower=0,
upper=Inf)
Error in eval(expr, envir, enclos) :
..1 used in an incorrect context, no ... to look in
Sincerely,
Olena Ageyeva
________________________________
Get more out of the Web. Learn 10 hidden secrets of Windows Live. Learn
Now<http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blo…