Hi, 

 

I am using R for estimation of salmon historical abundance (39 years) using 10 escapements and harvest data by constructing likelihood function with and minimizing log lilkelihood (with parameter constraints) using optim ().  This will estimate total of 49 parameters.  I do the same with EXCEL with Solver. 

 

My problem using optim() that optim() is slower to converge and produces inaccurate parameter estimates than that done by EXCEL with Solver. 

 

I appreciate any suggestions to speed up and produce better parameter estimates.   

 

 

Here is the log-likelihood function 

nyear = length(Year);

w = c(3, 2, 1, 1, 1, 2, 3, 3, 2, 2, 0.5);

#          Log Likelihood function

  mylikelihood=function(x){

            Nh=x[1:nyear];

            q1=x[nyear+1];

            q2=x[nyear+2];

            q3=x[nyear+3];

            q4=x[nyear+4];

            q5=x[nyear+5];

            q6=x[nyear+6];

            q7=x[nyear+7];

            q8=x[nyear+8];

            q9=x[nyear+9];

    q10=x[nyear+10];       

    

            loglink1 = sum(sum((log(q1*Tincup)-log(Nh-total.harvest))^2/w[1]^2,na.rm=T), sum((log(q2*Tatchum)-log(Nh-total.harvest))^2/w[2]^2,na.rm=T),sum((log(q3*L.Salmon)-log(Nh-total.harvest))^2/w[3]^2,na.rm=T), sum((log(q4*B.Salmon)-log(Nh-total.harvest))^2/w[4]^2,na.rm=T), sum((log(q5*Nisutlin)-log(Nh-total.harvest))^2/w[5]^2,na.rm=T), sum((log(q6*Ross)-log(Nh-total.harvest))^2/w[6]^2,na.rm=T), sum((log(q7*Wolf.a)-log(Nh-total.harvest))^2/w[7]^2,na.rm=T), sum((log(q8*Blind)-log(Nh-total.harvest))^2/w[8]^2,na.rm=T), sum((log(q9*Fishway)-log(Nh-total.harvest))^2/w[9]^2,na.rm=T), sum((log(q10*BM_R)-log(Nh))^2/w[10]^2,na.rm=T), sum((log(M.R)-log(Nh))^2/w[11]^2,na.rm=T));

 

loglink2 = sum(length(na.omit(Tincup)),length(na.omit(Tatchum)),length(na.omit(L.Salmon)),length(na.omit(B.Salmon)),length(na.omit(Nisutlin)),length(na.omit(Ross)),length(na.omit(Wolf.a)),length(na.omit(Blind)),length(na.omit(Fishway)),length(na.omit(BM_R)),length(na.omit(M.R)))/2;

loglink = log(loglink1)*loglink2;

loglink 

};

 

#Set the initial values

initial.values=c(rep(60000,nyear),rep(1,10));                      

 

value=optim(par=initial.values,fn=mylikelihood, method='L-BFGS-B', lower = c(total.count,rep(1,10)), hessian = T, control=list(maxit = 10000));

value; 

 

 

Toshihide "Hamachan" Hamazaki : $B_@:j=S=(!'IM$A$c$s(J

Alaska Department of Fish & Game

Division of Commercial Fisheries

333 Raspberry Rd. Anchorage, Alaska 99518

Ph: 907-267-2158

Fax: 907-267-2442

Cell: 907-440-9934

E-mail: toshihide.hamazaki@alaska.gov

 


	[[alternative HTML version deleted]]

