Skip to content

Commit

Permalink
school-step
Browse files Browse the repository at this point in the history
  • Loading branch information
friendly committed Dec 11, 2024
1 parent 262a150 commit ab363cd
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions extra/school-step.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,19 @@ school.mod <- lm(cbind(reading, mathematics, selfesteem) ~
education + occupation + visit + counseling + teacher, data=schooldata)
Anova(school.mod)

heplot(school.mod,
fill=TRUE, fill.alpha=0.1)

hyp <- rownames(coef(school.mod))[-1]
heplot(school.mod,
hypotheses = list("B=0" = hyp),
fill=TRUE, fill.alpha=0.1)



pairs(school.mod, fill=TRUE, fill.alpha=0.1)

# matrix algebra approach
Y <- schooldata[, c("reading", "mathematics", "selfesteem")] |> as.matrix()
X <- schooldata[, c("education", "occupation", "visit", "counseling", "teacher")] |> as.matrix()

Expand All @@ -29,3 +40,21 @@ Anova(school.mat.mod)

heplot(school.step.mod)
pairs(school.step.mod)

# residual approach


schooldata$math.read <- lm(mathematics ~ reading, data=schooldata) |>
residuals()
schooldata$self.read_math <- lm(selfesteem ~ reading + mathematics, data=schooldata) |>
residuals()

cor(schooldata[,6:8])

cor(schooldata[,c(6, 9,10)]) |> zapsmall()

school.resmod <- lm(cbind(reading, math.read, self.read_math) ~
education + occupation + visit + counseling + teacher, data=schooldata)
Anova(school.resmod)

pairs(school.resmod, fill=TRUE, fill.alpha=0.1)

0 comments on commit ab363cd

Please sign in to comment.