Hi,

I’m fitting a smooth, using stan_gamm4, to all positive data and have played around a fair bit with different data transformations and families. From my trials it seems like the Gamma family is best suited for my data unless I want to log transform the data and run it with the gaussian family (inverse.gaussian is a decent fit to untransformed data as well, but worse than Gamma and seems to take longer to fit). If I can avoid transformations then I would prefer that.

However, when I use plot_nonlinear function, the smooth from the Gamma model comes out upside down relative to the plot of the log transformed model smooth. Why is that and can it somehow be corrected? Does it have to do with the link function (1/mu^2) for Gamma?

I’ve uploaded some dummy/example data that works for demonstrating the issue

example.data.Rdata (8.0 KB)

.

```
example.gamma <- stan_gamm4(y ~ s(x, bs = 'ts'),
data = example.data, family = Gamma(),
warmup = 1000, iter = 3000, thin = 3, chains = 4, cores = 4,
adapt_delta = 0.99)
example.data$ylog <- log(example.data$y)
example.gaussian <- stan_gamm4(ylog ~ s(x, bs = 'ts'),
data = example.data, family = gaussian(),
warmup = 1000, iter = 3000, thin = 3, chains = 4, cores = 4,
adapt_delta = 0.99)
plot_nonlinear(example.gamma, smooths = 's(x)')
plot_nonlinear(example.gaussian, smooths = 's(x)')
```

Windows 10

rstanarm 2.32.1