This post was updated on .
Dear all, I try to conduct a SEM / two stage least squares regression with the following equations:
First: X = IV1 + IV2 * Y Second: Y = a + b X therein, IV1 and IV2 are the two instruments I would like to use. the structure I would like to maintain as the model is derived from economic theory. My problem here is that I have trouble solving the equations to get the reduced form so I can run the tsls function of the gmm package (or just run two regressions using the lm funcation) Has anybody encountered a similar problem yet? The regular text books such as Wooldridge, Greene, or Stock and Watson are not much help here. Thanks and kind regards HC 
On Sun, 23 Jun 2013, hck wrote:
> Dear all, I try to conduct a SEM / two stage least squares regression with > the following equations: See ivreg() in package "AER" or tsls() in "sem". hth, Z > First: X ~ IV1 + IV2 * Y > Second: Y ~ a + b X > > therein, IV1 and IV2 are the two instruments I would like to use. the > structure I would like to maintain as the model is derived from economic > theory. My problem here is that I have trouble solving the equations to get > the reduced form so I can run the tsls function of the gmm package (or just > run two regressions using the lm funcation) > > Has anybody encountered a similar problem yet? The regular text books such > as Wooldridge, Greene, or Stock and Watson are not much help here. > > Thanks and kind regards > HC > > > >  > View this message in context: http://r.789695.n4.nabble.com/2SLSTSLSSEMnonlineartp4670123.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/rhelp > PLEASE do read the posting guide http://www.Rproject.org/postingguide.html > and provide commented, minimal, selfcontained, reproducible code. > ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/rhelp PLEASE do read the posting guide http://www.Rproject.org/postingguide.html and provide commented, minimal, selfcontained, reproducible code. 
The challenge is to firstly calculate the reduced form. As far as I know, the SEM package does not do this automatically. Am I correct?

Dear HansChristian
> Original Message > From: [hidden email] [mailto:rhelpbounces@r > project.org] On Behalf Of hck > Sent: Saturday, June 29, 2013 11:19 AM > To: [hidden email] > Subject: Re: [R] 2SLS / TSLS / SEM nonlinear > > The challenge is to firstly calculate the reduced form. As far as I > know, the > SEM package does not do this automatically. Am I correct? > Right. If you look at the code in sem:::tsls.default, you'll see that it formulates and solves the 2SLS estimating equations directly (using a Cholesky decomposition). Moreover, tsls() is for linear structural equations. Best, John  John Fox Senator McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada > > > > >  > View this message in context: http://r.789695.n4.nabble.com/2SLSTSLS > SEMnonlineartp4670123p4670595.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/rhelp > PLEASE do read the posting guide http://www.Rproject.org/posting > guide.html > and provide commented, minimal, selfcontained, reproducible code. ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/rhelp PLEASE do read the posting guide http://www.Rproject.org/postingguide.html and provide commented, minimal, selfcontained, reproducible code. 
Please consider using the R package systemfit. It has existed for about 10
years, I've used it many times happily :) I've not used gmm package, I'm not criticizing it. But I have good results from systemfit. It has good documentation. "This package contains functions for fitting simultaneous systems of linear and nonlinear equations using Ordinary Least Squares (OLS), Weighted Least Squares (WLS), Seemingly Unrelated Regressions (SUR), TwoStage Least Squares (2SLS), Weighted TwoStage Least Squares (W2SLS), and ThreeStage Least Squares (3SLS)." If that doesn't work for you, please show us your example code, along with the error messages. On Sat, Jun 29, 2013 at 11:18 AM, John Fox <[hidden email]> wrote: > Dear HansChristian > > > Original Message > > From: [hidden email] [mailto:rhelpbounces@r > > project.org] On Behalf Of hck > > Sent: Saturday, June 29, 2013 11:19 AM > > To: [hidden email] > > Subject: Re: [R] 2SLS / TSLS / SEM nonlinear > > > > The challenge is to firstly calculate the reduced form. As far as I > > know, the > > SEM package does not do this automatically. Am I correct? > > > > Right. If you look at the code in sem:::tsls.default, you'll see that it > formulates and solves the 2SLS estimating equations directly (using a > Cholesky decomposition). Moreover, tsls() is for linear structural > equations. > > Best, > John > >  > John Fox > Senator McMaster Professor of Social Statistics > Department of Sociology > McMaster University > Hamilton, Ontario, Canada > > > > > > > > > > > >  > > View this message in context: http://r.789695.n4.nabble.com/2SLSTSLS > > SEMnonlineartp4670123p4670595.html > > Sent from the R help mailing list archive at Nabble.com. > > > > ______________________________________________ > > [hidden email] mailing list > > https://stat.ethz.ch/mailman/listinfo/rhelp > > PLEASE do read the posting guide http://www.Rproject.org/posting > > guide.html > > and provide commented, minimal, selfcontained, reproducible code. > > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/rhelp > PLEASE do read the posting guide > http://www.Rproject.org/postingguide.html > and provide commented, minimal, selfcontained, reproducible code. >  Paul E. Johnson Professor, Political Science Assoc. Director 1541 Lilac Lane, Room 504 Center for Research Methods University of Kansas University of Kansas http://pj.freefaculty.org http://quant.ku.edu [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/rhelp PLEASE do read the posting guide http://www.Rproject.org/postingguide.html and provide commented, minimal, selfcontained, reproducible code. 
Thank you John and Paul,
I started having a look into the systemfit. Basically, my two equations are: 1. Y = IV1 + IV2 x X 2. Y = a + b x X + u where Y and X are the two endogenous variables, IV1 and IV2 are the instruments, and u is the error term. 
Dear HC
On 30 Jun 2013 13:02, "hck" <[hidden email]> wrote: > I started having a look into the systemfit. > > Basically, my two equations are: > > 1. Y = IV1 + IV2 x X > 2. Y = a + b x X + u > > where Y and X are the two endogenous variables, IV1 and IV2 are the > instruments, and u is the error term. I do not understand your model specification. In your first equation IV1 and IV2 look like parameters. Is your model perhaps: Y = a + b x X + u X = c + d x IV1 + e x IV2 + v with a, b, c, d, and e being parameters and u and v being disturbance terms? Best wishes, Arne [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/rhelp PLEASE do read the posting guide http://www.Rproject.org/postingguide.html and provide commented, minimal, selfcontained, reproducible code. 
Dear Arne
Generally I would have the following equations X_i = IV3_i + IV4_i * Y_i applying for every company (i). In a first step, I am interested in estimating the relationship between X and Y: Y_i = a + b * X_i + u to ultimatly estimate X_i by substituting the Y_i and solving for X_i to be able to estimate the X_i by just IV3_i, IV4_i, and the a and b. Now, let's construct values from a sample of listed companies. In the capital market, I can observe IV3_i, IV4_i, and X_i. With these I calculate Y_i: Y_i = IV1_i + IV2_i * X_i (note: IV3 and IV4 are just a transformation of IV1 and IV2). Of course, I could rewrite this equation as Y_i = c + d * IV1_i + e * IV2_i * X_i + v. For a couple of observations, I have now combinations of X_i and Y_i to get the a and b coefficient by estimating Y_i = a + b * X_i + u. I hope the structure is more clear to you now. Let me know. I am looking very much forward to your answer. Best HC 
Dear HC
On 30 June 2013 18:53, hck <[hidden email]> wrote: > Generally I would have the following equations X_i = IV3_i + IV4_i * Y_i > applying for every company (i). In a first step, I am interested in > estimating the relationship between X and Y: Y_i = a + b * X_i + u to > ultimatly estimate X_i by substituting the Y_i and solving for X_i to be > able to estimate the X_i by just IV3_i, IV4_i, and the a and b. > > Now, let's construct values from a sample of listed companies. In the > capital market, I can observe IV3_i, IV4_i, and X_i. With these I calculate > Y_i: Y_i = IV1_i + IV2_i * X_i (note: IV3 and IV4 are just a transformation > of IV1 and IV2). Of course, I could rewrite this equation as Y_i = c + d * > IV1_i + e * IV2_i * X_i + v. For a couple of observations, I have now > combinations of X_i and Y_i to get the a and b coefficient by estimating Y_i > = a + b * X_i + u. It seems to me that this estimation is very simple: myModel < lm( Y ~ X ) but perhaps I did not completely understand your model specification. Best, Arne  Arne Henningsen http://www.arnehenningsen.name ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/rhelp PLEASE do read the posting guide http://www.Rproject.org/postingguide.html and provide commented, minimal, selfcontained, reproducible code. 
Free forum by Nabble  Edit this page 