RE: [R] Problem with systemfit 0.7-3 and transformed variables

From: John Fox <jfox_at_mcmaster.ca>
Date: Wed 25 May 2005 - 22:54:20 EST


Dear Mikko,

You might try the tsls function in the sem package (which also does 2SLS).

Regards,
 John



John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox

> -----Original Message-----
> From: r-help-bounces@stat.math.ethz.ch
> [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Mikko Pakkanen
> Sent: Wednesday, May 25, 2005 4:43 AM
> To: r-help@stat.math.ethz.ch
> Subject: [R] Problem with systemfit 0.7-3 and transformed variables
>
> The 'systemfit' function in systemfit 0.7-3 CRAN package
> seems to have a problem with formulas that contain
> transformed (eg. log) variables. If I have my data in a data
> frame, apparently systemfit doesn't "pass" the information of
> where the variables should be taken to the transforming function.
>
> I'm not entirely sure if this is a bug or just a limitation,
> I was just surprised when I attempted to estimate a model,
> which I'd previously estimated with OLS using 'lm', with 2SLS
> using 'systemfit' and it didn't accept those transformations
> like 'lm' does.
>
> Here's an example: this is, of course, OK:
>
> > data(kmenta)
> > demand <- q ~ p + d
> > instr <- ~ d + f
> > fit1 <- systemfit("2SLS", eqns=list(demand), inst=instr,
> data=kmenta)
>
> But, now if I'd like to estimate a model with logarithm of p
> as a regressor, an error occurs:
>
> > demand2 <- q ~ log(p) + d
> > fit2 <- systemfit("2SLS", eqns=list(demand2), inst=instr,
> data=kmenta)
> Error in log(p) : Object "p" not found
>
> However, estimating the same formula with OLS using the
> regular 'lm' is OK:
> > fit2.ols <- lm(demand2, kmenta)
>
> Transforming an instrument causes the same error too:
>
> > instr2 <- ~ log(d) + f
> > fit3 <- systemfit("2SLS", eqns=list(demand), inst=instr2,
> data=kmenta)
> Error in log(d) : Object "d" not found
>
> One could certainly just create those transformed variables
> to avoid the problem, but it would be much more convenient,
> if it wasn't necessary, especially if several regressors are involved.
>
> > version
> _
> platform i386-pc-mingw32
> arch i386
> os mingw32
> system i386, mingw32
> status
> major 2
> minor 1.0
> year 2005
> month 04
> day 18
> language R
>
> Regards,
>
> -Mikko Pakkanen
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed May 25 23:23:36 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:05 EST