Thanks for your help, I'll try this. S poetry seems to
be a very interesting guide.
Of course, there is a comma here :
cv.tree(arbre, FUN = prune.tree)
Just a mistake in the copy-paste procedure...
--- Patrick Burns <pburns@pburns.seanet.com> a écrit :
> It should work if you assign 'learning' to frame 1.
> S Poetry explains this -- I think mostly in the
> chapter
> on Formulas.
>
> Patrick Burns
> patrick@burns-stat.com
> +44 (0)20 8525 0696
> http://www.burns-stat.com
> (home of S Poetry and "A Guide for the Unwilling S
> User")
>
> Odile wrote:
>
> > 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 cette version sur http://fr.messenger.yahoo.com
|