1/44
Main takeaways for this course: how to ask and answer questions about political/social processes in a scientific way and how to use statistical software to conduct quantitative analysis
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What is quantitative analysis?
The use of numerical data to ask and answer questions. Often a matter of examining intuitions with measurable facts.
What is a dataset?
Most common way it is structures is in a series of columns (variables) and rows (cases). They’re constructed of data from the population of interest.
In R, a dataset is referred to as a data frame
What are “cases”?
Cases = observations = units
Cases (or observations) are drawn from the population thats being studied. (Ex. People → individuals, families)
If a dataset has an observation for every member of the population, that is enumeration.
If a data set has observations for some of the members of a population, that is a sample.
What are variables?
A variable is a logical grouping of a unit’s potential attributes, which take on a different value for each attribute. Variables take on only one value for each case in the dataset and the values that variables take on must be mutually exclusive.
Ex. Unit is people, so variables are height, religion, ethnicity, gender, etc
What are nominal-level variables?
Values that are categories and cannot be ranked in any particular order. They are just names.
Ex. hair color, religious affiliation, region of country
What are ordinal-level variables?
Values that are categories that can be ordered, but these valued don’t tell us anything about how they’re measures, or the intervals.
Ex. strongly agree → strongly disagree, water temp description, ideology
What are interval-level variables?
Values that are categories that can be ordered and tell us the intervals between any two units.
Ex. age, temperature (in degrees), income
What is the mode of a variable?
The mode of a variable is the value it takes on most frequently in a group of units.
What is the median of a variable?
The median of a variable is the value that divides the units right down the middle when we order them from lowest to highest values.
Start from the top of the tabulation and move down one row at a time, adding up the percentages until reaching the 50% threshold
What is the mean of a variable?
The mean of a variable is the quantity obtained when you add up all the values the variable takes on and divide by the total number of units.
What are measures of central tendency and levels of measurement?
Measures of Central Tendency: mean, median, and mode
Levels of Measurement: nominal, ordinal, and interval

