Announcement

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

  • create observations in a random sample

    Consider the following procedure yi=-5+xi+ui, where xi are generated from a random sample of the uniform distribution on the interval [0,10]; ui is obtained from the standard normal distribution. With this information, construct the observations for yi.

  • #2
    You may revise the sample size below.

    Code:
    clear
    insobs 1000
    gen y = 5 + runiform(0,10) + rnormal()
    Or

    Code:
    clear
    insobs 1000
    gen x = runiform(0,10)
    gen u = rnormal()
    gen y = 5 + x + u
    The second is better as you may need to do more simulations based on the same x.
    Last edited by Fei Wang; 29 Jun 2022, 20:11.

    Comment


    • #3
      thanks

      Comment

      Working...
      X