Obtaining minimum maximum output of a macro (funct

2019-09-14 16:59发布

问题:

I want to find to find extreme values produced by a macro as a function of input parameters:

For example purposes here is some data:

data Input_data;
    input X Y;
    cards;
    10 15
    20 18
    30 27
    33 41
    ;
run; 

The following is not the actual formula (as the minimum for this is easily found analytically.) and I want computational method. For examples sake I have semi-empirical rule, which takes three parameters in:

%macro Function(const1, const2 const3);
    data output;
        set input;
        X_eff1=((X > &const1.)*(X - &const1.)**2);
        X_eff2=((X > &const2.)*(X - &const2.)**2);
        X_eff3=((X > &const3.)*(X - &const3.)**2);
        Residual= Y - (1.3*X_eff1 - 2.7*X_eff2+ 3.1*X_eff3);
    run;
%mend;

I want the find const1, const2 const3 which produce the minimum value for variable 'Residual'. Can SAS do this? Few options that are to be considered:

a) Find global minimum

b) Find local minimum within boundary conditions, for example: const1[0,1] const2[10,17], const3[20, 22]

I could generate huge table and brute force feed it to the function. However, this is not feasible if the number of input parameter rise.

I could scratch program something?

I could do this in numpy (fmin from cipy.optimize comes to mind)or R if it proves hard for SAS.

Any thoughts on how to solve it??

标签: sas sas-macro