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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!