Browsed by
Category: Teaching

LaTeX problem sets with hidden answers

LaTeX problem sets with hidden answers

I like being able to hide content in documents, for example including but not revealing the answers in a problem set. That makes it very easy to then produce the problem set solutions, simply by revealing the answers. I made this easier with a \hide{} command, that can be “turned off” so the answers are revealed.

This is the basic code I use for producing problem sets. The only change needed to convert a problem set into a solution set is to redefine the \showanswers variable to equal 1 rather than 0.

\documentclass{article}

% Set this =0 to hide, =1 to show
\def\showanswers{0}

\newcommand{\hide}[1]{
   \ifnum\showanswers=1

   #1 \vspace{\baselineskip}
   \fi

   \ifnum\showanswers=0
   \vspace{2\baselineskip} \hspace{2cm}
   \fi
}

\begin{document}

\begin{enumerate}
   \item This is question 1.
   \hide{Here is a hidden solution.}

   \item What is the answer to question 2?
   \hide{The answer is here.}
\end{enumerate}

\end{document} 
University of Tennessee beamer theme

University of Tennessee beamer theme

I’m teaching econometrics next semester, and did not want to simply regurgitate the textbook’s lecture slides. However, the University of Tennessee has a branding website, so I made a beamer theme that replicates the official UT PowerPoint template.

There is a little page for the theme here. You can download the files needed to install the theme here.

How Michigan calculates teaching scores

How Michigan calculates teaching scores

Michigan’s Graduate Student Instructors (GSIs) receive student evaluations for every class they teach. The undergrads are invited to rate their GSIs using Likert Scales (aside: Likert had a degree in economics from the University of Michigan). Students see something like this:

Overall, the instructor was an excellent teacher
Strongly Disgree Disagree Neutral Agree Strongly Agree

The Registrar compiles this data, encoding “Strongly Disagree” as 1, “Strongly Agree” as 5, etc. They then provide GSIs with what is called their “Median score”, which is actually a slightly complicated interpolated form of the median.

The application of medians to discrete values was perplexing, so I asked the Office of the Registrar to provide me with the exact formula they use. They did so, and I reproduce it here in case any GSI in the future ever wonders as I once did. (I checked: the Registrar has no objection to this being made public knowledge.)

Their formula, which requires some lingo that is explained below, is:

\text{Median } = \text{Lower Real Limit } + \dfrac{0.5N - a}{b}

Calculate the range the median must lie in, e.g. somewhere between 2 and 3. Let’s call this range “the interval”. The Lower Real Limit is the midway point of the interval, i.e. 2.5.

The total number of observations (in the whole sample) is denoted N. Denote as a the number of responses below the Lower Real Limit. In this example, a would be equal to the numbers of 1s and 2s.

Recall that our interval is the range between 2 and 3. The upper-limit of this is 3. Finally, denote as b the number of observations that choose the upper-limit of this interval, i.e. the number of people that chose 3.

Now for an example, suppose you have the following scores:

Score 1 2 3 4 5
Frequency 2 1 8 14 7

By inspection, the median cannot be greater than 4 and cannot be lower than 3. Therefore our interval is 3-4, with a Lower Real Limit of 3.5. There are 32 responses, so N=32. Eleven people chose a score below the Lower Real Limit, so a=11. Fourteen people chose the upper-limit of the interval, so b=14. Plugging this into our equation above:

\text{Median } = 3.5 + \frac{0.5(32) - 11}{14} = 3.86.

A better way to teach EMH?

A better way to teach EMH?

While watching football this morning, I also kept an eye on the betting odds. As soon one team scored, the odds changed.

Instead of introducing the efficient market hypothesis to students as a theory about stocks and bonds, we should perhaps start by drawing parallels to sports-betting. It is hard to consistently make money betting on Premier League results. It’s not impossible, but it takes a lot of skill and/or luck to pull it off.

The same logic applies to beating the general rate of return in a market. Financial markets tend to adjust prices so that there are no obvious bargains. This is not a claim that sporting events never throw up shock victories, nor does it imply that markets never crash. If anything, it suggests that predicting a stock market crash is about as difficult as predicting a shock sporting victory.

