Skip to content

why delete.response?

3 messages · Saket Joshi, Thomas Lumley, Brian Ripley

#
Hi all,

I am running R1.5.0 under unix.

I recently used the function 'predict.tree' to make predictions with a
tree object and a dataframe of numeric items. The predict.tree internally,
calls a function 'delete.response'.

When I removed this function call from the source code of predict.tree, it
ran 10 times faster without any differences in the result obtained.
The documentation for delete.response says that this function is used for
deleting the response variable from the dataset. However the documentation
for the predict.tree function says that the response variable is ignored
during prediction.

Could someone tell me why the function 'predict.tree' calls
'delete.response'?

Thanks in advance,
-Saket.



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Fri, 23 Aug 2002, Saket Joshi wrote:

            
In order to ignore the response.

If you remove the call to delete.response() you will not be able to
predict on a new data set that does not have the response variable
defined. Eg, following example(predict.tree)
     data(shuttle, package="MASS")
     shuttle.tr <- tree(use ~ ., shuttle, subset=1:253,
                        mindev=1e-6, minsize=2)
     shuttle.tr
     shuttle1 <- shuttle[254:256, ]  # 3 missing cases
     predict(shuttle.tr, shuttle1)

     shuttle2<-shutlle1[,-7]  #drop response variable
     ## this doesn't work in your version
     predict(shuttle.tr, shuttle2)


It's very surprising that delete.response is that slow. I haven't seen it
take more than a few hundredths of a second

	-thomas

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Fri, 23 Aug 2002, Saket Joshi wrote:

            
To make prediction possible without having the response variable in
`newdata'.

Your description of `delete.response' is incorrect: see its help page.