|
Simple question. Does anyone have an example of syntax for effect coding? I have one variable with five categories that I need to recode using effect coding.
Thanks, Courtney Courtney Cronley, Ph.D. Postdoctoral Associate Center of Alcohol Studies Rutgers University [hidden email] ===================== 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 |
|
You just need four indicators. For each one, group 5 is coded -1. For the first, group 1 is coded 1 and groups 2-4 are coded 0, the second is coded 1 for group 2 and 0 for groups 1, 3 and 4, the third is coded 1 for group 3 and 0 for groups 1, 2, and 4, and the last is coded 1 for group 4 and 0 for groups 1-3.
Dr. Paul R. Swank, Professor and Director of Research Children's Learning Institute University of Texas Health Science Center-Houston -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Courtney M. Cronley Sent: Wednesday, May 26, 2010 1:00 PM To: [hidden email] Subject: Effect Coding Syntax Simple question. Does anyone have an example of syntax for effect coding? I have one variable with five categories that I need to recode using effect coding. Thanks, Courtney Courtney Cronley, Ph.D. Postdoctoral Associate Center of Alcohol Studies Rutgers University [hidden email] ===================== 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 |
|
In reply to this post by Courtney M. Cronley
See Elazar Pedhazur's (1997) Multiple Regression in
Behavioral Research (3rd Ed), pp360-363 where he explains what effects coding is, provides sample SPSS instructions, and a worked example. Then again, most multple regression texts should have a section on the different types of coding, how to implement them, and interpret the resulting analysis. -Mike Palij New York University [hidden email] ----- Original Message ----- From: "Courtney M. Cronley" <[hidden email]> To: <[hidden email]> Sent: Wednesday, May 26, 2010 1:59 PM Subject: Effect Coding Syntax > Simple question. Does anyone have an example of syntax for effect coding? I have one variable with five categories that I need to recode using effect coding. > > Thanks, > > Courtney > > Courtney Cronley, Ph.D. > Postdoctoral Associate > Center of Alcohol Studies > Rutgers University > [hidden email] > > ===================== > 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 |
|
In reply to this post by Courtney M. Cronley
Hi Courtney,
This is my favorite way to do this in syntax (I did not test this code, but use this often). There are others as well. COMPUTE married_yn = marital_status = 1. COMPUTE single_yn = marital_status = 2. COMPUTE divorced_yn = marital_status = 3. etc. HTH, Keith www.keithmccormick.com On Wed, May 26, 2010 at 1:59 PM, Courtney M. Cronley <[hidden email]> wrote: Simple question. Does anyone have an example of syntax for effect coding? I have one variable with five categories that I need to recode using effect coding. |
|
My apologies. I read the post too quickly. I provided a syntax example for dummy coding.
On Wed, May 26, 2010 at 2:52 PM, Keith McCormick <[hidden email]> wrote: Hi Courtney, |
|
Administrator
|
In reply to this post by Swank, Paul R
A DO-REPEAT works pretty well for carrying out Paul's instructions. E.g.,
data list free / group (f2.0). begin data 1 2 3 4 5 end data . numeric ec1 to ec4 (f2.0). do repeat v = ec1 to ec4 / g = 1 to 4 . - compute v = (group EQ g). - if (group EQ 5) v = -1. end repeat. list. Output: group ec1 ec2 ec3 ec4 1 1 0 0 0 2 0 1 0 0 3 0 0 1 0 4 0 0 0 1 5 -1 -1 -1 -1 Number of cases read: 5 Number of cases listed: 5
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
|
Hello, I have a file that includes multiple rows for the same id but
sometimes these rows are legitimate (two different values for variable A) and sometimes they are "true" duplicates (one row entered twice by mistake - the same id and the same values of variable A). I would like to do something like this: If (id=lag(id) and A=lag(A)) then delete one of these two rows. Could someone help me to write such syntax? Thanks so much. Bozena Bozena Zdaniuk, Ph.D. Human Early Learning Partnership (HELP) College for Interdisciplinary Studies UBC - UVic - SFU - UNBC - TRU - UBCO 440 - 2206 East Mall, Vancouver BC V6T 1Z3 Tel: 604-827-5552 / Fax: 604-822-0640 www.earlylearning.ubc.ca ===================== 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 |
|
If a 'true' duplicate is defined by duplicate values for id and A then
pointing and clicking: Data -> Identify Duplicate Cases -> Define Matching Cases by both of those variables, and paste your syntax. Then just select cases where the newly created variable PrimaryLast = 1. Hth, matt Matthew Pirritano, Ph.D. Research Analyst IV Medical Services Initiative (MSI) Orange County Health Care Agency (714) 568-5648 -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bozena Zdaniuk Sent: Wednesday, May 26, 2010 4:10 PM To: [hidden email] Subject: Deleting true duplicates Hello, I have a file that includes multiple rows for the same id but sometimes these rows are legitimate (two different values for variable A) and sometimes they are "true" duplicates (one row entered twice by mistake - the same id and the same values of variable A). I would like to do something like this: If (id=lag(id) and A=lag(A)) then delete one of these two rows. Could someone help me to write such syntax? Thanks so much. Bozena Bozena Zdaniuk, Ph.D. Human Early Learning Partnership (HELP) College for Interdisciplinary Studies UBC - UVic - SFU - UNBC - TRU - UBCO 440 - 2206 East Mall, Vancouver BC V6T 1Z3 Tel: 604-827-5552 / Fax: 604-822-0640 www.earlylearning.ubc.ca ===================== 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 |
|
Of course! Can't believe I did not think about it. Thanks so much, Matt.
Bozena Bozena Zdaniuk, Ph.D. Human Early Learning Partnership (HELP) College for Interdisciplinary Studies UBC - UVic - SFU - UNBC - TRU - UBCO 440 - 2206 East Mall, Vancouver BC V6T 1Z3 Tel: 604-827-5552 / Fax: 604-822-0640 www.earlylearning.ubc.ca -----Original Message----- From: Pirritano, Matthew [mailto:[hidden email]] Sent: Wednesday, May 26, 2010 4:21 PM To: [hidden email] Subject: Re: Deleting true duplicates If a 'true' duplicate is defined by duplicate values for id and A then pointing and clicking: Data -> Identify Duplicate Cases -> Define Matching Cases by both of those variables, and paste your syntax. Then just select cases where the newly created variable PrimaryLast = 1. Hth, matt Matthew Pirritano, Ph.D. Research Analyst IV Medical Services Initiative (MSI) Orange County Health Care Agency (714) 568-5648 -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bozena Zdaniuk Sent: Wednesday, May 26, 2010 4:10 PM To: [hidden email] Subject: Deleting true duplicates Hello, I have a file that includes multiple rows for the same id but sometimes these rows are legitimate (two different values for variable A) and sometimes they are "true" duplicates (one row entered twice by mistake - the same id and the same values of variable A). I would like to do something like this: If (id=lag(id) and A=lag(A)) then delete one of these two rows. Could someone help me to write such syntax? Thanks so much. Bozena Bozena Zdaniuk, Ph.D. Human Early Learning Partnership (HELP) College for Interdisciplinary Studies UBC - UVic - SFU - UNBC - TRU - UBCO 440 - 2206 East Mall, Vancouver BC V6T 1Z3 Tel: 604-827-5552 / Fax: 604-822-0640 www.earlylearning.ubc.ca ===================== 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 ===================== 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 |
|
In reply to this post by Mike
Hello Courtney
Here is some example syntax (untested)
COMPUTE G1=0. COMPUTE G2=0. COMPUTE G3=0. COMPUTE G4=0. IF GROUP=1 G1=1. IF GROUP=2 G2=1. IF GROUP=3 G3=1. IF GROUP=4 G4=1. DO IF GROUP=5. RECODE G1 TO G4 (0=-1). END IF. Hope this helps Tim
----- Original Message ----- From: "Courtney M. Cronley" <[hidden email]> To: <[hidden email]> Sent: Wednesday, May 26, 2010 1:59 PM Subject: Effect Coding Syntax > Simple question. Does anyone have an example of syntax for effect coding? I have one variable with five categories that I need to recode using effect coding. > > Thanks, > > Courtney > > Courtney Cronley, Ph.D. > Postdoctoral Associate > Center of Alcohol Studies > Rutgers University > [hidden email] > > ===================== > 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 |
|
Administrator
|
Tim, notice what happens on a case where GROUP is missing: Your G1 to G4 variables all take values of 0, whereas they should be missing. E.g., in the following output, 9 is a missing value for GROUP:
group G1 G2 G3 G4 1 1 0 0 0 2 0 1 0 0 3 0 0 1 0 4 0 0 0 1 5 -1 -1 -1 -1 9 0 0 0 0 To fix that problem, change: COMPUTE G1=0. COMPUTE G2=0. COMPUTE G3=0. COMPUTE G4=0. IF GROUP=1 G1=1. IF GROUP=2 G2=1. IF GROUP=3 G3=1. IF GROUP=4 G4=1. to: COMPUTE G1= (GROUP EQ 1). COMPUTE G2= (GROUP EQ 2). COMPUTE G3= (GROUP EQ 3). COMPUTE G4= (GROUP EQ 4). Notice that this is what I did in the DO-REPEAT solution I posted earlier: numeric ec1 to ec4 (f2.0). do repeat v = ec1 to ec4 / g = 1 to 4 . - compute v = (group EQ g). /* <-------- RIGHT HERE! . - if (group EQ 5) v = -1. end repeat. The (group EQ g) expression is evaluated. If it is TRUE, v is set to 1; if it is FALSE, v is set to 0. And crucially, if GROUP is missing, v is also missing. Here is the output from my revision to your approach, and from the DO-REPEAT method: group G1 G2 G3 G4 ec1 ec2 ec3 ec4 1 1 0 0 0 1 0 0 0 2 0 1 0 0 0 1 0 0 3 0 0 1 0 0 0 1 0 4 0 0 0 1 0 0 0 1 5 -1 -1 -1 -1 -1 -1 -1 -1 9 . . . . . . . . Now when GROUP is missing, so are the variables used for effect coding, as they should be.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
|
Thanks Bruce, that's really helpful! Courtney - use the code that Bruce posted! From: SPSSX(r) Discussion on behalf of Bruce Weaver Sent: Thu 27/05/2010 1:41 PM To: [hidden email] Subject: Re: Effect Coding Syntax Tim, notice what happens on a case where GROUP is missing: Your G1 to G4 |
| Free forum by Nabble | Edit this page |
