################################################ ## Exercice 1 ################################################ # imoprter le fichierEx1_Sommeil #2 r<-round(cor(Ex1_Sommeil$HeuresSommeil, Ex1_Sommeil$Note),3) r #3-4-6 modele <- lm(Note ~ HeuresSommeil, data = Ex1_Sommeil) summary(modele) #graphique(bonus) library(ggplot2) ggplot(Ex1_Sommeil, aes(x = HeuresSommeil, y = Note)) + geom_point() + geom_smooth(method = "lm", col = "green", se = FALSE) + labs(title = "Lien entre sommeil et note à l'examen", x = "Heures de sommeil", y = "Note à l'examen") + theme_minimal() #7Rc RC<-round(qt(1-0.05, df =48), 2) RC ## prediction prediction<-predict(modele, newdata = data.frame(HeuresSommeil = 8)) prediction # 11.Intervalle de prédiction pour un étudiant ayant dormi 8 heures predict(modele, newdata = data.frame(HeuresSommeil = 8), interval = "prediction", level = 0.95) ################################################ ## Exercice 2 ################################################ # importer le fichier Ex2_productivite.csv #1 r2<-round(cor(Ex2_productivite$jours_absence, Ex2_productivite$productivite),2) r2 #2 modele2 <- lm(productivite ~ jours_absence, data = Ex2_productivite) summary(modele2) #graphique(bonus) library(ggplot2) ggplot(Ex2_productivite, aes(x = jours_absence, y = productivite)) + geom_point() + geom_smooth(method = "lm", col = "red", se = FALSE) + labs(title = "Lien entre productivite et jours_absence", x = "jours_absence", y = "productivite") + theme_minimal() prediction<-predict(modele2, newdata = data.frame(jours_absence= 10)) prediction predict(modele2, newdata = data.frame(jours_absence= 10), interval = "prediction", level = 0.95) #3 predict(modele2, newdata = data.frame(jours_absence= 30)) ################################################ ## Exercice 3 ################################################ # importer le fichier Ex3_consomation.csv modele3 <- lm(consommation ~ inflation, data = Ex3_consomation) summary(modele3) #graphique(bonus) library(ggplot2) ggplot(Ex3_consomation, aes(x = temperature, y = consommation)) + geom_point() + geom_smooth(method = "lm", col = "red", se = FALSE) + labs(title = "Lien entre temperature et consommation", x = "temperature", y = "consommation") + theme_minimal() #1 prediction<-round(predict(modele3, newdata = data.frame(temperature= 25)),2) prediction #3 prediction3<- round(predict(modele3, newdata = data.frame(temperature= -18)),2) prediction3 ################################################ ## Exercice 4 ################################################ # importer le fichier Ex4_vente #1 Test.cor<- cor.test(Ex4_vente$ventes, Ex4_vente$inflation,"less") Test.cor Test.cor modele4 <- lm(ventes ~ inflation, data = Ex4_vente) summary(modele4) #graphique(bonus) library(ggplot2) ggplot(Ex4_vente, aes(x = inflation, y = ventes)) + geom_point() + geom_smooth(method = "lm", col = "red", se = FALSE) + labs(title = "Lien entre inflation et ventes", x = "inflation", y = "ventes") + theme_minimal() #2 prediction4<-round(predict(modele4, newdata = data.frame(inflation= c(3.896, 9.778 ))),3) prediction4 #3 Valeur.reelle <- subset(Ex4_vente, subset=(inflation >= 3.895 & inflation <= 3.897) | (inflation >= 9.777 & inflation <= 9.779)) Valeur.reelle