4545# ' fund members over the previous 5 years and 7.9\% growth over the
4646# ' previous ten years.
4747# '
48+ # ' @param r_generic (Present from version 2024.1.0) The factor to inflate other
49+ # ' columns. Subject to change in future versions. If \code{NULL}, the default,
50+ # ' an internal factor is used.
51+ # '
4852# '
4953# ' @return A sample file with the same number of rows as \code{sample_file} but
5054# ' with inflated values as a forecast for the sample file in \code{to_fy}.
@@ -86,7 +90,7 @@ project <- function(sample_file,
8690 check_fy_sample_file = TRUE ,
8791 differentially_uprate_Sw = NA ,
8892 r_super_balance = 1.05 ,
89- r_generic = 1 ) {
93+ r_generic = NULL ) {
9094 if (length(h ) != 1L ) {
9195 stop(" `h` had length-" , length(h ), " , " ,
9296 " but must be a length-1 positive integer." )
@@ -134,6 +138,8 @@ project <- function(sample_file,
134138 }
135139
136140
141+
142+
137143 if (check_fy_sample_file ) {
138144 # It's been a common error of mine to switch sample files
139145 # without updating the fy.year.of.sample.file
@@ -212,16 +218,32 @@ project <- function(sample_file,
212218 H <- h
213219 current.fy <- fy.year.of.sample.file
214220
215- to.fy <- yr2fy(fy2yr(current.fy ) + h )
221+ to.fy <- yr2fy(to.yr <- (fy2yr(current.fy ) + h ))
222+
223+
224+
216225
217226 if (is.null(wage.series )){
218- wage.inflator <- wage_inflator(from = current.fy , to = to.fy )
227+ wage.inflator <- wage_inflator(from = current.fy , to = to.fy ,
228+ series = grattanInflators :: wpi_original(FORECAST = TRUE ))
219229 } else {
220- wage.inflator <- wage_inflator(from = current.fy , to = to.fy )
230+ wage.inflator <- wage_inflator(from = current.fy , to = to.fy ,
231+ series = wage.series )
221232 }
222-
233+ dont_inflate_WEIGHT <- FALSE
223234 if (is.null(lf.series )) {
224- lf.inflator <- lf_inflator(from = current.fy , to = to.fy )
235+ n_taxpayers_2022_2034 <-
236+ c(16216182 , 16543257 , 16826686 , 17076658 , 17326098 , 17573757 ,
237+ 18006023 , 18438289 , 18870556 , 19144750 , 19409635 , 19669543 , 19917470 )
238+ if (to.yr %in% 2022 : 2034 ) {
239+ dont_inflate_WEIGHT <- TRUE
240+ WEIGHT <- NULL
241+ sample_file [, WEIGHT : = as.double(WEIGHT )]
242+ set(sample_file , j = " WEIGHT" , value = as.double(n_taxpayers_2022_2034 [to.yr - 2021 ] / nrow(sample_file )))
243+ } else {
244+ lf.inflator <- lf_inflator(from = current.fy , to = to.fy ,
245+ series = grattanInflators :: lfi_original(FORECAST = TRUE ))
246+ }
225247 } else {
226248 if (is.data.table(lf.series )) {
227249 stop(" lf.series should be a series as defined by lf_inflator." )
@@ -231,7 +253,14 @@ project <- function(sample_file,
231253 series = lf.series )
232254 }
233255
234- cpi.inflator <- cpi_inflator(from = current.fy , to = to.fy )
256+ cpi.inflator <- cpi_inflator(from = current.fy , to = to.fy ,
257+ series = grattanInflators :: cpi_seasonal(FORECAST = TRUE ))
258+
259+ if (is.null(r_generic )) {
260+ r_generic <- cpi.inflator
261+ } else if (! is.numeric(r_generic ) || length(r_generic ) != 1 || ! is.finite(r_generic )) {
262+ stop(" r_generic must be NULL or a length-one numeric." ) # nocov
263+ }
235264
236265 if (! is.logical(.recalculate.inflators )) {
237266 stop(" `.recalculate.inflators` was type " , typeof(.recalculate.inflators ), " , " ,
@@ -355,24 +384,24 @@ project <- function(sample_file,
355384 derived.cols ,
356385 Not.Inflated )]
357386
358- if (.recalculate.inflators ) {
359- generic.inflators <-
360- generic_inflator(vars = generic.cols ,
361- h = h ,
362- fy.year.of.sample.file = fy.year.of.sample.file ,
363- estimator = forecast.dots $ estimator ,
364- pred_interval = forecast.dots $ pred_interval )
365- } else {
366- generic.inflators <-
367- switch (current.fy ,
368- " 2012-13" = generic_inflators_1213 ,
369- " 2013-14" = generic_inflators_1314 ,
370- " 2014-15" = generic_inflators_1415 ,
371- " 2015-16" = generic_inflators_1516 ,
372- " 2016-17" = generic_inflators_1617 ,
373- stop(" Precalculated inflators only available when projecting from " ,
374- " 2012-13, 2013-14, 2014-15, 2015-16, and 2016-17." ))
375- }
387+ # if (.recalculate.inflators) {
388+ # generic.inflators <-
389+ # generic_inflator(vars = generic.cols,
390+ # h = h,
391+ # fy.year.of.sample.file = fy.year.of.sample.file,
392+ # estimator = forecast.dots$estimator,
393+ # pred_interval = forecast.dots$pred_interval)
394+ # } else {
395+ # generic.inflators <-
396+ # switch(current.fy,
397+ # "2012-13" = generic_inflators_1213,
398+ # "2013-14" = generic_inflators_1314,
399+ # "2014-15" = generic_inflators_1415,
400+ # "2015-16" = generic_inflators_1516,
401+ # "2016-17" = generic_inflators_1617,
402+ # stop("Precalculated inflators only available when projecting from ",
403+ # "2012-13, 2013-14, 2014-15, 2015-16, and 2016-17."))
404+ # }
376405
377406 # # Inflate:
378407
@@ -430,6 +459,9 @@ project <- function(sample_file,
430459 if (j %chin % Not.Inflated ) {
431460 next
432461 }
462+ if (j == " WEIGHT" && dont_inflate_WEIGHT ) {
463+ next
464+ }
433465 v <- .subset2(sample_file , j )
434466 v_new <-
435467 switch (inflator_switch(j ),
@@ -459,15 +491,16 @@ project <- function(sample_file,
459491 CG.inflator * v
460492 },
461493 " generic" = {
462- if (.recalculate.inflators ) {
463- if (nrow(generic.inflators )) {
464- generic.inflators [variable == j ]$ inflator * v
465- } else {
466- v
467- }
468- } else {
469- generic.inflators [.(H , j ), inflator ] * v
470- }
494+ r_generic * v
495+ # if (.recalculate.inflators) {
496+ # if (nrow(generic.inflators)) {
497+ # generic.inflators[variable == j]$inflator * v
498+ # } else {
499+ # v
500+ # }
501+ # } else {
502+ # generic.inflators[.(H, j), inflator] * v
503+ # }
471504 },
472505 " super" = {
473506 {r_super_balance ^ h } * v
0 commit comments