Hi Works for me without error. However are you sure your code does what you suppose it does?
It does not return anything visible BB is list 3000x13 with all values same except last element in each node. AA is list 3000x13 with various values. ro is a vector with 2997 values 0.001 one value .999 and 2 values 0.008 I did not check values of other objects. Regards Petr > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of irene castro conde > Sent: Monday, May 13, 2013 9:59 AM > To: R-help@r-project.org > Subject: [R] help: R GUI front-end has stopped working > > Hello, > > I'm using the function nlminb of the package stats inside a loop and > when the number of trials grows, R crashes and says "R GUI front-end > has stopped working". Could you help me with this problem? I have try > in versions 2.15.1,2.15.2 and 3.0.0. > > > sessionInfo() > R version 2.15.2 (2012-10-26) > Platform: i386-w64-mingw32/i386 (32-bit) > > locale: > [1] LC_COLLATE=Galician_Spain.1252 LC_CTYPE=Galician_Spain.1252 > [3] LC_MONETARY=Galician_Spain.1252 LC_NUMERIC=C > [5] LC_TIME=Galician_Spain.1252 > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > > This is my code: > > > > u<-runif(3000) > > k=13 > > n=length(u) > > prob=vector(length=n) > > ro=vector(length=n) > > beta1=vector(length=n) > > g1=vector(length=n) > > sb1=vector(length=n) > > low=vector(length=n) > > tlow=vector(length=n) > > effects=vector(length=n) > > vb1=vector(length=n) > > AA=list() > > BB=list() > > nnI=list() > > library(stats) > > for (i in 1:n){ > > v=as.numeric(u<=u[i]) > > p=mean(v) > > A=vector(length=k) > > n1=n%/%k > > A<-sapply(1:k,function(m) A<-sum(v[((m-1)*n1+1):(m*n1)])) > > A[k]=sum(v[((k-1)*n1+1):n]) > > AA[[i]]<-A > > B=c(rep(n1,k-1),length(v[((k-1)*n1+1):n])) > > BB[[i]]<-B > > l1=vector(length=(length(A))) > > L1<-function(pe,rho){ > > for(j in 1:length(A)){ > > if(A[j]==0){l1[j]=0} else {l1[j]<-sum(log(pe+(-rho/(rho-1))*(0:(A[j]- > 1))))} > > } > > return(sum(l1))} > > l2=vector(length=(length(B-A))) > > L2<-function(pe,rho){ > > for(j in 1:length(B-A)){ > > if((B[j]-A[j])==0){l2[j]=0} else {l2[j]<-sum(log(1-pe+(-rho/(rho- > 1))*(0:(B[j]-A[j]-1))))} > > } > > return(sum(l2))} > > l3=vector(length=(length(B))) > > L3<-function(pe,rho){ > > for(j in 1:length(A)){ > > if(B[j]==0){l1[j]=0} else {l3[j]<-sum(log(1+(-rho/(rho-1))*(0:(B[j]- > 1))))} > > } > > return(sum(l3))} > > L<-function(pe,rho){ > > L<-L1(pe,rho)+L2(pe,rho)-L3(pe,rho) > > return(L) > > } > > Max<- function(x){ -L(x[1], x[2])} > > > opt<-nlminb(c(0.01,0.01), Max,lower = rep(0.001,2), upper = > rep(0.999,2),control=list(rel.tol=1e-6)) > prob[i]=opt$par[1] > > ro[i]=opt$par[2] > > } > > > Thanks, > Irene Castro Conde. > [[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. ______________________________________________ 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.