# Use coefficient of variation as weight in GAM

Is it possible or reasonable to use the coefficient of variation in a GAM / GLM as a weight to incorporate uncertainty into a response variable?

I've got density estimates that have a CV value and need to model while taking into account the observation error.

If I understand correctly then yes you can. Though whether you can in practice and how you do this will depend on the software implementation you wish to use. For example:

In R's glm() and mgcv::gam() there is a weights argument. ?glm says

Non-NULL weights can be used to indicate that different observations have different dispersions (with the values in weights being inversely proportional to the dispersions); or equivalently, when the elements of weights are positive integers w_i, that each response y_i is the mean of w_i unit-weight observations.

From that description, I think you would need to use weights = 1/CV to get the desired effect.

• Thanks - yes, this is what I ended up interpreting as well. However, I had to normalize the weights (weights = weights/mean(weights) ) to get it to work. Not 100% sure why, but otherwise it just didn't work properly. Apr 21 '17 at 9:11
• I've seen that happen too in one case, but not with others data sets. I think what might be happening is the likelihood is being swamped by the weights and that's leading the model to be erroneously estimated with very low error &mdash; in the one example where it didn't work well confidence bands on smooth went to almost zero. Apr 21 '17 at 15:18