Hi, The department of economics at our university (Budapest) is planning a course on numerical methods in economics. They are trying to decide which software to use for that, and I would like to advocate R. The other alternative is Matlab. I have found comparisons in terms of computational time for matrix algebra, but I don't think that is relevant: the bottleneck for economists is usually the programmer's time: if it takes a couple of hours to write something that is run only a few times, one should not care whether it runs in 2 or 2.1 minutes... I am an economist, and I have used Octave, but only until I found R. So I am not in a position to evaluate Matlab vs R. I would be grateful if somebody could compare R to Matlab, especially regarding the following: 1. How "smart" the language is. R appears to be a nice functional programming language, is Matlab comparable? Last time I used Octave, it seemed to be little more than syntactic sugar on some C/Fortran libraries. It appears to me that using R gradually pushes people towards better programming habits, but I may be biased (I am a Scheme lover). 2. Learning curve. If somebody could share his/her experience on using R or Matlab or both in the classrom, how students take to it. 3. Which language do you think is better for students' further development? We would like to equip them with something they can use later on in their career even if they don't become theoretical economists (very few undergraduate students do that). 4. How flexible are these languages when developing new applications/functions? Very few of the problems I encounter have a ready-made solution in a toolbox/library. Thanks, Tamas -- Tam??s K. Papp E-mail: tpapp at axelero.hu Please try to send only (latin-2) plain text, not HTML or other garbage.
Gabor Grothendieck
2004-Apr-25 12:32 UTC
[R] R vs Matlab: which is more "programmer friendly"?
Tamas Papp <tpapp <at> axelero.hu> writes:> 4. How flexible are these languages when developing new > applications/functions? Very few of the problems I encounter have a > ready-made solution in a toolbox/library.You might want to check your assumption that what you need is not available. I believe that there is more not in CRAN than in CRAN. Henrik Bengtsson's site lists 370 packages: http://www.maths.lth.se/help/R/.R/doc/html/packages.html You could try posting if googling and looking at the usual places, cran.r-project.org, www.bioconductor.org and www.omegahat.org, does not turn up what you are looking for. Also, there is a document on the R site that provides a translation between Octave and R that might give you some insight into your questions: http://cran.r-project.org/doc/contrib/R-and-octave-2.txt
I have been using R for about 2 years and recently took a 6 week introductory course to Matlab. I can give entirely personal answers to your questions. 1. 'How smart?'. Don't know exactly what you mean, but both languages are extremely functional. Both emphasize writing of functions to call rather than repeatedly typing in the same code, so they encourage good programming practice. I started with R, so prefer its syntax. 2. 'Learning curve'. Similar. R has a simpler interface. Matlab has various enhancements that may help in the learning process, for example the path browser and workspace browser in which you can interactively keep track of all the objects in the workspace. Both have comprehensive help packages. 3. 'Further development'. Has to be R- its FREE! I don't know many students who would fork out the money for a Matlab license. 4. 'Flexibility'. Both are perhaps infinitely flexible. You can write any code you like, to do any statistical or mathematical processing. I would say R is better for statistical analysis (though Matlab has a stats package you can purchase), while Matlab is designed for mathematics. With Matlab you can compile GUIs to run analyses, which are probably useful for sharing with people who can't program. Some other points. 1. I have heard that Matlab is faster than S-PLUS (and hence R?) at performing calculations. 2. I found Matlab to be quite frustrating in its handling of data- for example it is extremely difficult to save a data frame in which variables are labelled with there names. Hope this helps. Dan Bebber Department of Plant Sciences University of Oxford South Parks Road Oxford OX1 3RB UK ------------------------------ Message: 24 Date: Sun, 25 Apr 2004 11:08:09 +0200 From: Tamas Papp <tpapp at axelero.hu> Subject: [R] R vs Matlab: which is more "programmer friendly"? To: R-help mailing list <r-help at stat.math.ethz.ch> Message-ID: <20040425090809.GA704 at localhost> Content-Type: text/plain; charset=iso-8859-1 Hi, The department of economics at our university (Budapest) is planning a course on numerical methods in economics. They are trying to decide which software to use for that, and I would like to advocate R. The other alternative is Matlab. I have found comparisons in terms of computational time for matrix algebra, but I don't think that is relevant: the bottleneck for economists is usually the programmer's time: if it takes a couple of hours to write something that is run only a few times, one should not care whether it runs in 2 or 2.1 minutes... I am an economist, and I have used Octave, but only until I found R. So I am not in a position to evaluate Matlab vs R. I would be grateful if somebody could compare R to Matlab, especially regarding the following: 1. How "smart" the language is. R appears to be a nice functional programming language, is Matlab comparable? Last time I used Octave, it seemed to be little more than syntactic sugar on some C/Fortran libraries. It appears to me that using R gradually pushes people towards better programming habits, but I may be biased (I am a Scheme lover). 2. Learning curve. If somebody could share his/her experience on using R or Matlab or both in the classrom, how students take to it. 3. Which language do you think is better for students' further development? We would like to equip them with something they can use later on in their career even if they don't become theoretical economists (very few undergraduate students do that). 4. How flexible are these languages when developing new applications/functions? Very few of the problems I encounter have a ready-made solution in a toolbox/library. Thanks, Tamas -- Tam??s K. Papp E-mail: tpapp at axelero.hu Please try to send only (latin-2) plain text, not HTML or other garbage. ------------------------------ _______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE read the posting guide! http://www.R-project.org/posting-guide.html End of R-help Digest, Vol 14, Issue 25
I was exposed to and have used Matlab and R both in and out of the classroom, both as a student and as an instructor. 1. Both Matlab and R are "smart." In terms of flexibility, I think they are both about the same. This includes their FSF or commercial counterparts Octave and SPlus respectively. With appropriate guidance, all of these applications can be used to develop better programming habits. As a general rule the commercial versions have a smoother appearance and better documentation...but this is not true of R. R has some of the best documentation around as well as superb on-line support via the R mailing lists. From a student's perspective access to well written documentation and on-line support are essential. 2. Both require the user to have some programming experience; otherwise the learning curve is steep in the beginning. Both can be used to introduce programming provided you make room in your syllabus for the basics in the beginning. 3. In my opinion, the main difference -- besides the obvious one...cost -- is that R is easily accessible anywhere in the world, costs nothing (which makes it affordable for students), has excellent documentation, a robust, friendly and helpful user base, superior on-line support ... 4. The power of R and Matlab is that they are both easily extensible. If you can't find a ready-made function to do what you want, you can easily, on the fly, write your own and then make it a permanent function for your use at any time. Bill -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Tamas Papp Sent: Sunday, April 25, 2004 05:08 To: R-help mailing list Subject: [R] R vs Matlab: which is more "programmer friendly"? Hi, The department of economics at our university (Budapest) is planning a course on numerical methods in economics. They are trying to decide which software to use for that, and I would like to advocate R. The other alternative is Matlab. I have found comparisons in terms of computational time for matrix algebra, but I don't think that is relevant: the bottleneck for economists is usually the programmer's time: if it takes a couple of hours to write something that is run only a few times, one should not care whether it runs in 2 or 2.1 minutes... I am an economist, and I have used Octave, but only until I found R. So I am not in a position to evaluate Matlab vs R. I would be grateful if somebody could compare R to Matlab, especially regarding the following: 1. How "smart" the language is. R appears to be a nice functional programming language, is Matlab comparable? Last time I used Octave, it seemed to be little more than syntactic sugar on some C/Fortran libraries. It appears to me that using R gradually pushes people towards better programming habits, but I may be biased (I am a Scheme lover). 2. Learning curve. If somebody could share his/her experience on using R or Matlab or both in the classrom, how students take to it. 3. Which language do you think is better for students' further development? We would like to equip them with something they can use later on in their career even if they don't become theoretical economists (very few undergraduate students do that). 4. How flexible are these languages when developing new applications/functions? Very few of the problems I encounter have a ready-made solution in a toolbox/library. Thanks, Tamas -- Tam??s K. Papp E-mail: tpapp at axelero.hu Please try to send only (latin-2) plain text, not HTML or other garbage. ______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Hi Tamas, I used Matlab starting in about 1990 then later (since about 1993) octave which I then stuck with without reverting to Matlab. Like you, since starting to get used to R I now rarely use octave (at any rate for staistics). Some comments below to add to those of others. These mainly refer to octave, since I have not been in contact with Matlab for a good few years. On 25-Apr-04 Tamas Papp wrote:> The department of economics at our university (Budapest) is planning a > course on numerical methods in economics. They are trying to decide > which software to use for that, and I would like to advocate R. The > other alternative is Matlab. > [...] > 1. How "smart" the language is. R appears to be a nice functional > programming language, is Matlab comparable? Last time I used Octave, > it seemed to be little more than syntactic sugar on some C/Fortran > libraries. It appears to me that using R gradually pushes people > towards better programming habits, but I may be biased (I am a Scheme > lover).I think you are being unfair on Matlab/octave, which has a full programming language with a very healthy supply of builtin routines for numerical operations on matrices and vectors. However, their main programming resources are of the kind assignment, looping, conditionals, etc. rather like C itself. Primitve types are also somewhat limited -- manily integers, reals, complex, and vectors and 2-D arrays of these, and "structures" which are basically lists of items each of which can be any of these types (access using C-like "." notation). Nevertheless these are enough to develop a great variety of applications. I don't know what the situation now is with Matlab, but octave has long suffered from not supporting arrays with more than 2 dimensions, which somewhat impedes its use for many statistical purposes, though I think the issue has been recently addressed in a more constructive fashion. You can emulate multidimensional arrays as structures, computing an index into a vector (linear array of elements): http://www.octave.org/octave-lists/archive/help-octave.2001/msg00338.html There has for quite some time been an offshoot of octave called "TeLa" ("Tensor Language") of which details can be found at http://www.geo.fmi.fi/prog/tela.html (According to the changelog on this site the latest version is 2.0 of August 2002). This was specifically written to support multidimensional arrays because of fmi.fi (Finnish Meteorological Institute)'s interest in complex multidimensional dynamics. It is quite easy to write "scripts" which define functions and implement complex programs using builtin and user-defined functions. Anything in Statistics which can be expressed in terms of vectors and matrices can easily be implemented in Matlab/octave. For a good few years I did all my statistical computing on Matlab, then octave. However, R beats either in terms of the flexibility and depth that the language offers. This however makes it a considerably more formidable learning task to get full benefit from it.> 2. Learning curve. If somebody could share his/her experience on > using R or Matlab or both in the classrom, how students take to it.No comment here for classrom use (except in the background for demonstration -- I haven't taught students how to use either for their own work, though I have tuaght PhD students how to use octave/Matlab and it worked well. I think at some of these might not have got on too easily with R. However, one point to consider is the graphical capabilities of Matlab/octave vs R. Probably matlab has come a long way on this front since I used to use it, but even in its early days it offered a wider range of graphics than octave did. Octave has always done graphics by creating files of commands which it submits to gnuplot, so it is limited by what the capabilities of gnuplot are at the time. On the other hand, you can suss out how octave does this and write your own scripts for implementing graphics in other commandfile-driven graphics programs (I once did this for Kenny Toh's now apparently dormant[*] PlotMTV, and it has also been done for PLPlot -- quite effectively in my view; you could even write an octave interface to R graphics if you wanted!). [*] Not further developed since about 1977, I think, though a very useful program.> 3. Which language do you think is better for students' further > development? We would like to equip them with something they can use > later on in their career even if they don't become theoretical > economists (very few undergraduate students do that).This has to depend on your judgement as to which language better provides the tools they will need in that field (or may be further developed to provide them). Matlab/octave are particularly well equipped to handle "signal processing" types of computation, especially with their special "toolboxes" -- assemblages of supplementary functions written for these purposes. This includes all kinds of filters, spectral analyses, etc. You can also readily supplement these with routines for additional analyses. As pointed out above, a lot of statistical analyses can be programmed by someone who knows what they are doing. They are also very well adapted for modelling and simulation, both deterministic and stochatic, and come equipped with solvers for systems of differential equations (non-linear as well as linear) and numerical quadrature routines. On the other hand, R is remarkable for its very broad coverage of different types of statistical analysis and model-fitting. Probably either is equally straightforward to use for basic work. For more advanced or complex work it may be better to use both, each for the kind of task it is better equipped for.> 4. How flexible are these languages when developing new > applications/functions? Very few of the problems I encounter have a > ready-made solution in a toolbox/library.In my experience, Matlab/octave -- because of the essential simplicity of both the programming language and the primtiive data types, is easiest and simplest for developing new applications or functions, provided you know well what it is you want to implement. But you may have to do a lot of work on the detail. On the other hand, R's complexity of language structure and richness of objects and types offers great flexibility with little effort provided you are familiar enough with its resources. I personally find that a lot of the time and effort I spend when developing applications goes on developing this familiarity. On a sort of analogy, working with Matlab/octave could be likened to working on an older (non-electronic) car: so long as you have good mechanical sense, are handy with a few tools, and are prepared to undo a lot of nuts and bolts, it is straightfoward though possibly tedious. Working with R is sometimes more like neurosurgery: you have to become aware of the existence of the particular structure you need to deal with, where to locate it, and what its function is in relation to other structures; and, when you have finally reached it, you may need to handle it with delicacy and finesse! Hoping this is useful! Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 167 1972 Date: 25-Apr-04 Time: 21:14:51 ------------------------------ XFMail ------------------------------
To get more opinions, you might be also interested to take a look at MATLAB newsgroup, there were some interesting threads on the topic, for example: http://newsreader.mathworks.com/WebX?50 at 88.3Z0AaB5okKu.1@.eec5e6d -- Fan Tamas Papp wrote:> Hi, > > The department of economics at our university (Budapest) is planning a > course on numerical methods in economics. They are trying to decide > which software to use for that, and I would like to advocate R. The > other alternative is Matlab. > > I have found comparisons in terms of computational time for matrix > algebra, but I don't think that is relevant: the bottleneck for > economists is usually the programmer's time: if it takes a couple of > hours to write something that is run only a few times, one should not > care whether it runs in 2 or 2.1 minutes... > > I am an economist, and I have used Octave, but only until I found R. > So I am not in a position to evaluate Matlab vs R. I would be > grateful if somebody could compare R to Matlab, especially regarding > the following: > > 1. How "smart" the language is. R appears to be a nice functional > programming language, is Matlab comparable? Last time I used Octave, > it seemed to be little more than syntactic sugar on some C/Fortran > libraries. It appears to me that using R gradually pushes people > towards better programming habits, but I may be biased (I am a Scheme > lover). > > 2. Learning curve. If somebody could share his/her experience on > using R or Matlab or both in the classrom, how students take to it. > > 3. Which language do you think is better for students' further > development? We would like to equip them with something they can use > later on in their career even if they don't become theoretical > economists (very few undergraduate students do that). > > 4. How flexible are these languages when developing new > applications/functions? Very few of the problems I encounter have a > ready-made solution in a toolbox/library. > > Thanks, > > Tamas >
James.Callahan@CityofOrlando.net
2004-Apr-27 00:25 UTC
[R] Re: R vs Matlab: which is more "programmer friendly"?
I have been lurking for a while, but I think this is my first post. I have tried to address your question from the perspective of an undergraduate student in Economics who has gone one to do some economic forecasting, but has made no contributions to theoretical economics. I have no experience with Matlab or Octave -- so I can't compare.> 3. Which language do you think is better for students' further > development? We would like to equip them with something they can use > later on in their career even if they don't become theoretical > economists (very few undergraduate students do that).Since you mention "undergraduate students" I assume you mean a course in content similar to Alpha Chiang's classic "Mathematical Methods in Economics." http://www.mcgraw-hill.co.uk/html/0070662193.html I believe you will find all you need in R, but I doubt you will find it in one place! The relevant techniques (see link to Alpha Chiang's textbook above) may be spread across many packages. For example, just recently there was a post to this list about how to estimate a nonlinear production function, both Cobb-Douglas and CES. Klein's Model I is also implemented in another R package. Numerous techniques for estimation, optimization and simulation, including Monte Carlo and resampling methods are all available in various R packages. Fortunately, your earlier post indicates that you are well acquainted with the R Help system. As far as "something they can use later in their careers." R has at least two advantages: 1. As mentioned R is open source which is beneficial to their student budget constraints. Institutions also have budget constraints and new graduates starting out on their careers can download R in any institution almost anywhere in the world where there is broadband Internet access. 2. The R mailing list is cross-disciplinary. Students can see how mathematics and statistics are applied in the cutting edge of a variety of fields. I have personally found the posts on geostatistics and biostatistics fascinating. If I were an undergraduate starting out -- I would probably want to try biostatistics (or bioinformatics or whatever its called). Are you interested in mathematical methods applied to classical macroeconomic models or newer financial techniques (portfolio & options)? If you want to demonstrate advanced econometric techniques applied to macroeconomics -- a very sadistic suggestion - for graduate students -- would be to port Professor Roy Fair's US, MC or MCU "Fairmodels" to R. This would cover numerical methods involved in both estimation and simulation -- grounded in a very applied context. I have contemplated doing that myself (on my own time) but sanity prevailed (I'll stick with OLS) -- but it would be a great learning experience... (so would climbing the Himalayas). see: http://fairmodel.econ.yale.edu/main2.htm and http://fairmodel.econ.yale.edu/fp/fp.htm If you want to demonstrate newer financial techniques (portfolios & options) you might look at the MITPress book, by Professor Simon Benninga "Financial Modeling" (an earlier book by this author was titled "Numerical Techniques in Finance") -- which incidentally uses MS Excel. The author uses matrix techniques in Excel which are rarely, if ever, covered in general purpose Excel books (but are very relevant to your course). see: http://mitpress.mit.edu/catalog/item/default.asp?sid=4296516E-E57D-4EDD-9094-17E4E86330AB&ttype=2&tid=3433 and http://finance.wharton.upenn.edu/~benninga/ of course these methods can (and have) been implemented in R as well (thanks Dirk!). If you were teaching only accounting or business students, "Business Analysis with Microsoft Excel" by Conrad Carlberg might be useful -- it has downloadable Excel add-ins for Arima and statistical process control. The choice and presentation of topics is very appropriate for a business setting. For an undergraduate or an MBA student, the learning curve for anything beyond MS Excel (or Gnumeric) is steep. For this reason, you might want to look at John Fox's GUI frontend to R -- to ease the shock. Over twenty years later I still recall estimating exactly one equation in SPSS -- and then only after careful spoon-feeding. I accepted the JCL on the first few punch cards on blind faith. Simulating, the Penn-FRB-Wharton model (again on punch cards) as an undergraduate was an exciting, but baffling experience. But, then my first job out of college I got to regress and simulate using XSIM (a wonderful command line econometric language).>From a strictly economic perspective, I would look (Google) at Gretl, Gor the Fair-Parkes program (again Fairmodel), but since your objective seems to be to go under the hood and look at the underlying mathematical techniques -- R is a good, though challenging choice. Gretl is open-source. G and Fair-Parkes are freely downloadable, but not, strictly speaking, GPL. As for R documentation, I keep PDFs of "An Introduction to R" and Julian Faraway's "Practical Regression and Anova using R" on my Windows desktop -- hint the appendices are the best place to start! I also keep paper copies of John Fox's "Companion to Applied Regression" and Peter Dalgaard's "Introductory Statistics with R" handy. One disadvantage of R is that, although Professor Ripley has done heroic work in debugging R dates; R dates are a pain and are often skipped as in John Fox's examples. Coming from a background in XSIM/Troll where dates were intrinsic to the times series data structure we used -- I find R dates very painful and not very useful. But, then we only used OLS in XSIM -- not n-stage least squares or full-information maximum likelihood (FIML). And we would never, ever attempt analysis of genomes in XSIM! The greatest advantage of R is the cross-pollenation provided by the mailing list. It is easy to guess that in the near future, numerous mathematical and statistical techniques will be developed to deal with the difficult challenges of the study of genomics (genes) and protonomics (proteins). The R mailing list will be a great window on those developments. Jim Callahan Management, Budget & Accounting City of Orlando (407) 246-3039 office (407) 234-3744 cell phone> Message: 24 > Date: Sun, 25 Apr 2004 11:08:09 +0200 > From: Tamas Papp <tpapp@axelero.hu> > Subject: [R] R vs Matlab: which is more "programmer friendly"? > To: R-help mailing list <r-help@stat.math.ethz.ch> > Message-ID: <20040425090809.GA704@localhost> > Content-Type: text/plain; charset=iso-8859-1 > > Hi, > > The department of economics at our university (Budapest) is planning a > course on numerical methods in economics. They are trying to decide > which software to use for that, and I would like to advocate R. The > other alternative is Matlab. > > I have found comparisons in terms of computational time for matrix > algebra, but I don't think that is relevant: the bottleneck for > economists is usually the programmer's time: if it takes a couple of > hours to write something that is run only a few times, one should not > care whether it runs in 2 or 2.1 minutes... > > I am an economist, and I have used Octave, but only until I found R. > So I am not in a position to evaluate Matlab vs R. I would be > grateful if somebody could compare R to Matlab, especially regarding > the following: > > 1. How "smart" the language is. R appears to be a nice functional > programming language, is Matlab comparable? Last time I used Octave, > it seemed to be little more than syntactic sugar on some C/Fortran > libraries. It appears to me that using R gradually pushes people > towards better programming habits, but I may be biased (I am a Scheme > lover). > > 2. Learning curve. If somebody could share his/her experience on > using R or Matlab or both in the classrom, how students take to it. > > 3. Which language do you think is better for students' further > development? We would like to equip them with something they can use > later on in their career even if they don't become theoretical > economists (very few undergraduate students do that). > > 4. How flexible are these languages when developing new > applications/functions? Very few of the problems I encounter have a > ready-made solution in a toolbox/library. > > Thanks, > > Tamas > > -- > Tamás K. Papp > E-mail: tpapp@axelero.hu > Please try to send only (latin-2) plain text, not HTML or other garbage. > > > > ------------------------------ > > _______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE read the posting guide!http://www.R-project.org/posting-guide.html> > > End of R-help Digest, Vol 14, Issue 25 > **************************************[[alternative HTML version deleted]]
Gabor Grothendieck
2004-Apr-27 01:41 UTC
[R] Re: R vs Matlab: which is more "programmer friendly"?
<James.Callahan <at> CityofOrlando.net> writes:> R dates are a painNote that R 1.9.0 has introduced a new Date class that has no time zones making Date easier to use and less error prone than POSIX dates.