rfunctiongamlss

R gamlss::predict.gamlss not an exported object from 'namespace:gamlss'


I am experiencing some confusing behavior from gamlss in R. The documentation lists predict.gamlss and ?predict.gamlss returns the function documentation in RStudio. However, the function does not autocomplete when typing out predict.gamlss, and trying to run it returns Error: 'predict.gamlss' is not an exported object from 'namespace:gamlss'. How does that happen? Is the function deactivated somehow? There is a separate function predictAll that does work.

The documentation does state

This function is under development

I am trying to access the function because I am experiencing some confusing results with predict and predictAll.

R version is 4.0.0. gamlss version is 5.1.6.


Solution

  • As far as I can tell, what you describe is expected and is normal S3 method dispatching. The method predict.gamlss is called when you call predict on a object of class gamlss.

    Consider the following (from the documentation of ?predict.gamlss)

    data(abdom)
    aa <- gamlss(y ~ cs(x^.5), data = abdom)
    #[1] 371.3931
    predict(aa)[610]
    

    Looking at the class of aa:

    class(aa)
    #[1] "gamlss" "gam"    "glm"    "lm"   
    

    The function is not exported, but the S3 method is registered.

    As to the difference between predictAll and predict.gamlss, you'll have to read the documentation (the two are documented together). My guess is that predictAll predict all listed in the what-argument of predict.gamlss.