Hi, I have some code that tries to minimize a function. The code is below: start odr_yrly (matrix, year);
yr_odr = j(nrow(matrix), year + 1, 0);
yr_odr[,1] = matrix[,ncol(matrix)];
do i = 1 to year;
yr_odr[,i + 1] = matrix ** 4 * yr_odr[,i];
end;
yr_odr = yr_odr[,2:6];
return(yr_odr);
finish;
start multi_year_dr_error(odr, full_matrix, year, pop);
odr_last = j(1,ncol(odr),1);
odr_full = odr // odr_last;
pop_dist = pop[,5] // {0};
odr_eff = odr_full[,3:6];
idx = loc(odr_eff > 0);
log_odr = j(nrow(odr_eff),ncol(odr_eff),0);
if ncol(idx) > 0 then log_odr[idx] = log(odr_eff[idx]);
odr_est = odr_yrly(full_matrix, year);
idx2 = loc(odr_est > 0);
log_odr_est = j(nrow(odr_est),ncol(odr_est),0);
if ncol(idx2) > 0 then log_odr_est[idx2] = log(odr_est[idx2]);
diff = (log_odr - log_odr_est[,2:5]) # pop_dist;
print log_odr diff pop_dist log_odr_est;
diff_sq = diff ## 2;
ssq = diff_sq[+];
return(ssq);
finish; Now I can't see any problem with my matrix multiplication line yr_odr[,i + 1] = matrix ** 4 * yr_odr[,i]; however it is giving me errors saying it overflowed. anyone has any idea why that is the case? Happy to post the full optimisation code here but its some long code with multiple parts to the optimisation. Regards, Cherrie
... View more