Question 1


Data


* Normal distribution
* Mean: 10 minutes
* Standard deviation: 1 minute

a.


curve(dnorm(x,10,1),5,15)


b.


pnorm(11,10,1)
## [1] 0.8413447


Conclusion


The probability that a randomly selected job will be completed in less than 11 minutes is 0.84


Question 2


Data


* Mean: 10 mm
* alpha: 0.05
* sample n= 100 parts * We can assume normality as n is large and we comply with the central limit theorem

a. Histogram

dat<-read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/diameter.csv")
hist(dat$Diameter,main="Measurements of diameter",xlab="Diameter",col="blue3",border="yellow")


a. Boxplot

boxplot(dat$Diameter,main = "Measurements of diameter",ylab = "Diameter")


b. Hypothesis Test


* \(H_o\): u = 10 mm
* \(H_a\): u ≠ 10 mm

t.test(dat$Diameter, mu=10,alternative = "two.sided")
## 
##  One Sample t-test
## 
## data:  dat$Diameter
## t = 7.6839, df = 99, p-value = 1.134e-11
## alternative hypothesis: true mean is not equal to 10
## 95 percent confidence interval:
##  10.12638 10.21438
## sample estimates:
## mean of x 
##  10.17038


Conclusion


From the plots: we assumed normality considering the sample size and the central limit theorem. The plots allow us to prove our hypothesis. The bell shape is very clear in the histogram. Now, in the boxplot we can see the expected symmetry towards the median.The data is well distributed and there are not outliers. From the test: As our p value 1.134e-11 is less than our alpha 0.05, we have enough evidence to reject the null hypothesis and accept the alterative hyphotesis. Therefore, the mean is not equal to 10 mm.


Question 3


Data


* alpha: 0.1
* 8 samples per population
* Normally distributed: use t-test with pooled variance

a.

dat3<-read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/Fabric.csv")
boxplot(dat3$ï..Abraided,dat3$Unabraided,main = "Breaking Force - Abraided vs. Unabraided", names = c("Abraided","Unabraided"), ylab = "Breaking Force")


b.


* \(H_o\): \(u_a\) = \(u_u\)
* \(H_a\): \(u_a\)\(u_u\)

t.test(dat3$ï..Abraided,dat3$Unabraided,var.equal = TRUE)
## 
##  Two Sample t-test
## 
## data:  dat3$ï..Abraided and dat3$Unabraided
## t = -1.3729, df = 14, p-value = 0.1914
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -18.448196   4.048196
## sample estimates:
## mean of x mean of y 
##    36.375    43.575


Conclusion


As our p value 0.1914 is greater than our alpha 0.1, we don´t have enough evidence to reject the null hyphotesis. Therefore, we don´t have enough evidence to say that the means are equal. However, the p value is not really high and also in the boxplot the median for each value are very different. Also, the variances are not that similar and the distributions have significant differences. Again, we don´t have enough evidence to reject the null hypothesis, but I would recommend to take more samples in order to get a more accurate result.


Question 4


dat<-read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/cropdata2.csv")
str(dat)
## 'data.frame':    96 obs. of  3 variables:
##  $ density   : int  1 2 1 2 1 2 1 2 1 2 ...
##  $ fertilizer: int  1 1 1 1 1 1 1 1 1 1 ...
##  $ yield     : num  177 178 176 178 177 ...
dat$density<-as.fixed(dat$density)
dat$fertilizer<-as.fixed(dat$fertilizer)
interaction.plot(dat$fertilizer,dat$density,dat$yield)

mod<-lm(yield~density+fertilizer+density*fertilizer,dat)
gad(mod)
## Analysis of Variance Table
## 
## Response: yield
##                    Df  Sum Sq Mean Sq F value    Pr(>F)    
## density             1  5.1217  5.1217 15.1945 0.0001864 ***
## fertilizer          2  6.0680  3.0340  9.0011 0.0002732 ***
## density:fertilizer  2  0.4278  0.2139  0.6346 0.5325001    
## Residual           90 30.3367  0.3371                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
mod<-lm(yield~density+fertilizer,dat)
gad(mod)
## Analysis of Variance Table
## 
## Response: yield
##            Df  Sum Sq Mean Sq F value    Pr(>F)    
## density     1  5.1217  5.1217 15.3162 0.0001741 ***
## fertilizer  2  6.0680  3.0340  9.0731 0.0002533 ***
## Residual   92 30.7645  0.3344                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1


Conclusions


