Correspondence Analysis Macro

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

Correspondence Analysis Macro

Brandon Paris
> Hi --
>
> I have a situation where I have run a correspondence analysis on an
> existing data set.  In the future, I will have periodic data that I
> would like to project onto the plots created with the original
> dataset.  I'd like to set this up the syntax so it can be used via the
> SPSS Production Utility.  Here the setup:
>
> *     My original data file has 122 row levels.  The file has one
> record for each row-column combination.  For instance, with 122 row
> items and 20 column items, there would be 2440 records containing 3
> variables -- rownum, columnum, score.
> *     The new data sets that will come in will have varying numbers of
> rows.  One data set may have 5; the next may have 10 or 12.  All
> columns are still the same.
> *     To avoid having empty rows in my output, I do pre-processing on
> the new data to start the row label at 122+1=123.  I then merge the
> new data with the old.
> *     I weight by score, which gives the cell counts when a table
> using rownnum*columnnum is created.
> *     The CORRESPONDENCE procedure has a call (SUPPLEMENTARY) to
> indicate which rows or columns in the data are supplemental to the
> analysis (generate CA positions but don't use them as inputs to the
> CA).
> *     Once CORRESPONDENCE runs, I can use OMS to pull the row points
> table for charting.
>
> Now, here's the issue:
> *     Many people will be using this code, some who are unfamiliar
> with SPSS syntax-- hence the Production Utility.  I want to allow for
> as few mistakes as possible.
> *     Assume I have 5 new products that I want to project onto the
> original map.  I would like to send a command like
>       /SUPPLEMENTARY = rownum(123 124 125 126 127).
> *     I would have the user pass on the number of new products (in
> this case 5) from the Product window.  I then calculate a Macro
> variable of the last rownum index (num rows from original data + num
> rows from new data = 122 + 5 = 127)
> *     THE PROBLEM:  I cannot figure out a way to pass the
> SUPPLEMENTARY rows in a short-list format (or blow out my list in a
> way that handles the dynamic nature of the data from dataset to
> dataset).  Given what I can come up with, I can pass a call like
> /SUPPLEMENTARY = rownum(123 !maxprod), but this only treats rows 123
> and 127 as supplemental rows.  Is there a way to do this in a Macro
> framework?
>
> My other option is to allow the user to pass through a string of
> numbers like @newrows = 123 124 125 126 127 and make the call
> /SUPPLEMENTARY = rownum(@newrows), but this adds room for error.  Does
> anyone have any advice?  The macro portion of my code (minus the
> pre-processing) is below (thanks to Raynald Levesque's website for
> addition using Macro variables trick).
>
> Brandon L. Paris
> Manager, Analytic Innovation
>
> DEFINE !getca ().
>
>   !LET !a = 122 .
>   !LET !b = 5 .
>   !LET !maxprod = !length(!concat(!blanks(!a), !blanks(!b))) .
>
>   CORRESPONDENCE
>     TABLE = rownum(1 !maxrow)  BY colnum(1, 20)
>     /SUPPLEMENTARY = rownum(123,!maxprod)
>     /DIMENSIONS = 2
>     /MEASURE = CHISQ
>     /STANDARDIZE = RCMEAN
>     /NORMALIZATION = SYMMETRICAL
>     /PRINT = TABLE RPOINTS CPOINTS .  
> !ENDDEFINE .
>
> OMS
>   /SELECT TABLES
>   /IF COMMANDS = ['Correspondence']
>       SUBTYPES = ['Overview Row Points']
>   /DESTINATION FORMAT=SAV OUTFILE='c:\temp.sav' .
>
> !getca .
>
> OMSEND .
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Correspondence Analysis Macro

Kooij, A.J. van der
If you use the supplementary subcommand, the supplementary rows and columns ARE projected in the plots created by CORRESPONDENCE. So, I'm not sure what exactly you want to do. ?
 
Regards,
Anita van der Kooij
Data Theory Group
Leiden University.

________________________________

From: SPSSX(r) Discussion on behalf of Brandon Paris
Sent: Thu 17/08/2006 18:31
To: [hidden email]
Subject: Correspondence Analysis Macro



