Sort the LaLonde Columns
Four types of variable, twelve columns, and what each type lets you compute.
The lalonde data (Matching package): 445 men in a job-training experiment
Six of the 445 rows.
- age
- age in years
- educ
- years of schooling
- black
- 1 = Black, 0 = not
- hisp
- 1 = Hispanic, 0 = not
- married
- 1 = married, 0 = not
- nodegr
- 1 = no high-school diploma, 0 = has one
- re74, re75, re78
- earnings in 1974, 1975 and 1978, in dollars
- u74, u75
- 1 = no earnings that year, 0 = some
- treat
- 1 = assigned to the training program, 0 = not
1. What type is each column?
You classified these before class. Now agree on one answer as a group.
As a group: put each column in its box.
ageeducblackhispmarriednodegrre74re75re78u74u75treat2. What does a column's type let you compute?
Pick a column. Once your group has committed step 1, each column is summarised the way its type allows.
The mean of black is 0.83. What does that number tell you?
The mean of treat is 0.42. Which reading is right?
Schooling, recorded twice
| educ (years) | 3–8 | 9 | 10 | 11 | 12 | 13–16 |
|---|---|---|---|---|---|---|
| Men | 64 | 68 | 102 | 114 | 75 | 22 |
Years of schooling run from 3 to 16.
| nodegr | 0 = has a diploma | 1 = no diploma |
|---|---|---|
| Men | 97 | 348 |
In every row, nodegr is 1 exactly when educ is below 12. A man with 8 years and a man with 11 years both get nodegr = 1.
3. One fact, two types
The data record schooling twice: educ in years, and nodegr, the same information cut at 12 years into diploma or not.
As a group: you want to know whether the training helped men who left school early. Which column would you use, and why? What does the column you didn't pick show that yours hides?
Points to compare
nodegrmatches how employers often screen: a diploma is a credential. But it treats 8 years and 11 years as the same.educkeeps that difference, but treating it as a number assumes every extra year counts the same. Any extra jump from finishing a diploma at year 12 doesn't show up as a step of its own.- You can make
nodegrfromeduc, but noteducfromnodegr. Cutting a quantity into categories throws information away, so the type is partly a choice, made when a variable is recorded or recoded. - Did your group say who “left school early” means? That definition decides which column fits.
4. Ask R
The first line asks R what kind of value each column holds. Run it as it is. Then replace the three NAs and run again:
share_treat: the share of men assigned to training, from the 0/1 columntreatn_educ: how many different valueseductakesn_re78: how many different valuesre78takes
Setup code (runs by itself)
Hint 1
The mean of a 0/1 column is its share of 1s.unique() lists a column's different values, and length() counts them.Hint 2
mean(lalonde$treat) for the share; length(unique(lalonde$educ)) for the count, and the same for re78.A new column
Suppose the study had also asked each man: “How satisfied are you with your job?”
| Code | Answer |
|---|---|
| 1 | Very unhappy |
| 2 | Unhappy |
| 3 | Neutral |
| 4 | Happy |
| 5 | Very happy |
5. What R's label means, then a new column
R calls treat, educ and re78 all “integer”. What does that tell you about their types?
Then: job satisfaction
As a group: what type is jobsat, and what can you safely report?
educ.A new file, no codebook
| id | region | score |
|---|---|---|
| 1 | 3 | 4 |
| 2 | 1 | 2 |
| 3 | 4 | 5 |
| 4 | 3 | 3 |
| 5 | 2 | 4 |
region takes the values 1 to 4; score takes 1 to 5. R calls both “integer”.
6. Before you take a mean
As a group: a colleague reports “mean region 2.6, mean score 3.6”. Before you trust either number, what would you check about each column, and how could each mean mislead a reader?
Points to compare
regionis probably four labels. If so, the mean of 2.6 means nothing, and renumbering the regions would change it. Report counts or shares.scorecould be a count (points on a quiz: discrete) or a rating from 1 to 5 (ordinal). For a rating, the mean assumes equal steps; the median and the share giving each answer don't.- Checks: find out what each value stands for, count the different values, and look at a table of them. R's class won't tell you.
You should now be able to:
- classify a column by what it measures, not by how it is stored (steps 1 and 4);
- say which summaries each type allows, and read the mean of a 0/1 column as a share (step 2);
- explain what is lost when a quantity is cut into categories (step 3);
- tell an ordered rating from a count, and report it with a median and shares (step 5).
Assumptions
- data
lalondefrom the R package Matching: 445 men in a job-training experiment. Earnings are rounded here to whole dollars. - simplificationHistograms use bins of one year (age), one year of schooling (educ) and $2,500 (earnings). SD is the sample SD (divide by n − 1).
- dataStep 4 reads the same 445 rows (earnings rounded to whole dollars) from a file, so R stores every column as “integer”. In the Matching package, earnings are stored with cents and R calls them “numeric”.
- dataIn these data,
nodegr= 1 exactly wheneduc< 12 (checked in R for all 445 men). - simplificationThe file in step 6 is made up, to pose the question.
- interpretationTypes follow the course's four categories. A variable is classified as recorded:
ageandeducare whole numbers, so discrete; earnings in dollars are treated as continuous; 0/1 codes are nominal categories. - interpretationAge is continuous in life but recorded here in whole years. The feedback says so rather than accepting both answers.
- interpretationNo column in
lalondeis ordinal; step 5 adds one.
How each column is classified is listed here once your group has committed step 1.
Left out: interval versus ratio scales, and whether to treat a 5-point scale as numeric in practice (a common, debated choice).