Pertemuan 5
Metodologi penelitian
setwd('WD')
di mana WD adalah paste-an working directory anda.
setwd('')
setwd()
library()
read_excel()
atau read_csv()
plot()
atau ggplot()
lm()
install.packages('nama package')
library()
readxl
dan tidyverse
readxl
readxl
maka kita gak bisa pake command read_excel()
install.packages()
sebelum diload dengan library()
.dat<-read_excel('latihan1.xlsx')
Call:
lm(formula = Y ~ X, data = dat)
Residuals:
Min 1Q Median 3Q Max
-9.6739 -5.5463 -0.5193 4.3495 10.6282
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 10.6809 1.1665 9.156 8.21e-15 ***
X 3.8993 0.1019 38.284 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 5.97 on 98 degrees of freedom
Multiple R-squared: 0.9373, Adjusted R-squared: 0.9367
F-statistic: 1466 on 1 and 98 DF, p-value: < 2.2e-16
setwd('C:/github/noodle') # AWAS SETWD-NYA PERBAIKI DULU
library('readxl')
library('tidyverse')
# Baca data
dat<-read_excel('latihan1.xlsx')
# Plot X dan Y
plot(dat$X,dat$Y,xlab="jam belajar",ylab="nilai UAS")
# regresi
reg1<-lm(Y~X,data=dat)
summary(reg1)
# Membuat error
dat$u<-resid(reg1)
# plot eror
plot(dat$Y,dat$u,xlab="jam belajar",ylab="nilai UAS")