Weird power law fit

I have a very simple and small dataset (see attached) for which I want to fit a power law. The model runs through without any errors, everything seems to look fine but the model fit itself. It does not at all fit the data. I think the error has to do with the scales of x and y since for another dataset, the same call works just fine and produces good results.

prior1 <- c(set_prior('normal(0, 5)', nlpar = "a"),
            set_prior('normal(1, 0.5)', nlpar = "b", lb = 0))


fit_test <-
  brm(
    bf(
      median_rating ~ a * num_saturation100 ^ b ,
      a + b ~ 1,
      nl = TRUE
    ),
    data = df_test,
    save_all_pars = T,
    sample_prior = 'yes',
    warmup = 2000,
    iter = 7000,
    cores = 4,
    control = list(adapt_delta = 0.96, max_treedepth = 15),
    prior = prior1,
  )

plot(conditional_effects(fit_test![test_plot|375x292](upload://wBIxzkh8lsFKEz6i8vSlz0tNlsT.jpeg) ), points = TRUE)

  • Operating System: macOs Mojave
  • brms Version: brms_2.12.0

Thanks in advance for your help!

test_dataset.csv (112 Bytes)
test_plot

1 Like

I would think that their is some problem in what the scale of the variables imply to the scale of the parameters. So how does a and b need to look like to match the curve for these variables? As usual, I would recommend changing the scale of both variables to roughly unity, but I guess you know this potential answer already.

1 Like

Hi Paul, thanks. I solved it by transforming the y-values. When I divided by 100, everything worked as expected.