How to create matrix in Stata

736 views Asked by At

I want to make a sample of two variables, according to a specific probability distribution. I thought of making a matrix that expresses the probability distribution but my code results in p is not defined.

p = matrix(c(0.04,0.1,0,0.06,0.05,0.3,0,0.05,0.14,0.1,0.06,0.1), nrow=3, ncol=4, byrow = TRUE) 
sample_100 = rDiscrete(n=50000,pf=p)

How can I fix this?

1

There are 1 answers

1
Arthur Morris On

Here is one way to create the matrix in your matrix() command:

matrix input p = (0.04,0.1,0,0.06 \ 0.05,0.3,0,0.05 \ 0.14,0.1,0.06,0.1)

This answers the question in the title of your post. If you provide more information about your question, you may be able to elicit a more complete answer.

As I mentioned: help matrix will give you the documentation, which will help you.