Advertisement
Guest User

Untitled

a guest
Mar 31st, 2021
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.66 KB | None | 0 0
  1. # true parameters
  2. gamma =  3
  3. beta  =  1
  4. theta = -1
  5. delta =  2
  6.  
  7. # explanatories
  8. x     = rnorm(250)
  9. z     = x * gamma + rnorm(250)
  10.  
  11. # errors
  12. err   = rnorm(250)
  13.  
  14. # dgp1
  15. y     = z * theta + x * beta + err
  16.  
  17. lm(y ~ z + x - 1) # good estimate of theta
  18.  
  19. # dgp2
  20. y     = (z - x * gamma) * theta + x * beta + err
  21.  
  22. lm(y ~ z + x - 1) # equivalent estimate of theta
  23.  
  24.  
  25. # dgp3
  26.  
  27. y     = z * theta + x * z * delta + x * beta + err
  28.  
  29. lm(y ~ z + x + z * x - 1) # good estimates of theta and delta
  30.  
  31.  
  32.  
  33. # dgp4
  34.  
  35. y     = (z - x * gamma) * theta + x * (z - x * gamma) * delta + x * beta + err
  36.  
  37. lm(y ~ z + x + z * x - 1) # good estimate of theta, bad estimate of delta
  38.  
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement