Hi, Sara.
Next, think about what your code is doing. You store b every time you run
the loop. This means that only the last value of b is returned. (It's
great that you got this far already, btw.) So how can you make R store
every value of b rather than just the last value?
Think about how i works in this context. You actually have a value i
which you observe inside the loop which keeps track of which iteration
you're on. You need to use i to tell R where to store the b's for the ith
run. Look at Zelig, p. 51 for a hint.
So think about this some more and send me another email if you get stuck.
Olivia.
On Tue, 28 Sep 2004, Sara Bleich wrote:
Olivia,
I am stuck on part b of the homework and I was hoping you could help. I am
using the following code:
sims <- 10
for (i in 1:sims){
b<-here I put the beta equation
}
After running this loop, I and looking at "b" I am only getting two values,
one for x1 and one for x2. Is that right or should I be getting 10 values
for x1 and 10 values for x2 since I set sims to 10? Since part c is asking
for confidence intervals it seems as if I would need to know all the means
in order to answer the question correctly. Thanks for your help.
Sara
Ph.D. Candidate in Health Policy
Harvard University
bleich(a)fas.harvard.edu
M: 617.899.5016
W: 617.495.5602