Course Outline
-
segmentGetting Started (Don't Skip This Part)
-
segmentCollege / Introductory Statistics with R (ABC)
-
segmentPART I: EXPLORING VARIATION
-
segmentChapter 1 - Welcome to Statistics: A Modeling Approach
-
segmentChapter 2 - Understanding Data
-
2.5 Measurement
-
segmentChapter 3 - Examining Distributions
-
segmentChapter 4 - Explaining Variation
-
segmentPART II: MODELING VARIATION
-
segmentChapter 5 - A Simple Model
-
segmentChapter 6 - Quantifying Error
-
segmentChapter 7 - Adding an Explanatory Variable to the Model
-
segmentChapter 8 - Digging Deeper into Group Models
-
segmentChapter 9 - Models with a Quantitative Explanatory Variable
-
segmentPART III: EVALUATING MODELS
-
segmentChapter 10 - The Logic of Inference
-
segmentChapter 11 - Model Comparison with F
-
segmentChapter 12 - Parameter Estimation and Confidence Intervals
-
segmentChapter 13 - What You Have Learned
-
segmentFinishing Up (Don't Skip This Part!)
-
segmentResources
list College / Introductory Statistics with R (ABC)
2.5 Measurement
Measurement is the process of turning variation in the world into data. When we measure, we assign numbers or category labels to some sample of cases in order to represent some attribute or dimension along which the cases vary.
Let’s make this more concrete by looking at some more measurements,
in a dataset called Fingers
. A sample of college students
filled in an online survey in which they were asked a variety of basic
demographic questions. They also were asked to measure the length of
each finger on their right hand.
require(coursekata)
Fingers <- Fingers %>%
mutate_if(is.factor, as.numeric) %>%
arrange(desc(Gender)) %>%
{.[1, "FamilyMembers"] <- 2; . } %>%
{.[1, "Height"] <- 62; . }
# A way to look at a data frame is to type its name
# Look at the data frame called Fingers
# A way to look at a data frame is to type its name
# Look at the data frame called Fingers
Fingers
ex() %>% check_output_expr("Fingers")
You’ll notice that trying to look at the whole data frame can be very cumbersome, especially for larger datasets.
require(coursekata)
Fingers <- Fingers %>%
mutate_if(is.factor, as.numeric) %>%
arrange(desc(Gender)) %>%
{.[1, "FamilyMembers"] <- 2; . } %>%
{.[1, "Height"] <- 62; . }
# Remember the head() command?
# Use it to look at the first six rows of Fingers
# Remember the head() command?
# Use it to look at the first six rows of Fingers
head(Fingers)
ex() %>% check_output_expr("head(Fingers)", missing_msg = "Did you call `head()` with `Fingers`?")
Gender RaceEthnic FamilyMembers SSLast Year Job MathAnxious Interest GradePredict Thumb Index Middle Ring Pinkie Height Weight Sex
1 2 3 2 NA 3 1 4 1 3.3 66.00 79.0 84.0 74.0 57.0 62 188 2
2 2 3 4 9 2 2 5 3 4.0 58.42 76.2 91.4 76.2 63.5 70 145 2
3 2 3 2 3 2 2 2 3 4.0 70.00 80.0 90.0 70.0 65.0 69 175 2
4 2 1 5 7 2 1 1 3 3.7 59.00 83.0 87.0 79.0 64.0 72 155 2
5 2 5 2 9 3 1 5 3 4.0 64.00 76.0 89.0 76.0 69.0 70 180 2
6 2 3 7 7037 3 1 5 2 3.3 67.00 83.0 95.0 86.0 75.0 71 145 2
The command head()
shows you the first six rows of a
data frame, but if you wanted to look at a different number of rows, you
can just add in a number at the end like this.
require(coursekata)
Fingers <- Fingers %>%
mutate_if(is.factor, as.numeric) %>%
arrange(desc(Gender)) %>%
{.[1, "FamilyMembers"] <- 2; . } %>%
{.[1, "Height"] <- 62; . }
# Try it and see what happens
head(Fingers, 3)
# Try it and see what happens
head(Fingers, 3)
ex() %>% check_function("head") %>% check_arg("n") %>% check_equal()
Gender RaceEthnic FamilyMembers SSLast Year Job MathAnxious Interest GradePredict Thumb Index Middle Ring Pinkie Height Weight Sex
1 2 3 2 NA 3 1 4 1 3.3 66.00 79.0 84.0 74.0 57.0 62 188 2
2 2 3 4 9 2 2 5 3 4.0 58.42 76.2 91.4 76.2 63.5 70 145 2
3 2 3 2 3 2 2 2 3 4.0 70.00 80.0 90.0 70.0 65.0 69 175 2
Notice that to answer these questions, you need to know something
about how these numbers were measured. You need to know: Was
Height
measured with inches? What number represents which
Gender
? Does FamilyMembers
include the person
answering the question?
We will be talking a lot about what measurements mean throughout the class. But before we go on, let’s learn one more way to take a quick look at a data frame.
require(coursekata)
Fingers <- Fingers %>%
mutate_if(is.factor, as.numeric) %>%
arrange(desc(Gender)) %>%
{.[1, "FamilyMembers"] <- 2; . } %>%
{.[1, "Height"] <- 62; . }
# Try using tail() to look at the last 6 rows of the Fingers data frame.
# Try using tail() to look at the last 6 rows of the Fingers data frame.
tail(Fingers)
ex() %>% check_function("tail") %>% check_result() %>% check_equal()
Gender RaceEthnic FamilyMembers SSLast Year Job MathAnxious Interest GradePredict Thumb Index Middle Ring Pinkie Height Weight Sex
152 1 4 7 6 3 1 5 2 3.0 59 69 79 72 56 67.5 193 1
153 1 4 7 3 3 1 5 2 3.0 50 71 78 75 57 65.5 145 1
154 1 4 8 2354 2 2 3 2 2.7 64 70 76 70 51 59.0 114 1
155 1 4 3 789 1 1 4 2 2.7 50 70 85 74 55 64.0 165 1
156 1 3 8 0 3 2 4 2 3.7 57 67 73 65 55 63.0 125 1
157 1 1 6 NA 2 1 5 3 3.3 56 69 76 72 60 72.0 133 1