> Hi --
>
> I have a situation where I have run a correspondence analysis on an
> existing data set.  In the future, I will have periodic data that I
> would like to project onto the plots created with the original
> dataset.  I'd like to set this up the syntax so it can be used via the
> SPSS Production Utility.  Here the setup:
>
> *     My original data file has 122 row levels.  The file has one
> record for each row-column combination.  For instance, with 122 row
> items and 20 column items, there would be 2440 records containing 3
> variables -- rownum, columnum, score.
> *     The new data sets that will come in will have varying numbers of
> rows.  One data set may have 5; the next may have 10 or 12.  All
> columns are still the same.
> *     To avoid having empty rows in my output, I do pre-processing on
> the new data to start the row label at 122+1=123.  I then merge the
> new data with the old.
> *     I weight by score, which gives the cell counts when a table
> using rownnum*columnnum is created.
> *     The CORRESPONDENCE procedure has a call (SUPPLEMENTARY) to
> indicate which rows or columns in the data are supplemental to the
> analysis (generate CA positions but don't use them as inputs to the
> CA).
> *     Once CORRESPONDENCE runs, I can use OMS to pull the row points
> table for charting.
>
> Now, here's the issue:
> *     Many people will be using this code, some who are unfamiliar
> with SPSS syntax-- hence the Production Utility.  I want to allow for
> as few mistakes as possible.
> *     Assume I have 5 new products that I want to project onto the
> original map.  I would like to send a command like
>       /SUPPLEMENTARY = rownum(123 124 125 126 127).
> *     I would have the user pass on the number of new products (in
> this case 5) from the Product window.  I then calculate a Macro
> variable of the last rownum index (num rows from original data + num
> rows from new data = 122 + 5 = 127)
> *     THE PROBLEM:  I cannot figure out a way to pass the
> SUPPLEMENTARY rows in a short-list format (or blow out my list in a
> way that handles the dynamic nature of the data from dataset to
> dataset).  Given what I can come up with, I can pass a call like
> /SUPPLEMENTARY = rownum(123 !maxprod), but this only treats rows 123
> and 127 as supplemental rows.  Is there a way to do this in a Macro
> framework?
>
> My other option is to allow the user to pass through a string of
> numbers like @newrows = 123 124 125 126 127 and make the call
> /SUPPLEMENTARY = rownum(@newrows), but this adds room for error.  Does
> anyone have any advice?  The macro portion of my code (minus the
> pre-processing) is below (thanks to Raynald Levesque's website for
> addition using Macro variables trick).
>
> Brandon L. Paris
> Manager, Analytic Innovation
>
> DEFINE !getca ().
>
>   !LET !a = 122 .
>   !LET !b = 5 .
>   !LET !maxprod = !length(!concat(!blanks(!a), !blanks(!b))) .
>
>   CORRESPONDENCE
>     TABLE = rownum(1 !maxrow)  BY colnum(1, 20)
>     /SUPPLEMENTARY = rownum(123,!maxprod)
>     /DIMENSIONS = 2
>     /MEASURE = CHISQ
>     /STANDARDIZE = RCMEAN
>     /NORMALIZATION = SYMMETRICAL
>     /PRINT = TABLE RPOINTS CPOINTS .
> !ENDDEFINE .
>
> OMS
>   /SELECT TABLES
>   /IF COMMANDS = ['Correspondence']
>       SUBTYPES = ['Overview Row Points']
>   /DESTINATION FORMAT=SAV OUTFILE='c:\temp.sav' .
>
> !getca .
>
> OMSEND .
>
>



**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Correspondence Analysis Macro

Brandon Paris
Hi Anita --

If I have a series of variables ending in numbers like v123 v124 v125
v126 v126, sometimes I can use "v123 TO v127", and variables v123
through v127 will be used.  I'm trying to determine is there a way to
make a similar call outright (i.e. /SUPPLEMENTARY=rownum(123 TO 127)),
or perhaps dynamically generate the numbers in a macro.  "TO" doesn't
work.

My alternative is to have the user specify in the Production Utility
"123 124 125 126 127", but that can lead to user error.

Hopefully this helps and someone may have some thoughts.  Thanks.

Brandon



-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Kooij, A.J. van der
Sent: Thursday, August 17, 2006 12:14 PM
To: [hidden email]
Subject: Re: Correspondence Analysis Macro

If you use the supplementary subcommand, the supplementary rows and
columns ARE projected in the plots created by CORRESPONDENCE. So, I'm
not sure what exactly you want to do. ?

Regards,
Anita van der Kooij
Data Theory Group
Leiden University.

________________________________

From: SPSSX(r) Discussion on behalf of Brandon Paris
Sent: Thu 17/08/2006 18:31
To: [hidden email]
Subject: Correspondence Analysis Macro



> Hi --
>
> I have a situation where I have run a correspondence analysis on an
> existing data set.  In the future, I will have periodic data that I
> would like to project onto the plots created with the original
> dataset.  I'd like to set this up the syntax so it can be used via the

