Biostats Lab 8

docx

School

California State University, Los Angeles *

*We aren’t endorsed by this school

Course

3000

Subject

Statistics

Date

Feb 20, 2024

Type

docx

Pages

8

Uploaded by CommodoreSeal5397

Report
LAB ASSIGNMENT #8 1. > pupa = read.csv("PupaWghts.csv") > pupa Media sex wght 1 wheat female 2.83 2 wheat female 2.30 3 wheat female 2.51 4 wheat male 2.48 5 wheat male 2.25 6 wheat male 2.36 7 corn female 2.60 8 corn female 1.82 9 corn female 1.92 10 corn male 1.79 11 corn male 1.49 12 corn male 2.18 13 oat female 2.20 14 oat female 2.23 15 oat female 2.69 16 oat male 1.33 17 oat male 1.14 18 oat male 1.29
2. > pupan = aggregate(wght ~ media + sex, pupa, length) > pupan media sex wght 1 corn female 3 2 oat female 3 3 wheat female 3 4 corn male 3 5 oat male 3 6 wheat male 3 > pupam = aggregate(wght ~ media + sex, pupa, mean) > pupam media sex wght 1 corn female 2.113333 2 oat female 2.373333 3 wheat female 2.546667 4 corn male 1.820000 5 oat male 1.253333 6 wheat male 2.363333 > pupasd = aggregate(wght ~ media + sex, pupa, sd) > pupasd media sex wght 1 corn female 0.4244212 2 oat female 0.2746513 3 wheat female 0.2668957 4 corn male 0.3459769 5 oat male 0.1001665
6 wheat male 0.1150362 > pupase = pupasd$wght / sqrt(pupan$wght) > pupase [1] 0.24503968 0.15857000 0.15409232 0.19974984 0.05783117 [6] 0.06641620 > pupam$media=as.factor(pupam$media) > pupam$sex=as.factor(pupam$sex) 3. > pupammat = matrix(pupam$wght,ncol=2,byrow=FALSE) > pupammat [,1] [,2] [1,] 2.113333 1.820000 [2,] 2.373333 1.253333 [3,] 2.546667 2.363333 > colnames(pupammat)=levels(pupam$sex) > rownames(pupammat)=levels(pupam$media) > pupammat female male corn 2.113333 1.820000 oat 2.373333 1.253333 wheat 2.546667 2.363333 > clrs=c("red","blue","green") > barx=barplot(pupammat,beside=TRUE,ylim = c(0,5), col=clrs, + ylab="Mean of Weight (mg)") > arrows(array(barx), pupam$wght, array(barx),
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
+ pupam$wght+pupase,angle=90,length=0.2) > legend("topright", legend=rownames(pupammat), + fill=clrs,title="Media")
4. > pupamodel = lm(wght~media*sex,data=pupa) > anova (pupamodel) Analysis of Variance Table Response: wght Df Sum Sq Mean Sq F value Pr(>F) media 2 1.34743 0.67372 8.6049 0.004807 ** sex 1 1.27467 1.27467 16.2805 0.001655 ** media:sex 2 0.78641 0.39321 5.0221 0.026020 * Residuals 12 0.93953 0.07829 ---Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 5. All three p-values are less than 0.05. The two sexes differ with respect to their effects on mean of weight. The three media/flours differ with respect to their mean of weight. There is a significant interaction between sex and media with respect to the effects on weight. 6. > pupa$trt=paste(pupa$media,pupa$sex,sep="-") > pupa media sex wght trt 1 wheat female 2.83 wheat-female 2 wheat female 2.30 wheat-female 3 wheat female 2.51 wheat-female 4 wheat male 2.48 wheat-male 5 wheat male 2.25 wheat-male 6 wheat male 2.36 wheat-male
7 corn female 2.60 corn-female 8 corn female 1.82 corn-female 9 corn female 1.92 corn-female 10 corn male 1.79 corn-male 11 corn male 1.49 corn-male 12 corn male 2.18 corn-male 13 oat female 2.20 oat-female 14 oat female 2.23 oat-female 5 oat female 2.69 oat-female 16 oat male 1.33 oat-male 17 oat male 1.14 oat-male 18 oat male 1.29 oat-male > bartlett.test(wght~trt,data=pupa) Bartlett test of homogeneity of variances data: wght by trt Bartlett's K-squared = 4.5315, df = 5, p-value = 0.4757 7. The p-value returned is 0.4757. Since this greater than alpha at 0.05, we do not reject the null hypothesis. There is no evidence that the equality of variances assumption of the ANOVA is violated. 8. > hist(residuals(pupamodel), breaks=10) > qqnorm(residuals(pupamodel)) > qqline(residuals(pupamodel))
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
9. Yes, it does appear that the normality of the residuals assumption is satisfied for your ANOVA. The reason is because there is a normal distribution in the histogram.