These are wonderful. I have been meaning to write a post on tips for solving and estimating structural models efficiently. Some advice for people starting out on this endeavor, in steps (nerdy post): https://twitter.com/tyleransom/status/1283076450187382784
1. Start with the simplest version of your model for coding. Don't go straight to the version with all the bells and whistles. Solve it in the dumbest way possible (for-loops).

2. Make sure it works properly. This means checking that things which should sum to 1 do in fact...
and that different specifications make sense (if you know how things should work with linear utility, check that it does), and so on. Check that all the relationships make sense

3. Only after this, speed up the code. Comment the for loops and write separate code that is faster..
... check that it is giving the same answers as before!

4. Only now should you start adding in the bells/whistles, one at a time (save the old code somewhere). Do step (2) for each additional element added.

5. Once this works, time to estimate! I like to start by generating...
..fake data from the model first. Then, run your estimation procedure (MLE, GMM, whatever) on the fake data. Are you able to recover the parameters which generated the data?

6. If yes, wow, in one try, thats unheard of. If not, its one of three problems (1) coding error ......
... standard kind or you didn't get to global min? (2) lack of identification, (3) your fake data is one noisy sample from the model. Fixing (3) is easy, take a bigger sample, and fixed the seed for your random number generator. For (2), proceed in the same way as building the...
...model. Start with estimating 1 parameter with 1 moment that you know should identify it. Does it work? If not, probably a coding error. If it works, proceed to add in another parameter and another moment....

7. This is when the often month/year long struggle begins. And this
8. AUTOMATE AND COMMENT EVERYTHING. pay the fixed cost up front, its worth it IMO.

Anything I missed?
You can follow @pilossopher.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: