Reputation: 756
I'd like to store the result of the boxtidwell in order to write some code to achieve automation and avoid manually transform the variables. See example below:
>boxTidwell(prestige ~ income + education, ~ type + poly(women, 2), data = Prestige)
## Score Statistic p-value MLE of lambda
## income -4.482406 0.0000074 -0.3476283
## education 0.216991 0.8282154 1.2538274
## iterations = 8
Because I do not want to transform the variable manually such as the code below:
>Prestige$income <- (Prestige$income )^(-0.3476283)
When there are many variables need to be transformed then it will be so time-consuming. I tried matrix and data.frame but both in vain.
> box<-boxTidwell(prestige ~ income + education, ~ type + poly(women, 2), data = Prestige)
> box<-as.data.frame(box)
#Error in as.data.frame.default(box) :
#cannot coerce class ""boxTidwell"" to a data.frame
> box<-as.matrix(box)
> box
#Error in round(x$result, digits) :
#non-numeric argument to mathematical function
I've searched for a while but seems in vain, many thanks for any suggestions and ideas in advance.
Upvotes: 0
Views: 93
Reputation: 406
It's accessible in box$result
, e.g.
box$result[,"MLE of lambda"]
income education
-0.3476283 1.2538274
so your code above becomes (crudely)
Prestige$income <- (Prestige$income )^box$result[1,3]
In general, to check out what's inside your object use str
Upvotes: 1