gadget-framework / gadget3

TMB-based gadget implemtation
GNU General Public License v2.0
8 stars 6 forks source link

Partial by_age / by_year ranges for g3_parameterized #100

Open lentinj opened 1 year ago

lentinj commented 1 year ago

From the desk of @bthe:

would it make sense to allow the user to specify the ranges for age and year in g3_parametrised, something akin to: g3_parametrised('apples', by_year = 1337:2203, by_age=TRUE)

It'd be incredibly easy to add, but I'm guessing that we'd quickly find hard-coding the years problematic, and what we really want is by_year = yes_but_not_the_first_two_years. This shouldn't be much harder, just needs a decent syntax. Something like by_year = c(skip_start = 2, skip_end=2) could work.

The implementation would (with crossed fingers) just need the values substituted into the expression generated here:

https://github.com/gadget-framework/gadget3/blob/f7585beda4e12d0e854c6abe4c7e315d62b20e61/R/params.R#L19-L21

lentinj commented 9 months ago

Also:

What happens if you would do by_year = c(1981, 1999:2004, 2010) ? It would be cool if this would be wrapped into:

if(year >= 1981 && year < 1999) 
par.1981
else if(year==1999)
par.1999
....
else if(year >=2004 && year < 2010)
par.2004
else
par.2010