xeris-s_lair

ch 5 exercise

Nov 11th, 2025
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.86 KB | Source Code | 0 0
  1. ## ch 5 exercise
  2. > mydata=ch5_exercise <- read.csv("C:/Users/benny/Downloads/ch5_exercise.csv")
  3. > View(mydata)
  4.  
  5. #for EACH VARIABLE (5), do the following:
  6.     ## VAR A
  7. > shapiro.test(mydata$variable_a) #shaprio-wilk normality test (normal if p >/= 0.05)
  8.     ### p-val = 0.02838 < 0.05 therfore NOT normal distribution
  9. > hist(mydata$variable_a,main = "Histogram of Var. A",xlab = "Variable A",)
  10. > boxplot(mydata$variable_a,main="Boxplot of Var. A")
  11. > qqnorm(mydata$variable_a,main = "Q-Q Plot of Var. A")
  12. > qqline(mydata$variable_a) #generates a Q-Q plot
  13.     ##step E: FALSE, data distribution is NOT normal
  14.  
  15.     ##VAR B
  16. > shapiro.test(mydata$variable_b) #p-val = 0.19 > 0.05 therefore normal dist :)
  17. > hist(mydata$variable_b,main = "Histogram of Var. B",xlab = "Variable B",)
  18. > boxplot(mydata$variable_b,main="Boxplot of Var. B")
  19. > qqnorm(mydata$variable_b,main = "Q-Q Plot of Var. B")
  20. > qqline(mydata$variable_b)
  21.     ##step E: TRUE, data distribution IS normal
  22.  
  23.     ##VAR C
  24. > shapiro.test(mydata$variable_c) #pval = 0.18
  25. > hist(mydata$variable_c,main = "Histogram of Var. C",xlab = "Variable C",)
  26. > boxplot(mydata$variable_c,main="Boxplot of Var. C")
  27. > qqnorm(mydata$variable_c,main = "Q-Q Plot of Var. C")
  28. > qqline(mydata$variable_c)
  29.     ##step E: TRUE, dist is normal
  30.  
  31.     ##VAR D
  32. > shapiro.test(mydata$variable_d) #p-val = 0.002 <0.05
  33. > hist(mydata$variable_d,main = "Histogram of Var. D",xlab = "Variable D",)
  34. > boxplot(mydata$variable_d,main="Boxplot of Var. B")
  35. > qqnorm(mydata$variable_d,main = "Q-Q Plot of Var. B")
  36. > qqline(mydata$variable_d)
  37.     ##step E: FALSE, dist is NOT normal
  38.  
  39.     ##VAR E
  40. > shapiro.test(mydata$variable_e) #p-val = 0.2317
  41. > hist(mydata$variable_e,main = "Histogram of Var. E",xlab = "Variable E",)
  42. > boxplot(mydata$variable_e,main="Boxplot of Var. E")
  43. > qqnorm(mydata$variable_e,main = "Q-Q Plot of Var. E")
  44. > qqline(mydata$variable_e)
  45.     ##step E: TRUE
Advertisement
Add Comment
Please, Sign In to add comment