If I use linear model, generalized linear model, partial least squares etc packages in R, and train it where, given key response variable RSP, the formula argument is of the form:

formula <- as.formula("f(RSP)~A + B + C") # use A,B,C predictors only


formula <- as.formula("f(RSP)~.") # use ALL predictors

and f(RSP) is some transformation function, such that:

f <- function(x){...}

when I then predict after training, would the returned prediction set need to have the anti-function applied? If P <- predict(...) is P of the form RSP or f(RSP), such that the true prediction: Pt, - needs to have the antifunction g(P) applied?


1 Answer 1


If you want to do this for general f then I guess you'll want to write yourself a family object and hand that to glm.

There are examples in the help page for family. See in particular the parameterised logexp function, which makes a fancy parameterised link function which is added to a more traditional distribution assumption and then handed to glm. I'm guessing that's your case. This will, as you suspect, require both f and its inverse function, plus some other stuff.

Once that's in place, predict(model, newdata=blah, type='response') should (although I admit I have not checked) give you the expected response, and you'll get the linear predictor by leaving out type, as is R's odd default behaviour.

I'm a bit unclear on the potential statistical consequences of doing this, i.e. the effect on Deviance computations etc. so perhaps others will dive in. But that seems to be the 'computational' answer.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.