Data imported using the functions shQuote() and paste()
sales1.ours <- c(4960.41, 6832.49, 8258.02, 5642.55, 6468.93, 5258.59,
6217.21, 9218.7, 5726.75, 8214.29, 8932.64, 9295.66,
9258.06, 5007.65, 9221.29, 9690.34, 5325.62, 8027.41,
7152.6, 8947.42, 9329.27, 5912.72, 5413.41, 10391.6,
5997.37, 4567.35, 8296.11, 7622.47, 10271.6, 4817.3,
6613.89, 10423.5, 8881.03, 10196.8, 7985.85, 10367.5,
7130.69, 7694.28, 6255.13, 7851.37, 10107.2, 10376.4,
6860.18, 6821.77, 6476.13, 9527.42)
sales1.competitor <- c(3814.55, 4784.18, 1696.35, 9113.88, 10772.98,
3631.26, 9527.9, 7806.29, 10500, 6890.67, 8048.16,
3620.4, 3946.07, 2229.71, 10550.2, 5007.26, 9873.22,
4926.48, 5212.84, 10438.7, 5757.86, 3388.45,
6429.97, 7676.87, 6727.72, 9087.33, 10444, 9135.64,
10300, 5349.38, 8270.39, 6026.13, 9314.74, 8142.23)
sales2.ours <- c(8117.99, 4877.18, 9923.17, 7899.34, 9600.43, 4784.7,
10150.4, 7146, 5001.22, 4935.55, 8325.62, 8121.26, 7474.38,
9085.15, 5684.88, 6962.25, 6911.91, 5979.44, 6910.81,
8653.46, 5080.04, 7968.13, 7648.03, 10024.8, 8122.5,
5435.23, 5837.22, 4784.97, 9522.59, 10226.7, 9899.77,
6240.26, 5448.68, 9404.81, 7377.72, 5753.05, 6734.27,
5845.7, 7144.39, 8814.34, 8839.03, 10372.3, 7834.13,
6544.11, 9311.07, 4766.91, 10383.4, 5534.78, 6064.76,
6061.98, 5177.43, 7037.6, 8162.49, 8728.4, 7821.87, 5592.15,
6371.55, 6927.05, 7106.73, 5311.97, 9822.17, 5245.32,
6970.61, 8774.27, 6869.43, 10398.4, 5923.86, 6979.11,
7415.85, 7825.28, 7900.99, 10415.5, 9159.3, 4770.21,
5727.9, 5078.09, 6859.2, 10291.1, 9807.69, 9234.28,7303.47,
4816.87, 4953.42, 10253.7, 8387.12, 6316.28, 8354.45,
6676.34, 8245.92, 5594.23, 8272.41, 8696.17, 8587.47,
6101.63, 7655.59, 5009.93, 8638.31, 8262.56, 8810.01,
9400.79, 7160.68, 8371.18, 8925.81, 10351.4, 8981.91,
6833.37, 6232.5, 6905.41, 6352.07, 7166.12, 8849.34,
5669.59, 7384.45, 4688.73, 5958.54, 6027.91, 5273.85,
5256.11, 8283.5, 7350.54, 7765.91, 6331.13, 8974.42,
10006.6, 10030.7, 6101.54, 8417.39, 5934.85, 6007.38,
9854.29, 10125.7, 6525.76, 7786.46, 8448.19, 6950.69,
8728.3, 8454.44, 10331.3, 8638.29, 10160.3, 9858.3, 10240.5,
7074.98, 10123.5, 4930.81, 7093.34, 5797.43, 6093.43,
8335.15, 5781.67, 6531.31, 7716.6, 6164.2, 7440.39, 4885.48,
7324.15, 6968.21, 9336.29, 9882, 8815.63, 10300.3, 7657.18,
9775.82, 8073.75, 6231.13, 9392.7, 10494.8, 8178.39, 6060.26,
6744.2, 8291.58, 9767.94, 5204.55, 8094.57, 7816.5, 10246.6,
9674.28, 9571.36, 5924.92, 5509.03, 9435.72, 7631.84,
9242.48, 9677.7, 7718.31, 5688.47, 8500.66, 5549.29, 8357.37,
8516.31, 4627.19, 9091.74, 9054.66, 6778.98, 9813.24,
10185.4, 5293.3, 5081.38, 9457.05, 9068.09, 7619.48, 4615.31,
6956.77, 6515.06, 5062.55, 7918.94, 7761.39, 9159.32,
10213.3, 6858.72, 9599.44, 7850.09, 5743.76, 7858.43,
10464.3, 7553.68, 9896.11, 7352.34, 10095.5, 8345.62,
7019.57, 8375.5, 5894.46, 5947.82, 7947.08, 10070.5, 7243.05,
8470.08, 6786.72, 7391.75, 8375.47, 5995.94, 6085.48,
8721.17, 6687.19, 8532.04, 9724.97, 6674.4, 6375.91, 6768.96,
7358.11, 5443.5)
sales2.competitor <- c(7625.87, 5837.27, 12164.9, 12045.8, 1105.68,
10774.4, 10691.7, 12586.1, 6060.27, 5804.11,
5016.12, 11507, 9489, 12542.9, 4522.77, 11085,
9746.04, 6061.03, 11305.8, 4668.64, 11464.8,
8737.44, 11818.8, 6985.72, 3998.48, 1463.21,
2242.89, 10779.2, 8576.05, 3731.57, 12462.1,
5499.64, 5998.38, 677.689, 6879.42, 9244.96,
2970.9, 10584.3, 6738.44, 3257.09, 11241.7,
11945.8, 9682.99, 5462.87, 5586.8, 12864.5,
12153.1, 11413.1, 7397.72, 9387.54, 8797.98,
9251.82, 10969.7, 10642.2, 4374.07, 9267.44, 10111,
11118.4, 10390, 9364.4, 2759.09, 10955.1, 10154.8,
12108.5, 12063.3, 6050.16, 11002.4, 9840.76,
5708.45, 7339.71, 9760.99, 12617.4, 7262.15,
11723.3, 10289.6, 4334.76, 7850.78, 11957.6,
9774.52, 12782.1, 11636.9, 9858.89, 12199.3,
7836.13, 9130.15, 11457.2, 8056.32, 10785.8,
11713.3, 8853.94, 8709.53, 11174.5, 8348.51,
8831.87, 10572.5, 6441.93, 12164, 11694.5, 8413.24,
10400.8, 5094.21, 11704.4, 9083.06, 11322.4,
9192.48, 4227.7, 11072.2, 11426.7, 2992.29,
8307.88, 11939.9, 12251.1, 12103.6, 8490.95,
12134.7, 6233.89, 8616.06, 10563.4, 5265.06,
9441.57, 4140.73, 8601.92, 4387.71, 1628.92,
10506.8, 11581, 8375.65, 12575.1, 11773.1, 3625.79,
4030.63, 10059.9, 4580.3, 5618.32, 4876.98,
11019.9, 11789.6, 9131.24, 4473.07, 9363.19,
9188.94, 6650.25, 11639.9, 12376.2, 6547.93,
6272.21, 3156.43, 8705.16, 562.226, 5363.15,
12957.8, 6509.7, 7026.19, 3484.21, 7832.21,
12440.7, 6295.22, 8243.43, 11535.1, 5710.38,
3447.32, 4994.76, 11365.9, 6414.05, 8611.54, 10741,
7994.54, 12568.1, 9983.25, 5525.25, 11023.9,
5205.45, 11296.8, 10005.3, 4216, 11249.4, 6591.14,
4668.43, 12286, 9078.32, 4822.94, 4639.8, 12976.8,
8292.33, 12529.3, 10887.4, 10495.6, 11452.5, 12478,
5508.96, 11995.8, 3443.92, 4408.83, 4963.43,
11813.5, 12154.7)
sales3.ours <- c(8117.99, 4877.18, 9923.17, 7899.34, 9600.43, 4784.7,
10150.4, 7146, 5001.22, 4935.55, 8325.62, 8121.26,
7474.38, 9085.15, 5684.88, 6962.25, 6911.91, 5979.44,
6910.81)
sales3.competitor <- c(10015.87, 8942.88, 5290.47, 11283.98, 4533.3,
12657.22, 6316.43, 1899.44, 1982.79, 5577.97,
5589.69, 11888.34, 3951.26, 8762.66, 4585.79,
5866.45, 5894.63, 5179.4, 4764.7)
sales4.ours <- c(4960.41, 6832.49, 8258.02, 5642.55, 6468.93, 5258.59,
6217.21, 9218.7, 5912.72, 5413.41, 10391.6, 5997.37,
4567.35, 8296.11, 7622.47)
sales4.competitor <- c(3814.55, 4784.18, 1696.35, 9113.88, 8732.48,
3631.26, 9527.9, 7806.29, 3388.45, 6429.97,
7676.87, 6727.72, 9087.33, 10444, 9135.64, 10300,
5349.38, 8270.39, 6026.13, 9314.74, 8142.23)
Create a 98% confidence interval for the difference of average our company’s average sales and that of the competition. Assume that the population standard deviations are 1700 (our company) and 2700 (their company)
sd1.ours <- 1700
sd1.competitor <- 2700
n1.ours <- length(sales1.ours)
n1.competitor <- length(sales1.competitor)
mean1.ours <- mean(sales1.ours)
mean1.competitor <- mean(sales1.competitor)
To find the difference of the average of our companies sales and that of the other companies sales, we use the formula below for \(\sigma_{\bar{x}_{1}-\bar{x}_{2}}\): \[ \begin{align} \sigma_{\bar{x}_{1}-\bar{x}_{2}} &= \sqrt{\frac{\sigma^{2}_{\textrm{ours}}}{n_{1}}+\frac{\sigma_{\textrm{competitor}}^{2}}{n_{2}}}\\ &= \sqrt{\frac{1700^{2}}{46}+\frac{2700^2}{34}} \end{align} \]
sigma1 <- sqrt(((sd1.ours)^2 / n1.ours) + ((sd1.competitor)^2 / n1.competitor) )
Calculating \(z_{c}\)
zc1 = qnorm((1 + 0.98) / 2)
To calculate (\(E\)): \[ E = z_{c} \sigma_{\bar{x}_{1}-\bar{x}_{2}} \]
moe1 <- z1 * sigma1
To calculate : \[ \begin{align} \textrm{CI}_{\textrm{lower}} &= \left(\bar{x}_{1} - \bar{x}_{2}\right) - E\\ \textrm{CI}_{\textrm{upper}} &= \left(\bar{x}_{1} - \bar{x}_{2}\right) + E \end{align} \]
mean1 <- mean1.ours - mean1.competitor
confidence1.upper <- mean1 - moe1
confidence1.lower <- mean1 + moe1
Suppose that our company’s overall standard deviation of sales is $1700 and that of the competition is $2700. Perform an appropriate two sample hypothesis testing at 0.05 level of significance manually to test whether our company’s average sales in more than that of the competition.
The standard deviations are still \(\sigma_{\textrm{ours}} = \$1700\) and \(\sigma_{\textrm{competitor}} = \$2700\),
and \(n1\) & \(n2\) are \(\geq 30\).
The formula for calculating \(H_{0}\) and \(H_{a}\) is given as: \[
\begin{align}
H_{0} &: \mu_{\textrm{ours}} - \mu_{\textrm{competitor}} > \mu_{0}\\
H_{a} &: \mu_{\textrm{ours}} - \mu_{\textrm{competitor}} < \mu_{0}
\end{align}
\] Next we are required to calculate our test statistic \(z\), which can be obtained using the following formula: \[
\begin{align}
z &=\frac{\left(\bar{x}_{\textrm{ours}} - \bar{x}_{\textrm{competitor}}\right) - \mu_{0}}{\sigma_{\bar{x}_{1}-\bar{x}_{2}}}\\
&=\frac{\left(7692.28 - 7012.99\right) - 0}{526.53}
\end{align}
\] We will calculate this below, along with the \(P\) value and \(z_{\textrm{crit}}\):
z1 <- mean1 / sigma1
p1 <- 1 - pnorm(z1)
zcrit <- qnorm(1 - 0.05)
Now that we have calculated \(P\), \(z\), and \(z_{\textrm{crit}}\), we can test to see which hypothesis to reject. \[ \begin{align} H_{0}\textrm{ if }& z \geq z_{\textrm{crit}}\\ H_{a}\textrm{ if }& P \leq \alpha \end{align} \] We can use R to create logical statements to determine the which to reject:
if(z1 >= zcrit && p1 <= 0.05){
print("Reject Null Hypothesis")
} else {
print("Reject Alternate Hypothesis")
}
[1] "Reject Alternate Hypothesis"
This tells us that we should reject \(H_{a}\).
Suppose that the standard deviation of our sales and that of the competition are unknow; however, they are known not to be equal. Perform an appropriate two sample hypotheses testing manually at 0.05 level of significance to test whether our company’s average sales in more than that of the competition.