Structural Distributions

VOR distribution

VOR <- veg.s.stack %>%
  filter(substr(response, 1,1) == "V")

VORndist <- tibble(
                  response = "VOR", 
                  dist = "normal",
                  X = seq(0, 10, 0.025),
                  value = dnorm(X, mean = MASS::fitdistr(VOR$value, "normal")$estimate [[1]], 
                                sd = MASS::fitdistr(VOR$value, "normal")$estimate [[2]]))

VORgdist <- tibble(
                  response = "VOR", 
                  dist = "gamma",
                  X = seq(0, 10, 0.025),
                  value = dgamma(X, shape = MASS::fitdistr(VOR$value, "Gamma")$estimate [[1]], 
                                 rate = MASS::fitdistr(VOR$value, "Gamma")$estimate [[2]]))

VORdist <- rbind(VORndist, VORgdist)

VORdist.gg <- 
  VOR %>%
  ggplot(aes(x=value)) + theme_bw() + 
  geom_histogram(aes(y=..density..),      
                 binwidth=.5,
                 colour="black", fill="lightgreen") +
  geom_density(alpha=.2, fill="#FF6666")+
  geom_line(data=VORdist, 
            aes(x = X, y = value, color = dist))

VORdist.gg

#vor is gamma dist

litter distribution

Litter <- veg.s.stack %>%
  filter(substr(response, 1,1) == "C")

litndist <- tibble(
                  response = "Litter",
                  dist = "normal",
                  X = seq(0, 40, 0.1),
                  value = dnorm(X, mean = MASS::fitdistr(Litter$value, "normal")$estimate [[1]],
                                sd = MASS::fitdistr(Litter$value, "normal")$estimate [[2]]))

litgdist <- tibble(
                  response = "Litter", 
                  dist = "gamma", 
                  X = seq(0, 40, 0.1),
                  value = dgamma(X, shape = MASS::fitdistr(Litter$value, "Gamma")$estimate [[1]], 
                                 rate = MASS::fitdistr(Litter$value, "Gamma")$estimate [[2]]))

litdist <-rbind(litndist, litgdist)

Litdist.gg <- 
  Litter %>%
  ggplot(aes(x=value)) + theme_bw() + 
  geom_histogram(aes(y=..density..),      
                 binwidth=1.5,
                 colour="black", fill="lightgreen") +
  geom_density(alpha=.2, fill="#FF6666")+
  geom_line(data=litdist, 
            aes(x = X, y = value, color = dist))

Litdist.gg

#litter is gamma dist

Compositional Distributions

write.csv(veg.c.stack, file="./veg.c.stack.csv", row.names = FALSE)

veg.c.stack <- read.csv("./veg.c.stack.csv")

POPR distribution

POPR <- veg.c.stack %>%
  filter(substr(response, 1,1) == "K")

POPRndist <- tibble(
  response = "Kentucky bluegrass",
  dist = "normal",
  X = seq(0, 70, 0.1),
  value = dnorm(X, mean = MASS::fitdistr(POPR$value, "normal")$estimate [[1]],
                sd = MASS::fitdistr(POPR$value, "normal")$estimate [[2]]))

POPRgdist <- tibble(
  response = "Kentucky bluegrass", 
  dist = "gamma", 
  X = seq(0, 70, 0.1),
  value = dgamma(X, shape = MASS::fitdistr(POPR$value, "Gamma")$estimate [[1]], 
                 rate = MASS::fitdistr(POPR$value, "Gamma")$estimate [[2]]))

POPRdist <-rbind(POPRndist, POPRgdist)

POPRdist.gg <- 
  POPR %>%
  ggplot(aes(x=value)) + theme_bw() + 
  geom_histogram(aes(y=..density..),      
                 binwidth=1.5,
                 colour="black", fill="lightgreen") +
  geom_density(alpha=.2, fill="#FF6666")+
  geom_line(data=POPRdist, 
            aes(x = X, y = value, color = dist))

POPRdist.gg

#popr is normal

BRIN dist

BRIN <- veg.c.stack %>%
  filter(substr(response, 1,2) == "sm")
  BRIN$value <- BRIN$value + 0.3
 
BRINndist <- tibble(
  response = "smooth brome",
  dist = "normal",
  X = seq(0, 70, 0.1),
  value = dnorm(X, mean = MASS::fitdistr(BRIN$value, "normal")$estimate [[1]],
                sd = MASS::fitdistr(BRIN$value, "normal")$estimate [[2]]))

BRINgdist <- tibble(
  response = "smooth brome", 
  dist = "gamma", 
  X = seq(0, 70, 0.1),
  value = dgamma(X, shape = MASS::fitdistr(BRIN$value, "Gamma")$estimate [[1]], 
                 rate = MASS::fitdistr(BRIN$value, "Gamma")$estimate [[2]]))

BRINdist <-rbind(BRINndist, BRINgdist)

BRINdist.gg <- 
  BRIN %>%
  ggplot(aes(x=value)) + theme_bw() + 
  geom_histogram(aes(y=..density..),      
                 binwidth=1.5,
                 colour="black", fill="lightgreen") +
  geom_density(alpha=.2, fill="#FF6666")+
  geom_line(data=BRINdist, 
            aes(x = X, y = value, color = dist))

BRINdist.gg

#BRIN is gamma

NatC3 dist

NatC3 <- veg.c.stack %>%
  filter(response == "native C3")
NatC3$value <- NatC3$value + 0.7

NatC3ndist <- tibble(
  response = "native C3",
  dist = "normal",
  X = seq(0, 70, 0.1),
  value = dnorm(X, mean = MASS::fitdistr(NatC3$value, "normal")$estimate [[1]],
                sd = MASS::fitdistr(NatC3$value, "normal")$estimate [[2]]))

NatC3gdist <- tibble(
  response = "native C3", 
  dist = "gamma", 
  X = seq(0, 70, 0.1),
  value = dgamma(X, shape = MASS::fitdistr(NatC3$value, "Gamma")$estimate [[1]], 
                 rate = MASS::fitdistr(NatC3$value, "Gamma")$estimate [[2]]))

NatC3dist <-rbind(NatC3ndist, NatC3gdist)

NatC3dist.gg <- 
  NatC3 %>%
  ggplot(aes(x=value)) + theme_bw() + 
  geom_histogram(aes(y=..density..),      
                 binwidth=1.5,
                 colour="black", fill="lightgreen") +
  geom_density(alpha=.2, fill="#FF6666")+
  geom_line(data=NatC3dist, 
            aes(x = X, y = value, color = dist))

NatC3dist.gg

# natC3 is gamma

natC4 dist

NatC4 <- veg.c.stack %>%
  filter(response == "native C4")
NatC4$value <- NatC4$value + 0.7

NatC4ndist <- tibble(
  response = "native C4",
  dist = "normal",
  X = seq(0,28, 0.1),
  value = dnorm(X, mean = MASS::fitdistr(NatC4$value, "normal")$estimate [[1]],
                sd = MASS::fitdistr(NatC4$value, "normal")$estimate [[2]]))

NatC4gdist <- tibble(
  response = "native C4", 
  dist = "gamma", 
  X = seq(0, 28, 0.1),
  value = dgamma(X, shape = MASS::fitdistr(NatC4$value, "Gamma")$estimate [[1]], 
                 rate = MASS::fitdistr(NatC4$value, "Gamma")$estimate [[2]]))

NatC4dist <-rbind(NatC4ndist, NatC4gdist)

NatC4dist.gg <- 
  NatC4 %>%
  ggplot(aes(x=value)) + theme_bw() + 
  geom_histogram(aes(y=..density..),      
                 binwidth=1.5,
                 colour="black", fill="lightgreen") +
  geom_density(alpha=.2, fill="#FF6666")+
  geom_line(data=NatC4dist, 
            aes(x = X, y = value, color = dist))

NatC4dist.gg

#natC4 is gamma

NatLeg dist

NatLeg <- veg.c.stack %>%
  filter(response == "native legume")
NatLeg$value <- NatLeg$value + 0.5

NatLegndist <- tibble(
  response = "native legume",
  dist = "normal",
  X = seq(0,28, 0.1),
  value = dnorm(X, mean = MASS::fitdistr(NatLeg$value, "normal")$estimate [[1]],
                sd = MASS::fitdistr(NatLeg$value, "normal")$estimate [[2]]))

NatLeggdist <- tibble(
  response = "native legume", 
  dist = "gamma", 
  X = seq(0, 28, 0.1),
  value = dgamma(X, shape = MASS::fitdistr(NatLeg$value, "Gamma")$estimate [[1]], 
                 rate = MASS::fitdistr(NatLeg$value, "Gamma")$estimate [[2]]))

NatLegdist <-rbind(NatLegndist, NatLeggdist)

NatLegdist.gg <- 
  NatLeg %>%
  ggplot(aes(x=value)) + theme_bw() + 
  geom_histogram(aes(y=..density..),      
                 binwidth=1.5,
                 colour="black", fill="lightgreen") +
  geom_density(alpha=.2, fill="#FF6666")+
  geom_line(data=NatLegdist, 
            aes(x = X, y = value, color = dist))

NatLegdist.gg

#natleg is gamma

intleg dist

IntLeg <- veg.c.stack %>%
  filter(response == "introduced legume")
IntLeg$value <- IntLeg$value + 0.5

IntLegndist <- tibble(
  response = "introduced legume",
  dist = "normal",
  X = seq(0,28, 0.1),
  value = dnorm(X, mean = MASS::fitdistr(IntLeg$value, "normal")$estimate [[1]],
                sd = MASS::fitdistr(IntLeg$value, "normal")$estimate [[2]]))

IntLeggdist <- tibble(
  response = "introduced legume", 
  dist = "gamma", 
  X = seq(0, 28, 0.1),
  value = dgamma(X, shape = MASS::fitdistr(IntLeg$value, "Gamma")$estimate [[1]], 
                 rate = MASS::fitdistr(IntLeg$value, "Gamma")$estimate [[2]]))

IntLegdist <-rbind(IntLegndist, IntLeggdist)

IntLegdist.gg <- 
  IntLeg %>%
  ggplot(aes(x=value)) + theme_bw() + 
  geom_histogram(aes(y=..density..),      
                 binwidth=1.5,
                 colour="black", fill="lightgreen") +
  geom_density(alpha=.2, fill="#FF6666")+
  geom_line(data=IntLegdist, 
            aes(x = X, y = value, color = dist))

IntLegdist.gg

#intleg is gamma

NatFrb dist

NatFrb <- veg.c.stack %>%
  filter(response == "native forb")
NatFrb$value <- NatFrb$value + 0.5


NatFrbndist <- tibble(
  response = "native forb",
  dist = "normal",
  X = seq(0,50, 0.1),
  value = dnorm(X, mean = MASS::fitdistr(NatFrb$value, "normal")$estimate [[1]],
                sd = MASS::fitdistr(NatFrb$value, "normal")$estimate [[2]]))

NatFrbgdist <- tibble(
  response = "native forb", 
  dist = "gamma", 
  X = seq(0, 50, 0.1),
  value = dgamma(X, shape = MASS::fitdistr(NatFrb$value, "Gamma")$estimate [[1]], 
                 rate = MASS::fitdistr(NatFrb$value, "Gamma")$estimate [[2]]))

NatFrbdist <-rbind(NatFrbndist, NatFrbgdist)

NatFrbdist.gg <- 
  NatFrb %>%
  ggplot(aes(x=value)) + theme_bw() + 
  geom_histogram(aes(y=..density..),      
                 binwidth=1.5,
                 colour="black", fill="lightgreen") +
  geom_density(alpha=.2, fill="#FF6666")+
  geom_line(data=NatFrbdist, 
            aes(x = X, y = value, color = dist))

NatFrbdist.gg

#natfrb is normal

intfrb dist

IntFrb <- veg.c.stack %>%
  filter(response == "introduced forb")
IntFrb$value <- IntFrb$value + 0.5

IntFrbndist <- tibble(
  response = "introduced forb",
  dist = "normal",
  X = seq(0,20, 0.1),
  value = dnorm(X, mean = MASS::fitdistr(IntFrb$value, "normal")$estimate [[1]],
                sd = MASS::fitdistr(IntFrb$value, "normal")$estimate [[2]]))

IntFrbgdist <- tibble(
  response = "introduced forb", 
  dist = "gamma", 
  X = seq(0, 20, 0.1),
  value = dgamma(X, shape = MASS::fitdistr(IntFrb$value, "Gamma")$estimate [[1]], 
                 rate = MASS::fitdistr(IntFrb$value, "Gamma")$estimate [[2]]))

IntFrbdist <-rbind(IntFrbndist, IntFrbgdist)

IntFrbdist.gg <- 
  IntFrb %>%
  ggplot(aes(x=value+0.5)) + theme_bw() + 
  geom_histogram(aes(y=..density..),      
                 binwidth=1,
                 colour="black", fill="lightgreen") +
  geom_density(alpha=.2, fill="#FF6666")+
  geom_line(data=IntFrbdist, 
            aes(x = X, y = value, color = dist))

IntFrbdist.gg

natwdy dist

NatWdy <- veg.c.stack %>%
  filter(response == "native woody")
NatWdy$value <- NatWdy$value + 0.5



NatWdyndist <- tibble(
  response = "native woody",
  dist = "normal",
  X = seq(0,30, 0.1),
  value = dnorm(X, mean = MASS::fitdistr(NatWdy$value, "normal")$estimate [[1]],
                sd = MASS::fitdistr(NatWdy$value, "normal")$estimate [[2]]))

NatWdygdist <- tibble(
  response = "native woody", 
  dist = "gamma", 
  X = seq(0, 30, 0.1),
  value = dgamma(X, shape = MASS::fitdistr(NatWdy$value, "Gamma")$estimate [[1]], 
                 rate = MASS::fitdistr(NatWdy$value, "Gamma")$estimate [[2]]))

NatWdydist <-rbind(NatWdyndist, NatWdygdist)

NatWdydist.gg <- 
  NatWdy %>%
  ggplot(aes(x=value)) + theme_bw() + 
  geom_histogram(aes(y=..density..),      
                 binwidth=1.5,
                 colour="black", fill="lightgreen") +
  geom_density(alpha=.2, fill="#FF6666")+
  geom_line(data=NatWdydist, 
            aes(x = X, y = value, color = dist))

NatWdydist.gg

#natwdy is normal