budyko_errbounds | R Documentation |
Generate errorbounds from a Budyko fit
budyko_errbounds(
fit = NULL,
res = 0.1,
hshift = FALSE,
dif = "nls",
data = NULL,
alpha = 0.05,
method = NULL
)
fit |
list dataframe object with names() method and entries "param" for parameter p, "err" for vertical fit error, and "hshift" for optional hshift value (default to zero) |
res |
numeric resolution of fit, defaults to 0.01 units |
hshift |
A boolean. T/F (default F), whether to test for horizontal shift. hs value must be defined in fit |
dif |
A string. One of the following: "nls" (default) "rsq" "mae". Determines whether to fit automatically with stats::nls, or manually, with best fit determined by either Pearson's R squared or Minimum Mean Absolute Error |
data |
list dataframe requiring the following two columns: "PET.P" for potential evapotranspiration divided by precipitation (units normalized, dimensionless), and "AET.P" for actual evapotranspiration divided by precipitation or one minus the runoff coefficient (Q/P) |
alpha |
numeric If using dif="nls", confidence value for bounds. Default to 0.05 (95% confidence) |
method |
A string. One of the following: Fu, Turc-Pike, Wang-Tang |
Given a "fit" dataframe object from budyko::budyko_fit, generate a dataframe of error bounds that can be fed to plot or ggplot2::ggplot. name (as in names()) of fit must be the method
library(ggplot2)
fitdata = budyko_errbounds(data=testdata,method="Fu")
blankBC+
geom_polygon(data=subset(fitdata,key!="fit"),aes(lty=key),
col=1,fill="transparent")+
geom_line(data=subset(fitdata,key=="fit"),aes(lty="fit"))+
scale_linetype_manual(values=c("fit"=1,"confidence"=2,"prediction"=3))+
geom_point(data=testdata)+
coord_cartesian(xlim=c(0,5),ylim=c(0,1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.