> SPSS Production Utility.  Here the setup:
>
> *     My original data file has 122 row levels.  The file has one
> record for each row-column combination.  For instance, with 122 row
> items and 20 column items, there would be 2440 records containing 3
> variables -- rownum, columnum, score.
> *     The new data sets that will come in will have varying numbers of
> rows.  One data set may have 5; the next may have 10 or 12.  All
> columns are still the same.
> *     To avoid having empty rows in my output, I do pre-processing on
> the new data to start the row label at 122+1=123.  I then merge the
> new data with the old.
> *     I weight by score, which gives the cell counts when a table
> using rownnum*columnnum is created.
> *     The CORRESPONDENCE procedure has a call (SUPPLEMENTARY) to
> indicate which rows or columns in the data are supplemental to the
> analysis (generate CA positions but don't use them as inputs to the
> CA).
> *     Once CORRESPONDENCE runs, I can use OMS to pull the row points
> table for charting.
>
> Now, here's the issue:
> *     Many people will be using this code, some who are unfamiliar
> with SPSS syntax-- hence the Production Utility.  I want to allow for
> as few mistakes as possible.
> *     Assume I have 5 new products that I want to project onto the
> original map.  I would like to send a command like
>       /SUPPLEMENTARY = rownum(123 124 125 126 127).
> *     I would have the user pass on the number of new products (in
> this case 5) from the Product window.  I then calculate a Macro
> variable of the last rownum index (num rows from original data + num
> rows from new data = 122 + 5 = 127)
> *     THE PROBLEM:  I cannot figure out a way to pass the
> SUPPLEMENTARY rows in a short-list format (or blow out my list in a
> way that handles the dynamic nature of the data from dataset to
> dataset).  Given what I can come up with, I can pass a call like
> /SUPPLEMENTARY = rownum(123 !maxprod), but this only treats rows 123
> and 127 as supplemental rows.  Is there a way to do this in a Macro
> framework?
>
> My other option is to allow the user to pass through a string of
> numbers like @newrows = 123 124 125 126 127 and make the call
> /SUPPLEMENTARY = rownum(@newrows), but this adds room for error.  Does

> anyone have any advice?  The macro portion of my code (minus the
> pre-processing) is below (thanks to Raynald Levesque's website for
> addition using Macro variables trick).
>
> Brandon L. Paris
> Manager, Analytic Innovation
>
> DEFINE !getca ().
>
>   !LET !a = 122 .
>   !LET !b = 5 .
>   !LET !maxprod = !length(!concat(!blanks(!a), !blanks(!b))) .
>
>   CORRESPONDENCE
>     TABLE = rownum(1 !maxrow)  BY colnum(1, 20)
>     /SUPPLEMENTARY = rownum(123,!maxprod)
>     /DIMENSIONS = 2
>     /MEASURE = CHISQ
>     /STANDARDIZE = RCMEAN
>     /NORMALIZATION = SYMMETRICAL
>     /PRINT = TABLE RPOINTS CPOINTS .
> !ENDDEFINE .
>
> OMS
>   /SELECT TABLES
>   /IF COMMANDS = ['Correspondence']
>       SUBTYPES = ['Overview Row Points']
>   /DESTINATION FORMAT=SAV OUTFILE='c:\temp.sav' .
>
> !getca .
>
> OMSEND .
>
>



**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they are
addressed. If you have received this email in error please notify the
system manager.
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Correspondence Analysis Macro

Kooij, A.J. van der
No, unfortunately "TO" does not work, as I notice now you mention it; we will add this in a future version of CORRESPONDENCE.
 
What I do when I need a list of numbers is copy and paste output from this syntax:

compute id = $CASENUM + 122.

FLIP VARIABLES=id  .

SAVE OUTFILE='e:\...\tmp.sav' /DROP CASE_LBL /COMPRESSED.

GET FILE='e:\...\tmp.sav' /RENAME (VAR001 TO VAR005= V1 TO V5)  .

FORMAT V1 TO V5 (F3.0).

list /var V1 TO V5 /FORMAT=single .

 

Regards,

Anita van der Kooij

Data Theory Group
Leiden University

________________________________

From: SPSSX(r) Discussion on behalf of Brandon Paris
Sent: Fri 18/08/2006 01:18
To: [hidden email]
Subject: Re: Correspondence Analysis Macro



Hi Anita --

If I have a series of variables ending in numbers like v123 v124 v125
v126 v126, sometimes I can use "v123 TO v127", and variables v123
through v127 will be used.  I'm trying to determine is there a way to
make a similar call outright (i.e. /SUPPLEMENTARY=rownum(123 TO 127)),
or perhaps dynamically generate the numbers in a macro.  "TO" doesn't
work.

