## condition rating
## C:25 Min. :1.333
## P:24 1st Qu.:2.000
## Median :2.333
## Mean :2.429
## 3rd Qu.:2.667
## Max. :4.000
There are two variables: The variable βcondition" is a factor with two levels, βC" that codes the Charismatic condition and βP" that codes the Punitive condition. The second variable is βrating", which is a numeric variable.
The sample average for the variable βrating" can be obtained from the summary or from the application of the function βmean" to the variable. The standard deviation is obtained from the application of the function βsd" to the variable:
The sample average and standard deviation for each sub-sample may be produced with the aid of the function βtapply". We apply the function in the third argument, first βmean" and then βsd" to the variable rating, in the first argument, over each level of the factor βcondition" in the second argument:
You may note that the rating given by students that were exposed to the description of the lecturer as charismatic is higher on the average than the rating given by students that were exposed to a less favorable description. The box plots of the ratings for the two conditions are presented in FigureΒ 11.3.1.
The 99% confidence interval for the expectation is computed by the formula \(\bar x \pm \mbox{\texttt{qt(0.995,n-1)}} \cdot s/\sqrt{n}\text{.}\) Only 0.5% of the \(t\)-distribution on \((n-1)\) degrees of freedom resides above the percentile βqt(0.995,n-1)". Using this percentile leaves out a total of 1% in both tails and keeps 99% of the distribution inside the central interval.
The 90% confidence interval for the variance is computed by the formula \(\big[\frac{n-1}{\mbox{\texttt{qchisq(0.95,n-1)}}} s^2 ,\;\frac{n-1}{\mbox{\texttt{qchisq(0.05,n-1)}}} s^2\big]\text{.}\) Observe that 5% of the chi-square distribution on \((n-1)\) degrees of freedom is above the percentile βqchisq(0.95,n-1)" and 5% are below the percentile βqchisq(0.05,n-1)".
The point estimate of the variance is \(s^2 = 0.5329833^2 = 0.2840712\text{.}\) The confidence interval for the variance is \([0.18722243, 0.4923093]\text{.}\)
Let us produce the sampling distribution of the sample average and the sample standard deviation for 20 observations from the \(\mathrm{Exponential}(1/4)\) distribution:
lam <- 1/4
n <- 20
X.bar <- rep(0,10^5)
S <- rep(0,10^5)
for(i in 1:10^5) {
X <- rexp(n,lam)
X.bar[i] <- mean(X)
S[i] <- sd(X)
}
We compute the confidence level for a confidence interval with a nominal confidence level of 95%. Observe that using the Normal approximation of the sample average corresponds to the application of the Normal percentile in the construction of the confidence interval.
The expectation of the measurement is equal to 4. This number belongs to the confidence interval 90.47% of the times. Consequently, the actual confidence level is 90.47%.
Using the same sampling distribution that was produced in the solution to QuestionΒ 1 we now compute the actual confidence level of a confidence interval that is constructed under the assumption that the measurement has a Normal distribution:
Based on the assumption we used the percentiles of the \(t\)-distribution. The actual significance level is 91.953% \(\approx\) 92%, still short of the nominal 95% confidence level.
It would be preferable to use the (incorrect) assumption that the observations have a Normal distribution than to apply the Normal approximation to such a small sample. In the current setting the former produced a confidence level that is closer to the nominal one. In general, using the percentiles of the \(t\)-distribution will produce wider and more conservative confidence intervals than those produces under the Normal approximation of the average. To be on the safer size, one typically prefers the more conservative confidence intervals.
The 80% confidence interval for the probability is computed by the formula \(\hat p \pm \mbox{\texttt{qnorm(0.90)}} \cdot \sqrt{\hat p(1-\hat p)/n}\text{:}\)