1/64
Looks like no tags are added yet.
R
A programming language and software environment used for statistical computing and graphics, widely used among statisticians and data miners.
R Studio
An integrated development environment (IDE) for R, providing tools for coding, debugging, and visualizing data.
Upper left window is called
R script (input)
Lower left window is called
R console (output)
upper right window is
environment (lists created objects)
##
distinguishes output from code
←
to create an object, left is name right is content (four← 1+3)
what should NOT be in quotes
names of objects, functions, and arguments as well as special values (TRUE, FALSE, NA, NULL)
required arguments
inputs we must specify in order to use a particular function
optional arguments
inputs that we could specify if we wanted to modify the functions default setting
sqrt()
square root
#
to comment on the code so R doesn’t read it
setwd()
set working directory
view()
opens a new tab in the upper left window with contents of data set
head()
shows first six rows of observations in a data set, n=x to display different amounts of lines
observation
the information collected from a particular individual in the study
i
row in the dataframe
variable
captures values of a changing characteristic for the multiple individuals
dim()
provides the dimensions of the data frame
$
access values of a single variable
nonbinary
average in nonprecentage
average causal effect
the average of all the individual causal effects of x on y within a group
randomized experiment
treatment assignment is random, ensuring that treatment and control groups are identical to eachother in all observed and unobserved pre-treatment characteristics
average effect formula
ytreatment-ycontrol
observational data
collected from naturally occurring events
==
measures whether two values are equal to eachother (TRUE or FALSE)
ifelse()
if logical test is true, return this, else, return that
““
around words
[]
to the left, we specify variable we want to subset, inside, specify the criterion of selection
to calculate average reading scores among only students who attended the small class
mean(starreading[starsmall==1])
nonbinary
same unit of measurement as the outcome variable
binary
percentage points (multiply result by 100)
factual outcome
potential outcome under the treatment condition taken in reality
counter factual outcome
potential outcome under the opposite treatment condition as the one taken in reality
reasons one couldn’t do a randomized experiment
ethical, logical, financial
ifelse must have how many arguments
3 arguments, logical test/return if TRUE/ return if FALSE
random sampling
randomly selecting individuals from the population
sampling frame
the complete list of individuals in a population
unit nonresponse
some randomly selected individuals might refuse to participate in the study
item nonresponse
when an individual chooses to not answer a question
misreporting
participants provide false information
Read and store data set
bes← read.csv(“BES.CSV”)
frequency table
shows the values the variable takes and the number of times each value appears in variable, table()
prop.table()
create a table of proportions
exclude=NULL
this will ensure that the function includes the missing values
na.rm
“NA Remove” setting equal to true
na.omit()
remove missing values
two-way frequency table
shows the number of observations that take each combination of values of two specified variables
two-way table of proportions
shows the proportion of observations that take each combination of values of two specified variables
density histogram
uses density instead of frequency as the height
descriptive statistics
numerically summarizes the main characteristics of its distribution
plot()
scatter plot
abline()
add straight line to the graph in R, vertical set argument equal to v, horizontal set argument equal to h
correlation coefficient
summarizes the direction and the linear association between 2 variables (-1 to 1)
z-score
the number of sd’s the observation is above or below the mean
cor()
correlation coefficient
acquiesces bias
select positive response (yes)
social desirability bias
select answer that makes them look good or cool
outcome variables
measures the attitude we are trying to explain
explanatory variables
measures attitude or experience we think explains the outcome
!
flips the value
Wording Pitfalls
Jargon or too much info
▶ Leading descriptions
▶ Double negatives
▶ Compound/double-barreled questions
▶ Ambiguous or vague terms
difference in mean
Δ ̂𝑌 = 𝑌𝑡𝑟𝑒𝑎𝑡𝑚𝑒𝑛𝑡−𝑌𝑐𝑜𝑛𝑡𝑟𝑜
What is partisan expressive response?
A partisan chooses the survey response option that portrays their ‘team’ in a positive light (or the other team in a negative light), even though that response is inconsistent with their real beliefs or attitudes