Sunday, March 22, 2015

How to- 95% Confidence Band in R

Puerto Rica Shade (2 level)
Dear Aaron, I deserve like 6 diet cokes for this.

DATA FILE

data <- read.csv("http://www.personal.psu.edu/dkp5177/PR.2.CHAO2.csv",
                 header=TRUE, na.strings = NA)
require(ggplot2)
## Loading required package: ggplot2
require(gridExtra)
## Loading required package: gridExtra
## Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
## logical.return = TRUE, : there is no package called 'gridExtra'
require(knitR)
## Loading required package: knitR
## Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
## logical.return = TRUE, : there is no package called 'knitR'
require(qplots)
## Loading required package: qplots
## Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
## logical.return = TRUE, : there is no package called 'qplots'

Chao2 graph without 95% Confidence Interval Band

ggplot(data=data, aes(x=lspr.s, y=chao.2.mean.lspr, group=1)) +
    geom_line() + geom_point()+ ylab("Chao 2") +
    ggtitle("Chao 2 of low-shade farms in Puerto Rico 2013") + theme_bw() +
   theme(
    panel.background = element_blank(),
  panel.grid.major = element_blank(),
    panel.grid.minor = element_blank())

Chao2 graph with the 95% Confidence Interval Band

ggplot(data=data, aes(x=lspr.s, y=chao.2.mean.lspr, group=1)) +
    geom_line() + geom_point()+ ylab("Chao 2") +
    ggtitle("Chao 2 of low-shade farms in Puerto Rico 2013") + theme_bw() +
   theme(
    panel.background = element_blank(),
  panel.grid.major = element_blank(),
    panel.grid.minor = element_blank())+
geom_ribbon(aes(ymin=chao.2.lb.lspr, ymax=chao.2.ub.lspr), alpha=0.2)

Chao2 graph with the 95% Confidence Interval Band and Estimated Species in Red

ggplot(data=data, aes(x=lspr.s, y=chao.2.mean.lspr, group=1)) +
    geom_line(size=1.1) + geom_point(size=2.6,color="black")+ ylab("Chao 2") +
    ggtitle("Chao 2 of low-shade farms in Puerto Rico 2013") + theme_bw() +
   theme(
    panel.background = element_blank(),
  panel.grid.major = element_blank(),
    panel.grid.minor = element_blank())+
geom_ribbon(aes(ymin=chao.2.lb.lspr, ymax=chao.2.ub.lspr), alpha=0.2, color = "blue") +
  geom_line(aes(x=lspr.s, y= lspr.sest,group=1), colour="red")+
  geom_point(aes(x=lspr.s,y= lspr.sest, group=1), colour="red",size = 2.5)

No comments:

Post a Comment