* a. In the first ANOVA table our Pr value for density:fertilizer is equal to 0.5325001. As our alpha=0.05, we can say that this interaction is not significant. Moreover, there is no intersection of the lines in our plot which confirms the results of the analysis.
* b. In the second ANOVA table both Pr values are less than 0.05 (our alpha). Hence, the main effects are significant.
* c.Fertilizer 3 would give the greatest yield: the yield value for fertilizer 3 is greater than the values for the other fertilizers for both densities as we can see in our interaction plot.
* d.I would have a greater yield planting the crop sparse as it is seen in the plot. For the value 1 (fertilizer A), the continuos line (density 2: sparse) presents a higher result for yield (y axis)

Question 5


Data


* Populations: 4
* ANOVA CRD
* alpha = 0.05
* Power = 0.85
* f = 0.5

Number of samples


pwr.anova.test(k=4,n=NULL,f=0.5,sig.level=0.05, power=0.85)
## 
##      Balanced one-way analysis of variance power calculation 
## 
##               k = 4
##               n = 13.32146
##               f = 0.5
##       sig.level = 0.05
##           power = 0.85
## 
## NOTE: n is number in each group


The sample for each level will be 14 (n=14)


Proposed collection table


trt1 <- c("lvl1","lvl2","lvl3","lvl4")
design<-design.crd(trt=trt1,r=14, seed=892815)
design$book
##    plots  r trt1
## 1    101  1 lvl4
## 2    102  1 lvl3
## 3    103  1 lvl1
## 4    104  2 lvl3
## 5    105  2 lvl1
## 6    106  1 lvl2
## 7    107  3 lvl3
## 8    108  2 lvl2
## 9    109  3 lvl1
## 10   110  2 lvl4
## 11   111  3 lvl4
## 12   112  4 lvl4
## 13   113  4 lvl1
## 14   114  5 lvl4
## 15   115  3 lvl2
## 16   116  6 lvl4
## 17   117  5 lvl1
## 18   118  6 lvl1
## 19   119  7 lvl4
## 20   120  4 lvl2
## 21   121  5 lvl2
## 22   122  4 lvl3
## 23   123  5 lvl3
## 24   124  7 lvl1
## 25   125  6 lvl2
## 26   126  7 lvl2
## 27   127  8 lvl1
## 28   128  6 lvl3
## 29   129  8 lvl4
## 30   130  9 lvl4
## 31   131 10 lvl4
## 32   132  7 lvl3
## 33   133  9 lvl1
## 34   134  8 lvl2
## 35   135 11 lvl4
## 36   136  8 lvl3
## 37   137  9 lvl3
## 38   138 10 lvl1
## 39   139 10 lvl3
## 40   140 12 lvl4
## 41   141  9 lvl2
## 42   142 10 lvl2
## 43   143 11 lvl1
## 44   144 12 lvl1
## 45   145 11 lvl2
## 46   146 11 lvl3
## 47   147 13 lvl4
## 48   148 12 lvl3
## 49   149 12 lvl2
## 50   150 14 lvl4
## 51   151 13 lvl1
## 52   152 14 lvl1
## 53   153 13 lvl2
## 54   154 13 lvl3
## 55   155 14 lvl3
## 56   156 14 lvl2


The seed used was = 892815


CODE USED

library(tidyverse)
library(dplyr)
library(GAD)
library(agricolae)
library(pwr)

#Question 1
#a. Plot the probability density function
curve(dnorm(x,10,1),5,15)

#b. Probability that job will be completed in less than 11 minutes?
pnorm(11,10,1)

#Question 2
#a
#Histogram
dat<-read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/diameter.csv")
hist(dat$Diameter,main="Measurements of diameter",xlab="Diameter",col="blue3",border="yellow")
#Boxplot
boxplot(dat$Diameter,main = "Measurements of diameter",ylab = "Diameter")

#b
t.test(dat$Diameter, mu=10,alternative = "two.sided")

#Question 3
#a
dat3<-read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/Fabric.csv")
boxplot(dat3$ï..Abraided,dat3$Unabraided,main = "Breaking Force - Abraided vs. Unabraided", names = c("Abraided","Unabraided"), ylab = "Breaking Force")

#b
t.test(dat3$ï..Abraided,dat3$Unabraided,var.equal = TRUE)

#Question 4
dat<-read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/cropdata2.csv")
str(dat)
dat$density<-as.fixed(dat$density)
dat$fertilizer<-as.fixed(dat$fertilizer)
interaction.plot(dat$fertilizer,dat$density,dat$yield)
mod<-lm(yield~density+fertilizer+density*fertilizer,dat)
gad(mod)
mod<-lm(yield~density+fertilizer,dat)
gad(mod)

#Question 5
#Number of samples to be collected
pwr.anova.test(k=4,n=NULL,f=0.5,sig.level=0.05, power=0.85)
#Proposed collection table
trt1 <- c("lvl1","lvl2","lvl3","lvl4")
design<-design.crd(trt=trt1,r=14, seed=892815)
design$book