Richard Asturia
2013-Mar-05 21:52 UTC
[R] Issues when using interaction term with a lagged variable
Hi there! Today I tried to estimate models using both plm and pgmm functions, with an interaction between X1 and lag(X2, 1). And I notice two issues. Let "Y=b_1 * X_1 + b_2 * X_2 + b_3 * X_1 * x_2 + e" be our model. 1) When using plm, I got different results when I coded the interaction term with I(X1 * lag(X2, 1)) and when I just saved this multiplication X1 * lag(X2, 1) in a different variable of the dataset and then used it. in the regression. 2) With pgmm it is not even possible to run a formula which contains I(X1 * lag(X2, 1)). How can I pass such interaction? Thanks in advance for your time! [[alternative HTML version deleted]]
Richard Asturia
2013-Mar-05 23:54 UTC
[R] Issues when using interaction term with a lagged variable
Actually, the problem number 2 is easy to solve: instead of using I(X1 * lag(X2,1)), one should use X1:lag(X2,1). It works. The issue number 1 remains, though. And also affects this solution for number 2. It means: results are different with one uses X1:lag(X2,1) whithin the formula or uses a new variable previouysly created with X1*lag(X2,1). Any insights here would be very hepful. 2013/3/5 Richard Asturia <richard.asturia@gmail.com>> Hi there! > > Today I tried to estimate models using both plm and pgmm functions, with > an interaction between X1 and lag(X2, 1). And I notice two issues. > > Let "Y=b_1 * X_1 + b_2 * X_2 + b_3 * X_1 * x_2 + e" be our model. > > 1) When using plm, I got different results when I coded the interaction > term with I(X1 * lag(X2, 1)) and when I just saved this multiplication X1 * > lag(X2, 1) in a different variable of the dataset and then used it. in the > regression. > > 2) With pgmm it is not even possible to run a formula which contains I(X1 > * lag(X2, 1)). How can I pass such interaction? > > Thanks in advance for your time! >[[alternative HTML version deleted]]
Millo Giovanni
2013-Mar-06 13:58 UTC
[R] Issues when using interaction term with a lagged variable
Hello. It is impossible to be of any real help w/o a reproducible example (see the Posting Guide). One guess might be that the data be a regular data.frame, so that outside the model lag() calls lag.default(), whose behaviour is different from lag.pseries(). Always better to do things inside formulas. Best wishes Giovanni Giovanni Millo, PhD Research Dept., Assicurazioni Generali SpA Via Machiavelli 3, 34132 Trieste (Italy) tel. +39 040 671184 fax +39 040 671160 --------------- original message --------------- Message: 58 Date: Tue, 5 Mar 2013 20:54:25 -0300 From: Richard Asturia <richard.asturia at gmail.com> To: r-help at r-project.org Subject: Re: [R] Issues when using interaction term with a lagged variable Message-ID: <CA+xNL7owdy=YxR_Z24acb8XnWsYdASnmHm8FDEGNsVRbVnQrag at mail.gmail.com> Content-Type: text/plain Actually, the problem number 2 is easy to solve: instead of using I(X1 * lag(X2,1)), one should use X1:lag(X2,1). It works. The issue number 1 remains, though. And also affects this solution for number 2. It means: results are different with one uses X1:lag(X2,1) whithin the formula or uses a new variable previouysly created with X1*lag(X2,1). Any insights here would be very hepful. 2013/3/5 Richard Asturia <richard.asturia at gmail.com>> Hi there! > > Today I tried to estimate models using both plm and pgmm functions,with> an interaction between X1 and lag(X2, 1). And I notice two issues. > > Let "Y=b_1 * X_1 + b_2 * X_2 + b_3 * X_1 * x_2 + e" be our model. > > 1) When using plm, I got different results when I coded theinteraction> term with I(X1 * lag(X2, 1)) and when I just saved this multiplicationX1 *> lag(X2, 1) in a different variable of the dataset and then used it. inthe> regression. > > 2) With pgmm it is not even possible to run a formula which containsI(X1> * lag(X2, 1)). How can I pass such interaction? > > Thanks in advance for your time! >------------- end original message ------------- ? Ai sensi del D.Lgs. 196/2003 si precisa che le informazi...{{dropped:12}}