—
df<-read.csv("df.csv")
table(df$rule_1)
##
## 1 2 3 4
## 53 53 6 2
table(df$rule_2)
##
## 1 2 3 4
## 46 58 8 2
table(df$rule_3)
##
## 1 2 3 4
## 45 55 10 4
table(df$rule_4)
##
## 1 2 3 4
## 47 56 7 4
table(df$rule_5)
##
## 1 2 3 4
## 54 48 8 4
str(df$rule_1)
## int [1:114] 1 2 1 1 1 1 1 3 3 2 ...
df$rule=(df$rule_1+df$rule_2+df$rule_3+df$rule_4+df$rule_5)/5
table(df$Edu)
##
## 1 2 3 4 99
## 1 45 64 3 1
df$Edu[df$Edu==1]<-2
df$Edu[df$Edu==2]<-2
df$Edu[df$Edu==3]<-4
df$Edu[df$Edu==4]<-4
library(dplyr)
##
## 다음의 패키지를 부착합니다: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
df<-df %>% filter(Edu!=99)
str(df$Edu)
## num [1:113] 4 4 4 2 2 4 2 2 4 4 ...
df$Edu<-factor(df$Edu)
df$Task<-ifelse(df$Task=="1,2","1",df$Task)
df$Task<-ifelse(df$Task=="2,3","3",df$Task)
df<-df %>% filter(Task!=99)
df$Task<-factor(df$Task)
attach(df)
m<-lm(rule~harm+Career+Task,data=df)
summary(m)
##
## Call:
## lm(formula = rule ~ harm + Career + Task, data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.96246 -0.41341 -0.04441 0.30776 1.50234
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.03174 0.23163 8.772 3.03e-14 ***
## harm 0.10331 0.05155 2.004 0.0476 *
## Career -0.21594 0.04872 -4.432 2.26e-05 ***
## Task2 -0.01093 0.17301 -0.063 0.9497
## Task3 0.37192 0.25045 1.485 0.1405
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5695 on 107 degrees of freedom
## Multiple R-squared: 0.2259, Adjusted R-squared: 0.1969
## F-statistic: 7.805 on 4 and 107 DF, p-value: 1.473e-05
plot(m)




library(car)
## Warning: 패키지 'car'는 R 버전 4.1.3에서 작성되었습니다
## 필요한 패키지를 로딩중입니다: carData
##
## 다음의 패키지를 부착합니다: 'car'
## The following object is masked from 'package:dplyr':
##
## recode
vif(m)
## GVIF Df GVIF^(1/(2*Df))
## harm 1.035570 1 1.017630
## Career 1.114086 1 1.055503
## Task 1.094218 2 1.022765