setwd("C:/Users/LG/Documents/Mediation,Moderation")
GLBWARM<-read.csv(file = "glbwarm.csv", header = T, sep=",")
head(GLBWARM)
## govact posemot negemot ideology age sex partyid
## 1 3.6 3.67 4.67 6 61 0 2
## 2 5.0 2.00 2.33 2 55 0 1
## 3 6.6 2.33 3.67 1 85 1 1
## 4 1.0 5.00 5.00 1 59 0 1
## 5 4.0 2.33 1.67 4 22 1 1
## 6 7.0 1.00 6.00 3 34 0 2
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.5.3
ggplot(data=GLBWARM, aes(x=negemot, y=govact))+geom_point(size=2, shape=1)+coord_cartesian(xlim = c(0,7), ylim = c(0,8))+labs(title="Figure2.1", x="NEGEMOT", y="GOVACT")
Figure2.1을 보면 확실히 연관성이 가지는 경향이 분명하게 나타남.
Figure2.2<-cor.test(GLBWARM$govact, GLBWARM$negemot, method = "pearson")
Figure2.2
##
## Pearson's product-moment correlation
##
## data: GLBWARM$govact and GLBWARM$negemot
## t = 20.183, df = 813, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.5301050 0.6217505
## sample estimates:
## cor
## 0.5777458
기후변화에 상대적으로 더 강력한 부적정서를 보고한 참가자들은 상대적으로 더 정부를 지지함.
상관계수를 가지고 Zx로 Zy를 예측할 때, 상관이 작아지면 Zy값이 Y의 평균에 가까워짐. : 평균으로 회귀
Linear regression model
Simple linear regression model
잔차제곱합 평균 (SS residual / n)은 추정의 표준오차이며 회귀선의 표준편차임.
ej : case j의 X에서 case j의 Y값을 추정하고 남은 오차
Figure2.3
simple<-lm(formula = govact ~ negemot, data=GLBWARM)
summary(simple)
##
## Call:
## lm(formula = govact ~ negemot, data = GLBWARM)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.3285 -0.6731 0.1018 0.7554 3.2142
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.75732 0.09866 27.95 <2e-16 ***
## negemot 0.51424 0.02548 20.18 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.111 on 813 degrees of freedom
## Multiple R-squared: 0.3338, Adjusted R-squared: 0.333
## F-statistic: 407.3 on 1 and 813 DF, p-value: < 2.2e-16
Figure 2.3
Simple linear regression model
Figure2.4
library(ggplot2)
ggplot(data=GLBWARM, aes(x=negemot, y=govact))+geom_point(size=2, shape=1)+coord_cartesian(xlim = c(0,7), ylim = c(0,8))+labs(title="Figure2.4", x="NEGEMOT", y="GOVACT")+geom_smooth(method = lm)
Figure 2.4
Simple linear regression model
Interpretation of the constant and regression coefficient
The standardized regression model
Simple regression with a Dichotomous antecedent variable
Figure 2.5
Simple regression with a Dichotomous antecedent variable
Interpretation of the constant and partial regression coefficients
명확한 인과적 해석을 위해서 최적의 방법은 공변량을 통제하는 것임.
공변량 통제후 부호가 변할 수 있음.
The standardized regression model
Testing a Null Hypothesis
Process Inference