# Coding

# Software

Stata is a statistical language and program. Stata is popular with social scientists today, especially economists. The ECO5011F Lab Sessions structure is Wittenberg's Applied Econometrics Handbook, which comes with data files and metadata documents on Vula. Aidan's solutions for this handbook.

## Stata

UCT uses Stata 15. Visit https://www.commerceit.uct.ac.za/StataLicensing2021 to obtain a licence for Stata 15, as well as the required installation files. This version is only available on Windows. Alternatively, students can operate Stata from any operating system, through Remote Desktop Protocol (RDP). You will need to use the UCT VPN for this, then connect to a computer in the Alumni Lab (see this video for guidance).

### Online help

DataFirst has an online course giving an introduction to Stata. The following text is copied from http://toolkit.uctecossoc.co.za/#h.f4b98jcbm4ei :

Stata Cheat Sheets: Nifty documents summarising the fundamental commands in Stata to import, explore, summarize, and create new variables. Also, R Cheat Sheets.

Statalist is the place to go with questions about how to do things in any version of Stata. It is very active: Stata developers from StataCorp and many experienced users are leading members. Questions cover basic Stata use, Stata programming, and statistical practice. Before posting, do study the FAQ Advice.

Questions about Stata syntax, programming and output are addressed on StackOverflow.

The official FAQs are extremely useful as well.

StataCorp also maintains a YouTube training channel.

Every copy of Stata comes with Stata’s complete PDF documentation. The PDF documentation may be accessed from within Stata by selecting Help > PDF documentation, or by typing help -command-. The full PDF documentation is also available online, e.g., the User Guide and the Reference manuals are usually a good place to start for general commands. To access the help files for specific commands, do a Google search for the command + "Stata", or form the url as http://www.stata.com/help.cgi? appended with the command name, like regress: http://www.stata.com/help.cgi?regress .

This subsection (on finding online help) was mostly copied from https://stats.meta.stackexchange.com/a/794/68965 .

## R

You should try to learn R, as R is a more modern language. It is becoming more popular within the economics discipline (especially for time-series analysis, web scraping or machine learning) and is also widely used outside of the economics discipline. R is more useful for graphs, whereas Stata is powerful for data cleaning. To learn R, I recommend DataCamp. You can also try the swirl package in R. Please see my markdown doc for more details.

When communicating mathematics online, for example on Math.SE, you can't use a pencil and piece of paper. Thus, it will be best that you try pick up the basics of MathJax. The LaTeX code for equations, in-between $ and $, can be used on Math.SE to make your question more presentable. You could even use a Math.SE Q&A template to quickly compile an image of an equation, which you can snip from your screen, save the image, and send in the Tutoring Channel in our MS Team.

You could also use a LaTeX editor to compile an equation, homework, essays, books, your dissertation, or papers for publication, later on in your career. If you want to learn LaTeX (a word processing markup language), then the Guide to LaTeX by Kopka and Daly (2007) (available at the main library at 686.22544 KOPK) is foundational. Although many people pick up LaTeX from tex.stackexchange.com, Kopka and Daly (2007) provide history; the basics; introduce important environments and commands (including their options); a chapter on mathematical expressions; describe how floating tables or graphics can be used; and introduce different document classes (such as article or beamer). You can use Aidan Horn's LaTeX Template to get started, but try think about what the different packages are used for. The biggest benefit of LaTeX is that you will not have to re-number figures, if you add in a new one at the beginning of your paper, and it has a reference management system, called BibLaTeX. The formatting of the entire document (font size, margins, baselineskip, parskip, parindent) all remains constant, every step of the way through your paper. That is because the formatting settings are defined in the preamble, before \begin{document}. There are so many tips to give, but let me highlight one that many people haven't figured out: fonts.

The very first line in the .TeX file is

\documentclass[11pt, a4paper]{article}

so, you can choose 10pt, 11pt or 12 point size for your \normalsize . Then, choose one of the commands in the image on the right if you need to change the size of your font in the document.

You can use any font on your computer, by using the LuaLaTeX engine. Do this with the fontspec package:

\usepackage{fontspec}

\setmainfont{Times New Roman}

\begin{document}

\mainfont \fontsize{10}{12.5} \selectfont

or just use the mathpazo package.

For the rest, you should Google the "package name + CTAN" to find the documentation. tex.stackexchange.com answers often provide a quick solution, but everything is documented in the package documentation. I think that people don't read the documentation because LaTeX is such a complicated language to use, so there are so many details in the documentation (but they are presented in an organized, linear fashion, and... ). Perhaps the constraint with using computer languages is that it involves problem-solving, but the solutions are always in the documentation. If you have a problem when using a computer language, try to break down the problem into small steps (this also goes for Stata). Bugs can be annoying, so try mentally prepare yourself before opening Stata.

Volunteers created the LaTeX packages, after Donald Knuth invented it in the 1980's. The TeX program is free, and there haven't been any bugs in it since version 3.141592 (π). If you struggle to get your document to compile in TeXmaker , you should read the error message. If you haven't done too much work since the last compile, you would probably know what changes you recently made to the .TeX file. You could scan through your code, looking for obvious errors. Or, just try a quick TeX.SE. Before asking a question, you need a minimal working example (MWE), which means that you should have copied the .TeX file into a new file, and deleted as much as possible until you did discover when the problem stopped occurring.

Although TeXmaker compiles more quickly, the Overleaf website comes pre-packaged with the necessary engine. It doesn't require you to download a LaTeX editor onto your computer, so the setting up is quicker. You therefore may want to compile your LaTeX documents on the Overleaf cloud, but there is a limitation on how long your documents can get, before they expect you to pay for a student subscription. If you're trying to encourage other researchers to adopt LaTeX, Overleaf is the smoothest entry, as you can collaborate with peers. The subscription would enable you to sync the Overleaf folder with a GitHub repository, if you would rather edit your LaTeX documents offline.