#This is the code I used in the statistical package R to determine confidence intervals, statistical significance and #averages for my advertising survey data. #R is open source and can be downloaded freely from http://www.r-project.org > advertising = read.table("C:/callListAnon.csv",sep=",",header=TRUE) > attach(advertising) > t.test(PurchaseRadio, purchaseTV) #Figure 1. --------------------------------------------------------------------------------- Welch Two Sample t-test data: PurchaseRadio and purchaseTV t = 1.1677, df = 88.565, p-value = 0.2460 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -0.0762676 0.2936589 sample estimates: mean of x mean of y 0.3260870 0.2173913 #The confidence interval for this t-test was used to find the 5% extremes in pricing for television advertising #At the low 95% I used the formula (1+(-.0762676))*price_per_impression to get a price price per impression figure that #will be lower than the actual price per impression cost 95% of the time. #At the upper 95% bound I used the formula (1+.2936589)*price_per_impression for a price per impression figure that will #be higher than the actual price per impression 95% of the time #-------------------------------------------------------------------------------------------- > t.test(Neither, PurchaseRadio) Welch Two Sample t-test data: Neither and PurchaseRadio t = 1.4901, df = 89.639, p-value = 0.1397 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -0.05071629 0.35506412 sample estimates: mean of x mean of y 0.4782609 0.3260870 > t.test(Neither, purchaseTV) Welch Two Sample t-test data: Neither and purchaseTV t = 2.7014, df = 86.89, p-value = 0.008302 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: 0.06892273 0.45281640 sample estimates: mean of x mean of y 0.4782609 0.2173913 > t.test(hoursRadioWork, hoursTVWork) Welch Two Sample t-test data: hoursRadioWork and hoursTVWork t = 4.6055, df = 46.759, p-value = 3.174e-05 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: 1.339886 3.418809 sample estimates: mean of x mean of y 2.5597826 0.1804348 > t.test(hoursTelevisionNight, hoursRadioNight) Welch Two Sample t-test data: hoursTelevisionNight and hoursRadioNight t = 0.1822, df = 81.135, p-value = 0.8559 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -0.5305872 0.6375437 sample estimates: mean of x mean of y 1.426087 1.372609 > t.test(purchaseTV) One Sample t-test data: purchaseTV t = 3.5355, df = 45, p-value = 0.0009559 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 0.09354903 0.34123358 sample estimates: mean of x 0.2173913 > t.test(PurchaseRadio) One Sample t-test data: PurchaseRadio t = 4.6663, df = 45, p-value = 2.770e-05 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 0.1853383 0.4668356 sample estimates: mean of x 0.3260870 > t.test(Neither) One Sample t-test data: Neither t = 6.4226, df = 45, p-value = 7.349e-08 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 0.3282804 0.6282413 sample estimates: mean of x 0.4782609 > t.test(hoursTVWork) One Sample t-test data: hoursTVWork t = 2.5224, df = 45, p-value = 0.01526 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 0.03635813 0.32451143 sample estimates: mean of x 0.1804348 > t.test(hoursRadioWork) One Sample t-test data: hoursRadioWork t = 5.003, df = 45, p-value = 9.108e-06 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 1.529265 3.590300 sample estimates: mean of x 2.559783 > t.test(hoursRadioNight) One Sample t-test data: hoursRadioNight t = 5.7327, df = 45, p-value = 7.773e-07 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 0.8903618 1.8548556 sample estimates: mean of x 1.372609 > t.test(hoursTelevisionNight) One Sample t-test data: hoursTelevisionNight t = 8.3968, df = 45, p-value = 9.185e-11 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 1.084017 1.768157 sample estimates: mean of x 1.426087 > summary(advertising) company purchaseTV PurchaseRadio Neither : 1 Min. :0.0000 Min. :0.0000 Min. :0.0000 Business 1 : 1 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.0000 Business 10: 1 Median :0.0000 Median :0.0000 Median :0.0000 Business 11: 1 Mean :0.2174 Mean :0.3261 Mean :0.4783 Business 12: 1 3rd Qu.:0.0000 3rd Qu.:1.0000 3rd Qu.:1.0000 Business 13: 1 Max. :1.0000 Max. :1.0000 Max. :1.0000 (Other) :40 hoursTVWork hoursRadioWork hoursRadioNight hoursTelevisionNight Min. :0.0000 Min. : 0.000 Min. :0.000 Min. :0.000 1st Qu.:0.0000 1st Qu.: 0.000 1st Qu.:0.170 1st Qu.:1.000 Median :0.0000 Median : 0.375 Median :1.000 Median :1.000 Mean :0.1804 Mean : 2.560 Mean :1.373 Mean :1.426 3rd Qu.:0.0000 3rd Qu.: 4.375 3rd Qu.:2.000 3rd Qu.:2.000 Max. :2.0000 Max. :10.000 Max. :8.000 Max. :4.000