How to combine loop and regression?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to combine loop and regression?

zhou yuming
Hi,

I am trying to perform a regression analysis with loop. In each loop, a
linear regression is first performed. Then, the Cook distance is examined.
If all data points have a Cook distance less than 1, the program will exit
the loop. Otherwise, the program will filter data points with Cook
distance larger than 1 and continue to the analysis.

However, my program does not work. Could you please give me a hand? Thank
you very much.

ZYM



The following is my program:

-----------------------
DEFINE !regresion(num = !tokens(1))

!DO !cnt=1 !TO !num

REGRESSION /VARIABLES = x1, x2, y
           /STATISTICS  = DEFAULTS
           /DEPENDENT = y
           /METHOD = ENTER
           /SAVE COOK.

SORT CASES BY coo_1.

DO IF (coo_1 < 1 AND $CASENUM = 1).
!BREAK.
END IF.

DO IF coo_1 GT 1.
+ COMPUTE myfilter = 0.
ElSE.
+ COMPUTE myfilter = 1.
END IF.

FILTER BY myfilter.

MATCH FILES FILE = * /DROP coo_1.

!DOEND
!ENDDEFINE.
*//////////////////////////////////////////////.

!regresion num = 100.