Modelling data following a laplace distribution using a non-linear model

Hi,

I’m trying to fit the following non-linear function to estimate parameter y

laplace_function <- function(x, y) { exp(-y * abs(x) }

where x = seq(-0.9, 0.9, 0.01).

Simulated data is produced as follows:

library(ggplot2)
library(ggthemes)

cf <- function(x, y) { 1 * exp(-y * abs(x + 0.05)) }

# Simulate data
set.seed(1)
n_countries <- 5
n_y_per_country <- 10  # 10 recordings of y per country
x <- seq(-0.9, 0.9, by = 0.01)  # 181 x values
n_obs <- length(x)  # 181 rows per y

# Population-level parameters
mu_population <- 8  # Population-level mean of y
sigma_population <- 3   # Across-country SD

# Country-level parameters
mu_country <- rnorm(n_countries, mean = mu_population, sd = sigma_population)
mu_country
sigma_country <- 1  # Within-country SD for y

# Generate data
data_list <- lapply(1:n_countries, function(country) {
  # Generate y values for this country
  y_values <- rnorm(n_y_per_country, mean = mu_country[country], sd = sigma_country)
  
  # Generate b_obs for each y and x
  do.call(rbind, lapply(y_values, function(y) {
    b_obs <- cf(x, y)  # Deterministic relationship
    data.frame(
      x = x,
      b_obs = b_obs,
      y = y,
      country = factor(country)
    )
  }))
})

# Combine all data into one dataset
data <- do.call(rbind, data_list)

ggplot(data) + 
  geom_line(aes(x = x, y = b_obs, group = y)) +
  facet_wrap(~country) + 
  theme_clean()

laplace_function <- function(x, y) { exp(-y * abs(x) }

I’ve modified the function above so that the function is multiplied by 0.99 rather than 1. This is so I can fit a beta model, though I have issues fitting this model (pp_checks are poor).

This is also the case when I model as gaussian with trunc(lb = 0, ub = 1). This also has issues with convergence/pp_checks are poor.

laplace_function <- function(x, y) { 0.99 * exp(-y * abs(x) }
laplace_function <- function(x, y) { 1 * exp(-y * abs(x) }

bform <- bf(
  b_obs | trunc(lb = 0, ub = 1) ~ 0.99 * exp(-y * abs(x + 0.05)),
  y ~ 1 + (1|x) +  (1|country),
  nl = TRUE
)
fit <- brm(
  bform,
  data = data,
  family = gaussian(),
  chains = 4, cores = 4, backend = "cmdstanr", control = list(adapt_delta = 0.99, max_treedepth = 12))

Does anyone have any suggestions for how this data could be modelled? Particularly, suitable families; any modifications that can be done to aid fitting (while still allowing y to be estimated).

Thank you :)