Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extractPriors: Incorrect way of extracting hyperparameters values #65

Open
mgilgu opened this issue Jul 23, 2024 · 0 comments
Open

extractPriors: Incorrect way of extracting hyperparameters values #65

mgilgu opened this issue Jul 23, 2024 · 0 comments

Comments

@mgilgu
Copy link

mgilgu commented Jul 23, 2024

The extractPriors function does not extract the correct values of the model hyperparameters.

In this reproducible example, the function is not able to extract the correct value for the prior in the var_1 linear component:

# Create some dummy data
trainData <- data.frame(
         y <- sample(c(0, 1), size = 100, replace = TRUE),
         var_1 <- rnorm(100)
     )
  
  # Define model components
  components <- ~ Intercept(1) + 
        var_1(main = var_1, model = "linear", copy = NULL, mean.linear = 0, prec.linear = 0.05)
  
  # Fit the model
  model <- inlabru::bru(
    components,
    inlabru::like(
      family = "binomial", 
      data = trainData,
      formula = y ~ Intercept + var_1
    )
  )
  
  # Extract hyperparameter information
  priorParams <- INLAutils:::extractPriors(model)
  
  # Prior precision for var_1 component
  var_1_prec <- priorParams$prec[2]
  var_1_prec # 0.001 (it should be 0.05)

The model is correctly using the input information for the var_1 precision prior, as it is demonstrated with:

model$all.hyper$linear[[2]]$prior.prec # 0.05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant