Question

I'm using the function step to perform a backward selection.

library(MASS)
full.m <- lm(fmla, data=mean.mydata)
back.m <- step(full.m, direction = "backward", trace = 1)

This method is then used to calculate a data transformation,

# Best transformation
bc <- boxcox(back.m)
lambda <- bc$x[which.max(bc$y)]

Now I would like to create the new formula with lambda and the selected variables,

lambda.fmla <- as.formula(paste("I(mass^lambda) ~ ", paste(variables, collapse= "+")))

Any ideas? I've looked in the back.m object but so far I could not find out.

Was it helpful?

Solution

Well, I figured it out.

I just have to pass the object as argument.

lambda.fmla <- as.formula(object=back.m)

and then change the matrix with the lambda.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top