2

Being a relatively newby on gamlss I am likely missing something. I'm trying to model some growth charts and have evaluated different options and find (by plotting, GAIC evaluation and hyper paramater optimisation) that the following model provides the best fit:

mod_fp_poly2_gg <- gamlss(value~fp(age,npoly = 2),sigma.formula = ~fp(age,npoly = 2), family = GG, data = data)

Now given that this is a growth chart I would like to be able to compute a z-score for any new data-point I am given, so I try this:

newdata <- data.frame(age = 1000, value = 600000, group = "new")
predictAll(mod_fp_gg2, newdata = newdata)
# as well as
centiles.pred(mod_fp_bct, xname = "age", xvalues = 1000, yval = 600000, type="z-scores")

both of these give the same error which seems related to the fact that this isn't a 'simple' lm fit

Error in lm.wfit(X[onlydata, , drop = FALSE], y, w) : incompatible dimensions

Is there a way to extract z-scores (or centiles for that matter) from new data with the given model?

lovalery
  • 4,524
  • 3
  • 14
  • 28
Richard
  • 21
  • 2
  • Please provide data to reproduce your `mod_fp_poly2_gg`; read https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610 – jay.sf Apr 29 '20 at 08:12
  • I came across the same problem when using `gamlss`, and I fixed it by adding both arguments `data = data`(original data used to fit the model) and `newdata = newdata` (new data to predict) in the function `centiles.pred()`. I looked at the source code of the function, somehow you need to specify the old data in the function. – Xiang Dec 24 '21 at 01:11
  • @lovalery Again, please stop abusing the quote environment for error messages. All line breaks will be lost and they generally make the message much harder to read because it uses the wrong font family. – samcarter_is_at_topanswers.xyz Jan 12 '22 at 00:30
  • @samcarter_is_at_topanswers.xyz, thank you for your feedback and sorry again. O.K. I won't use quotes anymore. I thought it was clearer to use them. And, in this particular case, it didn't seem to me that it changed the line breaks. Cheers. – lovalery Jan 12 '22 at 12:21

0 Answers0