linear model Flashcards
(10 cards)
How can a t-test be expressed as a linear model?
Example: lm(vitd ~ TEON, data=meddata)
Interpretation:
Intercept = mean of baseline group (TEON=”No”).
TEONYes coefficient = difference from baseline.
Matches t-test: Same p-value, CI, and estimates.
What’s the difference between a pooled t-test and a Welch t-test in linear models?
Linear model assumes equal variances (like pooled t-test).
Cannot directly model unequal variances (Welch) in basic lm().
How is one-way ANOVA performed using lm()?
Code: lm(vitd ~ ageTEON, data=meddata) (where ageTEON has 4 levels).
Output:
Intercept = mean of baseline group (e.g., NoOld).
Other coefficients = differences from baseline.
ANOVA table: anova(model) gives F-test for group differences.
How do you interpret the folate coefficient in lm(vitd ~ folate)?
Estimate: 0.0902 → Each 1-unit folate increase predicts 0.0902 higher vitamin D.
Non-significant: p = 0.45 → No evidence of linear relationship.
What does R-squared measure in regression?
Proportion of variance in vitd explained by predictors.
Example: R² = 0.009 → Folate explains 0.9% of vitamin D variation.
Write the matrix form of the linear model.
Y=Xβ+ϵ
Y: Response vector.
X: Design matrix (1s in column 1 for intercept).
β: Coefficient vector.
How are fitted values calculated using matrices?
Y^=Xβ^
What’s the difference between Type I and Type II SS in ANOVA?
Type I: Sequential (order matters).
Type II: Tests each predictor after accounting for others.
R Code: car::Anova(model, type=”II”).
How do you check linear model assumptions?
Use plot(model):
Residuals vs. Fitted: Check linearity.
Q-Q Plot: Check normality.
Scale-Location: Check homoscedasticity.
Why is the intercept sometimes meaningless?
It’s the predicted Y when all X=0. If X=0 is unrealistic (e.g., folate=0), interpret slope only.