I have these values (negative and positive) and I want to determine the nonlinear relationship between variable and predictor using generalized additive models (GAMs).

df= data.frame(variable=c(-1.03391679,-1.324947736,-0.511549589,-0.890394361,-0.114783801,-0.607616663,-0.06972697,

My variable has an almost "normal" distribution


But also, descdist tells me that the distribution is lognormal (but I have negative values)

descdist(cc_A$value, discrete=FALSE, boot=500)

My question is: What family can I use in my GAM if I have positive and negative values (I can't use Poison, gamma or other), and it's almost normal (and I don't want to transform).

I'm dealing with quasi-likelihood, but I don't know if it's okay, and I don't know how I can specify the link "" and the variance "".

The model are:

df$date<-as.POSIXct(df$date,"%Y-%m-%d",tz = "UTC")
df$date <- as.integer(as.Date(df$date, format = "%Y-%m-%d"))

mod1 <- mgcv::gam(variable ~s(date, bs="cr", k=10), data = df, method = "REML")

mod2 <- mgcv::gam(variable ~s(date, bs="cr", k=10), data = df, 
                   family=quasi(link = "identity", variance = "constant"), method = "REML")
  • 1
    $\begingroup$ Welcome to CV, Pablo. Why do you care about the distribution of your regression variables ($y$ or $x$)? GAMs will estimate relationships between both transformed and untransformed variables. Which (transformed or untransformed) do you substantively care about? $\endgroup$ – Alexis Apr 4 at 17:32
  • 1
    $\begingroup$ Hi @Alexis, thank you. I really thought that GAMs in mgcv need to specify the distribution family. I thought it was necessary for the penalty. Please, if I'm wrong, could you share a paper or book (S. Wood 2017 I already read it) about this. $\endgroup$ – Pablo Apr 4 at 18:32
  • 1
    $\begingroup$ We are interested in the conditional distribution of Y not the marginal distribution; what that means is we are not interested in the distribution of the raw response data. To choose a family, and you aren't familiar with which family might be used historically with such data, consider the properties of the response; yours is continuous and both positive and negative, so the options are somewhat limited in mgcv; start with gaussian() and then go form there, checking diagnostics etc. but the scat() family for a scaled t distribution is also possible $\endgroup$ – Gavin Simpson Apr 4 at 19:23
  • $\begingroup$ There's also the shash() family for the sinh-arcsinh distribution. Other distributions would be available in other packages such as the GAMLSS package. $\endgroup$ – Gavin Simpson Apr 4 at 19:27
  • $\begingroup$ Hi @GavinSimpson , thank you for your comment. When you say "then go from there, checking diagnostics" do you mean, run the models with different families (gaussian, scat, ...) and then compare them using, e.g., AIC, Deviance explained or R^2? And Yes, my values are negative and positive because I am standardizing (value - average) to compare the magnitude of the change before a disturbance (the first 15 dates are control, the rest are post-disturbance) $\endgroup$ – Pablo Apr 4 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.