## Regressions: An Electoral College Example

The most recent presidential election — where Donald Trump beat Hillary Clinton in terms of electoral college votes but lost the popular vote — had many people wondering just how electoral votes were assigned to states.

Suppose you read on the internet that the number of electoral votes a state received, was based on its population. In other words: electoral votes (Y) were determined by population (X).

You go on Twitter or Facebook, and post this “fact”. Of course, being social media, someone challenges you to prove it. Here’s how you do it.
You can do this with a statistical technique known as a regression. Here’s how:

Step 1. Collect the Data

Electoral votes and population are already measurable, you just have to find the data, and hope it’s reliable. Fortunately, Census.gov has the population data and Archive.gov has the number of electoral votes:

Source: Census.gov (https://www.census.gov/data/tables/2016/demo/popest/nation-total.html) for the population data and Archive.gov (https://www.archives.gov/federal-register/electoral-college/allocation.html) for the electoral votes

Step 2. Run a Statistical Operation

If you chart population versus electoral votes, you get the following figure, which suggests using a regression as the statistical operation. A regression finds the best line or curve that fits the data.

A Chart of Population versus Electoral Votes

The chart below show the results of the regression. In this case a line best fit the data. This particular regression was done in Microsoft Excel using Data > Data Analysis > Regression, on the table above.

A Regression for Population vs Electoral Votes. Because the curve is a line, this is known as a Linear Regression.

Step 3. See if the Results are Significant

Statistical operations often include a significance measure. For regressions, this measure is R-squared, which ranges from 0 (not significant) to 1 (significant). In the chart above R-squared is .9991 and since it is close to 1 it is significant.

Step 4. Declare your Hypothesis is a Theory, if Significant

Since R-squared is .9991, and this is a significant value, you can proudly post on social media that you’ve proven your theory:

“population determines number of electoral votes.”

And no one can argue with you, because your theories are backed up with reliable data and appropriate statistics.

An Aside on Predictive Power

What’s even better for you is that your theory is predictive. Let me explain.

When you run a regression, you also get the values you need to reconstruct the equation for the curve. For a line, this is an equation of the form:

y=mx+b

If you remember your high school algebra, m is the slope and b is the y-intercept.

You can partly see this equation in the chart above: y=1E-06x+1.9602. I say partly because 1E-06 is really 1.41874E-06. The Excel regression gives the exact values in a table:

Plugging these values in, you get the equation:

ELECTORAL VOTES = 1.41871/1,000,000 * POPULATION+ 1.96

In plain English, take a state’s population, divide by 1 million, multiply by 1.42, add 1.96, and round up.

CHECK

California’s Population: 37,253,956
Divide by 1,000,000 = 37.253956
Multiply by 1.42=52.90
Round up: 55 ← CORRECT

Wyoming’s Population: 563,626
Divide by 1,000,000: .563626
Multiply by 1.42=0.80
Round up: 3 ← CORRECT

So the regression yields an equation with the correct value, but what does this equation actually mean? According to Archive.gov:

Electoral votes are allocated among the states based on the Census. Every state is allocated a number of votes equal to the number of senators and representatives in its U.S. Congressional delegation — two votes for its senators in the U.S. Senate plus a number of votes equal to the number of its members in the U. S. House of Representatives.

The 1.42 times the population in millions denotes the number of representatives a state has. The 1.92 denotes the 2 senators. It’s quite astonishing that a simple statistical operation was able to discover precisely what that statement means!

## Programming 101 FAQ

Welcome to Programming 101 (aka MGMT 330 — Fundamentals of Business Programming at the University of New Mexico’s Anderson School of Management).

I’m Professor Flor and I’ll be your instructor. Now, it’s a long semester and we have plenty of time to answer questions, so let me answer just a couple of the most common and important questions.

What Will I Learn?

I’m going to teach you how to program business applications using the following technologies:

• HTML (language for building user interfaces)
• JavaScript (language for client-side scripting)
• C# (language for server-side scripting)
• SQL Server (database)
• ASP.NET (API: Application Programming Interface)
• Visual Studio (IDE: Integrated Development Environment)

Yes, those bullet items are what you list in your resume under skills.

A business application is a computer program that’s useful for a business. Such applications usually store and retrieve different “views” of information, usually customer or product information.

Contrast business applications with scientific applications that focus on running large volumes of information through equations and graphing the results.

We’ll do some graphical representation of the information, but the focus will be on storing and retrieving business-related information to help managers make decisions.

Great! How do I Start?

Three steps:

2. Do the First Week’s Readings
3. Do the First Homework Assignment

How Do I Do Well in the Course?

Easy:

• Do the homework assignment
• Make sure you can write all the assignments from scratch, from your head, without looking.

That last point is very important. Here’s why: If you can do an assignment from scratch, you’ve internalized the important concepts.

Many programmers never internalize the skill needed to develop innovative applications. They’re stuck copying other people’s code off the internet and making superficial changes. To be honest, you can create many apps with this kind of superficial knowledge, but the chances of you doing anything truly innovative go way down. And when you can’t find someone else’s code to copy, you’re lost.

Don’t be a superficial programmer. aka a Script Kiddie.

How Do I Become an Expert Programmer?

Programming is a form of mental exercise. Like any exercise, say physical exercise, you get better, stronger, and faster with practice. So practice writing a lot of different kinds of applications.

Practice is the only way.  There are no shortcuts.

Reinvent the wheel — reprogram those basic pieces of code — before you reuse other people’s wheels.

As I already mentioned too many people just Copy And Tweak (“CAT” strategy) other people’s code. That will only get you so far. If you want to be an expert, write your own code, at least while you’re learning.

I Found a Great Piece of Code on The Internet Can I Just Copy & Reuse It? I Understand it. I Swear

No. This is an introductory class and you need to prove you understand the concepts by writing them from scratch.

If you are caught plagiarizing code off the internet or from your fellow students, I will FAIL YOU FROM THE COURSE. “Ain’t nobody got no time for that cheating nonsense,” and believe me, I’ve heard all the excuses.

## Programming 101: Key Mental Models

Programming is about casting spells on machines so that they serve your will.

Okay, okay. So maybe it’s not really magic. But it is magic-like. You have to learn a cryptic language, and you have to speak (type) the symbols in the right order for your spell to work properly.

So why does programming have a reputation for being hard? Because there are many pieces involved, which require many different “Mental Models”.  What’s a mental model, you ask? A mental model is something in your head that helps you make predictions about how things in the world (people, animals, machines, etc.) will react in response to your actions or events in the world.

Suppose you’re a teen and you stay out late—past midnight on a school day. You know your parents will be very upset with you, and possibly yell at you the next day. How do you know that? You have a mental model of your parents! Another example: Don’t stare a dog in the eye because you might make it mad and it will bite you. How do you know that? You have a mental model of dogs.

A mental model doesn’t have to be 100% accurate. It’s merely a guide for your expectations and actions. You create mental models constantly and you constantly update your mental models in response to new information.

So let’s go through the mental models you need to know for programming.

Mental Model: Programming as Communication

Setting aside colorful magic, wizard, and spell metaphors, how should you think about programming?

Programming is communicating directions to a computer. So, you know how you sometimes give driving directions to other people? It’s like that. But instead of driving directions to a person (in English), it’s directions to a computer (in a language like C# or Java) for taking information and either

• Storing the information in memory, disk/USB drives, across the network;
• Calculating new information by using information in equations;
• Displaying the information.

And technically it’s only storing and calculating, because displaying information is a kind of storing of the information on screen or on paper.

Summary

So if someone asks you what programming is, tell them:

A. Programming is communicating directions to computers. But instead of communicating with a person, you’re communicating with a computer. Instead of communicating in English, you’re communicating in C# (or Java, JavaScript, C, C++, python, Pascal, or some other programming language).

B. Computers only know how to follow three directions:

1. store information,
2. calculate new information, or
3. display information.

Mental Model: Programming as Communicating With Computers

But how exactly do you communicate with a computer? Can you simply talk to it? Technically yes, but let’s pretend our computer doesn’t have voice recognition like our smart phones. And let’s continue using “communicating with people” as our starting point for understanding programming computers.

When we communicate with other people we simply talk and if they’re paying attention, they hear us and respond appropriately.

When we’re communicating with a computer, instead of speaking words in English, we’re:

1. Typing code from a computer language into an editor.
2. Saving our code as a file on the computer. And then telling the computer to
3. Run the code.

Mental Model: Coding as Storytelling

Almost every well-written story consists of three parts: a beginning, a middle, and an end.  In the beginning, the hero encounters a problem. The middle is spent searching for a solution. And in the end the hero solves the problem.

Similarly, almost all code also has a three-part structure:

1. Input: getting information from the user, or from storage or from the network
2. Processing: running calculations on the information
3. Output: displaying the information to the user, or storing it, which may involve sending the information across the network.

Mental Model: Syntax as Grammar

Just like you can’t randomly mix words in a sentence and expect people to understand what you’re saying, you can’t randomly mix programming terms and expect the computer to run your program without crashing.

English has a grammar, and Programming Languages have a syntax. When you hear the term “syntax” think grammar. Bad syntax leads to your code crashing, just like bad grammar leads to people misunderstanding you (a kind of human crash).

Mental Model: How Software and Hardware Interact

A computer consists of storage (hard drive, usb drive), memory (RAM), a processor (Intel or AMD), and a graphics card (NVidia, AMD). Yes, there’s the network too, but let’s ignore it for now.

• Your program is kept in storage.
• When you run your program, it gets moved into memory.
• The processor reads and executes each line of code in memory.
• Any code for displaying information gets sent to the graphics card.

Those are the key mental models. Again they are not necessarily 100% accurate, but they should help organize your learning, and keep you from getting lost, as I teach you the syntax of the computer language. We’ll start off with JavaScript & HTML.

## The Problem with Disinviting Disagreeable Speakers on College Campuses

I’ll keep this short and simple. Three very good things can happen when faced with a disagreeable viewpoint:

1. You find out you are wrong, and you learn something.
2. You find out you are right, and your own viewpoints are strengthened.
3. You increase your critical analysis skills in the process of identifying the flaws in the speaker’s arguments.

I call these three things, the 3 consequential benefits of disagreeable speech, or simply The Three Benefits. So why would college administrators disinvite a speaker? Arguments in favor of disinvitation fall into three categories:

1. This speaker doesn’t represent the inclusiveness of our university
2. We don’t want to legitimize or to give a platform for harmful speech
3. We don’t want students’ feelings to be hurt

The fundamental problem with all those arguments — aside from being illogical — is that none of them outweigh the three benefits.

College students aren’t mindless sheep waiting to be brainwashed by a Cult Wolf Leader. College students are taught how to recognize bad arguments, and to react & counter them with facts and objective reasoning.

If a speaker’s viewpoint is indeed harmful, you aren’t legitimizing it or giving it a platform for spreading — again, that assumes students are helpless & mindless sheep. No, instead you’re actually preparing students for fighting it and for helping others fight back.

College is the Shaolin Temple of Argument-Style Kung Fu. Don’t deny students the opportunity to hone their minds and their skills by disinviting speakers with disagreeable viewpoints.

And if you don’t believe me, because I’m too conservative, maybe you’ll listen to this guy:

## Cognitive Gamification, Part 2: Why Games?

Why do people like playing games in the first place? Evolution provides an answer.

63% of American Household have at least one person that plays video games regularly (3 or more hours per week), according to the Entertainment Software Association’s 2016 Essential Facts Report.

It’s clear that a large number of people enjoy playing video games, and games in general, but it’s not clear why. Playing games is a counter-productive activity. It takes time away from useful activities like actual work, or studying, or housework.

So again, why do people enjoy doing a counter-productive activity?

We like playing games today because, fundamentally, they allow us to practice those skills — eye-hand, exploring, gathering, strategic, and social — that gave primitive man a survival advantage.

For example, throwing a rock at a tree stump honed eye-hand coordination skills needed for hunting. Searching for and collecting things like shiny rocks honed the exploration and pattern-recognition skills needed for gathering. Finally, trading shiny rocks with others honed negotiation and other social skills.

There are many more examples we can imagine, but the point is this: those primitive people that enjoyed playing games were the ones who survived to pass on their genes.

In short, we are Wired by Evolution to enjoy games.

Today, most of us no longer need to hunt or to gather our food, so playing games seems like a counter-productive activity.

Nevertheless, the widespread playing of video games in modern society can be understood as a pre-adaptation for survival, co-opted for business.

Bird feathers are an example of a pre-adaptation for warmth, co-opted for flight. For a fascinating read on adaptions, pre-adaptations and exaptations, see:
Gould, S. J., & Vrba, E. S. (1982). Exaptation—a missing term in the science of form. Paleobiology, 8, 4-15.

## The Data Disagrees with the GOPe

by Nick V. Flor • February 27, 2016 • @ProfessorF

The New York Times recently published an article outlining several secret plans by the GOP Establishment (“GOPe”) to take down Trump should he become the Republican nominee.  Why? Because they are absolutely terrified that Trump will win the Republican nomination, yet then go on to lose big to Hillary in the general election. They’re certain that the best path to victory is some other candidate that reflects conservative values (well, other than Ted Cruz, of course, because “no one likes him”, they say).

What hypocrites.

For eight years Republican politicians have been telling us that they are the true party of We The People, that they are the only ones that care for and value Americans.  Well, if that’s true, and We The People vote Trump as the nominee, shouldn’t they care for and value our decision, instead of fighting against what we voted for?

I guess it’s all about The Greater Good. But let’s not dwell on their hypocrisy.  Let’s decide this with data.  Let’s see what the data says about their key claims: (1) Trump will win the Republican nomination; and (2) Trump will lose big to Hillary.

Claim 1: Trump Will Win the Republican Nomination (Likely)

You can check this claim via prediction markets. A prediction market is a bunch of people that place actual money bets on who will win various events—like sports and elections. Because money is on the line, bettors tend to do their homework and research shows market predictions are more accurate than polls.

Here are the latest results from my favorite prediction market:

Note that the market has Trump winning by 61 points over his closest rival Rubio.  Conservative favorite, Ted Cruz, comes in last with only 1% of the market thinking he will be the Republican nominee. And the market is usually right.

Data says: Likely.

Claim 2: Trump Will Lose Big To Hillary (Unlikely to “Lose Big”)

One way to check this claim is to look at polling data, and one of the best sources of polling data is RealClearPolitics (“RCP”). They average different polls to come up with a single number for a variety of candidates and match-ups.  In their latest matchup between Trump & Hillary, they have Hillary up by 2.8 points:

But this particular poll includes a poll by PPD conducted in early February.  If that data point is removed, Hillary is only up by 1.3 points.

Data says: Unlikely (to losing “big”). But any loss is bad, and there is indeed a likelihood of losing.

My Recommendation to the GOPe

The data shows that Trump is not going to “lose badly” to Hillary if he’s the GOP nominee. In fact, the polling trend favors Trump.

If Trump does win the Republican nomination, my advice to the GOPe is this: Instead of secret plans to take down Trump, consider strategic plans to work with Trump to win the general election.

It is irrational to do otherwise.

(And no, I have not selected a candidate yet. I just don’t like the hypocrisy of the GOPe)