##6.2.3

data<-c(10.0, 8.9, 9.1, 11.7, 7.9)
'mean'
## [1] "mean"
mean<-mean(data); mean
## [1] 9.52
'sd'
## [1] "sd"
sd<-sd(data);sd
## [1] 1.428986
'SE'
## [1] "SE"
SE<-sd/(5^(1/2));SE
## [1] 0.6390618

##6.3.3(a-b)

y<-31.7
sd<-8.7
n<-5
'SE'
## [1] "SE"
SE<-sd/(n^(1/2));SE
## [1] 3.890758
'critical value (table)'
## [1] "critical value (table)"
cv_ifNequalinfinity<-qnorm(.95,0,1)

df<-4
critical_value<-qt(.95,df);critical_value
## [1] 2.131847
'90% CI'
## [1] "90% CI"
upper_vector<-y+critical_value*SE
lower_vector<-y-critical_value*SE
CI<-c(lower_vector,upper_vector);CI
## [1] 23.4055 39.9945

##6.3.4(a)

'Critical Value 95%'
## [1] "Critical Value 95%"
critical_value<-qt(.975,df);critical_value
## [1] 2.776445
upper_vector<-y+critical_value*SE
lower_vector<-y-critical_value*SE
'95% CI'
## [1] "95% CI"
CI<-c(lower_vector,upper_vector);CI
## [1] 20.89752 42.50248

##6.3.4(b) We are 95% confident that the true population mean number of thymus gland weights for chick embryos after 14 days incubation is between 20.899 mg and 42.501 mg.

##6.3.5(a)

y<-28.7
sd<-4.6
n<-6
SE<-sd/(n^(1/2))
df<-n-1
critical_value<-qt(.975,df)

upper_vector<-y+critical_value*SE
lower_vector<-y-critical_value*SE
'95% CI'
## [1] "95% CI"
CI<-c(lower_vector,upper_vector);CI
## [1] 23.8726 33.5274

##6.3.5(b) We are 95% confident that the true population mean number for blood serum concentration of Gentamicin 1.5 hours after injection in Suffolk sheep is between 23.873 (mg/ml) and 33.527 (mg/ml). ##6.3.7(a-b) An 80% confidence interval would be narrower because we are less confident that it will be in this range. Another way to look at it would be to consider if we took 100 samples of the mean, aproximately 80 of the 100 would be in CI where as aproximately 95 of 100 would be contained in a 95% CI.

The CI listed would again be narrower because the SE would be smaller (sd/sqrt(500) rather than sd/sqrt(86)), smaller SE equals a narrower CI. ##6.3.11(a)

y<-13
sd<-12.4
n<-10
SE<-sd/(n^(1/2))
df<-n-1
critical_value<-qt(.975,df)

upper_vector<-y+critical_value*SE
lower_vector<-y-critical_value*SE
'95% CI'
## [1] "95% CI"
CI<-c(lower_vector,upper_vector);CI
## [1]  4.129574 21.870426

##6.3.11(b-c) b) We are 95% confident that the true population mean for the difference between HBE levels before and after implementing a physical fitness program will be between 4.130 and 21.870 (pg/ml). c) We are 95% confident that the true population mean for the difference between HBE levels before and after implementing a physical fitness program will be between 4.130 and 21.870 (pg/ml). This confidence interval does not include the value zero meaning that the levels before and after implementing exercise are statistically significantly different and HBE levels are different. ##6.3.16 a) Techically, I would argue that this study does not tell us anything about the effects of the solution on neurological development because I do not have any data from a control or any population data on premature infants that do not take this aluminum depleted IV-feeding solution. An 95% confidence interval of 93.8-102.1 does include the population average of 100 for all infants this age so we can argue that premature infants that take this solution do fall within the population average IQ as those infants that are not premature that do not take solution. b) This interval does indicate that the sampled population’s mean is below the population IQ mean of 100, but does not mean that this is not due to sampling error. The sampling distribution mean is: 97.95.

y<-93.8+(102.1-93.8)/2;y
## [1] 97.95

##6.4.1(a) Greater than or equal 16.

sd<-20
SE<-5
n<-(sd/SE)^2;n
## [1] 16
sd<-40
SE<-5
n<-(sd/SE)^2;n
## [1] 64

##6.4.1(b) No, if the guess of the SD is doubled the number of cattle necessary to get the same standard error is 4 times great or 2^2 times greater. ##6.4.2 178 men

sd<-40
SE<-3
n<-(sd/SE)^2;n
## [1] 177.7778

##6.5.2(a) The hierarchical nature to data and nesting are problematic in using n=36 since the cells came from a signle localized region in the brains of only 7 different adult guinea pigs. ##6.5.2(b) The data looks slightly right skewed and non-normal which could be due to the heirarchical nature of the data in that n is not equal to 36 but rather a much smaller sample of 7 thus variability/ SE is increased.

data_dendrite<-c(38,42,25,35,35,33,48,53,17,24,26,26,47,28,24,35,38,26,38,29,49, 26,41,26,35,38,44,25,45,28,31,46,32,39,59,53)

hist(data_dendrite, xlim=c(10,70), breaks = 10)

## ? 6.5.4(a) No, it does not ppear reasonable to assume that the population distribution of Y is normal. I cannot determine if 1 fly planted all eggs, if all larvae were from one moth, if fly plants eggs in larvae multiple times, etc. Also, the data does not appear normal, possibly due to multiple egg laying overlap or large egg lays (not determinable in this scenario). "Hierarchical structure [can] result from repeated measurements on the same individual organism.

y<-2.368
sd<-1.95
n<-c(15,242)
SE<-sd/(n^(1/2))
df<-n-1
critical_value<-qt(.975,df)

upper_vector<-y+critical_value*SE
lower_vector<-y-critical_value*SE
'95% CI'
## [1] "95% CI"
CI<-c(lower_vector,upper_vector);CI
## [1] 1.288126 2.121077 3.447874 2.614923

? 6.5.4(b)

Must be a random sample from population of interest-knowing the mean of a biased sample does not provide iformation about the population mean.

More importantly in this scenario for Student t’s method to be valid, Y must follow a normal distribution in the population; if the populataion distribution is not normal than than Student’s t confidencce interval is aproximately valid if the sample size is large. I can only defend Student’s t method if the data sample size is large enough which it appears to be.

##6.5.8 This random sample is not from a large population and the sample is greater than 5% of population at 11.8%.

n<-30
N<-255
percent_N<-n/N;percent_N
## [1] 0.1176471

##6.6.3 4.305

n1<-5
n2<-7
y1<-44
y2<-47
s1<-6.5
s2<-8.4

SE1<-s1/sqrt(n1)
SE2<-s2/sqrt(n2)

SE_y1y2<-sqrt(SE1^2+SE2^2);SE_y1y2
## [1] 4.304649
SE_y1y2<- sqrt((s1^2/n1)+(s2^2/n2)); SE_y1y2
## [1] 4.304649

##6.6.8 0.161

s1<-.4
n1<-9
s2<-.220
n2<-6

SE_y1y2<- sqrt((s1^2/n1)+(s2^2/n2)); SE_y1y2
## [1] 0.1607621

##6.7.8 -0.1198 to 0.2358

df<-35.7
n1<-22
n2<-17
y1<-8.498
y2<-8.44
s1<-.283
s2<-.262

SE_y1y2<- sqrt((s1^2/n1)+(s2^2/n2))
cv<-qt(.975, df)

upper_vector<-(y1-y2)+cv*SE_y1y2
lower_vector<-(y1-y2)-cv*SE_y1y2

CI<-c(lower_vector,upper_vector);CI
## [1] -0.1197654  0.2357654
library(BSDA)
## Loading required package: lattice
## 
## Attaching package: 'BSDA'
## The following object is masked from 'package:datasets':
## 
##     Orange
tsum.test(8.498,.283,22,8.44,.262,17)
## 
##  Welch Modified Two-Sample t-Test
## 
## data:  Summarized x and y
## t = 0.66191, df = 35.729, p-value = 0.5123
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.1197603  0.2357603
## sample estimates:
## mean of x mean of y 
##     8.498     8.440

##6.7.8(b-c) (b)We are 95% confident that body size of head witdth being -.1198 mm smaller leads to nonsuccesful mating to as much as .2358 mm greater head width leads to succeful mating. (c) The mean difference is containted within the confidence interval and therefore there we are 95% confident that mean head width does not play a role in succcesful versus unsuccesful mating. ##6.7.11(a) CI (-7.305622 10.105622)

df<-17.3
n_caf<-9
n_dec<-11
y_caf<-7.3
y_dec<-5.9
s_caf<-11.1
s_dec<-11.2

SE_y1y2<- sqrt((s_caf^2/n_caf)+(s_dec^2/n_dec))
cv<-qt(.95, df)

upper_vector<-(y_caf-y_dec)+cv*SE_y1y2
lower_vector<-(y_caf-y_dec)-cv*SE_y1y2

CI<-c(lower_vector,upper_vector);CI
## [1] -7.305622 10.105622

##6.7.11(b) We are 90% confident because zero is included in the CI (-7.305622 10.105622), there is no difference between the HR of those administered caffeine and those administered a decaf coffee. ##6.7.11(c) It is possible, we are 90% confident caffeine could have lowered BPM by as much as 7.306 BPM or raised HR by as much as 10.106BPM. ##6.7.11(d) My answers to B and C are contradictory in that the statistics contain 0 and thus we are 90% confident that there is no statistical difference between groups but because it is a CI, there is the possibility that it we are also 90% confident that caffeine lowers HR by the lower vector or raises HR by the upper vector.