Mata newbie here. I'm looking to use Halton draws (rather than pseudouniform random draws) in a estimator that uses maximum simulated likelihood methods. I want draws in 2 dimensions.
I know I can use Mata to generate Halton draws. For example, suppose I have 10 observations, then the following code generates a matrix x containing a vector of draws (one draw per obs). I can use these for the first calculation of the simulated likelihood.
But what about the second and subsequent calculations? For these I need further sets of draws for each obs. I read the Mata manual and -help mf_halton- as telling me that I can modify x using _halton()
_halton(x) modifies the n x d matrix x so that it contains a Halton set of dimension d of length n.
_halton(x, start) does the same thing, but the first row of the returned matrix contains the sequences starting at index start. The default is start = 1.
...
_halton() modifies x and can be used when repeated calls are made to generate long sequences in blocks. Here update the start index between calls by using start = start + rows(x).
So, I try the following and discover the new matrix y is empty.
So, clearly, I'm misunderstanding something. If _halton() is not for me, do I need instead to use halton() itself to generate a ( nobs*S) x 2 matrix, where S is the number of simulations, and then extract the draws in chunks of n?
PS using _halton(x) by itself doesn't change x
I know I can use Mata to generate Halton draws. For example, suppose I have 10 observations, then the following code generates a matrix x containing a vector of draws (one draw per obs). I can use these for the first calculation of the simulated likelihood.
Code:
. mata: x = halton(10,2,1)
. mata: x
1 2
+-----------------------------+
1 | .5 .3333333333 |
2 | .25 .6666666667 |
3 | .75 .1111111111 |
4 | .125 .4444444444 |
5 | .625 .7777777778 |
6 | .375 .2222222222 |
7 | .875 .5555555556 |
8 | .0625 .8888888889 |
9 | .5625 .037037037 |
10 | .3125 .3703703704 |
+-----------------------------+
_halton(x) modifies the n x d matrix x so that it contains a Halton set of dimension d of length n.
_halton(x, start) does the same thing, but the first row of the returned matrix contains the sequences starting at index start. The default is start = 1.
...
_halton() modifies x and can be used when repeated calls are made to generate long sequences in blocks. Here update the start index between calls by using start = start + rows(x).
Code:
. mata: y = _halton(x) . mata: y .
PS using _halton(x) by itself doesn't change x
Code:
. mata: _halton(x)
. mata: x
1 2
+-----------------------------+
1 | .5 .3333333333 |
2 | .25 .6666666667 |
3 | .75 .1111111111 |
4 | .125 .4444444444 |
5 | .625 .7777777778 |
6 | .375 .2222222222 |
7 | .875 .5555555556 |
8 | .0625 .8888888889 |
9 | .5625 .037037037 |
10 | .3125 .3703703704 |
+-----------------------------+

Comment