PSYC 278 Lab 6 Problem Set

pdf

School

University of British Columbia *

*We aren’t endorsed by this school

Course

278

Subject

Statistics

Date

May 24, 2024

Type

pdf

Pages

6

Uploaded by ChancellorNeutronLyrebird25

Report
Joseph Kim PSCY 278 – Lab Section 01 Student No: 18608240 Q1. Given the population set of scores {3,4,5,6,7,8,9}, use base R graphics or ggplot to generate a bar graph representing the sampling distribution of mean for samples of N = 4. Assume sampling is one at a time with replacement. Give your graph a descriptive title, and be sure to include appropriate labels for the y-and x-axes. Code (q1): install.packages(c("psych", "pracma", "ggplot2", "latex2exp")) library(psych) library(pracma) library(ggplot2) library(latex2exp) scores <- 3:9 # expand.grid, permutations with replacement samp.dist.m <- data.frame(expand.grid(rep(list(scores), 4))) colnames(samp.dist.m) <- c('score.1', 'score.2', 'score.3', 'score.4') samp.dist.m$mean <- rowMeans(samp.dist.m) print(t <- table(samp.dist.m$mean)) require(latex2exp) pct <- as.numeric(t) / sum(t) xlab <- names(t) df <- data.frame(xlab, pct) p <- ggplot(data = df, aes(x = xlab, y = pct)) + geom_bar(stat = "identity", fill = 'skyblue2') + labs(x = TeX("$\\bar{\\textit{X}}$"), y = TeX("$\\textit{p}(\\bar{\\textit{X}})$"), title = TeX("Sampling distribution of $\\bar{\\textit{X}}$ with $\\textit{N} = 4$")) +
theme_classic() + scale_y_continuous(breaks = seq(0, 0.24, .04)) + theme(axis.title.x = element_text(margin = unit(c(3.5,0,0,0), "mm"), size = 11), axis.title.y = element_text(margin = unit(c(0,3.5,0,0), "mm"), size = 11), axis.text = element_text(size = 9.5)) p Output (q1):
Q2. A professor has been teaching statistics for many years. His records show that the overall mean for final exam scores is 73, with a standard deviation of 11. The professor believes that this year’s class is superior to his previous ones. The mean for final exam scores for this year’s class of 68 students is 76. Using 𝛼 = 0.051-tail, state your conclusion and report Zobt and the associated p-value. Code (q2): n <- 68 xobt <- 76 mu <- 73 sigma <- 11 sem <- sigma / sqrt(n) print(zcrit <- round(qnorm(p = .05, lower.tail = FALSE), 2)) print(zobt <- round((xobt - mu) / sem, 2)) print(zobt >= zcrit) print(p_value <- round(pnorm(zobt, lower.tail = FALSE), 3)) Output (q2): [1] 1.64 [1] 2.25 [1] TRUE [1] 0.012 Answer (q2): Conclusion: Reject 𝐻 0. The data indicates that the mean for final exam scores for this year’s class of 68 students was significantly greater than the overall mean for final exam scores as z_obt = 2.25 was greater than z_crit = 1.64 (which is based on a one-tailed test with alpha level = 0.05). Furthermore, the associated p-value (.012) was less than the alpha level of 0.05.
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
Q3. Pagano’s (2013, p. 316) Practice Problem 12.2 presented hypothetical data testing a new gasoline additive. A large number of mileage measurements on the gasoline without the additive showed a mean of 24.7 miles per gallon and a standard deviation of 4.8. An experiment was performed in which 75 cars were tested using the gasoline plus the additive. The results showed a sample mean of 26.5 miles per gallon. To evaluate these data, a directional test with 𝛼 = 0.051-tail was used. Suppose that before doing the experiment, the manufacturer wants to determine the probability that he will be able to detect a real mean increase of 2.0 miles per gallon with the additive if the additive is at least that effective. a. If he tests 25 cars, what is the power to detect a mean increase of 2.0 miles per gallon? Report your answer to exactly four decimal places. (1 pt.) b. If he increases the N to 75 cars, what is the power to detect a mean increase of 2.0 miles per gallon? Report your answer to exactly four decimal places. (1 pt.) c. Again using only 25 cars, what is the probability the manufacturer would make a type-II error rate if there was a mean increase of 2.0 miles per gallon? Report your answer to exactly four decimal places. (1 pt.) d. How many cars should he use if he wants to have a 95% chance of detecting a mean increase of 2.0 miles per gallon? Use 𝛼 = 0.051-tail and report your answer to the nearest integer that satisfies the power requirement. (1 pt.) Code (q3a): mu <- 24.7 sigma <- 4.8 n <- 25 mu_real <- mu + 2 sem <- sigma / sqrt(n) zcrit <- qnorm(p = .05, lower.tail = FALSE) xcrit <- mu + zcrit*sem zobt_real <- (xcrit - mu_real) / sem round(pnorm(zobt_real, lower.tail = FALSE), digits = 4)
Output (q3a): [1] 0.6695 Code (q3b): mu <- 24.7 sigma <- 4.8 n <- 75 mu_real <- mu + 2 sem <- sigma / sqrt(n) zcrit <- qnorm(p = .05, lower.tail = FALSE) xcrit <- mu + zcrit*sem zobt_real <- (xcrit - mu_real) / sem round(pnorm(zobt_real, lower.tail = FALSE), digits = 4) Output (q3b): [1] 0.9752 Code (q3c): mu <- 24.7 sigma <- 4.8 n <- 25 mu_real <- mu + 2 sem <- sigma / sqrt(n) zcrit <- qnorm(p = .05, lower.tail = FALSE) xcrit <- mu + zcrit*sem zobt_real <- (xcrit - mu_real) / sem power <- round(pnorm(zobt_real, lower.tail = FALSE), digits = 4) print(beta <- 1 - power) Output (q3c): [1] 0.3305
Code (q3d): mu <- 24.7 mu_real <- mu + 2 zcrit <- qnorm(p = 0.95, lower.tail = F) zobt.need <- qnorm(p = 0.95, lower.tail = F) numer <- sigma * (zcrit + zobt.need) denom <- mu_real - mu print(N <- (numer / denom)^2) Output (q3d): [1] 62.33572 Answer (q3d): He should use 63 cars (rounded up from 62.33572) to have a 95% chance of detecting a mean increase of 2.0 miles per gallon.
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