1

I was wondering if it is possible to use frequency weights in an mgcv multinomial GAM fit (i.e. using weight=the count of that outcome, Freq below). E.g. for a dataset with 3 outcome levels for VARIANT I was hoping I could do

library(mgcv)
fit = gam(formula = list(VARIANT ~ te(longitude, latitude, k=c(10, 10), bs=c("cc", "cs")) + date,
                                 ~ te(longitude, latitude, k=c(10, 10), bs=c("cc", "cs")) + date,
                                 ~ te(longitude, latitude, k=c(10, 10), bs=c("cc", "cc")) + date),
           data=data, family=multinom(K=3), weight=Freq, method="REML")

(similar to how one can do this in nnet::multinom multinomial fits)

Unfortunately, it appears that using frequency weights like this is not supported right now in multinomial GAM fits, and that such fits expect the data to be recoded in the long data format. Due to the size of my dataset & the very large counts I have this would computationally be very inefficient though. Would anyone know what would be required in terms of changes in the codebase of the mgcv package to allow the use of frequency weights?

Tom Wenseleers
  • 7,535
  • 7
  • 63
  • 103

0 Answers0