Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Simulation of sample size

    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

  • #2
    Sounds like a homework problem. Here are some tips:

    . help graph combine
    . help rename


    It's not at all clear why you think

    . gen y = 9-1.5*(uniform1)+0.85*(normal2)+normal3

    is the correct way to achieve

    y = 25 - 2(x1) + 0.95(x2) + e

    so you may want to provide more context.

    cheers,
    J


    Comment

    Working...
    X