Recently I came across a complex model written in Access with complex SQL queries all over the place. The engineer who was maintaining it and I did some analysis and agreed that the model was using SQL in an unnatural way (things SQL isn't good at) - complex logic, formatting etc.

We agreed to use SQL and a more powerful programming language to re-build the model. The engineer is familiar with Stata, so he quickly wrote Stata code. When I looked at the Stata code, it looked fairly easy to reproduce it in R. I've posted some R commands for the Stata commands I found in that code.

What are the advantages of using Stata? Why shouldn't I use R for this?

I never really understood the appeal of Stata other than being more relaxed about semicolons, which apparently flummox new users. I suppose so might the '<-', but then again, nowhere above would the equals-sign not have sufficed. My guess is that the c() function is enough to cause a good number of people to prefer Stata's marginal simplicity, as well as the row/column indexing. Non-programming-background users have trouble with that stuff at first.

ReplyDeleteit's also interesting to note how much more of a PITA some of that would be in SAS

ReplyDeleteOther than "id <- 1" you don't ever take advantage of the fact that you attached the data (twice). Your R-code could be more concise. I just mention that because it gives a poor impression of the efficiency of the code for Stata users reading this and considering switching.

ReplyDeleteWhy not use R? That's a good question. When I wrote "R for SAS and SPSS Users" I began by pointing out how very different those are from R. But when Joe Hilbe & I wrote "R for Stata Users", we reversed that by describing the many things R and Stata have in common. You can read that discussion on pages 1-3 at:

ReplyDeletehttp://www.amazon.com/R-Stata-Users-Statistics-Computing/dp/1441913173/ref=sr_1_1?ie=UTF8&qid=1297471571&sr=8-1

Cheers,

Bob Muenchen

The reason someone would use Stata over R is that they know Stata and don't know R. As a student that is much more familiar with Stata than R, I would use Stata. People that are more familiar with R will use R. Would like to note that Stata does seem simpler than R.

ReplyDeleteEvery person I know who knows both Stata and R very well (about 10 or so) always prefers R, and only uses Stata for updating old Stata do files. I think only economists use Stata, but eventually I think that will change.

ReplyDeleteIn response to the last comment by Anonymous: I disagree. Having been trained on both Stata and R, I prefer to use Stata for 99% of things I need to do daily. It's syntax is more concise/simple, easier to remember/memorize, and I find it's subscripting and bys syntax much more powerful for complex data management. I don't come from a programming background, so maybe that explains why I have so much more trouble remembering R syntax and understanding complex R syntax -- it's just not as intuitive (to me at least) as Stata syntax. I wish Stata had better graphs, but that's it only real advantage for me (price isn't a factor since I'm luck enough to have my employer pay for Stata MP licenses- but I understand how that is a barrier for many out there).

ReplyDelete