Like comparative advantage, it’s hard for undergrads to grasp this idea. I have found that the sporting analogy works well as a stepping stone.

(While on the topic of the EMH: there’s a fun contrast between the predicament of Cassandra, who could perfectly predict the future but nobody would believe her, and the EMH. The more people believe in EMH, the less likely they are to actively search for arbitrage opportunities. This will tend to leave market-beating returns uncollected, nullifying the EMH. The converse also holds. In this respect, EMH is a self-defeating prophecy.)

Tips for students on how to write an email

Tips for students on how to write an email

  1. Check if your question is answered in the syllabus.
  2. Make sure the subject is informative. “Exam” is much less useful as a subject line than “Econ 101 exam conflict”.
  3. Start with “Dear Prof. Jones,” skip two lines, and begin your first paragraph.
    There is some confusion about the appropriate title (Mr/Dr/Prof) to use. Somebody with a PhD can be addressed as “Dr”. A professorship is a particular job that comes with the title “Professor”. Most, but not all, faculty should be called “Prof”. (That is, not all faculty are professors. There are different grades, just like there are Congressmen and Senators.) A quick check of somebody’s website should indicate whether they’re a professor or not. If not, it’s best to play it safe and be over-dressed instead of under-dressed.
    Ideally everybody would be just be called by their first name. Unfortunately it doesn’t work like that. There are plenty of things that would be fine to say to somebody in a pub or on the street that would be very unprofessional to say in a classroom or during office hours. There is a different social dynamic there that professors/teachers must follow. Similarly, the student should be aware of this dynamic too, and go with “Dear Prof. Jones” instead of “Hi Mike”.
  4. Don’t use txt spk ever. Typos are fine; asking “where is ur office?” is not.
  5. Don’t use smiley faces.
  6. Use paragraphs.
  7. In your first paragraph, explain why you are emailing, and what you want.
  8. Keep the email short. Almost 100% of emails can remain polite and express their point in two paragraphs.
  9. Sign off with something nice like “Kind regards” or “All the best”
  10. Before you click send, ask yourself “Am I being reasonable here?”
A shortcut for price elasticity of demand

A shortcut for price elasticity of demand

Undergrads are taught many formulae for the Price Elasticity of Demand. The most common one I have encountered is the particularly unwieldy “midpoint formula”:
\epsilon_D = \dfrac{ \frac{Q_2-Q_1}{(Q_1+Q_2)/2} }{\frac{P_2-P_1}{(P_1+P_2)/2}}

The elasticity at one point is a little more reasonable:
\epsilon_D = \dfrac{ \Delta Q }{ \Delta P }\times \dfrac{P}{Q}

There is an elegant simplification in the case of linear demand. With a demand curve like this:


We can use the formula above, and note that the (absolute value of) PED at point E is:

     \begin{align*} \epsilon_D &= \dfrac{ \Delta Q }{ \Delta P }\times \dfrac{P}{Q} \\  &= \dfrac{b-d}{c} \times \dfrac{c}{d} \\  &= \dfrac{b-d}{d}\\ \end{align*}

Or, equivalently:

     \begin{align*} \epsilon_D &= \dfrac{ \Delta Q }{ \Delta P }\times \dfrac{P}{Q} \\  &= \dfrac{d}{a-c} \times \dfrac{c}{d} \\  &= \dfrac{c}{a-c}\\ \end{align*}

I am pretty sure it was Steve Salant who taught me this.

Updated Feb 2014: Steve Salant adds two more points. Firstly, that this trick also applies to nonlinear demand curves. Draw a tangent to the curve at the point of interest. Its slope will equal the slope of the curve at the point of tangency, and you can then follow the same procedure as above. Secondly, that the elasticity can be expressed in terms of either a and c, or b and d. I have altered the post to reflect this.

The three types of inefficiency

The three types of inefficiency

Students ask me this all the time, so here’s my explanation of the three types of inefficiency.

1. Productive inefficiency. This is a supply-side idea. Mattie and Joe both produce bananas. The bananas are identical. It cost Mattie $12 to produce his last kilogram of bananas, and it cost Joe $10 to produce his last kilogram. They would both better off if, instead of producing that last unit for $12, Mattie paid Joe e.g. $11.50 to produce it. That way Mattie saves 50c and Joe makes a profit of $1.50.

