Lab Assignment 7 PDF

Title Lab Assignment 7
Author Brenna Galamay
Course Biostatistics
Institution California State University Los Angeles
Pages 7
File Size 301.6 KB
File Type PDF
Total Downloads 65
Total Views 135

Summary

lab assignment 7...


Description

BIOL 3000 – Lab Assignment #7 Name: Brenna Galamay CIN: 400159861 Instructions: For all of the problems below, copy both the R commands and the results of the R commands into the green boxes. 1. Run the Pupa Weight applet (see handout), save the data in a csv file, and import the results as a data frame called pupa in R. Type the name of the data frame to display the data. Copy/paste your R commands and the resulting output into the green box below. (1 point) > pupa = > pupa media 1 wheat 2 wheat 3 wheat 4 wheat 5 wheat 6 wheat 7 corn 8 corn 9 corn 10 corn 11 corn 12 corn 13 oat 14 oat 15 oat 16 oat 17 oat 18 oat

read.csv("PupaWghts.csv") sex female female female male male male female female female male male male female female female male male male

wght 2.83 2.30 2.51 2.48 2.25 2.36 2.60 1.82 1.92 1.79 1.49 2.18 2.20 2.23 2.69 1.33 1.14 1.29

2. Use the aggregate() function to compute the sample sizes (pupan), means (pupam), and standard deviations (pupasd) for the islands, and then compute the standard errors (pupase) of pupa weights. Make sure the numeric values are visible in your output. Copy/paste your R commands and the resulting output into the green box below. (1 point) > pupan > pupan media 1 corn 2 oat 3 wheat 4 corn 5 oat 6 wheat > pupam > pupam media

= aggregate(wght ~ media + sex, pupa, length) sex wght female 3 female 3 female 3 male 3 male 3 male 3 = aggregate(wght ~ media + sex, pupa, mean) sex

wght

1 2 3 4 5 6 > >

corn female 2.113333 oat female 2.373333 wheat female 2.546667 corn male 1.820000 oat male 1.253333 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. Create a grouped bar plot of the means of pupa weights for the six treatment groups. Use red, blue, and green to represent the different media types. Add a legend and standard error bars to the plot. Copy/paste your R commands and the resulting figure into the green box below. (1 point) > 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), + pupam$wght+pupase,angle=90,length=0.2) > legend("topright", legend=rownames(pupammat), + fill=clrs,title="Media")

4. Create an interaction plot for mean pupa weights. Add standard error bars to the plot. Copy/paste your R commands and the resulting figure into the green box below. (1 point) > interaction.plot(pupa$media,pupa$sex,pupa$wght, + ylab="Means of Pupa Weight",xlab="Flour Media", + trace.label="Sex",legend=TRUE,ylim=c(0,4)) > x=c(1:3,1:3) > x [1] 1 2 3 1 2 3 > arrows(x,pupam$wght-pupase,x,pupam$wght+pupase, + angle=90,length=0.05,code=3)

5. Conduct a two factor ANOVA for pupa weight. Copy/paste your R commands and the resulting output into the green box below. (1 point) > 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

6. In your own words, write your conclusion regarding the effects of media, sex, and the interaction of media and sex on pupa weight at the 5% level of significance. Do not just write “reject H0” or “do not reject H0.” Your three conclusions must say something about the main factors and interaction. Write the conclusion in the green box below. (1 point) 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.

7. Conduct an Bartlett test of homogeneity of variances for pupa weight among the six treatment groups. Copy/paste your R commands and the resulting output into the green box below. (1 point) > 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 15 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

8. In your own words, write your conclusion regarding the equality of variances in pupa weight among the treatment groups. Do not just write “reject H0” or “do not reject H0.” Your conclusion must say something about validity of the equality of variances assumption for the ANOVA. Write the conclusion in the green box below. (1 point) 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.

9. Create a histogram and quantile-quantile plot of the model residuals. Add a line with the expectation of a normal distribution to the quantile-quantile plot. Copy/paste your R commands and the two figures into the green box below. (1 point) > hist(residuals(pupamodel), breaks=10) > qqnorm(residuals(pupamodel)) > qqline(residuals(pupamodel))

10. Conduct an Tukey HSD analysis for the differences in mean pupa weight for the two-factor experimental design. No plots are needed. Copy/paste your R commands and the resulting output into the green box below. (1 point) > TukeyHSD(aov(wght~media*sex,data=pupa)) Tukey multiple comparisons of means 95% family-wise confidence level Fit: aov(formula = wght ~ media * sex, data = pupa) $media diff lwr upr p adj oat-corn -0.1533333 -0.58432461 0.2776579 0.6211020 wheat-corn 0.4883333 0.05734206 0.9193246 0.0266127 wheat-oat 0.6416667 0.21067539 1.0726579 0.0048695 $sex diff lwr upr p adj male-female -0.5322222 -0.8196172 -0.2448273 0.0016545 $`media:sex` diff lwr upr oat:female-corn:female 0.2600000 -0.5073962 1.02739615 wheat:female-corn:female 0.4333333 -0.3340628 1.20072948 corn:male-corn:female -0.2933333 -1.0607295 0.47406282 oat:male-corn:female -0.8600000 -1.6273962 -0.09260385 wheat:male-corn:female 0.2500000 -0.5173962 1.01739615 wheat:female-oat:female 0.1733333 -0.5940628 0.94072948

corn:male-oat:female oat:male-oat:female wheat:male-oat:female corn:male-wheat:female oat:male-wheat:female wheat:male-wheat:female oat:male-corn:male wheat:male-corn:male wheat:male-oat:male

-0.5533333 -1.1200000 -0.0100000 -0.7266667 -1.2933333 -0.1833333 -0.5666667 0.5433333 1.1100000 p adj oat:female-corn:female 0.8564901 wheat:female-corn:female 0.4480208 corn:male-corn:female 0.7880897 oat:male-corn:female 0.0252528 wheat:male-corn:female 0.8745990 wheat:female-oat:female 0.9695851 corn:male-oat:female 0.2227488 oat:male-oat:female 0.0037895 wheat:male-oat:female 1.0000000 corn:male-wheat:female 0.0672930 oat:male-wheat:female 0.0011406 wheat:male-wheat:female 0.9616197 oat:male-corn:male 0.2043798 wheat:male-corn:male 0.2373835 wheat:male-oat:male 0.0040690

-1.3207295 0.21406282 -1.8873962 -0.35260385 -0.7773962 0.75739615 -1.4940628 0.04072948 -2.0607295 -0.52593718 -0.9507295 0.58406282 -1.3340628 0.20072948 -0.2240628 1.31072948 0.3426038 1.87739615...


Similar Free PDFs