Confidence intervals for two means, Exercises of Statistics

Confidence intervals for the mean: “proc ttest” stands for the t test procedure. We will use it again in chapter 8 for hypothesis testing but for now it.

Typology: Exercises

2022/2023

Uploaded on 03/01/2023

lumidee
lumidee 🇺🇸

4.4

(48)

363 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lab 3
When turning in labs: (Hard Copy, Please)
BE SURE TO PUT YOUR NAME, Sec # / CLASS TIME, AND THE LAB # ON YOUR SUBMISSION. BE
SURE TO LABEL EACH PART WITH THE PROBLEM NUMBER AND PUT THEM IN LOGICAL
ORDER. 1 POINT WILL BE CUT OFF FOR NOT DOING SO.
************************************************************************************************
Purposes: 1) Confidence intervals for mean
2) Confidence intervals for two means
3) Confidence intervals for paired data
Confidence intervals for the mean:
“proc ttest” stands for the t test procedure. We will use it again in chapter 8 for hypothesis testing but for now it
gives us the confidence interval for the mean. For SAS coding, you cannot directly specify the confidence level,
C, however, you can specify alpha which relates to the confidence as such, alpha = 1 – C, so for 95% we
specify alpha = 0.05.
SAS Learning code:
proc ttest data=one alpha=0.05;
var score;
run;/*Generates a 95% confidence interval for the mean score*/
SAS Learning output (look for the bolded part):
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!The!TTEST!Procedure!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Statistics!
!!!!!!!!!!!!!!!!!!!!!Lower!CL!!!!!!!!!!!!Upper!CL!!!Lower!CL!!!!!!!!!!!!!Upper!CL!
!!Variable!!!!!!!N!!!!!!!Mean!!!!!Mean!!!!!!!Mean!!!!Std!Dev!!!Std!Dev!!!!Std!Dev!!!Std!Err!
!!score!!!!!!!!!21!!!!!!!87.3!!!93.667!!!!!100.03!!!!!10.701!!!!13.987!!!!!20.198!!!!3.0522!
!
So the 95% C.I. for µ is (87.3, 100.03).!
!
Problem 1
Use the data contained in the file dogs.txt, which contains the weights in pounds of a random sample of some
dogs, to answer the following questions:
a) Generate a QQplot to verify that the data is at least “roughly” normal. (It is supposed to be for the small
sample t confidence interval to be valid.)
b) Generate a 99% confidence interval for the mean weight. You will have to change the “alpha” in the
code accordingly.
c) Suppose your friend claims that the mean weight of the dogs is 60lbs. Do you believe him? Explain
how you are determining your belief referencing the confidence interval you created.
Confidence intervals for two means:
For two means, we will again use “proc ttest”, we just use a group variable as we learned before. So for each
observation, we would have a group #, and a score. For example:
group score
1 58
1 49
pf3

Partial preview of the text

Download Confidence intervals for two means and more Exercises Statistics in PDF only on Docsity!

Lab 3

**When turning in labs: (Hard Copy, Please) BE SURE TO PUT YOUR NAME, Sec # / CLASS TIME, AND THE LAB # ON YOUR SUBMISSION. BE SURE TO LABEL EACH PART WITH THE PROBLEM NUMBER AND PUT THEM IN LOGICAL ORDER. 1 POINT WILL BE CUT OFF FOR NOT DOING SO.


Purposes: 1) Confidence intervals for mean

  1. Confidence intervals for two means 3 ) Confidence intervals for paired data**

Confidence intervals for the mean:

“proc ttest” stands for the t test procedure. We will use it again in chapter 8 for hypothesis testing but for now it gives us the confidence interval for the mean. For SAS coding, you cannot directly specify the confidence level, C, however, you can specify alpha which relates to the confidence as such, alpha = 1 – C, so for 95% we specify alpha = 0.05. SAS Learning code: proc ttest data=one alpha= 0.05 ; var score; run ;/Generates a 95% confidence interval for the mean score/ SAS Learning output (look for the bolded part): The TTEST Procedure Statistics Lower CL Upper CL Lower CL Upper CL Variable N Mean Mean Mean Std Dev Std Dev Std Dev Std Err score 21 87.3 93.667 100.03 10.7 01 13.987 20.198 3. So the 95% C.I. for μ is (87.3, 100.03). Problem 1 Use the data contained in the file dogs.txt, which contains the weights in pounds of a random sample of some dogs, to answer the following questions: a) Generate a QQplot to verify that the data is at least “roughly” normal. (It is supposed to be for the small sample t confidence interval to be valid.) b) Generate a 99% confidence interval for the mean weight. You will have to change the “alpha” in the code accordingly. c) Suppose your friend claims that the mean weight of the dogs is 60lbs. Do you believe him? Explain how you are determining your belief referencing the confidence interval you created.

Confidence intervals for two means:

For two means, we will again use “proc ttest”, we just use a group variable as we learned before. So for each observation, we would have a group #, and a score. For example: group score 1 58 1 49

Be aware that you must sort the data by the group variable first, in order for the proc ttest to work correctly. SAS Learning code: proc sort data=two; by group; run ; proc ttest data=two alpha= 0.05 ; class group; var score; run ; /Generates a 95% confidence interval for the difference in mean scores, by default it uses the order group1 minus group2/ SAS Learning output (look for the bolded part): Lower CL Upper CL Lower CL Upper CL Variable group N Mean Mean Mean Std Dev Std Dev Std Dev Std Err score 1 21 46.466 51.476 56.487 8.4213 11.007 15.895 2. score 2 23 34.106 41.522 48.937 13.263 17.149 24.271 3. score Diff (1-­‐2) 1.0913 9.9545 18.818 11.998 14.551 18.495 4. So the 95% C.I. for μ 1 – μ 2 is (1.0913, 18.818). Problem 2 The Survey of Study Habits and Attitudes (SSHA) is a psychological test that measures students' study habits and attitude toward school. Scores range from 0 to 200. Higher scores indicate better attitudes. An educational psychologist believes that older students (group 1) have a better attitude toward school than younger students (group 2). Use the data contained in the file ssha.txt to answer the following questions: a) Generate a 90 % confidence interval for the difference between the 2 means. b) Interpret your interval by giving a correct statistical statement regarding the interval. (Hint: “We are 90%..., and 90% refers to the long-run proportion, not to any particular calculated interval”) c) Is there a difference between the older and younger students according to the ssha scores? Explain how you know in plain language so that anyone could understand (even if they don’t know statistics).

Confidence intervals for paired data:

For paired data, we will again use “proc ttest”, we just use a “paired” command for both variables in place of the “var” command for a single variable. SAS Learning code: proc ttest data=three alpha= 0.05 ; paired posttestpretest; run ;/Generates a 95% confidence interval for the mean of the differences, posttest minus pretest*/