I'm trying to evaluate the residual normality for three objects: one lm() object, one nnet() and one randomForest(). For lm() using the code:
> qqnorm(rstudent(lmodel)); qqline(rstudent(lmodel))"
it worked fine. But for nnet() and RandomForest() I had no success:
> Error in UseMethod("rstudent") :
no applicable method for 'rstudent' applied to an object of class "nnet"
Does somebody have some suggestion to deal with this issue?
rstudent is a so called generic function, this means that rstudent will call a different function for different input objects. In computer science this is known as polymorphism, i.e. rstudent is a polymorphic function. For example, rstudent(lm()) will trigger the function rstudent.lm.
These specific implementation of the generic function need to be written for every object type the function supports, and are not automagically generated. The error you get indicates that there is no specific implementation of rstudent for the output of your neural net function, i.e. No rstudent.nnet.
The solution is to write this specific implementation yourself, or propose its implementation to the package maintainer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With