The condition needed to satisfy productive efficiency is that the marginal cost for Company A equals the marginal cost for Company B. If the marginal costs differ, then there are gains from trade from the low marginal cost company (e.g. Joe) selling the item to the company with the high marginal cost (e.g. Mattie).

2. Distributive inefficiency. This is a consumer-side idea. Let’s say that for some reason bananas sell for $1 in the US and $3 in Canada. Then there are people in Canada who are willing to pay, say, $2.75 for bananas but do not receive them. Suppose some American is willing to pay up to (but no more than) $1.20 for bananas. If he sells the bananas to the Canadian for e.g. $2.50, then everyone is better off. Although the American was receiving 20c in consumer surplus by purchasing the bananas for $1, he is clearly better off by selling them for $2.50. (Obviously transport costs have to be small for this to hold.) The Canadian gets the bananas and 25c consumber surplus, so he is also better off. Therefore the $1 and $3 prices generate inefficiencies.

The condition needed to satisfy distributive efficiency is that the marginal benefit to Mr 1 equals the marginal benefit to Mr 2. If they differ, then there are gains from trade from the person with the low MB (e.g. $1) selling the item to the person with the high MB (e.g. $3).

3. Allocative inefficiency. This puts the consumer-side and the producer-side together. Suppose everything regarding productive efficiency (marginal costs for Company A and Company B are the same) and distributive efficiency (marginal benefits for Mr 1 and Mr 2 are the same) is just fine. You can still have inefficiency if the marginal benefits don’t equal the marginal costs. For example, if the costs of the last kg of bananas is $10 but consumers are only willing to pay $3 for it, then producing that last unit is inefficiently costly.

Thus the condition needed to satisfy allocative efficiency is that the marginal benefits (consumer side) equal the marginal costs (producer side).

Intro to Social Science Reading List

Intro to Social Science Reading List

I wrote up an “Introduction to Social Science” reading list for interested students in Econ 101. I printed out ten copies and brought them along on Friday, and allocated them on the basis of who got answers right in class.

I’m happy to report that demand exceeded supply, so it’s available here.

Writing MCQs in LaTeX: the qanda class

Writing MCQs in LaTeX: the qanda class

I was writing a series of practice multi-choice questions for the class I teach when I decided I wanted to write a LaTeX function to automate the formatting. I wanted to include the answer as an argument of that function (possibly with room for an explanation) but not to display the answer until the end of the document. (This is a reasonably simple process. For a more hardcore setup, see the eqexam package.)

I hacked away at the endnotes package until I got what I wanted. Editing packages is a pain though, so I summarized the changes into a Questions and Answers class: qanda.cls.

This does the dirty work in the background and defines two new commands: \q and \qtf. The former takes six arguments: the question, four multi-choice options, and the answer. The latter takes four arguments: the question, two multi-choice options (e.g. true and false, thus the tf in command name), and the answer.

This makes writing multi-choice questions very easy. Here is some sample code.

\documentclass{qanda}
\title{An Example of the qanda Class}
\author{Enda Hargaden}
\begin{document}
\maketitle
This document is an example of the output of the qanda (``q and a'') class.

\q{Who wrote \textit{Animal Farm}?}{Hargaden}{Orwell}{Marx}{Huxley}{Orwell}
\qtf{There are subtle historical parallels in \textit{Animal Farm}.}{True}{False}{True; it is an allegory for the unfortunate route Communism took.}
\q{Who wrote \textit{Capital}?}{Hargaden}{Orwell}{Marx}{Huxley}{Marx}

\newpage
\theendnotes

\end{document}

This produces this nifty document.

To use the qanda class:

  1. Download qanda.cls
  2. Place it in the folder your .tex is in
  3. Start your document with \documentclass{qanda}

To produce the answers to your questions, simply include the \theendnotes command where you want them in your document. Preface this with \newpage if you want them on a new page.

Note that the qanda class is based on the scrartcl class, so you need that on your computer. You also will need to have installed the enumerate and setspace packages.

Enjoy!