Mastodon
List

Mathematica is a powerful computational engine, and I do all my research and some of my teaching using it. Cosma Shalizi has posted his thoughts on programming well in R, and Martin at Geary has posted his thoughts and some cool links on Stata, so I thought I'd write something about Mathematica, rather than ranting about the Irish economy for a while. There are much more qualified people than me doing that anyway.

gazebo1

First thing you should know is I taught Mathematica for economists a few years ago, and the course files are located here. Check them out and give me some feedback if you like them.

Second thing you should know is I'm not an expert, though I have taken classes from Wolfram research on using Mathematica to program. Details of those are here. I'm just barely qualified to use it for my own ends. I'm going to assume you've never taken a programming class, as with most social scientists. But in spite of all those caveats, I've got some tips for you, and in time-honoured bloggy fashion, I've made a list.

  1. Don't jump right in. Write down what you want to do on a piece of paper before going anywhere near a computer. Jumping straight into coding is a mistake. It's better to think carefully about what you want the code to do before coming up with the code itself. Begin by asking what you want to do. Then ask how Mathematica can do that. Then search the help browser for commands and syntax to help you do that.
  2. Code small. When you know what you want to do, code in tiny functions which do one thing, then splice those functions together. Don't iterate too much throughout, or you'll really slow your program down. Write comments in (* *) like this to yourself throughout the code. You'll want to do this, because right after staying up all night to finish the first draft of the code through bleeding eyeballs, you're going to...
  3. Bin the first draft. When you've written the first draft, and you're sure it works, throw it away. Then cry. Then get back to work.
  4. No, really. Chuck it. The first draft of the code will take, say, 30% of your time in coding, because you are really trying to find the language to ask Mathematica to perform some computation for you. The second draft will take 10% of the time it took you to write the first draft, and you'll write a better, more compact, and more efficient program. Honestly. It will save more time in the long run.
  5. Write tests. Write tests for accuracy in the program. Within Mathematica, there are many simple checks you can make to ensure the program is doing what you think it might be doing, so use them, or write your own. My favourite is MaxPrecision.
  6. Graph stuff. Mathematica (especially version 7) has extensive statistical and graphing capabilities, so use them to get a handle on what it is your program is doing, and what kind of outputs you can expect. Chances are you're using Mathematica to produce graphs anyway, so just build these into the program (Module) as outputs to separate files. It's a great way to produce results you can compare in different runs, especially when you simulate.
  7. Ask people things. Check the help browser and the net, and if you get really stuck, join the Mathematica group, and ask a question. Most people (I say most, not all) are very helpful, and will get back to you in a week or so.
  8. Read books. Here are my favourites: "Programming in Mathematica (3rd Edition)" (Roman Maeder), "Mathematical Statistics with MATHEMATICA" (Colin Rose, Murray D. Smith) and "An Introduction to Programming with Mathematica, Third Edition" (Paul R. Wellin, Richard J. Gaylord, Samuel N. Kamin)

That's it, any more hints, tips, etc, leave in comments, email me, or if I think of them, I'll post them.

  Posts

1 2 3 154
December 10th, 2019

Using Social Media to Boost your profile

My talk for the social media summit is here. 

November 5th, 2019

Innospace UL talk

Thanks for the invitation to speak, the whole talk is here. 

October 9th, 2019

Understanding the macroeconomy podcast

I really enjoyed my interview with Dr Niall Farrell of the Irish Economics Podcast. You can listen to it here:

September 15th, 2018

Identifying Mechanisms Underlying Peer Effects on Multiplex Networks

New paper with Hang Xiong and Diane Payne just published in JASS: Abstract: We separately identify two mechanisms underlying peer […]

March 24th, 2018

Capital inflows, crisis and recovery in small open economies

Our latest paper, and my first with my Melbourne School of Government affiliation (plus my UL one, of course) is […]

March 7th, 2018

Southern Charm

What's it like working at Australia's number one university, ranked 23rd in the world for social sciences? It's pretty cool, […]

February 7th, 2018

Freedom interview

I did an interview for an app I love using called Freedom. Basically I pay them to block off the […]

December 10th, 2017

Marian Finucane Interview

I did a fairly long interview about the experience of moving to Australia with my family. You can listen here.

November 17th, 2017

Increasing wages for macroeconomic stability

My first piece for the conversation is here. I'm arguing the economy would benefit from wage increases, paid for from […]

November 14th, 2017

Health Workforce Planning Models, Tools and Processes: An Evidence Review

Below is my recorded talk, here are my slides, and the handout for the 4th Global Forum on Human Resources for […]

October 5th, 2017

Aalborg Keynote

My talk from the fourth Nordic Post Keynesian conference is up. The full list of keynotes is here.

October 1st, 2017

AIST Debt and Demography talk

(Apparently Limerick is in the UK now!)

September 7th, 2017

My AIST Keynote: Europe Exposed

In which a camera man faints halfway through--he's OK though, I checked afterwards!

July 22nd, 2017

MacGill Summer School Speech

My speech at the MacGill Summer School is here. Thanks to Joe Muholland for inviting me to speak.

May 25th, 2017

Business Post Articles

All my Sunday Business Post articles (back to 2014/5, when I joined the paper) are available here, behind a paywall, and […]

@barrd on Mastodon