This post was updated on .
I have a linear model like the following:
DV = Var1 + Var2 + … + Var9 + Var10 + E with DV = dependent variable, Var1 to Var10 predictor variables E = error term. Var9 is a dummy variable (0-1) and Var10 is date (time). The effect of Var9 is not constant, but depends on time (V10). That’s why I would like to code the interaction between Var9 and Var10. How can I code the interaction between Var9 and Var10 within a linear model? (as a product of Var9 X Var10 ? – Would that be possible with a dummy variable and a time variable?)
Dr. Frank Gaeth
|
Administrator
|
Frank: Riddle me this.
In what way is this time variable different from any other 'continuous' variable? What characteristics of this variable 'time' would suggest treating it any differently in an analysis? Socrates signing off! --
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
it's about the dummy variable, not the time variable
Dr. Frank Gaeth
|
Administrator
|
Please elaborate! You are maybe over-thinking the issue?
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
because the standardized coefficient (beta) term of the interaction (as a product: dummy X time) varies substantially depending on how the dummy is coded:
(0/1), (1/2), ... . As far as I know, this should not be the case.
Dr. Frank Gaeth
|
In reply to this post by drfg2008
Of course you can code the simple, linear interaction as the product
of the two terms. That would be the way to test whether there is a linear time-effect in one (dummy-indicated) group and not in the other. If there is some other pattern that you expect, the effective contrast would be something that fits the shape of that other pattern. For instance, if you expect an intervention at time 3 to cause a jump, followed by a linear return all the way to baseline, you might model the single degree-of-freedom variable (and coefficient, and test) as a pattern like (0,0, 9,8,7,6,5,4,3,2,1,0) for a time variable scaled from 1 to 12. - Or, you could look with more flexibility by using more than one d.f. for the patterns and testing. - When you have "time" and "varying effect", it makes me wonder if you have time-series data with auto-correlated data, where the usual tests won't automatically apply. -- Rich Ulrich > Date: Tue, 12 Mar 2013 08:24:41 -0700 > From: [hidden email] > Subject: Interaction > To: [hidden email] > > I have a linear model like the following: > > DV = Var1 + Var2 + … + Var9 + Var10 + E > > with DV = dependent variable, > Var1 to Var10 predictor variables. > > Var9 is a dummy variable (0-1) and Var10 is date (time). The effect of Var9 > is not constant, but depends on time (V10). That’s why I would like to > code the interaction between Var9 and Var10. > > How can I code the interaction between Var9 and Var10 within a linear model? > (as a product of Var9 X Var10 ? – Would that be possible with a dummy > variable and a time variable?) > > |
In reply to this post by David Marso
Hi,
I've also wondered about the role of a dummy variable. When you multiply the two predictors together (to get the interaction predictor), a dummy of 0-1 will obviously give the same term (0) for half the entries regardless of the time. Won't this influence the result? If my dummy variable was coded 1-2 then I would expect different results because the impact of time is present for all the observations for all the data points. Mike -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso Sent: 12 March 2013 16:13 To: [hidden email] Subject: Re: Interaction Please elaborate! You are maybe over-thinking the issue? drfg2008 wrote > it's about the dummy variable, not the time variable ----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Interaction-tp5718579p5718582.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 |
In reply to this post by drfg2008
Hi,
Your results will vary. The critical one - in terms of "significance" - will be changing from 0-1 to some other coding. Mike -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of drfg2008 Sent: 12 March 2013 16:38 To: [hidden email] Subject: Re: Interaction because the standardized coefficient (beta) term of the interaction (as a product: dummy X time) varies substantially depending on how the dummy is coded: (0/1), (1/2), ... . As far as I know, this should not be the case. ----- Dr. Frank Gaeth FU-Berlin -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Interaction-tp5718579p5718584.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 |
Administrator
|
In reply to this post by drfg2008
"As far as I know, this should not be the case."
Why? AFAIK the simple correlations would not be at all the same? Can you provide reasoning to suggest otherwise?
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Administrator
|
In reply to this post by MOram
Try the following demo.
NEW FILE. DATASET CLOSE all. * Modify the path on the next line as needed. GET FILE = "C:\SPSSdata\1991 U.S. General Social Survey.sav". descriptives age prestg80. frequencies sex. compute male = (sex EQ 1). compute female = (sex EQ 2). compute AGExSEX = age*sex. compute AGExMALE = age*male. compute AGExFEMALE = age*female. formats male female(f1). * [1] Y = b0 + b1*Age + b2*Sex + b3*Age*Sex. REGRESSION /STATISTICS COEFF OUTS CI(95) R TOL /DEPENDENT prestg80 /METHOD=ENTER age sex AGExSEX /SAVE pred(Yhat1) . * [2] Y = b0 + b1*Age + b2*Male + b3*Age*Male. REGRESSION /STATISTICS COEFF OUTS CI(95) R TOL /DEPENDENT prestg80 /METHOD=ENTER age male AGExMALE /SAVE pred(Yhat2) . * [3] Y = b0 + b1*Age + b2*Female + b3*Age*Female. REGRESSION /STATISTICS COEFF OUTS CI(95) R TOL /DEPENDENT prestg80 /METHOD=ENTER age female AGExFEMALE /SAVE pred(Yhat3) . compute diff12 = Yhat1-Yhat2. compute diff13 = Yhat1-Yhat3. compute diff23 = Yhat2-Yhat3. descriptives diff12 to diff23.
--
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 for the code Bruce.
A good example that I would like - if you don't mind - to incorporate into my teaching of psychology post-grads. Shows the issue: the matrix inverse varies if you code a binary (or multinomial variable) as 0-(n-1) or 1-n. Interesting that the impact is only on the "main effect" of the non-multinomial variable, but then my knowledge of how data structure influences the matrix inverse is not what it should be. Presumably this effect varies according to the relative "n" [i.e. setting more 0's would have a bigger impact on the "main effect"] I wonder how many papers have reported effect ( or no effect) for what I think of as "main effects" where a different result would have been obtained using a different coding of interactions... Is there a way around this issue? Running the analysis with and without the interaction term won't help... Anyone got a solution? Mike -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bruce Weaver Sent: 12 March 2013 18:05 To: [hidden email] Subject: Re: Interaction Try the following demo. NEW FILE. DATASET CLOSE all. * Modify the path on the next line as needed. GET FILE = "C:\SPSSdata\1991 U.S. General Social Survey.sav". descriptives age prestg80. frequencies sex. compute male = (sex EQ 1). compute female = (sex EQ 2). compute AGExSEX = age*sex. compute AGExMALE = age*male. compute AGExFEMALE = age*female. formats male female(f1). * [1] Y = b0 + b1*Age + b2*Sex + b3*Age*Sex. REGRESSION /STATISTICS COEFF OUTS CI(95) R TOL /DEPENDENT prestg80 /METHOD=ENTER age sex AGExSEX /SAVE pred(Yhat1) . * [2] Y = b0 + b1*Age + b2*Male + b3*Age*Male. REGRESSION /STATISTICS COEFF OUTS CI(95) R TOL /DEPENDENT prestg80 /METHOD=ENTER age male AGExMALE /SAVE pred(Yhat2) . * [3] Y = b0 + b1*Age + b2*Female + b3*Age*Female. REGRESSION /STATISTICS COEFF OUTS CI(95) R TOL /DEPENDENT prestg80 /METHOD=ENTER age female AGExFEMALE /SAVE pred(Yhat3) . compute diff12 = Yhat1-Yhat2. compute diff13 = Yhat1-Yhat3. compute diff23 = Yhat2-Yhat3. descriptives diff12 to diff23. Michael Oram wrote > Hi, > > I've also wondered about the role of a dummy variable. > > When you multiply the two predictors together (to get the interaction > predictor), a dummy of 0-1 will obviously give the same term (0) for > half the entries regardless of the time. Won't this influence the > result? If my dummy variable was coded 1-2 then I would expect > different results because the impact of time is present for all the > observations for all the data points. > > Mike > > > -----Original Message----- > From: SPSSX(r) Discussion [mailto: > SPSSX-L@.UGA > ] On Behalf Of David Marso > Sent: 12 March 2013 16:13 > To: > SPSSX-L@.UGA > Subject: Re: Interaction > > Please elaborate! You are maybe over-thinking the issue? > > drfg2008 wrote >> it's about the dummy variable, not the time variable > > > > > > ----- > Please reply to the list and not to my personal email. > Those desiring my consulting or training services please feel free to > email me. > -- > View this message in context: > http://spssx-discussion.1045642.n5.nabble.com/Interaction-tp5718579p57 > 18582.html Sent from the SPSSX Discussion mailing list archive at > Nabble.com. > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (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 > LISTSERV@.UGA > (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 ----- -- Bruce Weaver [hidden email] http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Interaction-tp5718579p5718593.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 |
Banned User
|
I will be out of the office until Wednesday, March 13, 2013, with limited access to email. However, please know that your message is very important
to me and I will respond when I return. Thank you.
Sincerely,
Cheryl _____________________________________________________
Cheryl A. Boglarsky, Ph.D. Human Synergistics, Inc.
39819 Plymouth Road
Plymouth, MI 48170
734.459.1030
This message includes legally privileged and confidential information that is intended only for the use of the recipient named above. All readers
of this message, other than the intended recipient, are hereby notified that any dissemination, modification, distribution or reproduction of this e-mail is strictly forbidden.
|
Administrator
|
In reply to this post by MOram
Hi Mike. Feel free to use the example. See also "Multiple Regression: Testing and Interpreting Interactions", by Aiken & West. IIRC, the way they put it is that the highest order interaction term is invariant to how you scale the variables. Lower order terms are not invariant to scaling.
Note too that what you called "main effects" are not main effects in the ANOVA sense -- i.e., they do not collapse across levels of the other variable. It would be better to call them partial effects. In the models in my example, the coefficient for Age gives the effect of a one-unit increase in age on the fitted value of Y (i.e., the simple slope for age) when the other variable (Sex, Male or Female, depending on which model) is held constant at a value of 0. (Note that 0 is the only value at which Sex/Male/Female can be "held constant" when the product term is in the model, and you increase Age by one unit.) One reason not to use 1-2 coding for Sex in this model is that you get the simple slope for age at an impossible value of Sex. ;-) HTH.
--
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/). |
Administrator
|
I forgot to reply to this:
"Is there a way around this issue? Running the analysis with and without the interaction term won't help... Anyone got a solution? " See the book by Aiken & West -- they discuss this issue extensively. Finally, here's a little bonus syntax for the earlier demo. Take a look at the output from this model, and notice that the Male - Female difference in the first EMMEANS table (with Age = 0) matches the coefficient for Sex=1 in the table of parameter estimates. It also matches the coefficient for Male in the regression model that used Male as the indicator for sex. ;-) UNIANOVA prestg80 BY sex WITH age /METHOD=SSTYPE(3) /INTERCEPT=INCLUDE /PRINT=PARAMETER /EMMEANS=TABLES(sex) WITH(age=0) COMPARE ADJ(LSD) /EMMEANS=TABLES(sex) WITH(age=mean) COMPARE ADJ(LSD) /CRITERIA=ALPHA(.05) /DESIGN=age sex age*sex.
--
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/). |
I was hoping to add to your ANOVA code, but I can't seem to find the data file. Oh well... On Tue, Mar 12, 2013 at 4:18 PM, Bruce Weaver <[hidden email]> wrote: I forgot to reply to this: |
Administrator
|
In reply to this post by MOram
Personally, If I were a student I would find the following exercise to be more meaningful from a AHA/epiphany inducing perspective:
Simply have the students 1. Generate the two sets of coding and the product terms, then algebraically derive the PPM correlations. 2. Discuss: How are the two matrices different and why? 3. Extra credit: Apply the SWEEP operator to each matrix and express the final standardized coefficients in terms of the original correlations. 3b: Read the love letters and hate mail from various students depending upon their level of quantitative aptitude. ---------------------- Conclusions: Indeed the results ARE different and if they ever are identical it is an oddity. --
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
OT: I think I have said this before, but it is probably worth reiterating...In general, I think it would be useful for graduate students in the social sciences to be provided with a comprehensive introduction to probability theory and linear algebra before learning the application of general linear models and beyond.
My humble 2 cents. Ryan On Tue, Mar 12, 2013 at 4:40 PM, David Marso <[hidden email]> wrote: Personally, If I were a student I would find the following exercise to be |
Administrator
|
I concur!!!
Without some background in the basics of probability theory, inferential statistics and linear algebra, GLM is like teaching Greek to a savage. Forget about the rubes who step into such fun as SEM because they love the pretty pictures ;-( "Real Stats real Easy" ==> GIGO ... =================================================================
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
In reply to this post by Rich Ulrich
Yes I do have auto-correlated time series data (lag 1 r~0.6). And I would prefer to use ARIMA models (the time series modeler) to integrate the AR component in the model. The only problem is that I have one predictor variable where I have to estimate the effect in absolute size (i.e. how much revenues were lost due to a certain intervention at a certain time) which is not possible by using the time series modeler (to my knowledge).
Instead, when I use a linear model and code the variable "time" as a set of dummies: year / month / day AND additional as a linear function I can at least model seasonality and trend. Then, by dummy coding the moment of intervention, I thought I could estimate the effect caused by this intervention in absolute size. Is it appropriate to do so ? I still don't know how to integrate the AR component into a linear model (however, the residuals of the linear model are only slightly auto-correlated: lag1 r <.25).
Dr. Frank Gaeth
|
Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: drfg2008 <[hidden email]> To: [hidden email], Date: 03/13/2013 03:44 AM Subject: Re: [SPSSX-L] Interaction Sent by: "SPSSX(r) Discussion" <[hidden email]> Yes I do have auto-correlated time series data (lag 1 r~0.6). And I would prefer to use ARIMA models (the time series modeler) to integrate the AR component in the model. The only problem is that I have one predictor variable where I have to estimate the effect in absolute size (i.e. how much revenues were lost due to a certain intervention at a certain time) which is not possible by using the time series modeler (to my knowledge). >>>Why not? The Expert Modeler allows for independent variables. Instead, when I use a linear model and code the variable "time" as a set of dummies: year / month / day AND additional as a linear function I can at least model seasonality and trend. Then, by dummy coding the moment of intervention, I thought I could estimate the effect caused by this intervention in absolute size. Is it appropriate to do so ? I still don't know how to integrate the AR component into a linear model (however, the residuals of the linear model are only slightly auto-correlated: lag1 r <.25). >>>If you are including lags of the dependent variable as predictors, the coefficients are biased, and the model will soak up error autocorrelations, so looking at residual autocorrelation in that setup tells you nothing. ----- Dr. Frank Gaeth FU-Berlin -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Interaction-tp5718579p5718609.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 |
Free forum by Nabble | Edit this page |