Answered You can hire a professional tutor to get the answer.

QUESTION

qattachments_45e54ca3f03c77b6ee984d46f3255af3e858df53 course miles.school major school.hours credit.hours campus 0.1 Other 50 13 campus 268 Civil or...

R Code DA3

##### Code from DA3 Parts I - IV ######################################## Part I ################################### Upload the ST314 Student Information Data Set.ST314.Population = read.csv(file.choose(), header = TRUE)head(ST314.Population)#Create a histogram of the variable height. Consider this the population. hist(ST314.Population$height, main = "Population: ST314 Student Data", xlab = "Height in inches", col = "blue")# What is the size of the population. In other words, how many students took the survey? # USe the command length() to find, N = ? N = length(ST314.Population$height)N# Calculate the population mean mumu = mean(ST314.Population$height)mu# Calculate the population standard deviation sigma. # Note sd() gives sample standard deviation. To remedy this we need to multiply by sqrt((N-1)/N). sigma = sd(ST314.Population$height)*sqrt((N-1)/N)sigma# Take a sample of size 25 from the students of ST314. ST314.Sample = ST314.Population[sample(1:N,25),]ST314.Sample#Create a histogram of the variable height for your sampled data.hist(ST314.Sample$height, main = "Sample: ST314 Student Data", xlab = "height in inches", col = "green")# Calculate the sample mean for height.x.bar = mean(ST314.Sample$height)x.bar# Calculate the sample standard deviation for height.s = sd(ST314.Sample$height)s##### Part II ################################## Simulate 1000 samples from the population. Plot each of their sample means. # set up your vectors for your simulation values to fill. # nsim is the number of times you want to take a sample of 25 from the population.nsim = 1000samp.means = rep(0,nsim)# write a loop that will take a sample of size 25 and from that sample calculate the mean. # Store those values in a vector for each of the 1000 samples.# Be sure to highlight all of the code from for through the last }. # The code will take a few moments to run but nothing will happen except it showing up in the console.for(i in 1:nsim){ Samp = ST314.Population[sample(1:N,25),]  samp.means[i] = mean(Samp$height)}# Create a histogram of sample means. This is the sampling distribution of xbar. hist(samp.means, main = "Sampling Distribution", xlab = "Sample Means , n = 25", col = "orange")# Take mean and standard deviation of the sampling distribution from xbar. mean(samp.means)sd(samp.means)# Count the number of sample means that are greater than or equal to 70sum(samp.means>=70)/1000############ PART III ############################# Upload data set called sunspots2.csv. Let's call it sunspots. sunspots = read.csv(file.choose(), header= TRUE)# look at the variable name and the first 6 lines of datahead(sunspots)### Make a histogram or boxplot of the sunspots data using appropriate commands.### You may reference the code above or the code in week 3 lessons or from the week 3 module.# Perform a t test using the t.test() command. t.test(sunspots$spots, mu = 41, alternative = "greater")# Note the above command will give a one sided confidence interval. # To get a two sided confidence interval run the default t.test() # and pull out just the confidence interval.   t.test(sunspots$spots)$conf.int#################### Part IV ######################## This output is already provided to you in the data analysis but is included here # for an optional look at how a two sample t test can be done in R.  # CD WRITER DATAwriter = c(rep("CD-Writer", 17), rep("No CD-Writer", 23))batterytime =c(3.69, 4.45, 5.33, 4.10, 4.94, 4.27, 4.96, 3.60, 5.23, 3.94,                4.20, 5.70, 5.06, 3.66, 5.26, 5.64, 5.41, 5.64, 4.64, 4.29,                6.24, 4.99, 3.95, 5.36, 5.57, 6.28, 5.17, 4.81, 6.00, 4.54,               4.43, 4.87, 4.74, 5.01, 6.06, 4.93, 5.28, 4.43, 4.76, 5.14)CDdata = as.data.frame(cbind(as.factor(writer),batterytime))aggregate(batterytime~writer, CDdata, mean)aggregate(batterytime~writer, CDdata, sd)boxplot(batterytime~writer,         main = "Possible Effect of CD Writers on Laptop Batteries",         xlab = "Battery Time in Hours",         horizontal = TRUE, col = c("tomato1", "royalblue2"))t.test(batterytime~writer, conf.level = 0.90)boxplot(sunspots$spot, horizontal = TRUE, main = "Add a title here ;) ", col = "firebrick2", xlab = "Add an x title here")

文件上传
  • Attachment 1
  • Attachment 2
  • Attachment 3
Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question