| To: | s-news@lists.biostat.wustl.edu |
|---|---|
| Subject: | cv.tree in a function |
| From: | Odile <mullodi@yahoo.fr> |
| Date: | Wed, 7 Sep 2005 09:52:01 +0200 (CEST) |
| Domainkey-signature: | a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.fr; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=zU0nrrzSYDJr/TgFdKUxWS1+JxfxeKRE2Z9OrlPXsytAdf6Oxc9K2bTeBcf1+Bo+NxmAjDNT7TzS/aa4QoHBFXa+KAsM7brvtIUm1+opvH9lSNicoxXaKNOud5Om/LjA/4kMsTy5TV1ByCDLU63GL9NlleWD4PvxkwGNmBU+mvw= ; |
|
Hello,
My s-plus programm does not work and I do not know why! The problem may come from the function cv.tree.
Here is my function :
"bagging"<- function(learning,test) { n <- nrow(learning) m <- nrow(test) K <- 25 predi <- matrix(nrow = m, ncol = K) arbre <- tree(learning) cval <- cv.tree(arbre FUN = prune.tree) # It stops here! print("here") # That is not printed... for (i in 1:K){ XXX <- learning[sample(n,n,T),] arb <- tree(XXX,control=tree.control(nrow(learning),mindev=0.005)) cval <- cv.tree(arb, FUN = prune.tree) mi <- min(cval$dev) p <- min(cval$size[cval$dev==mi]) # (number of nodes when the deviance is min) elag <- prune.tree(arb, best=p) predi[,i] <- predict.tree(elag,newdata=test) } pred <- rowMeans(predi) errors(pred,test[,1]) } bagging(app1,test1) S-plus reply is : "Error: Object "learning" not found" or if I just run what is inside for {}, I get "missing values are not allowed" app1 and test1 are dataframes I get with the funtion read.table and they do not contain any missing values. Actually, if I type : arbre <- tree(app1) cval <- cv.tree(arbre, FUN = prune.tree) in the command window, it works (cval is calculated). Thanks for your help, odile.
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger Téléchargez le ici ! |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: Coercing to character, Richard M. Heiberger |
|---|---|
| Next by Date: | writing to Excel files, Eric yang |
| Previous by Thread: | Coercing to character, asanquer |
| Next by Thread: | Re: cv.tree in a function, Odile |
| Indexes: | [Date] [Thread] [Top] [All Lists] |