Hi guys, I was just hoping to get some advice with stata simulation
I'm playing around with a couple of variables, x1 - uniform distribution, (5,10), x2 - normal distribution (5/2.5) and e which is. normal dist (0/1)
So the question is trying to generate these, and put it into a single outcome variable where
y = 25 - 2(x1) + 0.95(x2) + e
So assuming I'm working with a sample size of 10,000
set obs 10000
for x1
gen uniform1 = runiform(5,10)
histogram uniform1, graphregion(color(white))
for x2
gen normal2 = rnormal(5,2.5)
histogram normal2, normal graphregion(color(white))
I've managed to get separate histos, but to combine i've tried 'graph combine', but do i need to label the graphs to use it in this setting?
also what would be the best way to generate outcome variable for y?
assuming that i can get e using the following
gen normal3 = rnormal(0,1)
is the below the correct way to approach?
generate y=9-1.5*(uniform1)+0.85*(normal2)+normal3
Also, how would i go about renaming variables X1 X2 e and Y to age, screen, sleep and error respectively.
Help would be much appreciated
I'm playing around with a couple of variables, x1 - uniform distribution, (5,10), x2 - normal distribution (5/2.5) and e which is. normal dist (0/1)
So the question is trying to generate these, and put it into a single outcome variable where
y = 25 - 2(x1) + 0.95(x2) + e
So assuming I'm working with a sample size of 10,000
set obs 10000
for x1
gen uniform1 = runiform(5,10)
histogram uniform1, graphregion(color(white))
for x2
gen normal2 = rnormal(5,2.5)
histogram normal2, normal graphregion(color(white))
I've managed to get separate histos, but to combine i've tried 'graph combine', but do i need to label the graphs to use it in this setting?
also what would be the best way to generate outcome variable for y?
assuming that i can get e using the following
gen normal3 = rnormal(0,1)
is the below the correct way to approach?
generate y=9-1.5*(uniform1)+0.85*(normal2)+normal3
Also, how would i go about renaming variables X1 X2 e and Y to age, screen, sleep and error respectively.
Help would be much appreciated
Comment