[R] errorest: Error in cv.numeric()

Steffen Neumann sneumann at TechFak.Uni-Bielefeld.DE
Tue Jun 24 18:30:43 CEST 2003


Hi,

I am trying to get an error estimation 
for a classification done using lda.

The examples work fine, however I don't get 
my own code to work.

The data is in object d

	> d
	    class hydrophobicity    charge     geometry
	1       2      6490.0400 1434.9700    610.99902
	2       2      1602.0601  400.6030  -5824.00000
	3       2       969.0060  260.1360   -415.00000
	4       1       527.2310  158.7020    -22.00010
	...
	180     1       299.5190   85.9201   -680.00000
	181     2      1385.6801  298.8360   -353.00000
	182     1       428.8740  130.8020   -328.00000
	183     1       287.5540   98.0767     34.00000

Since predict.lda does not return simply the classification 
it is wrapped, as in the docs:

	mypredict.lda <- function(object, newdata) predict(object, newdata = newdata)$class

In trying errorest() I get the message

	> errorest(class ~ hydrophobicity + charge, data=d, model=lda, predict=mypredict.lda)
	Error in cv.numeric(y, formula, data, model = model, predict = predict,  : 
	        predict does not return numerical values

even though a "manual" lda seems to provide the correct types:

	> l <- lda(class ~ hydrophobicity + charge, data=d)
	> mypredict.lda(l,d)
	  [1] 2 2 1 1 2 2 1 2 1 2 2 1 2 1 1 2 1 1 2 1 1 2 2 1 2 1 1 2 1 1 1 1 1 2 1 1 1
	...
	[149] 1 2 1 1 1 1 1 1 2 1 2 1 2 1 1 1 1 2 1 2 2 2 1 2 1 1 1 1 1 1 1 1 1 1 1
	Levels: 1 2

	> typeof(mypredict.lda(l,d))
	[1] "integer"

So what did I miss, I am fairly new to programming in R/S,
so I might have missed some conventions and/or conversions.

Software used is

	R Version 1.6.2  (2003-01-10) / Linux
	ipred_0.6-14.tar.gz

Yours,
Steffen




More information about the R-help mailing list