[R] limited formula length in tsls
Prof Brian D Ripley
ripley at stats.ox.ac.uk
Thu Aug 23 08:53:59 CEST 2001
On Wed, 22 Aug 2001, John Fox wrote:
> Dear Zsombor,
>
> I believe that tsls.formula is from my sem package. What you list as the
> "original source" and your modified version appear to be reversed.
The `tsls package' had me confused ...
> The reason that the original version manipulates (somewhat awkwardly) the
> model and instrumental-variables formulas in character form to produce a
> combined formula is to insure that missing data get treated consistently;
> this will not be the case, I believe, in your modified version. (I note, by
> the way, that you seem to have added a function for weighted two-stage
> least-squares estimation.)
>
> The source of the problem appears to be that when model formulas are
> translated into character, the right-hand-side of the model gets truncated
> at (I think) 68 characters. Consider the following example:
>
> > mod <- this ~ is + a + very + long + formula + with + a + very + large +
> number + of + characters
> > mod
> this ~ is + a + very + long + formula + with + a + very + large +
> number + of + characters
> > as.character(mod)
> [1] "~"
> [2] "this"
> [3] "is + a + very + long + formula + with + a + very + large + number + "
> >
>
> Clearly, the current situation is unsatisfactory, but it's unclear to me
> what the best course of action is. A more elegant approach to treating the
> model formula and instruments consistently would solve the problem, but
> as.character should probably not truncate formulas.
as.character is not the best tool for formulae. Use deparse:
> deparse(mod)
[1] "this ~ is + a + very + long + formula + with + a + very + large + "
[2] " number + of + characters"
say via
paste(deparse(mod, 500), collapse="")
which will cope with arbitrary long formulae.
The cutoff limit is 500, and a trivial change to the internals of
as.character (which I have just made for 1.3.1) increases the cutoff from
60 to 500. Nevertheless. paste(deparse(mod, 500), collapse="") remains
better.
[...]
Brian
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list