How do I save cluster centers from Hierarchical Cluster Analysis?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How do I save cluster centers from Hierarchical Cluster Analysis?

BonnieNP
I want to first run Hierarchical Cluster Analysis to form 3 clusters, and then second, run K Means Cluster Analysis with the initial cluster centers coming from the hierarchical procedure.

How do I save the cluster centers from hierarchical?
Then how do I specify using them as initial cluster centers in k means? Do I need to put them in their own dataset? If so how?

Thanks,
Bonnie P
Reply | Threaded
Open this post in threaded view
|

Re: How do I save cluster centers from Hierarchical Cluster Analysis?

BonnieNP
More information:
I already found the follwing from previous topics:
*       Steps:
1.      Run a Hierarchical Cluster analysis on a small sample
2.      Choose a solution
3.      Aggregate the variables used in the Cluster Analysis according
to the cluster variable
**Change the name of variables in the aggregate file to be the same as
originally
4.      Name the first variable 'cluster_' in the aggregated file
5.      The aggregated file will be used as centre in the K-Means
procedure
6.      Use the aggregated file as centres when running a K-means on the
whole data set
*       Clustering new cases using a previous cluster analysis
o       Save the final centre points.
o       Use them a centres for the new file

So exactly how do I do step 3 above?
Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: How do I save cluster centers from Hierarchical Cluster Analysis?

Ruben Geert van den Berg
In reply to this post by BonnieNP
Dear Bonnie,

AFAIK, hierarchical cluster analysis can't write cluster centers to a file or dataset that can be used by k-means. However, the approach you propose (using HCA output as KCA input) is very standard and you can work around this with (quite) a bit of syntax. For an example, see below. 
Mind you that the output (assignment of cases to clusters) of any clustering method in SPSS may depend on the (arbitrary!) order of the cases in the data file (which I find seriously odd by the way). You might want to randomly reorder your cases a couple of times before you settle on some outcome.

Best,

Ruben

*Create small test dataset.

cd 'c:/temp'.
set seed 1.

data list free/id.
begin data
0 1 2 3 4 5 6 7 8 9  10
end data.

do repeat v=v1 to v4.
compute v=tru(rv.uni(1,5)).
end repeat.

dataset name d1.

*Run HCA.

CLUSTER   v1 v2 v3 v4
  /METHOD WARD
  /MEASURE=SEUCLID
  /PRINT SCHEDULE
  /PLOT NONE
  /SAVE CLUSTER(3).

*Manually create cluster centers file.

* OMS.
DATASET DECLARE  means.
OMS
  /SELECT TABLES
  /IF COMMANDS=['Means'] SUBTYPES=['Report']
  /DESTINATION FORMAT=SAV NUMBERED=TableNumber_
   OUTFILE='means'
  /TAG='means'.

means v1 to v4 by clu3_1
/cel mean.

omsend tag=['means'].
dataset activate means.

*Now we have the cluster centers in a dataset. However, we have to adjust the format a little bit before saving it.

select if var1 ne 'Total'.
compute cluster_=numeric(var1,f1).

*Now we write a file containing the cluster centers.

save outfile 'initial_kmeans_3a.sav'
/keep cluster_ v1 to v4.

*Now we return to the original data.

dataset close means.
dataset activate d1.

*Now we run KCA with the HCA centers as initial cluster centers.

QUICK CLUSTER v1 v2 v3 v4
  /MISSING=LISTWISE
  /CRITERIA=CLUSTER(3) MXITER(10) CONVERGE(0)
  /METHOD=KMEANS(NOUPDATE)
  /SAVE CLUSTER
  /PRINT INITIAL
  /FILE='C:\temp\initial_kmeans_3a.sav'.

*HAPPY END!!!!!!!!!.




> Date: Wed, 9 Mar 2011 16:40:57 -0800
> From: [hidden email]
> Subject: How do I save cluster centers from Hierarchical Cluster Analysis?
> To: [hidden email]
>
> I want to first run Hierarchical Cluster Analysis to form 3 clusters, and
> then second, run K Means Cluster Analysis with the initial cluster centers
> coming from the hierarchical procedure.
>
> How do I save the cluster centers from hierarchical?
> Then how do I specify using them as initial cluster centers in k means? Do I
> need to put them in their own dataset? If so how?
>
> Thanks,
> Bonnie P
>
> --
> View this message in context: http://spssx-discussion.1045642.n5.nabble.com/How-do-I-save-cluster-centers-from-Hierarchical-Cluster-Analysis-tp3422571p3422571.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: How do I save cluster centers from Hierarchical Cluster Analysis?

Art Kendall-2
In reply to this post by BonnieNP
TWOSTEP  does this.  First a hierarchical clustering and then applying
the results to the whole dataset.

If you have not done the H clustering, how did you decide that there are
3 clusters?

Do you have so many cases that it is impractical to just do hierarchical
on the whole dataset?



Art Kendall
Social Research Consultants

On 3/9/2011 7:40 PM, BonnieNP wrote:

> I want to first run Hierarchical Cluster Analysis to form 3 clusters, and
> then second, run K Means Cluster Analysis with the initial cluster centers
> coming from the hierarchical procedure.
>
> How do I save the cluster centers from hierarchical?
> Then how do I specify using them as initial cluster centers in k means? Do I
> need to put them in their own dataset? If so how?
>
> Thanks,
> Bonnie P
>
> --
> View this message in context: http://spssx-discussion.1045642.n5.nabble.com/How-do-I-save-cluster-centers-from-Hierarchical-Cluster-Analysis-tp3422571p3422571.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD
>

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: How do I save cluster centers from Hierarchical Cluster Analysis?

tjohnson
In reply to this post by BonnieNP
You can use the aggregate procedure in SPSS, having saved your
Hierarchical Solution to the dataset.  From the drop downs, this is
Data/Aggregate.  However, it seems that SPSS will automate this for you
via the TwoStep cluster routine.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
BonnieNP
Sent: 10 March 2011 01:06
To: [hidden email]
Subject: Re: How do I save cluster centers from Hierarchical Cluster
Analysis?

More information:
I already found the follwing from previous topics:
*       Steps:
1.      Run a Hierarchical Cluster analysis on a small sample
2.      Choose a solution
3.      Aggregate the variables used in the Cluster Analysis according
to the cluster variable
**Change the name of variables in the aggregate file to be the same as
originally
4.      Name the first variable 'cluster_' in the aggregated file
5.      The aggregated file will be used as centre in the K-Means
procedure
6.      Use the aggregated file as centres when running a K-means on the
whole data set
*       Clustering new cases using a previous cluster analysis
o       Save the final centre points.
o       Use them a centres for the new file

So exactly how do I do step 3 above?
Thanks!

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/How-do-I-save-cluster-cent
ers-from-Hierarchical-Cluster-Analysis-tp3422571p3422598.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD