R/sample_per_decrease.R
sample_per_decrease.Rd
A Function to Sample the Annual Percentage Decrease with Uncertainty
sample_per_decrease(df, max_year = NULL, min_year = NULL, samples = 100, years_to_avg = 3)
df | A dataframe containing a year variable and with the second variable being the one to sample from. |
---|---|
max_year | Numeric, set as greater than the maximum year in the dataframe if interested in projection.
Defaults to |
min_year | Numeric, set as smaller than the minimum year in the dataframe if interested in backwards projection.
Defaults to |
samples | Numeric, the number of samples to take. |
years_to_avg | Numeric, the number of years over which to average the percentage decrease when estimating the ongoing percentage decrease. |
A dataframe containing annual percentage decrease samples.
df <- data.frame(year = c(2000:2010), measure = seq(10, 110, 10)) sample_per_decrease(df, samples = 2)#> year sample prop_decrease_sample #> 1 2001 1 -0.91639928 #> 2 2001 2 -0.98043991 #> 3 2002 1 -0.49002278 #> 4 2002 2 -0.56266488 #> 5 2003 1 -0.35892570 #> 6 2003 2 -0.35503676 #> 7 2004 1 -0.29527794 #> 8 2004 2 -0.22419860 #> 9 2005 1 -0.22118227 #> 10 2005 2 -0.25581355 #> 11 2006 1 -0.10238774 #> 12 2006 2 -0.13276572 #> 13 2007 1 -0.16145445 #> 14 2007 2 -0.15543653 #> 15 2008 1 -0.15623216 #> 16 2008 2 -0.08207690 #> 17 2009 1 -0.07652777 #> 18 2009 2 -0.14024365 #> 19 2010 1 -0.12074288 #> 20 2010 2 -0.14937032