3

My y variable (n=30,000) is distributed with very heavy tails (both positive and negative), for which the fitDist GAMLSS function selects the ST4 family.

I tried to assess a GAMLSS-based regression with an explanatory variable x (pb smoothing), but tails on y are so heavy that convergence does not reach after 50 cycles, even after refit (time consuming+++).

Therefore, I normalized y using the orderNorm transformation (bestNormalize package), which allowed to easily and quickly reach convergence, and then to predict the fitted value from the GAMLSS object.

However, these fitted "orderNormalized" values are a GAMLSS object, and thus cannot be inversed using the predict function from bestNormalize (since this latter seems to not recognize a GAMLSS object).

My question: is it possible, whatever the means, to apply an inverse orderNorm transformation to fitted values from a GAMLSS object?

caxapexac
  • 781
  • 9
  • 24
denis
  • 199
  • 1
  • 8
  • An example would be helpful. The answer posted below is not helpful in my opinion because no example is given in the question. – Brigitte Oct 29 '21 at 17:55

2 Answers2

2

It is easy to get confused about on what to use the predict function, so I list here the steps without code (as there is no example in the question):

1) transposeObj = orderNorm(data$outputvariable)
2) fitObj = gamlls(transposeObj$x.t ~., data)
3) pred   = predict(fitObj, type = 'response')
4) inversedpredictions = predict(transposeObj, newdata = pred, inverse = TRUE)

In plain text, you normalize your data, fit a model, make predictions with the fit, and then predict on the predictions with the normalization object obtained from orderNorm.

Brigitte
  • 813
  • 11
  • 23
  • Thank you Brigitte! The trick was the 'type', which is set by default to 'link' (see 'predict.gamlss' function from the gamlss package) but that we had to set to 'response'. – denis Dec 07 '21 at 21:32
0

The vignette for bestNormalize has a similar example, using lm instead of GAMLSS. See the application section of the vignette. Once you have run the normalization procedure, you should be able to repeat and invert the transformation with the predict function.

The key is storing a transformation object as an R object that can then be fed into the predict (or rather, the predict.bestNormalize) function.

petersonR
  • 49
  • 3