Displaying 1 result from an estimated 1 matches for "ttabnew".
Did you mean:
ttable
2011 Nov 28
1
code problem with the optim() function
...,dim=c(nrow(pp),ncol(pp)))
d[i,j]<-ifelse(i==j,1,0)
po<-array(NA,dim=c(nrow(pp),ncol(pp)))
po[i,j]<-d[i,j]*pp[i,j]
for (i in 1:nrow(ttab)){
for (j in 1:ncol(ttab)){
d[i,j]<-ifelse(i==j,1,0)
po[i,j]<-d[i,j]*pp[i,j]
}
}
}
}
pseudo<-1
total<-total+1
ttabnew<-ttab+pseudo/(ncol(ttab)*nrow(ttab))
ttabnew<-prop.table(ttabnew)
pah<-(margin.table(ttabnew,1))
pbh<-(margin.table(ttabnew,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]
}
ssu...