Dear all,

When I try to return some vectors from some functions within a function, it 
indicate an error," Error in rbind(ck1, ck2, ck3) : object 'ck1' not found", 
in one of the iterations and stop.  Since I am not experienced in programming, 
can anyone give me a suggestion to inspect this error?
The followings are the functions I created :

###################
# functions in the convg #
###################
check1 <- function(sumgt,beta1.0,gamma.0,sigma.0){
   if (any(!is.finite(sumgt))){
       count1 <- count1+1
       return(c(count1,beta1.0,gamma.0,sigma.0))
   }
  else {return(c(NaN,NaN,NaN,NaN))}
 }
check2 <- function(v0,maxit,iter,beta1.0,gamma.0,sigma.0){
    if (is.nan(sum(v0))==TRUE | any(!is.finite(v0)) | maxit == iter){
       count1 <- count1+1
       return(c(count1,beta1.0,gamma.0,sigma.0)) 
   } 
   else {return(c(NaN,NaN,NaN,NaN))}
 }
check3 <- function(maxit,diff,error,beta1.0,gamma.0,sigma.0){
    if (diff < error) { 
       return(c(count,beta1.0,gamma.0,sigma.0))           
   }
   else {return(c(NaN,NaN,NaN,NaN))}    
 }

convg <- 
function(count1,count,sub,rep,n,data1,beta1.0,gamma.0,sigma.0,v0,L,diff,error,iter,maxit){
  
 while(diff > error && maxit < iter && max(abs(c(beta1.0,gamma.0,sigma.0))) < 
10 && is.nan(sum(v0))==FALSE && any(is.finite(v0))){
           :
           :
 ck1 <- check1(sumgt,beta1.0,gamma.0,sigma.0)
           : 
           :
 ck2 <- check2(v0,maxit,iter,beta1.0,gamma.0,sigma.0)
           :
           :
 ck3 <- check3(maxit,diff,error,beta1.0,gamma.0,sigma.0)
 
} 
return(rbind(ck1,ck2,ck3))
}
 
Thank you so much


Sincerely,


Joe


      
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to