The following packages are required for this practical:
library(dplyr)
library(magrittr)
library(mice)
library(ggplot2)
library(DAAG)
library(MASS)
The data sets elastic1 and elastic2 from the package DAAG were obtained using the same apparatus, including the same rubber band, as the data frame elasticband.
elastic1 and elastic2 on the same graph. Do the two sets of results appear consistent?elastic1 and elastic2, determine the regression of distance on stretch. In each case determine:Compare the two sets of results. What is the key difference between the two sets of data?
plot() on the fitted objectrlm() from the MASS package to fit lines to the data in elastic1 and elastic2. Compare the results with those from use of lm():elastic2 variable stretch to obtain predictions on the model fitted on elastic1.elastic2A recruiter for a large company suspects that the process his company uses to hire new applicants is biased. To test this, he records the application numbers that have been successfully hired in the last hiring round. He finds the following pattern:
numbers <- data.frame(hired = c(11, 19, 13, 4, 8, 4),
not_hired = c(89, 81, 87, 96, 92, 11))
numbers$probability <- round(with(numbers, hired / (hired + not_hired)), 2)
rownames(numbers) <- c(paste("Application number starts with", 0:5))
numbers
## hired not_hired probability
## Application number starts with 0 11 89 0.11
## Application number starts with 1 19 81 0.19
## Application number starts with 2 13 87 0.13
## Application number starts with 3 4 96 0.04
## Application number starts with 4 8 92 0.08
## Application number starts with 5 4 11 0.27
decreasing <- data.frame(hired = c(16, 14, 12, 10, 8, 1),
not_hired = c(84, 86, 88, 91, 93, 14))
decreasing$probability <- round(with(decreasing, hired / (hired + not_hired)), 2)
decreasing
## hired not_hired probability
## 1 16 84 0.16
## 2 14 86 0.14
## 3 12 88 0.12
## 4 10 91 0.10
## 5 8 93 0.08
## 6 1 14 0.07
The board of the company would like to improve their process if the process is systematically biased. They tell the recruiter that their standard process in hiring people is as follows:
The recruiter suspects that the following psychological process is occuring: The board realized at the coffee break that they were running out of vacancies to award the remaining half of the applications, then became more conservative for a while and return to baseline in the end.
If that were true, the following expected cell frequencies might be observed:
oops <- data.frame(hired = c(14, 14, 14, 2, 12, 3),
not_hired = c(86, 86, 86, 98, 88, 12))
oops$probability <- round(with(oops, hired / (hired + not_hired)), 2)
oops
## hired not_hired probability
## 1 14 86 0.14
## 2 14 86 0.14
## 3 14 86 0.14
## 4 2 98 0.02
## 5 12 88 0.12
## 6 3 12 0.20
oops pattern would fit to the observed pattern from the numbers data. Again, use a chi-squared test.decreasing probability patternoops pattern.chisq.test() or the fisher.test(). Create the function such that it:bacteria (from MASS) by testing independence between compliance (hilo) and the presence or absence of disease (y).bacteria dataset?The mammalsleep dataset is part of mice. It contains the Allison and Cicchetti (1976) data for mammalian species. To learn more about this data, type
?mammalsleep
brw is modeled from bwbrw is predicted from both bw and speciesbrw?exercise 16. What issues can you detect?End of Practical JK.