Hello. I am trying to approximate a 36 points series to a quaterly data of 9 quarters. The objetive here is that the optimized series of 36 points fits the goal for those 9 quarters with minimal error while being a smooth and monotonous function. I was trying to use the following code:
proc iml;
/* Step 1: Define Bayes values from macro variables */
bayes = {
&bayes1,
&bayes2,
&bayes3,
&bayes4,
&bayes5,
&bayes6,
&bayes7,
&bayes8,
&bayes9
};
/* Step 2: Define initial guess (e.g., from macro variables &pd1–&pd36) */
PD_ini = {
&PD1, &PD2, &PD3, &PD4, &PD5, &PD6, &PD7, &PD8, &PD9, &PD10, &PD11, &PD12, &PD13, &PD14, &PD15, &PD16, &PD17, &PD18, &PD19, &PD20, &PD21, &PD22, &PD23, &PD24, &PD25, &PD26, &PD27, &PD28, &PD29, &PD30, &PD31, &PD32, &PD33, &PD34, &PD35, &PD36
};
PD_init=t(PD_ini);
/* Step 3: Define the objective function */
start objetive(pd) global(bayes);
S = j(1, 36, .);
CumPD = j(1, 36, .);
S[1] = 1 - pd[1];
CumPD[1] = 1 - S[1];
do t = 2 to 36;
S[t] = S[t-1] * (1 - pd[t]);
CumPD[t] = 1 - S[t];
end;
obj = 0;
do i = 0 to 8;
t = i * 3 + 1; /* Corresponds to months 0, 3, ..., 24 */
condPD = (CumPD[t+12] - CumPD[t]) / S[t];
err = (condPD - bayes[i+1]) * 100;
obj = obj + err##2;
end;
return (obj);
finish;
/* Step 4: Call optimizer */
optn = {0}; /* 0 = minimize */
call nlpqn(rc, result, "objetive", initPD, optn);
/* Step 5: Output results */
print rc result;
quit;
But I keep getting this error:
74 ! /* 0 = minimize */
75 call nlpqn(rc, result, "objetive", initPD, optn);
ERROR: (execution) Matrix has not been set to a value.
I have also tried to use the initial matrixes as constants but it didnt work either.
Ex: bayes = {0.0002639011, 0.0003372667, 0.0004005217, 0.0004619689, 0.0005238603, 0.0005852403, 0.000645032, 0.0007037884, 0.0007612079 and PD_ini = j(1,36,0.01);
Note: My base SAS software is 9.4 and the IML is For SAS/IML 15.2.
Can someone give some pointers or some help. I would apreciate it 😃