Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## ch 5 exercise
- > mydata=ch5_exercise <- read.csv("C:/Users/benny/Downloads/ch5_exercise.csv")
- > View(mydata)
- #for EACH VARIABLE (5), do the following:
- ## VAR A
- > shapiro.test(mydata$variable_a) #shaprio-wilk normality test (normal if p >/= 0.05)
- ### p-val = 0.02838 < 0.05 therfore NOT normal distribution
- > hist(mydata$variable_a,main = "Histogram of Var. A",xlab = "Variable A",)
- > boxplot(mydata$variable_a,main="Boxplot of Var. A")
- > qqnorm(mydata$variable_a,main = "Q-Q Plot of Var. A")
- > qqline(mydata$variable_a) #generates a Q-Q plot
- ##step E: FALSE, data distribution is NOT normal
- ##VAR B
- > shapiro.test(mydata$variable_b) #p-val = 0.19 > 0.05 therefore normal dist :)
- > hist(mydata$variable_b,main = "Histogram of Var. B",xlab = "Variable B",)
- > boxplot(mydata$variable_b,main="Boxplot of Var. B")
- > qqnorm(mydata$variable_b,main = "Q-Q Plot of Var. B")
- > qqline(mydata$variable_b)
- ##step E: TRUE, data distribution IS normal
- ##VAR C
- > shapiro.test(mydata$variable_c) #pval = 0.18
- > hist(mydata$variable_c,main = "Histogram of Var. C",xlab = "Variable C",)
- > boxplot(mydata$variable_c,main="Boxplot of Var. C")
- > qqnorm(mydata$variable_c,main = "Q-Q Plot of Var. C")
- > qqline(mydata$variable_c)
- ##step E: TRUE, dist is normal
- ##VAR D
- > shapiro.test(mydata$variable_d) #p-val = 0.002 <0.05
- > hist(mydata$variable_d,main = "Histogram of Var. D",xlab = "Variable D",)
- > boxplot(mydata$variable_d,main="Boxplot of Var. B")
- > qqnorm(mydata$variable_d,main = "Q-Q Plot of Var. B")
- > qqline(mydata$variable_d)
- ##step E: FALSE, dist is NOT normal
- ##VAR E
- > shapiro.test(mydata$variable_e) #p-val = 0.2317
- > hist(mydata$variable_e,main = "Histogram of Var. E",xlab = "Variable E",)
- > boxplot(mydata$variable_e,main="Boxplot of Var. E")
- > qqnorm(mydata$variable_e,main = "Q-Q Plot of Var. E")
- > qqline(mydata$variable_e)
- ##step E: TRUE
Advertisement
Add Comment
Please, Sign In to add comment