1/45
Looks like no tags are added yet.
Standard deviation (SD)
The average distance of the observations to the mean.
Standard deviation function (R)
sd(X , na.rm = T)
Standard deviation formula (R)
sd(X) = sqrt(sum(obsevation_x - mean_x)² / sum(x))
Normal distribution
Range of data where 95% of the observations fall within 1.96 SDs from the mean.
Z-scores
Distance from the mean in standard deviations for a individual observation.
Z-score formula (R)
observation_x - mean_x / sd(x)
Centering
Center the data around the mean to determine if the observation is above or below the mean.
Scaling
Adjusts the data to to tell us how many SDs away an observation is from the mean.
Variance
Square of the standard deviation, used to measure spread of distribution.
Scatterplot
Visualize relationship between two variables by plotting X against Y.
Correlation Coefficient
Summarizes the direction and strength of the linear association between the two variables.
Correlation Coefficient Formula (descriptive)
Sum of the product of the z-scores of X and Y divided by the number of observations.
Correlation Coefficient Interpretation: Line of Best Fit
cor > 0 = line of best fit is positive
cor < 0 = line of best fit is negative
Correlation Coefficient Interpretation: Strength of Linear Association
|cor| = 0 : no linear association
|cor| = 1 : perfect linear association
Process of Prediction
Fitting a model and making predictions.
Predictors
Variables that are used as the basis for our prediction (X).
Outcome Variable
Variables that are used to measure what we want to predict (Y)
Y(hat)
The predicted value of Y based on the values of X and the model that summarizes the relationship between X and Y.
E(hat) = Y - Y(hat)
The errors of our predictors.
Line coefficients
Intercept & Slope
Intercept - a(hat)
Specifies the vertical location of the line.
Slope - b(hat)
Angle or steepness of the line.
Line formula.
Y(hat) = a(hat) + b(hat)X
lm()
Used to fit a linear model. lm(Y ~ X, data = df)
Fitted line
Used to measure the linear relationship between X and Y.
Fitted Line Formula
Y(Hat) = a(hat) + b(hat)X
Residual
The difference between the predicted value and the actual value.
Least squares method
Used to minimize residuals by finding a fitted line where the sum of the square of the prediction errors is lowest.
Model Fit
How good does the model do in making predictions?
R2
Measure the proportion of the variation in the outcome variable explained by the model.
Impact of R2
Higher value means that the model better fits the data.
Formula of R2
R^2 = cor(X , Y )^2
Linear Models - Best Practice
Find X variables that are correlated with Y.
Observational Data
Data collected about naturally occurring events,
Confounders
Variables that affects both the treatment and outcome variables.
Issue of Confounders
Confounders obscure the causal relationship between X and Y.
Relationship between slope and difference-in-means
Same value.
Relationship between intercept and control group.
Same value.
Multiple Linear Regression
Linear regression with more than one treatment variables.
Interpreting Coefficients in Multiple Linear Regression
Intercept is Y when all X are 0. (A)
Slope is the change of Yj associated with the change of Xj = 1 while holding all other X variables constant. (B)
Confounding and Muliple Linear
Adding confounders as controls in the model makes treatment and control group s comparable after controls.
Controlling Confounding
Adding Z as a control variable in the model makes the values of Z constant.
Probability
Proportion of specific events over infinitely many identical trials.
Probability Distribution
Likelihood of each value can take.
Sample Variation
Variance of the sample’s observation.
Effects of Sample Size
Larger sample sizes are closer to the true effect of the population.