I was wondering why this loop doesn't work! for (i in 1:k) fnTr[i] <- function (p) 0.5* sum ( n*log(2*pi) - log(sd(i)^2) +(logitp(i)-p)^2/sd(i)^2 ) outTr[i]<- nlm (fnTr[i],p=c(10),hessian=TRUE) minimumTr[i] <- outTr[i]$minimum valueTr[i] <- outTr[i]$estimate list (minimumTr[i],valueTr[i]) Has anyone can help me? Thank you very much Hathaikan
Hathaikan Chootrakool wrote:>I was wondering why this loop doesn't work! > >for (i in 1:k) >fnTr[i] <- function (p) 0.5* sum ( n*log(2*pi) - log(sd(i)^2) > +(logitp(i)-p)^2/sd(i)^2 ) >outTr[i]<- nlm (fnTr[i],p=c(10),hessian=TRUE) >minimumTr[i] <- outTr[i]$minimum >valueTr[i] <- outTr[i]$estimate >list (minimumTr[i],valueTr[i]) > >Has anyone can help me? > >Thank you very much >Hathaikan > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > > >missing {} on your code block for(...){ ... } EJ
just one more thing. Why are you defining the function over and over again... On Wed, 31 Aug 2005, Hathaikan Chootrakool wrote:> I was wondering why this loop doesn't work! > > for (i in 1:k) > fnTr[i] <- function (p) 0.5* sum ( n*log(2*pi) - log(sd(i)^2) > +(logitp(i)-p)^2/sd(i)^2 ) > outTr[i]<- nlm (fnTr[i],p=c(10),hessian=TRUE) > minimumTr[i] <- outTr[i]$minimum > valueTr[i] <- outTr[i]$estimate > list (minimumTr[i],valueTr[i]) > > Has anyone can help me? > > Thank you very much > Hathaikan > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >