library(readr)
covid19_2 <- read_csv("PSDA PROJECT2/DATA DOSM/covid19 2.csv")

View(covid19_2)
library(ggplot2)

cor(covid19_2$Deaths,covid19_2$`New Cases` )

df <- data.frame(states=c("Selangor","WP Kuala Lumpur","N Sembilan","Johor","Sarawak",
                          "Pahang","Sabah","Perak","Melaka","Kelantan","P Pinang",
                          "Terengganu","Kedah","WP Putrajaya","Perlis","WP Labuan"), 
                 newcase=c(8,38,0,0,0,0,0,0,0,0,0,0,0,1,0,0),
                 deaths=c(21,17,8,19,17,6,5,6,5,3,1,1,1,1,2,0) )
df  

x <- c(8,38,0,0,0,0,0,0,0,0,0,0,0,1,0,0)
y <- c(21,17,8,19,17,6,5,6,5,3,1,1,1,1,2,0)

relation <- lm(y~x)
print(relation)
print(summary(relation))

ggplot(covid19_2, aes(x = covid19_2$`New Cases`, y = covid19_2$Deaths)) +
geom_point() +
stat_smooth(method = lm)

#predict deaths with new cases=100
a <- data.frame(x =100)
result <-  predict(relation,a)
print(result)

confint(relation)

sigma(relation)*100/mean(covid19_2$Deaths)