EXAMEN FINAL 2014
rwbbsurvey<-read.csv("C:/MCF202/examen/rwbbsurvey.csv", header=T)
head(rwbbsurvey)
## SiteName Year Restoration Reference ObserverNames Precipitation
## 1 IGH 2005 3 3 Tyler_Amanda 0
## 2 Kelly 2005 4 2 Patrick_Chelsea 0
## 3 Carlton 2005 2 3 David_Megan 0
## 4 IGH 2006 9 6 Tyler_Amanda 0
## 5 Kelly 2006 9 1 David_Megan 0
## 6 Carlton 2006 7 3 Patrick_Chelsea 0
## Temperature
## 1 48
## 2 48
## 3 48
## 4 52
## 5 52
## 6 52
mean(rwbbsurvey$Restoration)
## [1] 11.11
sd(rwbbsurvey$Restoration)
## [1] 6.22
mean(rwbbsurvey$Reference)
## [1] 4.389
sd(rwbbsurvey$Reference)
## [1] 3.852
Carlton <- subset(rwbbsurvey, SiteName=="Carlton")
head(Carlton)
## SiteName Year Restoration Reference ObserverNames Precipitation
## 3 Carlton 2005 2 3 David_Megan 0
## 6 Carlton 2006 7 3 Patrick_Chelsea 0
## 9 Carlton 2007 11 2 Patrick_Chelsea 12
## 12 Carlton 2008 13 3 Patrick_Chelsea 0
## 15 Carlton 2009 20 1 Tyler_Amanda 0
## 18 Carlton 2010 24 4 Tyler_Amanda 0
## Temperature
## 3 48
## 6 52
## 9 41
## 12 54
## 15 55
## 18 61
mean(Carlton$Restoration)
## [1] 12.83
sd(Carlton$Restoration)
## [1] 8.134
mean(Carlton$Reference)
## [1] 2.667
sd(Carlton$Reference)
## [1] 1.033
boxplot(rwbbsurvey$Restoration,rwbbsurvey$Reference, col="gray")
Carlton <- subset(rwbbsurvey, SiteName=="Carlton")
head(Carlton)
## SiteName Year Restoration Reference ObserverNames Precipitation
## 3 Carlton 2005 2 3 David_Megan 0
## 6 Carlton 2006 7 3 Patrick_Chelsea 0
## 9 Carlton 2007 11 2 Patrick_Chelsea 12
## 12 Carlton 2008 13 3 Patrick_Chelsea 0
## 15 Carlton 2009 20 1 Tyler_Amanda 0
## 18 Carlton 2010 24 4 Tyler_Amanda 0
## Temperature
## 3 48
## 6 52
## 9 41
## 12 54
## 15 55
## 18 61
boxplot(Carlton$Restoration,Carlton$Reference, col="gray")
Como en la base de datos se tiene un efecto tiempo, con esto indica que es de Muestras independintes, por lo tanto se plante el siguiente hipotesis
Ho: La diversidad de especies es igual con el paso de los años.
t.test(rwbbsurvey$Reference, mu=0)
##
## One Sample t-test
##
## data: rwbbsurvey$Reference
## t = 4.834, df = 17, p-value = 0.0001554
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
## 2.473 6.305
## sample estimates:
## mean of x
## 4.389
La diferencia entre las medias es significativa? si con un valor de P-value de 0.0001554 y una media de 4.38
boxplot(rwbbsurvey$Reference,rwbbsurvey$Restoration, col="gray")
var.test(rwbbsurvey$Reference, rwbbsurvey$Restoration)
##
## F test to compare two variances
##
## data: rwbbsurvey$Reference and rwbbsurvey$Restoration
## F = 0.3835, num df = 17, denom df = 17, p-value = 0.05589
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
## 0.1435 1.0253
## sample estimates:
## ratio of variances
## 0.3835
t.test(rwbbsurvey$Restoration, rwbbsurvey$Reference, var.equal=T)
##
## Two Sample t-test
##
## data: rwbbsurvey$Restoration and rwbbsurvey$Reference
## t = 3.898, df = 34, p-value = 0.0004334
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 3.218 10.227
## sample estimates:
## mean of x mean of y
## 11.111 4.389
NO hay diferencia significativa, por tal razon se ocipa el var.equal=T La diferencia entre las medias es significativa? y con la prueba de tuke nos da una probabilidad de 0.00043
Ho: La diversidad del sitio Reference
Con los datos de tiempo(Year) y la abundancia de especies en el sitio resultado(Restoration) ajustar un modelo de regresión para el área
plot(rwbbsurvey$Restoration, rwbbsurvey$Year)
rwbbsurvey.reg <- lm(rwbbsurvey$Year ~rwbbsurvey$Restoration)
abline(rwbbsurvey.reg)
rwbbsurvey.reg
##
## Call:
## lm(formula = rwbbsurvey$Year ~ rwbbsurvey$Restoration)
##
## Coefficients:
## (Intercept) rwbbsurvey$Restoration
## 2004.899 0.234
summary(rwbbsurvey.reg)
##
## Call:
## lm(formula = rwbbsurvey$Year ~ rwbbsurvey$Restoration)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.006 -0.596 -0.420 0.281 2.292
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.00e+03 5.00e-01 4009.70 < 2e-16 ***
## rwbbsurvey$Restoration 2.34e-01 3.95e-02 5.92 2.1e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.01 on 16 degrees of freedom
## Multiple R-squared: 0.687, Adjusted R-squared: 0.667
## F-statistic: 35.1 on 1 and 16 DF, p-value: 2.14e-05
fitted(rwbbsurvey.reg)
## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
## 2006 2006 2005 2007 2007 2007 2008 2005 2007 2007 2008 2008 2009 2009 2010
## 16 17 18
## 2008 2008 2011
resid(rwbbsurvey.reg)
## 1 2 3 4 5 6 7 8
## -0.60101 -0.83514 -0.36689 -1.00574 -1.00574 -0.53750 -0.70811 1.63311
## 9 10 11 12 13 14 15 16
## -0.47399 0.99426 -0.17635 0.05777 -0.11284 0.35541 -0.58108 2.29189
## 17 18
## 1.58953 -0.51757
rwbbsurvey.res<-resid(rwbbsurvey.reg)
plot(rwbbsurvey.res)
coeficientes de regresion alfa: 2.005e+03 coeficiente de regresion beta: 2.341e-01
Regresoras significativas alfa: <2e-16*** altamente significativa Regresoras significativas beta: 2.14e-05*** altamente significativa
Gráfica de regresión con linea de ajuste presentado anteriormente
boxplot(rwbbsurvey$Restoration~ rwbbsurvey$Year, col="gray", xlab="Año", ylab= "Restoration")
abundancia.aov<- aov(rwbbsurvey$Restoration~ rwbbsurvey$SiteName)
summary(abundancia.aov)
## Df Sum Sq Mean Sq F value Pr(>F)
## rwbbsurvey$SiteName 2 27 13.7 0.33 0.73
## Residuals 15 630 42.0
abundancia.aov
## Call:
## aov(formula = rwbbsurvey$Restoration ~ rwbbsurvey$SiteName)
##
## Terms:
## rwbbsurvey$SiteName Residuals
## Sum of Squares 27.4 630.3
## Deg. of Freedom 2 15
##
## Residual standard error: 6.482
## Estimated effects may be unbalanced
Se acepta la Ho, por tal razon no existe diferencia significativa entre los sitios y la abundancia de especies y no se realizo la prueba de Tukey.