Question: Lab 6 Sampling: Decision - Making Thresholds A key focus of Chapter 1 0 is how to make inferences about populations based on samples. The
Lab Sampling: DecisionMaking Thresholds
A key focus of Chapter is how to make inferences about populations based on samples. The essential logic lies in comparing a single instance of a statistic, such as a sample mean, to a distribution of such values. The comparison can lead to one of two conclusions the sample statistic is either extreme or not extreme. But what are the thresholds for making this kind of judgment call ie whether a value is extreme or not This activity explores that question.
The problem is this: You receive a sample containing the ages of students. You should be able to telwhether this sample is a group of undergraduates mean age years or graduates mean age years To answer this question, you must compare the mean of the sample you receive to a distribution of means from the population. The following fragment of R code begins the solution:
#q: this is to set seed. By doing so the initiation point is always the same, not random.
set.seed
# assign the value to the variable "sampleSize"
sampleSize
#q: randomly generate numbers that obeyed normal distribution with mean and standard deviation
# Then assign those numbers to the vector "studentPop".
studentPop rnormmeansd
#investigate studentPop now. How many rows? What are the values look like? Are they close to the mean value
#q: draw sampleSize sample defined above from studentPop and assign the numbers to "undergrads".
undergrads samplestudentPopsizesampleSize,replaceTRUE
#q: create a sample of graduate studentsrandomly generate numbers use sampleSize that obeyed normal distribution with mean and sd See the mean is years older than the undergraduate sample apparently.
# Assign the numbers to the vector "grads".
# Sample size is sampleSize mean is standard deviation is
grads rnormsampleSizemeansd
#q: Randomly assign either the grads sample or the undergrads sample to testSample, depending on the value generated by runif
# "runif would generate a random number between and
# If the number is greater than assign grads sample to testSample. Otherwise, assign undergrads sample to testSample.
if runif testSample grads else testSample undergrads
meantestSample
#q: calculate the mean of "testSample" What is the mean of testSample?
After you run this code, the variable testSample will contain either a sample of undergrads or a sample of grads. The line before last flips a coin by generating one value from a uniform distribution by default the distribution covers to and comparing it to The question you must answer with additional code is: Which is it grad or undergrad?
#q: Generate sample means from studentPop and assign it as mySample
mySample replicateyour code here
#q: Compare meantestSample to that list of sample means mySample and see where it falls. quantile function helps display data distribution. Produce quantiles on thresholds and
your code here
#q: if the sample mean is less than quantiles on thresholds or greater than quantiles on thresholds then it can be definded as extreme. Otherwise it is not extreme.
if meanobject name here quantileobject name here, probs meanobject name herequantileobject name here, probs
printSample mean is extreme" else printSample mean is not extreme"
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
