Written Assignment Unit 3

pdf

School

University of the People *

*We aren’t endorsed by this school

Course

5226

Subject

Statistics

Date

Jan 9, 2024

Type

pdf

Pages

6

Uploaded by UltraChinchilla1269

Report
Written Assignment Unit 3 When changing the sample size ( n ), we can expect the output diagrams to reflect the Law of Large Numbers. As n increases, the sample mean and sample standard deviation will generally approach the true mean ( mu ) and true standard deviation ( sd ) of the population. Interpretation: For n=10: The histogram might not resemble the normal distribution very closely, and the sample mean and standard deviation may vary substantially from ‘mu’ and ‘sd’ . For n=100: The histogram should start to resemble the normal distribution more closely, and the sample mean and standard deviation should be closer to ‘mu’ and ‘sd’ . For n=10000: The histogram should very closely resemble the normal distribution, and the sample mean and standard deviation should be very close to ‘mu’ and ‘sd’ . Calculated Values of the Mean and the Standard Deviation: Mean: The calculated sample mean ( mean(v) ) represents the average of the sample data. It provides an estimate of the population mean ( mu ). As n increases, the sample mean tends to approach the true population mean due to the Law of Large Numbers. Standard Deviation: The calculated sample standard deviation ( sd(v) ) represents the spread or dispersion of the sample data. It provides an estimate of the population standard deviation ( sd ). Again, as n increases, the sample standard deviation tends to approach the true population standard deviation(R Core Team, 2022). What is the purpose of Pr(t)? In the code, Pr(t) represents the p-value from a one-sample t-test comparing the sample mean to the population mean mu . The p-value tells us the probability of observing a sample mean as extreme as the one observed, assuming the true population mean is mu . If Pr(t) is small (typically ≤ 0.05), you might reject the null hypothesis that the sample comes from a population with mean mu , suggesting a significant difference between the sample mean and the presumed population mean.
If Pr(t) is large, there is insufficient evidence to reject the null hypothesis, and it's plausible that the sample comes from a population with mean mu . Step 1: Screenshot for of the sample code and the output for the Changed sample size of n for 10 Screenshot for of the sample code and the output for the Changed sample size of n for 100
Screenshot for of the sample code and the output for the Changed sample size of n for 10000 Step 2: Using the original sample code (n=30), and using “for” command and repeating all of the calculations and output details for 3 samples’ replications. for (i in 1:3) . Solution: In this modified code, a “for” loop is introduced to repeat the graphing and calculation procedure for three sample replications, with each iteration plotting the histogram, true normal distribution, estimated distribution, and sample parameters for each sample(Moore, et al., 2017). # Sample size n <- 30 # parameters of the normal distribution mu <- 180; sd_val <- 20 # changed sd to sd_val to avoid conflict with sd() function # set up graphic display par(mfrow=c(3, 1)) # changed to 3, 1 to accommodate 3 plots vertically # number of sd's for histogram display sdd <- 3.5 # compute bin width from sd and the number of bars bin.width = sd_val/3 # scale x-axis x.min <- mu-(sdd*sd_val); x.max <- mu+(sdd*sd_val) # scale y-axis y.max <- n*0.5*bin.width/sd_val # Repeat for 3 replications
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
for(i in 1:3) { v <- rnorm(n, mu, sd_val) hist(v, xlim=c(x.min,x.max), ylim=c(0, y.max), breaks = seq(mu-5*sd_val, mu+5*sd_val, by=bin.width), main=paste("Sample", i), xlab="Value") x <- seq(x.min, x.max, length=120) # true normal distribution points(x, dnorm(x, mu, sd_val)*(n*bin.width), type="l", col="blue", lty=1, lwd=1.8) # distribution estimated from sample points(x, dnorm(x, mean(v), sd(v))*(n*bin.width), type="l", col="red", lty=2, lwd=1.8) # print sample params and Pr(t) text(x.min, 0.9*y.max, paste("mean:", round(mean(v),2)), pos=4) text(x.min, 0.8*y.max, paste("sdev:", round(sd(v),2)), pos=4) text(x.min, 0.7*y.max, paste("Pr(t):", round((t.test(v, mu=mu))$p.value,2)), pos=4) } # clean up par(mfrow=c(1,1)) rm(n, mu, sd_val, v, sdd, bin.width, x.min, x.max, y.max, x, I)
Step 3: With the same for command (only one loop) try to repeat six samples in two rows and three columns. Your program must have the feature that declares two variables for rows and columns through which it could be possible to create output in any number of rows and columns . Solution: To achieve this, we can use par(mfrow=c(rows, columns)) to set up the desired number of rows and columns for the graphical output. You will also create variables rows and columns that you can modify as needed to arrange the output plots. Below is the modified R code to repeat the calculations and output details for 6 samples with 2 rows and 3 columns. In this code, the rows and columns variables determine the number and arrangement of the output plots. By modifying these two variables, we can create output in any number of rows and columns as per your requirement.
Conclusion In conclusion, When interpreting the output diagrams, particularly for smaller ‘ n’ , it is important to be mindful of the variability. A single sample, especially a small one, might not accurately reflect the population parameters due to sampling error. Multiple samples or larger sample sizes will generally provide more reliable estimates of the population parameters. References R Core Team. (2022). R: A language and environment for statistical computing. R Foundation for Statistical Computing. https://www.R-project.org/ Moore, D.S., McCabe, G.P., & Craig, B.A. (2017). Introduction to the Practice of statistics. (9th ed.). W. H. Freeman. ISBN-13: 978-1319013387.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help