partial_and_semipartial_correlation
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
partial_and_semipartial_correlation [2024/10/17 10:28] – [e.g. Using ppcor.test with 4 var] hkimscil | partial_and_semipartial_correlation [2025/06/04 08:37] (current) – [X1과 X2 간의 상관관계가 심할 때 Regression 결과의 오류] hkimscil | ||
---|---|---|---|
Line 502: | Line 502: | ||
summary(reg.3)$r.square | summary(reg.3)$r.square | ||
# so common explanation area should be | # so common explanation area should be | ||
- | summary(reg.all)$r.square - carm(list=ls()) | + | summary(reg.all)$r.square - ca |
- | library(ggplot2) | ||
- | library(dplyr) | ||
- | library(tidyr) | ||
- | library(faux) | ||
- | |||
- | set.seed(101) | ||
- | scholar <- rnorm_multi(n = 50, | ||
- | mu = c(3.12, 3.3, 540, 650), | ||
- | sd = c(.25, .34, 12, 13), | ||
- | r = c(0.15, 0.44, 0.47, 0.55, 0.45, 0.88), | ||
- | | ||
- | | ||
- | attach(scholar) | ||
- | |||
- | # library(psych) | ||
- | describe(scholar) # provides descrptive information about each variable | ||
- | |||
- | corrs <- cor(scholar) # find the correlations and set them into an object called ' | ||
- | corrs # print corrs | ||
- | |||
- | pairs(scholar) | ||
- | |||
- | # install.packages(" | ||
- | library(ppcor) | ||
- | |||
- | reg.f.sh <- lm(FGPA ~ SATV + HSGPA) | ||
- | res.f <- resid(reg.f.sh) | ||
- | |||
- | reg.s.fh <- lm(SATV ~ FGPA + HSGPA) | ||
- | res.s <- resid(reg.s.fh) | ||
- | |||
- | reg.h.sf <- lm(HSGPA ~ FGPA + SATV) | ||
- | res.h <- resid(reg.h.sf) | ||
- | |||
- | reg.all <- lm(GREV ~ HSGPA + FGPA + SATV) | ||
- | reg.1 <- lm(GREV ~ res.f) | ||
- | reg.2 <- lm(GREV ~ res.s) | ||
- | reg.3 <- lm(GREV ~ res.h) | ||
- | |||
- | summary(reg.all) | ||
- | summary(reg.1) | ||
- | summary(reg.2) | ||
- | summary(reg.3) | ||
- | |||
- | reg.1$coefficient[2] | ||
- | reg.2$coefficient[2] | ||
- | reg.3$coefficient[2] | ||
- | |||
- | spr.y.f <- spcor.test(GREV, | ||
- | spr.y.s <- spcor.test(GREV, | ||
- | spr.y.h <- spcor.test(GREV, | ||
- | |||
- | spr.y.f$estimate | ||
- | spr.y.s$estimate | ||
- | spr.y.h$estimate | ||
- | |||
- | spr.y.f$estimate^2 | ||
- | spr.y.s$estimate^2 | ||
- | spr.y.h$estimate^2 | ||
- | |||
- | summary(reg.1)$r.square | ||
- | summary(reg.2)$r.square | ||
- | summary(reg.3)$r.square | ||
- | |||
- | ca <- summary(reg.1)$r.square + | ||
- | summary(reg.2)$r.square + | ||
- | summary(reg.3)$r.square | ||
- | # so common explanation area should be | ||
- | summary(reg.all)$r.square - ca | ||
</ | </ | ||
Line 763: | Line 694: | ||
> | > | ||
</ | </ | ||
+ | |||
+ | ---- | ||
{{: | {{: | ||
Line 773: | Line 706: | ||
그런데 이 coefficient값은 독립변인 각각의 고유의 설명력을 가지고 (spcor.test(GREV, | 그런데 이 coefficient값은 독립변인 각각의 고유의 설명력을 가지고 (spcor.test(GREV, | ||
+ | reg.all | ||
+ | {{: | ||
+ | reg.1 | ||
+ | {{: | ||
+ | reg.2 | ||
+ | {{: | ||
+ | reg.3 | ||
+ | {{: | ||
또한 세 독립변인이 공통적으로 설명하는 부분은 | 또한 세 독립변인이 공통적으로 설명하는 부분은 | ||
* 0.39 | * 0.39 | ||
Line 937: | Line 878: | ||
m <- lm(weights ~ LSS + RSS) | m <- lm(weights ~ LSS + RSS) | ||
- | ## F-value is very small, but neither LSS or RSS are significant | + | ## F-value is very large, and significant. |
+ | # but neither LSS or RSS are significant | ||
summary(m) | summary(m) | ||
partial_and_semipartial_correlation.1729128498.txt.gz · Last modified: 2024/10/17 10:28 by hkimscil