cv.fold<-function(i, size=3, rang=0.3){
       cat('Fold ', i, '\n')
       out.fold.c <-((i-1)*c.each.part +1):(i*c.each.part)
       out.fold.n <-((i-1)*n.each.part +1):(i*n.each.part)

      train.cv <- n.cc[-out.fold.c, c(2:2401, 2417)]
       train.nv <- n.nn[-out.fold.n, c(2:2401, 2417)]

       train.v<-rbind(train.cv, train.nv) #training data for feature
selection

    # grow tree
fit.dimer <- rpart(as.factor(out) ~ ., method="class", data=train.v)
at<-grep("<leaf>", fit.dimer$frame[, "var"], value=FALSE, ignore.case=TRUE)
varr<-as.character(unique(fit.dimer$frame[-at, "var"]))

       train.cc <- n.cc[-out.fold.c,]
       valid.cc <- n.cc[out.fold.c,]

       train.nn <- n.nn[-out.fold.n,]
       valid.nn <- n.nn[out.fold.n,]

       train<-rbind(train.cc, train.nn) #training data
       valid<-rbind(valid.cc, valid.nn) # validation data

#creat data set contains the following variables
myvar<-names(gh9_h) %in% c(varr, "out")

       train<-train[myvar] # update training set
       valid<-valid[myvar]

nnet.fit<-nnet(as.factor(out) ~ ., data=train,  size=size, rang=rang,
decay=5e-4, maxit=500)  # model fitting

       #get the validation error
     mc<-table(valid$out, predict(nnet.fit, valid, type="class")) #confusion
matrix

       fp<-mc[1,2]/sum(mc[1,]) #false positive
       fn<- mc[2,1]/sum(mc[2,]) #false negative
      accuracy.r<-1-(mc[1,2]+mc[2,1])/sum(mc) #total accuracy rate

return(c(fp, fn, accuracy.r))

                               }

result.fun <- lapply(1:2, cv.fold(i, size=5, rang=0.3))

I got the following error message:

*Error in match.fun(FUN) :
  'cv.fold(i, size = 5, rang = 0.3)' is not a function, character or symbol


I do want to change the size and rang parameters some time.

*
Can anyone help me this this?  Thanks so much!


-- 
Sincerely,
Changbin
--

	[[alternative HTML version deleted]]

