commit
fb6754aeac
@ -0,0 +1,26 @@ |
||||
library(corrplot) |
||||
library(lattice) |
||||
|
||||
a <- mtcars |
||||
a |
||||
mcor2 <- cor(mtcars$gear, mtcars$carb) |
||||
mcor2 |
||||
|
||||
xyplot(gear ~ carb, data = mtcars) |
||||
|
||||
lm <- plot(mtcars$gear, mtcars$carb) |
||||
abline(lm(mtcars$gear~mtcars$carb)) |
||||
|
||||
mcor <- cor(mtcars) |
||||
mcor |
||||
round(mcor, 2) |
||||
|
||||
corrplot(mcor) |
||||
|
||||
plot(mtcars) |
||||
|
||||
library(ggplot2) |
||||
qplot(gear, carb, data = mtcars) |
||||
|
||||
cor(mtcars$wt, mtcars$mpg) |
||||
qplot(wt, mpg, data=mtcars, color=factor(carb)) |
@ -0,0 +1,36 @@ |
||||
year <- c(26,16,20,7,22,15,29,28,17,3,1, |
||||
16,19,13,27,4,30,8,3,12) |
||||
annual_salary <- c(1267,887,1022,511,1193,795, |
||||
1713,1477,991,455,324,944,1232, |
||||
808,1296,486,1516,565,299,830) |
||||
|
||||
data <- data.frame(year, annual_salary) |
||||
|
||||
summary(data) |
||||
|
||||
plot(year, annual_salary) |
||||
cor(year, annual_salary) |
||||
|
||||
ls <- lm(annual_salary~year, data = data) |
||||
summary(ls) |
||||
|
||||
# Residuals: |
||||
# Min 1Q Median 3Q Max |
||||
# -115.282 -59.636 -3.018 37.011 215.873 |
||||
|
||||
# Coefficients: |
||||
# Estimate Std. Error t value Pr(>|t|) |
||||
# (Intercept) 252.375 39.766 6.346 5.59e-06 *** |
||||
# year 42.922 2.179 19.700 1.25e-13 *** |
||||
# --- |
||||
# Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 |
||||
|
||||
# Residual standard error: 89.02 on 18 degrees of freedom |
||||
# Multiple R-squared: 0.9557, Adjusted R-squared: 0.9532 |
||||
# F-statistic: 388.1 on 1 and 18 DF, p-value: 1.25e-13 |
||||
|
||||
# 1) 회귀식: y = 252.375 + 42.922x |
||||
# 2) 총 변수 중 회귀선에 의에 95.57%(Multiple R-square)가 설명됨 |
||||
# 3) 유의수준 0.001에서 p-value가 더 작으므로 귀무가설 기각 |
||||
# 해석: 회귀계수가 0이 아니며 귀구가설이 기각되어 근무연수는 연봉에 매우 영향을 미친다고 보여짐 |
||||
|
Loading…
Reference in new issue