开发者

cross validation in SAS

开发者 https://www.devze.com 2023-04-10 04:15 出处:网络
I have split my data into 5 folds in SAS. So I have s1,s2,s3,s4,s5 I was wondering what\'s the best way to iterate through each of the folds to perform cross validation. For example, th开发者_如何学

I have split my data into 5 folds in SAS. So I have

s1,s2,s3,s4,s5

I was wondering what's the best way to iterate through each of the folds to perform cross validation. For example, th开发者_如何学JAVAe first iteration I want to use s1 as my test set and s2,3,4,5 as the training sets, the second iteration use s2 as the test and s1,3,4,5 as training etc.

what kind of loop in SAS would accomplish this goal?

Thanks!


Probably best to call upon a macro to make it a bit easier to call upon.

%Macro Validate(cur,i) ;
%Do j = 1 %to 5 ;

  %If &j <> &i %THEN

  %DO;

  Data &Cur._&j. ;

    Set &cur S&j. ;

    <validation steps>

  Run;

  %END;

%End;

%mend Validate ;

Data _null_ ;

Do i = 1 to 5 ;

Call Execute("%Validate(s"||strip(i)||","||strip(i)||");");

End;

Run;


Proc gmlselect performs k-folds cross validation with multiple methods to choose best models. It is experimental in 9.1 but released in production for 9.2+

Further info here

Hope this help.

0

精彩评论

暂无评论...
验证码 换一张
取 消