Skip to content

Check correctness GAM output #52

@damianooldoni

Description

@damianooldoni

I am writing unit-tests for the in-development function apply_gam, based on function defined in modelling pipeline, which on its turn has been developed from a function of @ToonVanDaele.

@ToonVanDaele: could you please check basic GAM of this dummy data, please?

# dummy data
df_gam <- data.frame(
  taxonKey = rep(2224970, 19),
  canonicalName = rep("Palaemon macrodactylus", 19),
  year = seq(2001, 2019),
  n_observations = c(1, 5, 8, 12, 18, 23, 30, 40, 60, 40, 20, 10, 1, 
                     3, 10, 20, 35, 50, 80),
  stringsAsFactors = FALSE
)

# define evaluation year(s)
evaluation_year <- 2018

# apply function without any baseline correction
basic_gam <- apply_gam(df = df_gam,
                       y_var = "n_observations",
                       eval_years = evaluation_year)

I get these values for the minimal guaranteed growth, i.e. model$family$linkinv(lower):

> basic_gam$output$growth
 [1] 1.7777714 1.6977409 1.6088981 1.4940603 1.3330764 1.1393911 0.9689625 0.8451249
 [9] 0.7635014 0.7126579 0.6854127 0.6902043 0.7421756 0.8565297 1.0434188 1.2814552
[17] 1.5424851 1.8369261 2.1775717

which I find strange if we see the output graph:
image

I would expect a negative first derivative when not emerging (green dots) and a negative lower CI value of it as well. @ToonVanDaele : what do you think about? Do you find it strange as well?
If yes, could you please check results using your code?
If no, could you explain me why is it not strange?

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions