Question
STATS Use the R function rnorm() to simulate selecting a random sample of size 25 from a population with mean 80 and s.d. 20. The
STATS
Use the R function rnorm() to simulate selecting a random sample of size 25 from a population with mean 80 and s.d. 20. The goal here is to show how contamination affects the mean, s.d., and z-scores.
(a) Obtain the sample mean and sample sd of the simulated sample and use them to obtain the z-score for 100.
(b) Create the vector contam = c(0,seq(1000,10000,length=21)) To show the effects of contamination, separately add each value of contam to the largest value in the simulated data set, and then recompute the sample mean, sd, and z-score of 100 for each of these contaminated samples. This will result in vectors of length 22 that contain the recomputed means, sd's, and z-scores. Note that the first element of each of these vectors will be the corresponding mean, sd, and z-score of the original simulated data. For the following plots use type = "b" so that the points are connected by lines.
(c) Plot the recomputed means versus the values of contam.
(d) Plot the recomputed s.d.'s versus the values of contam.
(e) Plot the recomputed z-scores versus the values of contam.
Note: the sorted data can be obtained by
xs = sort(x,decreasing=TRUE)
You need to add each value of contam to the largest value in the sample which is xs[1]. So you will end up with 22 recomputed means, 22 recomputed s.d.'s, and 22 recomputed z-scores. An efficient way to setup this problem is to create a matrix that contains 22 columns each of which is the sorted vector xs.
nc = length(contam)
xmat = matrix(rep(xs,nc),ncol=nc)
Then add contam to the first row of that matrix to obtain the contaminated samples (the first column will be unchanged since the first element of contam is 0). Next use the apply function to obtain column means and sd's.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started