AT_BANNER([QUICK CLUSTER])

AT_SETUP([QUICK CLUSTER with small data set])
AT_DATA([quick-cluster.sps], [dnl
DATA LIST LIST /x y z.
BEGIN DATA.
22,2930,4099
17,3350,4749
22,2640,3799
20, 3250,4816
15,4080,7827
4,5,4
5,6,5
6,7,6
7,8,7
8,9,8
9,10,9
END DATA.
QUICK CLUSTER x y z
  /CRITERIA=CLUSTER(2) MXITER(20).
])
AT_CHECK([pspp -o pspp.csv quick-cluster.sps])
AT_CHECK([cat pspp.csv], [0], [dnl
Table: Reading free-form data from INLINE.
Variable,Format
x,F8.0
y,F8.0
z,F8.0

Table: Final Cluster Centers
,Cluster,
,,
,1,2
,,
x,6.50,19.20
y,7.50,3250.00
z,6.50,5058.00

Table: Number of Cases in each Cluster
Cluster,1,6
,2,5
Valid,,11
])
AT_CLEANUP

AT_SETUP([QUICK CLUSTER with large data set])
AT_DATA([quick-cluster.sps], [dnl
input program.
loop #i = 1 to 500000.
compute x = 3.
end case.
end loop.
end file.
end input program.
QUICK CLUSTER x /CRITERIA = CLUSTER(4) MXITER (100).
])
AT_CHECK([pspp -o pspp.csv quick-cluster.sps])
AT_CHECK([cat pspp.csv], [0], [dnl
Table: Final Cluster Centers
,Cluster,,,
,,,,
,1,2,3,4
,,,,
x,.00,.00,.00,3.00

Table: Number of Cases in each Cluster
Cluster,1,0
,2,0
,3,0
,4,500000
Valid,,500000
])
AT_CLEANUP


AT_SETUP([QUICK CLUSTER with weights])
AT_DATA([qc-weighted.sps], [dnl
input program.
loop #i = 1 to 400.
 compute x = mod (#i, 4).
 compute w = 5.
 end case.
end loop.
loop #i = 1 to 400.
 compute x = mod (#i, 4).
 compute w = 3.
 end case.
end loop.
end file.
end input program.

weight by w.

QUICK CLUSTER x /CRITERIA = CLUSTER(4) MXITER (100).
])

AT_CHECK([pspp -o pspp-w.csv qc-weighted.sps])


AT_DATA([qc-unweighted.sps], [dnl
input program.
loop #i = 1 to 3200.
 compute x = mod (#i, 4).
 end case.
end loop.
end file.
end input program.

QUICK CLUSTER x /CRITERIA = CLUSTER(4) MXITER (100).
])

AT_CHECK([pspp -o pspp-unw.csv qc-unweighted.sps])

AT_CHECK([diff pspp-w.csv pspp-unw.csv], [0])

AT_CLEANUP

AT_SETUP([QUICK CLUSTER with listwise missing])
AT_DATA([quick-miss.sps], [dnl
data list notable list /x *.
begin data.
1
1
2
3
4
.
2
end data.

QUICK CLUSTER x /CRITERIA = CLUSTER(4) MXITER (100).
])

AT_CHECK([pspp -o pspp-m.csv quick-miss.sps])

AT_DATA([quick-nmiss.sps], [dnl
data list notable list /x *.
begin data.
1
1
2
3
4
2
end data.

QUICK CLUSTER x /CRITERIA = CLUSTER(4) MXITER (100).
])

AT_CHECK([pspp -o pspp-nm.csv quick-nmiss.sps])

AT_CHECK([diff pspp-m.csv pspp-nm.csv], [0])

AT_CLEANUP


AT_SETUP([QUICK CLUSTER with pairwise missing])
AT_DATA([quick-s.sps], [dnl
data list notable list /x * y *.
begin data.
1   2
1   2.2
1.1 1.9
1   9
1   10
1.3 9.5
0.9 8.9
3.5 2
3.4 3
3.5 2.5
3.1 2.0
3.9 2.5
3.8 2.0
end data.

QUICK CLUSTER x y 
	/CRITERIA = CLUSTER(3) MXITER (100)
	.
])

AT_CHECK([pspp -O format=csv quick-s.sps | tail -5 > pspp-s.csv])

AT_DATA([quick-pw.sps], [dnl
data list notable list /x * y *.
begin data.
1   2
1   2.2
1.1 1.9
1   9
1   10
1.3 9.5
0.9 8.9
3.5 2
3.4 3
3.5 2.5
3.1 2.0
3.9 .
3.8 .
end data.

QUICK CLUSTER x y 
	/CRITERIA = CLUSTER(3) MXITER (100)
	/MISSING = PAIRWISE
	.
])

AT_CHECK([pspp -O format=csv quick-pw.sps | tail -5 > pspp-pw.csv])

AT_CHECK([diff pspp-s.csv pspp-pw.csv], [0])


AT_CLEANUP
