Extracting best Lambda for Box Cox transformation

How can i extract the best lambda for boxcox transformation of data?
For the moment, i am using the below code:
best.lamb_1 <-bc.model.lantana_1$x(which(bc.model.lantana_1=max(bc.model.lantana_1$y)))
Error: attempt to apply non-function

Thank you.

You haven't provided any details, but almost surely bc.model.lantana_1$x is a variable, and is not callable. With a variable u, you cannot do u(...), that's possible with functions only. Since your objective is to index it, use [...] instead of (...). That's what giving you this specific error.

Also, note that there's a function which.max. It'll give you only one index, but most probably you're not looking for more than one in this situation.

Try something like this:

bc.model.lantana_1$x[which.max(bc.model.lantana_1$y)]

(To save typing, you can try with)

Hope this helps.

1 Like

Thanks alot.
The code works well.
NM

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.