讀取資料
library(haven)
pisa.dat <- read_sav("PISA_tawian2022_trimmed_lab.sav")
View(pisa.dat)
使用圖表套件
library(ggplot2)
library(ggExtra)
library(ggpubr)
ESCS和PV1MATH的散布圖
ggplot(pisa.dat, aes(x=ESCS, y=PV1MATH)) +
geom_point()
ESCS和PV1MATH的散布圖+直方圖
ggMarginal(
ggplot(pisa.dat, aes(x = ESCS, y = PV1MATH)) + geom_point(),
type = "histogram"
)
ESCS和PV1MATH
ggscatter(pisa.dat, x= "ESCS", y="PV1MATH",
add = "reg.line", conf.int = TRUE,
cor.coef = TRUE, cor.method = "pearson",
xlab = "Index of economic,social and cultural status", ylab = "Plausible Value 1 in Mathematics")
皮爾森相關係數以及p值(ESCS和PV1MATH)
cor.test(pisa.dat$ESCS, pisa.dat$PV1MATH, method = "pearson")
##
## Pearson's product-moment correlation
##
## data: pisa.dat$ESCS and pisa.dat$PV1MATH
## t = 31.952, df = 5597, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.3703870 0.4146987
## sample estimates:
## cor
## 0.3927708
皮爾森相關係數(ESCS和PV1MATH)
cor(pisa.dat$ESCS, pisa.dat$PV1MATH, method = "pearson")
## [1] 0.3927708
AGE和ESCS的散布圖
ggplot(pisa.dat, aes(x=AGE, y=ESCS)) +
geom_point()
AGE和ESCS的散布圖+直方圖
ggMarginal(
ggplot(pisa.dat, aes(x = AGE, y = ESCS)) + geom_point(),
type = "histogram"
)
AGE和ESCS
ggscatter(pisa.dat, x= "AGE", y="ESCS",
add = "reg.line", conf.int = TRUE,
cor.coef = TRUE, cor.method = "pearson",
xlab = "Student's age", ylab = "Index of economic,social and cultural status")
皮爾森相關係數以及p值(AGE和ESCS)
cor.test(pisa.dat$AGE, pisa.dat$ESCS, method = "pearson")
##
## Pearson's product-moment correlation
##
## data: pisa.dat$AGE and pisa.dat$ESCS
## t = -0.33172, df = 5597, p-value = 0.7401
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.03062489 0.02176306
## sample estimates:
## cor
## -0.004433958
皮爾森相關係數(AGE和ESCS)
cor(pisa.dat$AGE, pisa.dat$ESCS, method = "pearson")
## [1] -0.004433958