Displaying 1 result from an estimated 1 matches for "sumpah".
Did you mean:
sumah
2011 Nov 28
1
code problem with the optim() function
...bnew,2))
s<- foreach (ii =1:4) %dopar% {
for (i in 1:ncol(ttabnew)){
for (j in 1:ncol(ttabnew)){
s<-rep(NA,2)
s[ii]<-d[i,j]*pah[i]*pbh[j]
}
ssum<-sum(as.vector(unlist(s)))
pbhh<-NA
pahh<-NA
pbhh[j]<- d[i,j]*pbh[j]
pahh[i]<-d[i,j]*pah[i]
sumpbh<-sum(pbhh)
sumpah<-sum(pahh)
pah[i]<-pa[i]/(1-alphanew+(alphanew*sumpbh/ssum) )
pbh[j]<-pb[j]/(1-alphanew+(alphanew*sumpah/ssum) )
# s<-sum(d[i,j]*pah[i]*pbh[j])
pp[i,j]<-(1-alphanew+(alphanew*d[i,j]/ssum ))*pah[i]*pbh[j]
logpp<-log(pp[i,j])
}
}
return(-logpp)
}
optim(c(alpha,as.vector(pa),...