search for: acwrk

Displaying 3 results from an estimated 3 matches for "acwrk".

2010 Sep 07
5
question on "optim"
...ccl<-matrix(1,n,ns) eta<-c(0,0) # setup the parts for loglikelihood q1<-exp(par[1]) pr1<-q1/(1+q1) pr2<-1-pr1 eta[2]<-par[2] a<-par[3:6] b<-par[7:11] w<-par[12:npar] for(m in 1:ns){ ?for(i in 1:nt){ ?? regw[,i]<-w[1]+ w[2]*eta[m]+exp(w[3]+w[4]*eta[m])*actr[,i]+w[5]*acwrk[,i] ??? vbar2[,i]=a[1]+???? eta[m]+regw[,i]*a[2]+acwrk[,i]*a[3]+actr[,i]*a[4] ??? vbar3[,i]=b[1]+b[2]*eta[m]+regw[,i]*b[3]+acwrk[,i]*b[4]+actr[,i]*b[5] ??? v8[,i]=1+exp(vbar2[,i])+exp(vbar3[,i]) ???? ?? for(j in 1:n){ ?? ?if (home[j,i]==1) lia[j,i]=1/v8[j,i] ????? if (wrk[j,i]==1) lia[j,i]=exp(vba...
2010 Aug 17
1
replace loops with matrix
...0 of the time the loop method takes. it may still have room to improve it. at least, the?following part?looks ugly. ccl[,m]<-lia[,1]*lia[,2]*lia[,3]*lia[,4]*lia[,5] any suggestion are appreciated. The Loop code: for(m in 1:ns){ ?for(i in 1:nt){ ??? vbar2[,i]=a[1]+???? eta[m]+acedu[,i]*a[2]+acwrk[,i]*a[3] ??? vbar3[,i]=b[1]+b[2]*eta[m]+acedu[,i]*b[3]+acwrk[,i]*b[4] ??? v8[,i]=1+exp(vbar2[,i])+exp(vbar3[,i]) ????? for(j in 1:n){ ?? ???? ? if (edu[j,i]==1) lia[j,i]=1/v8[j,i] ????????? if (wrk[j,i]==1) lia[j,i]=exp(vbar2[j,i])/v8[j,i] ????????? if (home[j,i]==1) lia[j,i]=exp(vbar3[j,i])/v8[j...
2010 Sep 15
1
optim with BFGS--what may lead to this, a strange thing happened
...lia<-matrix(0,n,nt) ccl<-matrix(1,n,ns) eta<-c(0,0) # setup the parts for loglikelihood q1<-exp(par[1]) pr1<-q1/(1+q1) pr2<-1-pr1 eta[2]<-par[2] a<-par[3:6] b<-par[7:11] w<-par[12:npar] for(m in 1:ns){ regw<-exp(w[1]+w[2]*eta[m])*actr+exp(w[3]+ w[4]*eta[m])*acwrk vbar2=a[1]+ eta[m]+regw*a[2]+acwrk*a[3]+actr*a[4] vbar3=b[1]+b[2]*eta[m]+regw*b[3]+acwrk*b[4]+actr*b[5] v8=1+exp(vbar2)+exp(vbar3) lia<-ifelse(home==1,1/v8, ifelse(wrk==1,exp(vbar2)/v8, ifelse(tr==1,exp(vbar3)/v8,1))) wden<-ifelse(wrk==1,...