1/83
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
View()
allows you to view dataframes in a spreadsheet format
glimpse()
shows you an overview of the dataframe - the columns and first few rows
names()
returns a list of variable/column names
getwd()
returns the path for your working directory
YAML
sets the document details -> name, format, date
install.packages()
installs a package to the first time onto your computer
library()
loads a package in your workspace
ggplot()
initializes data visualization object with ggplot2
tidyverse
collection of R packages that have common grammar and data structure
geom_point()
makes a scatterplot
geom_boxplot()
makes a boxplot
geom_bar()
makes a bar chart
geom_line()
makes a line graph
labs()
sets labels
size
sets the variable to determine size of points
color
sets the variable to determine color
alpha
sets the transparency
fill
sets the color
#| warning: false
suppresses warnings that result from code
#| message: false
suppresses messages that result from code
filter()
filters to rows matching certain criteria
slice()
pick rows using an index/range of indeces
distinct()
filters for unique rows
select()
chooses variables by name
arrange()
orders rows by a certain value, ascending is default--use desc() for descending
summarize()
creates a new variable and displays summary statistics
group_by()
groups observations by a variable
mutate()
creates a new variable
sample_n()
takes a random sample with n observations
sample_frac()
takes a random sample of a fraction of observations
case_when()
creates a set of conditions/formulas for defining new variables
|>
pipes the previous row into the next- used output of one row as input for next
na.rm = T
removes NA values
dibinom(______)
k, size=n, prob=p
dipois(_____)
x=k, lambda=λ
Representative Sample
characteristics of the sample are similar to that of the population
Generalizability
extent that results form a sample can be used to draw conclusions about a population
Probability Sample
all units have a known probability of being selected
Simple Random Sample
every individual has an exact, equal, and independent chance of being chosen
Stratified Sample
a sample drawn in such a way that known subgroups within a population are represented in proportion to their numbers in the general population
Cluster Sample
obtained by selecting all individuals within a randomly selected collection or group of individuals
Non-Probability Sample
some units can't be selected or there is no way of knowing the probability of selecting any individual
Quota Sample
selecting individuals until a specific number is met
Convenience Sample
only members of the population who are easily accessible are selected
Snowball Sample
a sample in which respondents are asked to identify additional members of a population
Experimental Studies
researchers control exposure/treatment
Observational Studies
exposures/treatments are not assigned by the researchers
Selection Bias
the sample is not representative of the population being studied
Reporting Bias
the tendency to under-report available info
Non-Response Bias
bias introduced to a sample when a large fraction of those sampled fails to respond
Attrition Bias
occurs when participants drop out of a long-term experiment or study
Falsified Data
Data that are fabricated, or made up, by researchers intentionally trying to pass off research results that are inaccurate. This is a serious ethical breach and can even be a criminal offense.
Why is transparency important in research?
to uphold integrity, promote trust, and prevent harm
Reproducibility
being able to use the original data and methods/code to get the same results
Replicability
being able to independently repeat a study with the same methods with new data
Exploratory Data Analysis
summarizes a dataset main characteristics to help you get familiar with the data and identify and data quality issues
Nominal Categorical Data
named categories with no numeric meaning
Ordinal Categorical Data
ordered categories with relative comparisons
Count or Rank Numerical Data
e.g. number of drinks consumed
Continuous Data
measurable quantities that can take on any value
Parameters
describe a population
Statistics
describe a sample
Frequentist
probability is defined by the frequency of an event
Bayesian
probability as a measure of certainty about an event, updates as information becomes available
Probability Space
models random experiments or real world random events
Sample Space
set of all possible outcomes
Event
any possible number of outcomes (subset of sample space)
Disjoint/Mutually Exclusive
P(A or B) = P(A) + P(B)
Complement Rule
P(Ac) = 1 - P(A)
Komolgorov Axioms
1. Probability of any event occurring in the sample space is between 0 and 1
2. Probability of the whole sample space is 1
3. If A and B are disjoint, P(A or B) = P(A) + P(B)
Independence
P(A and B) = P(A) x P(B)
Prevalence
% of people with a condition
Sensitivity
true positive rate
Specificity
true negative rate (1 - false positive rate)
Positive Predictive Value
The probability that subjects with a positive test truly have the disease.
Negative Predictive Value
The probability that a person with a negative test result is truly disease free
Discrete Probability Distributions
1. outcomes are disjoint
2. probability of each outcome is between 0 and 1
3. sum of probabilities of all outcomes is 1
Bernoulli Distribution
binary outcomes with probability of success = p
Binomial Distribution
1. fixed number of Bernoulli trials
2. outcomes are independent
3. probability of success p is the same for each trial
Poisson Distribution
1. within any interval, k can take on any value 0,1,2...infinity
2. each event occurs independently
3. the average rate that events occur in an interval is constant
4. two events can't occur simultaneously
Expected Value
weighted avg of possible outcomes
Bernoulli: p
Binomial: np
Poisson: lambda
Variance
expected spread of values around the expected value
Bernoulli: p(1-p)
Binomial: np(1-p)
Poisson: lambda
Continuous Probability Distributions
given by a probability density function with are under the curve = 1 -- described for ranged or values
z-score
z=(x-mu)/sigma --> tells us how many population standard deviations an observation is away from the population mean