Announcement

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

  • How to obtain artificial data conditional on known mean and variance of random variables

    I am an absolute beginner to MATA. I wish to write a program that demands as input from the user both a variance-covariance matrix and the means of 2 normally distributed random variables. As is standard, the diagonal elements of the variance-covariance matrix denotes the variances of these variables and the off diagonal elements denote their covariance. Once the user inputs these parameters, the program should produce as output, say, 200 realizations of each of these variables that is consistent with the statistical process inputted by the user. Any help is greatly appreciated.

  • #2
    You should probably work your way to that objective gradually. Start by writing simpler programs in Mata, say, at a "Hello, world" level, so that you gain knowledge of its syntax rules, familiarity with at least a handful of its commonly used built-in functions, and learn how to find things in the Mata help files. Then work your way up to creating a pair of (uncorrelated) normal random variables, having Mata place them in the Stata dataset, if that's your ultimate goal. Then Google generating correlated normal random variables or something similar in order to get the algorithm.

    I don't recommend it, but if you want to get immersed in the problem quickly, then you can
    Code:
    viewsource drawnorm.ado
    for clues, and you can look a the Methods and formula section in the user's manual's entry for the drawnorm command. The bivariate-normal case can be implemented without the matrix operations involved there, though.

    Comment

    Working...
    X