From 6204ace3ab517c510852a1b7f4be3ca10ecc22c0 Mon Sep 17 00:00:00 2001 From: SELoomis Date: Wed, 29 Jul 2020 14:47:58 -0400 Subject: [PATCH 1/2] More Elfgen edits --- .../Elfgen/Elfgen_Intake_Facility_Algorithm.R | 33 ++++++++----------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/HARP-2020/Elfgen/Elfgen_Intake_Facility_Algorithm.R b/HARP-2020/Elfgen/Elfgen_Intake_Facility_Algorithm.R index 8838bf1e..093b7732 100644 --- a/HARP-2020/Elfgen/Elfgen_Intake_Facility_Algorithm.R +++ b/HARP-2020/Elfgen/Elfgen_Intake_Facility_Algorithm.R @@ -86,22 +86,16 @@ elf <- elfgen("watershed.df" = watershed.df, #### Solving for confidence interval lines -xdat <- c(elf$plot$data$x_var) -ydat <- c(elf$plot$data$y_var) -data <- as.data.frame(elf$plot$data) uq <- elf$plot$plot_env$upper.quant upper.lm <- lm(y_var ~ log(x_var), data = uq) -predict <- as.data.frame(predict(upper.lm, newdata = data.frame(x_var = mean_intake), interval = 'confidence')) - -species_richness<-elf$stats$m*log(mean_intake)+elf$stats$b - -# Comparing predict to actual values -#fit<-as.numeric(predict$fit) -#species_richness<-elf$stats$m*log(mean_intake)+elf$stats$b -#percent_error<-((fit-species_richness)/species_richness)*100 +predict.df <- as.data.frame(predict(upper.lm, newdata = data.frame(x_var = mean_intake), interval = 'confidence')) +# this section is not necessarily needed - use as a check for percent error +# fit<-as.numeric(predict.df$fit) +# species_richness<-elf$stats$m*log(mean_intake)+elf$stats$b +# percent_error<-((fit-species_richness)/species_richness)*100 xmin <- min(uq$x_var) xmax <- max(uq$x_var) @@ -115,14 +109,14 @@ ymax1 <- yval2[3] # top right point, line 1 ymin2 <- yval1[3] # top left point, line 2 ymax2 <- yval2[2] # bottom right point, line 2 -m <- elf$stats$m -b <- elf$stats$b +m <- elf$stat$m +b <- elf$stat$b int <- m*log(mean_intake) + b # solving for mean_intake y-value -m1 <- (ymax1-ymin1)/(log(xmax)-log(xmin)) # line 1 +m1 <- (ymax1-ymin1)/(log(xmax)-log(xmin)) # slope and intercept of confidence interval line 1 b1 <- ymax1-(m1*log(xmax)) -m2 <- (ymax2-ymin2)/(log(xmax)-log(xmin)) # line 2 +m2 <- (ymax2-ymin2)/(log(xmax)-log(xmin)) # slope and intercept of confidence interval line 2 b2 <- ymax2 - (m2*log(xmax)) @@ -143,15 +137,14 @@ elf$plot + elf$stats$m <- m1 elf$stats$b <- b1 -percent_richness_change_bound1 <- richness_change(elf$stats, "pctchg" = flow_reduction_pct, "xval" = mean_intake) -abs_richness_change_bound1 <- richness_change(elf$stats, "pctchg" = flow_reduction_pct) +pct_richness_change_1 <- richness_change(elf$stats, "pctchg" = flow_reduction_pct, "xval" = mean_intake) +abs_richness_change_1 <- richness_change(elf$stats, "pctchg" = flow_reduction_pct) elf$stats$m <- m2 elf$stats$b <- b2 -percent_richness_change_bound2 <- richness_change(elf$stats, "pctchg" = flow_reduction_pct, "xval" = mean_intake) -abs_richness_change_bound2 <- richness_change(elf$stats, "pctchg" = flow_reduction_pct) - +pct_richness_change_2 <- richness_change(elf$stats, "pctchg" = flow_reduction_pct, "xval" = mean_intake) +abs_richness_change_2 <- richness_change(elf$stats, "pctchg" = flow_reduction_pct) #### Saving From 8cfb557ae84ed67812c1ffa493c593f93ced572e Mon Sep 17 00:00:00 2001 From: SELoomis Date: Wed, 29 Jul 2020 14:55:46 -0400 Subject: [PATCH 2/2] Elfgen edits - typos --- HARP-2020/Elfgen/Elfgen_Intake_Facility_Algorithm.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HARP-2020/Elfgen/Elfgen_Intake_Facility_Algorithm.R b/HARP-2020/Elfgen/Elfgen_Intake_Facility_Algorithm.R index 093b7732..1d70f1a9 100644 --- a/HARP-2020/Elfgen/Elfgen_Intake_Facility_Algorithm.R +++ b/HARP-2020/Elfgen/Elfgen_Intake_Facility_Algorithm.R @@ -109,8 +109,8 @@ ymax1 <- yval2[3] # top right point, line 1 ymin2 <- yval1[3] # top left point, line 2 ymax2 <- yval2[2] # bottom right point, line 2 -m <- elf$stat$m -b <- elf$stat$b +m <- elf$stats$m +b <- elf$stats$b int <- m*log(mean_intake) + b # solving for mean_intake y-value m1 <- (ymax1-ymin1)/(log(xmax)-log(xmin)) # slope and intercept of confidence interval line 1