#PACKAGE
library(lmtest)
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
library(ggplot2)
library(car)
## Loading required package: carData
#MEMANGGIL DATA
data=read.table(file.choose(), header=T)
data
## Y X1 X2
## 1 59 90 70
## 2 60 97 77
## 3 62 97 77
## 4 65 99 77
## 5 69 106 76
## 6 65 110 68
## 7 69 115 78
## 8 70 115 78
## 9 74 118 79
## 10 70 122 80
## 11 75 127 79
## 12 76 127 79
## 13 78 127 79
## 14 81 135 85
## 15 85 140 88
#SCATTER PLOT Y (Hasil belajar mahasiswa) DAN X1 (Tingkat IQ)
ggplot(data, aes(x = X1, y = Y)) +
geom_point(color = "hotpink", size = 2) +
geom_smooth(method = "lm", se = FALSE,
color = "springgreen4", linewidth = 1.2) +
ggtitle("Scatter Plot Antara Tingkat IQ dan Hasil belajar") +
ylab("Hasil belajar mahasiswa") +
xlab("Tingkat IQ") +
theme(plot.title = element_text(hjust = 0.5))
## `geom_smooth()` using formula = 'y ~ x'

#SCATTER PLOT Y (Hasil belajar mahasiswa) DAN X2 (Motivasi)
ggplot(data, aes(x = X2, y = Y)) +
geom_point(color = "hotpink", size = 2) +
geom_smooth(method = "lm", se = FALSE,
color = "springgreen4", linewidth = 1.2) +
ggtitle("Scatter Plot Antara Motivasi dan Hasil belajar") +
ylab("Hasil belajar mahasiswa") +
xlab("Motivasi") +
theme(plot.title = element_text(hjust = 0.5))
## `geom_smooth()` using formula = 'y ~ x'

#REGRESI LINIER BERGANDA
model=lm(Y~X1+X2,data=data)
summary(model)
##
## Call:
## lm(formula = Y ~ X1 + X2, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.0542 -0.8326 0.0654 1.4173 2.8417
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.69711 9.43046 0.074 0.942
## X1 0.42708 0.05444 7.846 4.59e-06 ***
## X2 0.26567 0.16869 1.575 0.141
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.019 on 12 degrees of freedom
## Multiple R-squared: 0.9404, Adjusted R-squared: 0.9304
## F-statistic: 94.59 on 2 and 12 DF, p-value: 4.504e-08
#PENDETEKSIAN MULTIKOLINIERITAS
#<10
vif(model)
## X1 X2
## 2.290752 2.290752
#PENGUJIAN ASUMSI
bptest(model,varformula=~fitted.values(model), studentize=FALSE)
##
## Breusch-Pagan test
##
## data: model
## BP = 0.032304, df = 1, p-value = 0.8574
dwtest(model,alternative='two.sided')
##
## Durbin-Watson test
##
## data: model
## DW = 2.0697, p-value = 0.7751
## alternative hypothesis: true autocorrelation is not 0
shapiro.test(resid(model))
##
## Shapiro-Wilk normality test
##
## data: resid(model)
## W = 0.96508, p-value = 0.7797