My alternative is to have the user specify in the Production Utility
"123 124 125 126 127", but that can lead to user error.

Hopefully this helps and someone may have some thoughts.  Thanks.

Brandon



-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Kooij, A.J. van der
Sent: Thursday, August 17, 2006 12:14 PM
To: [hidden email]
Subject: Re: Correspondence Analysis Macro

If you use the supplementary subcommand, the supplementary rows and
columns ARE projected in the plots created by CORRESPONDENCE. So, I'm
not sure what exactly you want to do. ?

Regards,
Anita van der Kooij
Data Theory Group
Leiden University.

________________________________

From: SPSSX(r) Discussion on behalf of Brandon Paris
Sent: Thu 17/08/2006 18:31
To: [hidden email]
Subject: Correspondence Analysis Macro



> Hi --
>
> I have a situation where I have run a correspondence analysis on an
> existing data set.  In the future, I will have periodic data that I
> would like to project onto the plots created with the original
> dataset.  I'd like to set this up the syntax so it can be used via the

> SPSS Production Utility.  Here the setup:
>
> *     My original data file has 122 row levels.  The file has one
> record for each row-column combination.  For instance, with 122 row
> items and 20 column items, there would be 2440 records containing 3
> variables -- rownum, columnum, score.
> *     The new data sets that will come in will have varying numbers of
> rows.  One data set may have 5; the next may have 10 or 12.  All
> columns are still the same.
> *     To avoid having empty rows in my output, I do pre-processing on
> the new data to start the row label at 122+1=123.  I then merge the
> new data with the old.
> *     I weight by score, which gives the cell counts when a table
> using rownnum*columnnum is created.
> *     The CORRESPONDENCE procedure has a call (SUPPLEMENTARY) to
> indicate which rows or columns in the data are supplemental to the
> analysis (generate CA positions but don't use them as inputs to the
> CA).
> *     Once CORRESPONDENCE runs, I can use OMS to pull the row points
> table for charting.
>
> Now, here's the issue:
> *     Many people will be using this code, some who are unfamiliar
> with SPSS syntax-- hence the Production Utility.  I want to allow for
> as few mistakes as possible.
> *     Assume I have 5 new products that I want to project onto the
> original map.  I would like to send a command like
>       /SUPPLEMENTARY = rownum(123 124 125 126 127).
> *     I would have the user pass on the number of new products (in
> this case 5) from the Product window.  I then calculate a Macro
> variable of the last rownum index (num rows from original data + num
> rows from new data = 122 + 5 = 127)
> *     THE PROBLEM:  I cannot figure out a way to pass the
> SUPPLEMENTARY rows in a short-list format (or blow out my list in a
> way that handles the dynamic nature of the data from dataset to
> dataset).  Given what I can come up with, I can pass a call like
> /SUPPLEMENTARY = rownum(123 !maxprod), but this only treats rows 123
> and 127 as supplemental rows.  Is there a way to do this in a Macro
> framework?
>
> My other option is to allow the user to pass through a string of
> numbers like @newrows = 123 124 125 126 127 and make the call
> /SUPPLEMENTARY = rownum(@newrows), but this adds room for error.  Does

> anyone have any advice?  The macro portion of my code (minus the
> pre-processing) is below (thanks to Raynald Levesque's website for
> addition using Macro variables trick).
>
> Brandon L. Paris
> Manager, Analytic Innovation
>
> DEFINE !getca ().
>
>   !LET !a = 122 .
>   !LET !b = 5 .
>   !LET !maxprod = !length(!concat(!blanks(!a), !blanks(!b))) .
>
>   CORRESPONDENCE
>     TABLE = rownum(1 !maxrow)  BY colnum(1, 20)
>     /SUPPLEMENTARY = rownum(123,!maxprod)
>     /DIMENSIONS = 2
>     /MEASURE = CHISQ
>     /STANDARDIZE = RCMEAN
>     /NORMALIZATION = SYMMETRICAL
>     /PRINT = TABLE RPOINTS CPOINTS .
> !ENDDEFINE .
>
> OMS
>   /SELECT TABLES
>   /IF COMMANDS = ['Correspondence']
>       SUBTYPES = ['Overview Row Points']
>   /DESTINATION FORMAT=SAV OUTFILE='c:\temp.sav' .
>
> !getca .
>
> OMSEND .
>
>



**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they are
addressed. If you have received this email in error please notify the
system manager.
**********************************************************************