y<-c(125,18,20,34) l0<--1000000 EMa<-function(theta0,y){ test<-3 while (test!=10) { t<-125*theta0/(theta0+2) x<-c(t,y[2],y[3],y[4]) theta.new<-(t+x[4])/(t+x[2]+x[3]+x[4]) if (abs(theta.new-theta0)<=10^(-6)) { test<-10} else { print(theta.new) theta0<-theta.new } } return(list(theta.new=theta.new)) }