1. Reading the data

##  [1] "mpg"  "cyl"  "disp" "hp"   "drat" "wt"   "qsec" "vs"   "am"   "gear"
## [11] "carb"

Comparing Means Through Summary Tables & Charts

2a. Display the distribution of the Variable wt in the mtcars dataset

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.513   2.581   3.325   3.217   3.610   5.424
##    vars  n mean   sd median trimmed  mad  min  max range skew kurtosis   se
## X1    1 32 3.22 0.98   3.33    3.15 0.77 1.51 5.42  3.91 0.42    -0.02 0.17

2b. Display the Boxplot of the Variable wt in the mtcars dataset

2c. Boxplot using Plotly

3. Bivariate Relationship between Weight (wt) and Transmission (am)

3a. Display a summary table showing the descriptive statistics of weight of the cars broken down by transmission (am=1 or am=0)

##   am        x
## 1  0 3.768895
## 2  1 2.411000
##   am         x
## 1  0 0.7774001
## 2  1 0.6169816
## 
##  Descriptive statistics by group 
## group: 0
##    vars  n mean   sd median trimmed  mad  min  max range skew kurtosis   se
## X1    1 19 3.77 0.78   3.52    3.75 0.45 2.46 5.42  2.96 0.98     0.14 0.18
## ------------------------------------------------------------ 
## group: 1
##    vars  n mean   sd median trimmed  mad  min  max range skew kurtosis   se
## X1    1 13 2.41 0.62   2.32    2.39 0.68 1.51 3.57  2.06 0.21    -1.17 0.17

3b. Visualizing Means – mean plot showing the average weight of the cars, broken down by transmission (am=1 & am=0)

3c. Visualizing Median using Box Plot – median weight of the cars broken down by transmission (am=1 & am=0)

Boxplot using Plotly

4. Bivariate Relationship between Weight (wt) and Cylinders (cyl)

4a. Display a summary table showing the mean weight of the cars broken down by cylinders (cyl=4,6,8)

##   cyl        x
## 1   4 2.285727
## 2   6 3.117143
## 3   8 3.999214
##   cyl         x
## 1   4 0.5695637
## 2   6 0.3563455
## 3   8 0.7594047
## 
##  Descriptive statistics by group 
## group: 4
##    vars  n mean   sd median trimmed  mad  min  max range skew kurtosis   se
## X1    1 11 2.29 0.57    2.2    2.27 0.54 1.51 3.19  1.68  0.3    -1.36 0.17
## ------------------------------------------------------------ 
## group: 6
##    vars n mean   sd median trimmed  mad  min  max range  skew kurtosis   se
## X1    1 7 3.12 0.36   3.21    3.12 0.36 2.62 3.46  0.84 -0.22    -1.98 0.13
## ------------------------------------------------------------ 
## group: 8
##    vars  n mean   sd median trimmed  mad  min  max range skew kurtosis  se
## X1    1 14    4 0.76   3.76    3.95 0.41 3.17 5.42  2.25 0.99    -0.71 0.2

4b. Show a mean plot showing the mean weight of the cars broken down by cylinders (cyl=4,6,8)

4c. Show a box plot showing the median weight of the cars broken down by cylinders (cyl=4,6,8)

4d. Boxplot using Plotly

5. Distribution of Weight (wt) by Cylinders (cyl = {4,6,8}) and Transmisson Type (am = {0,1})

5a Display a summary table showing the mean weight of the cars broken down by Transmission Type (am=1 & am=0) & cylinders (cyl=4,6,8)

##   am cyl        x
## 1  0   4 2.935000
## 2  1   4 2.042250
## 3  0   6 3.388750
## 4  1   6 2.755000
## 5  0   8 4.104083
## 6  1   8 3.370000

5b. Visualization - Show a box plot showing the mean weight of the cars broken down by Transmission Type (am=1 & am=0) & cylinders (cyl=4,6,8)

5c. Visualization - Show a mean plot showing the mean weight of the cars broken down by Transmission Type (am=1 & am=0) & cylinders (cyl=4,6,8)

6: Comparing Means Through Statistical Tests

6a. One Sample t-test

To compare whether the mean weight of the cars differ from 3 (1000 lbs), a value determined in a previous study.

H0: The mean weight of the cars is not different from theoretical mean 3 (1000 lbs). H1: The mean weight of the cars is different from theoretical mean 3 (1000 lbs).

## 
##  One Sample t-test
## 
## data:  wt
## t = 1.256, df = 31, p-value = 0.2185
## alternative hypothesis: true mean is not equal to 3
## 95 percent confidence interval:
##  2.864478 3.570022
## sample estimates:
## mean of x 
##   3.21725

The p-value of the test is 0.2185, which is greater than the significance level alpha = 0.05. So we fail to reject the null hypothesis, We can conclude that the mean weight of the cars is not different from theoretical mean 3 (1000 lbs)

6b. One-Sample Wilcoxon Signed Rank Test

The one-sample Wilcoxon signed rank test is a non-parametric alternative to one-sample t-test when the data cannot be assumed to be normally distributed. It’s used to determine whether the median of the sample is equal to a known standard value (i.e. theoretical value).

To compare whether the median weight of cars the differ from 3 (1000 lbs), a value determined in a previous study.

H0: The median weight of the cars is not different from theoretical median 3 (1000 lbs). H1: The median weight of the cars is different from theoretical median 3 (1000 lbs).

## 
##  Wilcoxon signed rank test with continuity correction
## 
## data:  wt
## V = 319, p-value = 0.3081
## alternative hypothesis: true location is not equal to 3

The p-value of the test is 0.3081, which is greater than the significance level alpha = 0.05. So we fail to reject the null hypothesis, We can conclude that the median weight of the cars is not different from theoretical median 3 (1000 lbs)

6c. Two Sample t-test

To compare whether the mean weight of the cars having am = 0 is significantly different from mean weight of the cars having am = 1.

H0: The mean weight of the cars having am = 0 is not significantly different from mean weight of the cars having am = 1 H1: The mean weight of the cars having am = 0 is significantly different from mean weight of the cars having am = 1

## 
##  Two Sample t-test
## 
## data:  wt by am
## t = 5.2576, df = 30, p-value = 1.125e-05
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.8304317 1.8853577
## sample estimates:
## mean in group 0 mean in group 1 
##        3.768895        2.411000

The p-value of the test is 1.125e-05, which is less than the significance level alpha = 0.05. We can reject the null hypothesis,and conclude that mean weight of the cars having am = 0 is significantly different from mean weight of the cars having am = 1

6d. Two-Sample Wilcoxon

The unpaired two-samples Wilcoxon test (also known as Wilcoxon rank sum test or Mann-Whitney test) is a non-parametric alternative to the unpaired two-samples t-test, which can be used to compare two independent groups of samples. It’s used when your data is not normally distributed.

To compare whether the median weight of the cars having am = 0 is significantly different from median weight of the cars having am = 1.

H0: The median weight of the cars having am = 0 is not significantly different from median weight of the cars having am = 1

H1: The median weight of the cars having am = 0 is significantly different from median weight of the cars having am = 1

## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  wt by am
## W = 230.5, p-value = 4.347e-05
## alternative hypothesis: true location shift is not equal to 0

The p-value of the test is 4.347e-05, which is less than the significance level alpha = 0.05. We can reject the null hypothesis,and conclude that median weight of the cars having am = 0 is significantly different from median weight of the cars having am = 1