Steps to uploading a dataset into R
Upload to R
Click on the file and select import dataset
Library(readr)
dataset ← read_csv(“dataset”)
What are the different components on the R inerface
Source: where the data frame is loaded into
Console: the commands used to import the data
Environment: lists active objects (data frames)
Files: lists all files in working directory, and where histograms show up
Comman commands in R
Library(readr) → downloads the package needed to analyze the data
dataset ← read_csv(“datasetI”) → transforms the object into the dataset
View(dataset) → displays the object in the source window
dim(dataset) → shows the dimensions (how many rows and columns)
head/tail(dataset) → shows the first/last few rows of the dataset
dataset<em>variable</em>→selectsthedatasetandthevariableyou’relookingtoexplore</p></li><li><p>hist(<em>dataset</em>variable) → creates a histogram for the variable in the sample
install.packages(“descr”) → package that has a lot of functions and allows for freq
freq(variable) → produces frequency distributions for the variable
summary(dataset) → provides the summary statistics on all the variables in dataset
sd(dataset$variable, na.rm=TRUE) → calculating the standard deviation
How do you run commands on R?
His command+enter or click “Run” in the upper right corner of the source window
What is percent, valid percent, and cumulative percentages?
Percent is using all cases, even the ones that are NA
Valid percent is calculates with cases that have no non-missing data (no NA, or “valid cases”) in the denominator
Cumulative percentages indicate the share of cases with values equal to or less than the value shown in the row, making it quick to see the median (look for the first value greater than 50%)
R only produces cumulative percentages for ordered factors
T/F: You need to install packages every time you use them in R
False → once a package is downloaded and installed on your device, it does not need to be downloaded or installed again
T/F: You need to activate a package every time you use it in R
True → packages are activates using the library () function. The name of the package is not enclosed in ““
T/F: the dollar sign $ “comments out” text in an R script for R to ignore
False → to comment out text in R script you use the # symbol. The $ is used to invoke variables in R with the syntax dataframe$variable
T/F: the assignment operator (→) is a way that functions transform objects into new objects
Almost true → the assignment operator is written with an arrow pointed to the left (←)
T/F: there are often multiple ways to do the same thing in R
True → for example, the hist() and freq() functions make histograms
What are statistics?
Statistics are numbers that summarize data
What is the summation sign?
Σ (sigma) which means add up everything after it
What is the difference between N and n?
N refers to the total number of observations
n is a reference to any individual observation
How do you use ellipsis?
For example, when you want to refer to multiple observations (n=1 to n=10), you can write it as n=1…10. Here, the ellipsis refers to 2, 3, 4, 5, 6, 7, 8, and 9.
Used to denote a range of values between two endpoints
What is indexing?
If you want to talk about a variable’s value for any observation in a dataset, you index it with its n. This appears as a subscript: variablen
Ex. birthyear2 = 2005
What does X bar mean?
The bar refers to the mean of a specific variable
What are measures of spread?
More dispersion (no clear middle): more polarized and more disagreements
Less dispersion (a clear middle): least polarized and more consensus
Assessing dispersion is not just of statistical interest. Spread can often have political implication.
What is the standard deviation?
The measure of spread used most frequently with interval-level data. It is the typical distance by which observations fall from their mean.
The name comes from the fact that the statistic tells us the standard amount by which observations deviate from their mean
Symmetric vs. Skewed means
Symmetric: the distributions are mirror images of one another on either side of the mean
Skewed: non-symmetrical with tails skewed to the left or right (if a tail goes to the left that means it’s skewed to the left, even if the tail is shorter than the other distributions)
Unimodal vs. Bimodal distributions
Unimodal: when there is a single peak in the data distribution
Bimodal: when there are multiple peaks in the data distribution
What is a distribution?
A distribution describes how the values of a variable are spread across (or distributed across) all the possible outcomes, and how often each outcome occurs. Typically displayed as tables/histograms
What are dichotomous and binary variables?
Dichotomous Variable: A categorical variable that naturally or conceptually has only two possible categories or states (ex. yes/no, alive/dead, male/female)
Binary Variable: A specific sub-type of a dichotomous variable that is specifically coded using 0 and 1, where 1 represents the presence of a characteristic and 0 represents its absence
What are logical expressions?
Logical expressions are how you state conditions that must be met for R to take action. The four key types of logical expression:
Equal to: ==
Not equal to: !=
And: &
Or: |
Ex. “run the histogram for all observation that meet the condition where X is not equal to Y” → hist(dataset<em>variable</em>)<br>[<em>dataset</em>X != “Y”])
What is as.numeric?
It is helpful in recording a variable into a dichotomous zero-one variable. You basically tell R what observations you want scored 1 and all the other observations are scored 0.
Written as: dataset<em>variable01</em><br>←as.numeric(<em>dataset</em>variable==”value you want to be scored 1”
In principle, any variable can be transformed into a dichotomous variable
What changes about the modes and medians of dichotomous variables?
The medians of dichotomous zero-one variables are equal to the value most frequently observed, either 0 or 1. This means that the median is always equal to the mode.
What do dispersions and sd’s of dichotomous variables mean?
As any dichotomous variable’s mean tends toward 0 or 1, it becomes less dispersed/more concentrated. As a dichotomous variable’s mean tends toward 0.5, it becomes more dispersed.
How to answer this question on R: What’s percentage of the countries in the dataset are in the EU?
library(descr)
freq(dataset$variable)
The variable will show the percentage
What is the Law of Large Numbers?
With representative samples we expect X-bar to be equal to μ. As the size of a representative sample increases, we expect the mean of the sample to get closer to the population mean.
Large samples are more likely to be similar to the population than small samples.
The LLN tells us that a sample size of…
• … N = 5 is less likely to have X-barage near μage then a sample of N = 50.
• … N = 50 is less likely to have X-barage near μage then a sample of N = 500.
• … N = 500 is less likely to have X-barage near μage then a sample of N = 5,000

How do you look at just two columns in a dataframe on R?
Create a new dataframe with just those two variables:
justprop ← data.frame(dataframe<em>variable1</em>,<em>dataframe</em>variable2)
What is the Central Limit Theorem?
Posits that larger representative samples yield X-bars that are distributed Normal, and we can describe this Normal distribution with a known formula.
(the sampling distribution of a sample mean approximates a normal distribution as the sample size gets larger, regardless of the shape of the population's original distribution)
The normal distribution is a special kind of symmetric, unimodal distribution that appears over and over again when we aggregate data.
What happens to a distribution when the standard deviation of a Normal distribution gets larger?
With all things being equal, as the sd of a normal distribution gets larger, its tails become fatter but the unimodal, symmetric, bell-shape distribution is always there.
What are some characteristics of a normal distribution?

This is the shape of every Normal distribution. It is centered on its mean, and just about every observation lies within 3 sd’s on either side of its mean. For any variable to be distributed normal it must be unimodal, symmetrical about its mean, and describes with a formula that tells us exactly how much of the data lies at any interval in the distribution.
This means 50% of the observations are greater than μ
95.4% of all the observations are within 2 sd’s of μ
95% of all the observations are within 1.96 sd’s of μ
Central Limit Theorem tells us the Normal distribution’s mean (μ) and sd
What do the LLN and CLT tell us about the distributions of X-bars from skewed, bimodal, and dichotomous distributions?

They will all be distributed normal with the mean and sd:
