STAT 1 level lab

profilezhaght
ins3_2.pdf

1

LAB 3 INSTRUCTIONS

ONE-SAMPLE AND TWO-SAMPLE INFERENCES

The primary purpose of the lab instructions is to demonstrate how the inferential tools in StatCrunch can be

applied to one-sample and two–sample problems about the mean and the difference in two population

means, respectively. In particular, you will learn how to obtain confidence intervals for the population

parameters of interest and how to test statistical hypotheses about the parameters. We will consider two

classes of inferential procedures available in StatCrunch depending on whether the population standard

deviation(s) are known or unknown.

1. One-Sample Inferences about the Mean

Statistical inference is inference about a population from a random sample drawn from it. We will

consider two important methods of statistical inference: interval estimation (confidence intervals)

and hypothesis testing (tests of significance).

(a) Confidence Intervals about the Mean

The purpose of a confidence interval is to estimate an unknown population parameter with an

indication of how accurate the estimate is and of how confident we are the result is correct. In

summary, a confidence interval contains the most plausible values for the parameter.

Any confidence interval has the form

Estimate of the parameter  Margin of error.

A (1-α)∙100% confidence interval for the mean  of a normal population with known standard

deviation , based on a random sample of size n, is given by

where se= / n is the standard error and / 2z is the z-score corresponding to the confidence

level 1-α. The z-score has right-tail probability α/2. In particular, z=1.96 when 1-α =0.95 (95%

confidence interval).

The confidence level C states the probability that the method will produce a confidence interval

containing the population parameter. That is, if you obtain 95% confidence intervals repeatedly, in

the long run 95% of your intervals will contain the true population parameter. However, you

cannot know whether a particular confidence interval contains the parameter.

When the population standard deviation σ is unknown, the standard error se is estimated by the

ratio /s n , where s is the sample standard deviation. In this case, the confidence interval is based on the formula

where / 2

t 

is the t-score of the t-distribution with (n-1) degrees of freedom and it has right tail

probability of α/2.

/ 2 ( ),x z se 

/ 2 ( ),x t se 

2

(b) Tests about the Mean

Another inferential method about the population mean μ called hypothesis testing analyzes the

evidence that the sample data provide in favor of a specific claim about the mean. In general, in

any hypothesis testing problem there are two alternative claims under consideration: the null

hypothesis denoted by H0 (the claim initially assumed to be true) and the alternative hypothesis

denoted by Ha (the claim we suspect is true instead of H0). Both hypotheses are statements about a

population parameter; our goal is to determine which of them is more consistent with the sample

data. Two possible actions regarding H0 are either reject or not reject H0.

Consider a normal population with unknown mean  and known standard deviation . In order to

test H0:  = 0 based on a random sample of size n from the population, we use the z statistic

defined as

Thus, the value of z is the distance between the sample mean and the hypothesized value 0 of  in

standard errors. The larger the absolute value of z, the stronger the evidence against the null

hypothesis. The p-value is the probability of observing the value of the test statistic as extreme or

more extreme (more extreme values provide even stronger evidence against the null hypothesis)

than the value observed. In other words, the p-value is a measure of risk we take by rejecting the

null hypothesis when in fact it is true. The smaller the p-value, the stronger the evidence against

H0.

When the population standard deviation σ is unknown, the following t statistic is used

where t follows the t-distribution with (n-1) degrees of freedom.

The implementation of confidence intervals and hypothesis tests for the population mean in

StatCrunch will be described in Section 3.

2. Two-Sample Inferences about the Mean

Consider two normal populations with the unknown means μ1 and μ2 and known standard

deviations σ1 and σ2, respectively. Suppose two independent random samples, one from each

population of size n1 and n2 produced the sample means equal to 1x and 2 ,x respectively.

(a) Confidence Intervals about μ1 – μ2

A level (1-α)∙100% confidence interval for the difference in two population means μ1 – μ2 is based

on the formula

where the standard error can be calculated from the values of σ1 and σ2 as follows:

0 0 . x x

z se n

 

   

0 0 , x x

t se s n

    

1 2 / 2 ( ) ( ),x x z se  

3

2 2

1 2

1 2

.se n n

   

Here / 2

z 

is the z-score corresponding to the confidence level C that has right-tail

probability α/2.

In case, the population standard deviations σ1 and σ2 are unknown, they can be estimated with the

sample standard deviations s1 and s2, respectively and the confidence interval formula has the form

where the standard error se can be calculated from the values of s1 and s2 as follows:

2 2

1 2

1 2

. s s

se n n

 

In case, the population standard deviations σ1 and σ2 are known to be equal, the standard error se

is defined as follows

1 2

1 1 ,se s

n n   where the pooled standard deviation s is defined as

2 2

1 1 2 2

1 2

( 1) ( 1)

2

n s n s s

n n

   

  .

The confidence intervals based on the standard error value computed under the assumption of

equal variances are slightly narrower than the confidence intervals based on the standard error

value without the assumption.

(a) Hypothesis testing about μ1 – μ2

Consider two normal populations with unknown means 1 and 2 and known standard deviations

σ1 and σ2, respectively. . We test H0: 1- 2=0 versus the alternative H0: 1- 2≠0 with the z

statistic defined as follows:

where the standard error se is defined as

2 2

1 2

1 2

.se n n

   

In case, the population standard deviations σ1 and σ2 are unknown, the statistic is defined as

follows:

1 2 / 2 ( ) ( ),x x t se

   

1 2 . x x

z se

 

1 2 , x x

t se

 

4

where t follows a t-distribution with the number of degrees of freedom to be determined by the

software and the standard error se is estimated as

2 2

1 2

1 2

. s s

se n n

 

In case, the population standard deviations σ1 and σ2 are unknown but known to be equal, the

standard error se is defined as follows

1 2

1 1 ,se s

n n  

where the pooled standard deviation s is defined as 2 2

1 1 2 2

1 2

( 1) ( 1)

2

n s n s s

n n

   

  .

The above test is a special version of the two-sample t test that assumes that the two population

variances are equal. The test is based on a more accurate (pooled) estimate of the common

standard deviation and is slightly more powerful than the test without the assumption (it is more

likely to detect a difference in the means if there is such a difference).

The equal variances t-test can be only used when you are reasonably sure that the population

variances are the same or nearly the same. Otherwise a serious error may occur.

3. Z-Statistics

In case the population standard deviation σ for one-sample problem or the population standard

deviations σ1 and σ2 for two-sample problem are known, the suitable inferential tools can be

accessed by selecting Z Statistics option in the Stat menu.

(a) One Sample Option

In case when  is unknown, the confidence intervals and test statistics are based on the z

distribution. The related theory was discussed in Section 2.

We will use the Framingham Heart Study data to illustrate the Z Statistics tool. We assume that

the standard deviation σ is known and equal to 20. We will obtain a 95% confidence interval for

the mean systolic blood pressure, separately for males and females and also test whether the mean

systolic blood pressure exceeds the value of 135 for each group.

Click the One sample option. The following dialog box is displayed:

5

If more than one column is selected, a separate confidence interval and test will be done for each

column.

If you click directly the Calculate button, the test about the mean will be performed as this is the

default option. Click the Next button.

The following dialog box will allow you to select between a hypothesis test and confidence

interval computation.

Click the Calculate button to obtain the results.

Select the column (variable) containing the

sample values from the population about which

inferences are to be made.

Enter an optional standard deviation value. If

no value is entered, the sample standard

deviation will be used

Specify the rows to be included in the analysis.

If nothing is entered, all rows will be included.

Select an optional Group By column to group

results.

Enter the hypothesized value of the population

mean

Choose one of the three options, not equal, less

than or greater than for the alternative hypothesis

Enter a value between 0 and 1 for the confidence

level. The default value is 0.95 (95% confidence

interval)

6

Based on the p-values provided in the output, we conclude that there is no evidence that the mean

systolic blood pressure exceeds 135 for either gender.

If you choose a 95% confidence interval option in the above dialog box, you will obtain the

following output.

(b) Two Sample Option

We will use again the Framingham Heart Study data to illustrate the Z Statistics tool for the Two

Sample option. We assume that the standard deviations σ1 and σ2 are known and equal to 30

(females) and 20 (males), respectively.

We will obtain a 95% confidence interval for the difference in the mean systolic blood pressure for

the two genders (the mean for females minus the mean for males), and also test whether there is

evidence that the mean systolic blood pressure for females exceeds the mean systolic blood

pressure for males.

7

As the systolic blood pressure readings for males and females are in the same column (Systolic) ,

the dialog box for the two-sample test should be filled in as follows:

Click the Next button.

In the above dialog box you can either request performing a hypothesis test about the mean or

calculating a confidence interval for the population mean.

If you choose to perform a hypothesis test, leave the radio button at Hypothesis Test checked. You

will have to specify a null hypothesis test value (hypothesized value of ). The default value is 0.

Moreover, you will have to define the alternative hypothesis by choosing less than (lower-tailed),

not equal (two-tailed), or greater than (upper-tailed). The default is a two-tailed test (not equal).

Define the alternative hypothesis by

choosing less than (lower-tailed), not

equal (two-tailed), or greater than

(upper tailed). The default is a two-

tailed test.

Specify the hypothesized value of the

mean difference. The default value is

zero.

8

If you decide to obtain a confidence interval, check the Confidence Interval radio button and

specify a confidence level for the confidence interval (the default is 95%). The output for the test

option is given below.

The p-value of 0.2618 indicates that there is no evidence of any difference in the mean systolic

blood pressure for the two gender groups.

4. T-Statistics

In case the population standard deviation σ for one-sample problem or the population standard

deviations σ1 and σ2 for two-sample problem are unknown, the suitable inferential tools can be

accessed by selecting T Statistics option in the Stat menu.

(a) One Sample Option

Use One Sample option to compute a confidence interval and perform a hypothesis test about the

population mean when the population standard deviation  is unknown. Both the confidence

interval and test statistics use the t distribution with an appropriate number of degrees of freedom

rather than the standard normal distribution z.

The dialog box displayed below is very similar in appearance to the dialog box for One Sample

option in the Z Statistics menu.

9

The dialog boxes are similar in appearance to the dialog boxes for the tool when the population

standard deviation σ is known discussed in Section 3.

(b) Two Sample Option

We will use the Two Sample option to obtain a 95% confidence interval for the difference in the

mean systolic blood pressure for the two genders (the mean for females minus the mean for

males), and also test whether there is evidence that the mean systolic blood pressure for females

exceeds the mean systolic blood pressure for males.

Click the Two Sample option and fill in the dialog box as follows:

If you check the Pool variances box in the dialog box, the sample standard deviations are pooled

to obtain a single estimate of σ. The two-sample t-test with a pooled standard deviation is slightly

more powerful than the two-sample t-test without equal variances, but serious error can result if

the standard deviations are not equal. You should use the test only if there is strong evidence that

the two population standard deviations are equal. This evidence can be derived from the analysis

of the process that produced the data or from the sample data.

10

However, as the advantages of using the equal-variances test are relatively small and verifying the

assumption of equal variances is difficult especially for small samples, we recommend that in

general you avoid the test assuming equal variances.

In case of the Framingham Heart Study data, we uncheck the Pool variances check box as we do

not have any information or evidence supporting the assumption of equal variances for the two

gender groups.

Click the Next> button to obtain the dialog box that allows you to choose either hypothesis test

or confidence interval. First select the Hypothesis Test option. Fill in the dialog box as follows:

Click the Calculate button to obtain the following output:

If you select the Confidence Interval option, you will have to specify the confidence level for the

confidence interval. The default is 95%. The following output will be produced:

11

(c) Paired Data Option

Paired Data feature computes a confidence interval and performs a hypothesis test of the

difference between two population means when observations are paired (matched). In particular,

the feature is suitable for before-and-after measurements obtained for the same subjects The

paired data t-procedure results in a smaller variance and greater power of detecting differences

than would the above discussed two-sample procedure, which assumes that the samples are

independently drawn.

Suppose that the systolic blood pressure measurements were obtained for the same 14 female and

male subjects after subjecting them to a relaxing session. In order to see whether the session was

effective in reducing the systolic blood pressure, we use the paired data test. We may separately

test for the effectiveness of the session for females and males. The data are provided below:

Clicking on Options opens the following dialog box:

12

The paired data test and confidence interval are valid under the assumption of normality for the

differences. Check the Save differences box if you are planning to verify the assumption with the

Q-Q Plot feature (see the next section).

Click the Next> button to obtain the dialog box that allows you to choose either hypothesis test

or confidence interval. First select the Hypothesis Test option. Fill in the dialog box as follows:

In other words, we test whether the mean difference (systolic blood pressure before minus systolic

blood pressure after) is positive or equivalently, that the relaxing session is effective. Click the

Calculate button to obtain the output shown below. Notice that the p-values for both gender

groups strongly indicate that the relaxing session is effective.

13

If you select the Confidence Interval option, with 0.95 confidence level, you will obtain the

following output:

The confidence intervals for the two gender groups (both endpoints are positive for each gender)

also strongly support the claim that the relaxing session is effective in reducing blood pressure.

5. Normal Q-Q Plot

Many statistical analyses are valid under the assumption that the data come from a normal

distribution. An informal approach to testing normality is to compare the histogram of sample data

to a normal density curve. The histogram should be bell-shaped and resemble the normal

distribution. If the histogram is clearly skewed and the sample size is not small, the data may come

from a non-normal distribution.

One of the more formal, graphical tools to verify the normality assumption is Normal Q-Q Plot.

The first Q stands for the quantiles (or percentiles) of your sample data. Those are the points on

the horizontal line that divide your sample data into intervals containing the same fraction of

observations. Notice that if your data indeed follows a normal distribution those intervals would

be very narrow close to the center of the data but much wider in the tails. The second Q stands for

the quantiles (or percentiles) of a standard normal population. The Q-Q plot plots sample quantiles

versus the quantiles of a standard normal distribution.

14

If your data is indeed from a normal distribution, the two quantiles should match up well and the

points in the Q-Q plot should fall close to a straight line. Systematic deviations from a straight line

pattern indicate that the data is very unlikely to come from a normal distribution.

The Q-Q Plot option in the Graphics menu produces a normal Q-Q plot for given data. For

example, in order to check the normality of three samples labelled Normal1, Normal2, and

Normal3 (those three samples from a normal distribution can be produced with the Simulate tool),

click the Q-Q Plot option and fill the resulting dialog box as follows:

Enter an option Where statement to specify the rows in the data table included in the analysis. If

you select Group By column a Q-Q plot will be obtained for each distinct value of the Group By

column. Click the Next button and specify the axes titles and the graph title. Finally, click the

Create Graph! button to obtain the graph.

The three Q-Q plots for the data obtained in the previous section (one for each column) will show

the points reasonably close to a straight line.