Professional Documents
Culture Documents
library(ellipse) # gambar
library(leaps) # regresi
library(locfit) # regresi local
library(nutshell) # sample data
library(lars) # teknik memperkecil error untuk regresi
library(car) # sample data
# data dummy
# x <- array(1:900, dim=c(100,3))
# menghilangkan unknown
# table(data_kelahiran$DMETH_REC)[-2]
# table(data_kelahiran$DMETH_REC)[-c(2,4)]
# dbwt = data_kelahiran$DBWT
# define list
# data_list <- list(a = 1:10, beta = exp(-3:3), logic = c(TRUE,FALSE,FALSE,TRUE))
# lapply(data_list,max)
DAN
#Contoh--Correlation
Problem
Find the correlation coefficient of the eruption duration and waiting time in the data set faithful.
Observe if there is any linear relationship between the variables.
Solution
We apply the cor function to compute the correlation coefficient of eruptions and waiting.
> duration = faithful$eruptions # the eruption durations
> waiting = faithful$waiting
> cor(duration, waiting)
[1] 0.90081
Answer
The correlation coefficient of the eruption duration and waiting time is 0.90081. Since it is close to
1, we can conclude that the variables are positively linearly related.