##### SCA-13 ##### ##### One-Sample Variance Procedures ##### ### This gives a few examples of the analysis process for testing ### for a population variance ### Preamble # Import extra functionality source("http://rfs.kvasaheim.com/stat200.R") ### Example I: Risk of IBM # # I would like to estimate the risk (variance) of an investment # in IBM stock. To do this, I measure closing price of IBM for # 10 random days in the past month. # IBM = c(152.64, 153.45, 149.00, 153.94, 152.14, 153.84, 152.69, 158.07, 160.91, 148.79) shapiroTest(IBM) onevar.test(IBM) # Conclusion: There is no evidence that the stock price of IBM # does not follow a Normal distribution (p-value = 0.2521). # Because of this, I use the Chi-square provedure for variance. # According to that procedure, a 95% confidence interval for the # risk (variance) of an investment in IBM is between 6.4 and 45.1, # with a point estimate of 13.5. ### Example II: Risk of Microsoft # # I would like to estimate the risk (variance) of an investment # in Microsoft stock. To do this, I measure closing price of # Microsoft for 10 random days in the past month. # MSFT = c(89.39, 88.52, 92.33, 90.77, 91.86, 93.08, 96.07, 96.11, 95.35, 92.31) shapiroTest(MSFT) onevar.test(MSFT) # Conclusion: There is no evidence that the stock price of MSFT # does not follow a Normal distribution (p-value = 0.4989). # Because of this, I use the Chi-square provedure for variance. # According to that procedure, a 95% confidence interval for the # risk (variance) of an investment in IBM is between 3.3 and 23.4, # with a point estimate of 7.0. ### Example III: Relative Risk of Microsoft # # I would like to estimate the risk (variance) of an investment # in Microsoft stock and compare it to the expected risk for a # stock in the technology sector, which is 25. To do this, I # measure closing price of Microsoft for 10 random days in the # past 1 month. # MSFT = c(89.39, 88.52, 92.33, 90.77, 91.86, 93.08, 96.07, 96.11, 95.35, 92.31) shapiroTest(MSFT) onevar.test(MSFT, s2=25) # Conclusion: There is no evidence that the stock price of MSFT # does not follow a Normal distribution (p-value = 0.4989). # Because of this, I use the Chi-square provedure for variance. # According to that procedure, there is significant evidence that # Microsoft has a significantly lower risk than what is expected # for technology stocks (p-value = 0.0397). # # A 95% confidence interval for the risk (variance) of an investment # in IBM is between 3.3 and 23.4, with a point estimate of 7.0. ### Example IV: Relative Risk of Gold # # I would like to estimate the risk (variance) of an investment # in gold metal and compare it to the expected risk for a # stock in the NYSE, which is 15. To do this, I measure closing # price of gold for 10 random days in the past 1 month. # Au = c(1310.3, 1319.6, 1366.8, 1315.1, 1340.4, 1366.4, 1348.6, 1369.1, 1367.0, 1316.0) shapiroTest(Au) st = numeric() for(i in 1:1e4) { x = sample(Au, replace=TRUE) st[i] = var(x) } mean(st<=15) quantile(st, c(0.025,0.5,0.975)) # Conclusion: There is evidence that the gold prices do not # follow a Normal distribution (p-value = 0.0351). Because of # this, I use the non-parametric bootstrapping procedure for # the variance. According to that procedure, there is significant # evidence that gold has a significantly higher risk than what is # expected for the (p-value = 0.0003). # # A 95% confidence interval for the risk (variance) of a gold # investment is between 282.1 and 762.9, with a point estimate # of 560.3.