I wonder how do u decide if family = gaussian() or family = cox.ph(link='identity') or family = binomial(link="logit") in GAM ( generalized additive model ) is suitable for the analysis? For my case, my dependent variable is in the form of percentage from 0 - 100%. Stage is a form of time variable. comparison_type is the two different activities performed by the same individual over a specific stage, which means time.

My end goal is to see if there is any significant difference in patterns between the two activities performed by the same individual over time.


b <- gam(ssim_exp ~ s(stage, k = 4, fx = TRUE, by = comparison_type) + comparison_type, data = df, family = cox.ph(link='identity'))

The distribution of my dependent variable looks like the below

enter image description here

Any input?


1 Answer 1


The choice of the conditional distribution of the response should be motivated by the features of the response variable you are modelling. The Gaussian distribution can be used for data that are continuous and over the whole real line (not integers and can be positive or negative), whereas the gamma, inverse Guassian, or Tweedie distributions are for positive (non-negative in the Tweedie case) continuous random variables. Distributions such as the Poisson or negative binomial are for non-negative, integer valued responses. Binomial is for counts from a total (number of heads out of m coin tosses, for example). The Cox PH family is for modelling survival data (time to event data), where you are interested in modelling the hazard of an event.

None of these distributions are suitable for the data you describe, which are bounded at some upper and lower value, but are continuous between the two bounds. If the data were recast to the interval 0-1, then you could look at the beta distribution (family = betar()) in {mgcv}, but you can't have true 0s and 1s (100%) in that family ({mgcv} will adjust the data so that the 0s are just slightly greater than 0, and the 1s slightly less than 1). If you have many such values, then zero-one-inflated beta models (which combine separate models for the 0s, 1s, and everything else) would be a starting point. But that distribution is not available in {mgcv}; you could look at {brms} for example as an option in that case.

I've taken you to have a continuous bounded value as the response, but there is some wiggle-room in your use of "form of"; if there is something specific you think we should know then edit your question to include it.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.