roger koenker wrote:
Thanks. Yes, I wrote rqss, and attempted to follow the structure of lm, and various analogues, for example in survival4. My problem seems to be that my lam variable is not part of the data frame d, and I don't know how to manipulate the environment for the formula
so that it is found.  There is an untangle.specials() call

    tmpc <- untangle.specials(Terms, "qss")

and then each of the "specials"  terms are evaluated in:

    qss <- lapply(tmpc$vars, function(u) eval(parse(text = u), data))

which is fine if the data hasn't been specified so it defaults to parent.frame(), since in
this case variables and lam can all be found in the parent.frame,  but if
it is specified as a data frame for the variables of the model, then the lam value is unavailable. My impression is that it is somewhat unusual to pass data other than variables from the data frame itself for evaluation of the formula -- I thought there were examples in mgcv, but I now see that lamdas in gam() are passed as separate arguments, rather than in the special components of the formula. Perhaps I need to revert to this strategy, but I'd prefer not to. Surely, there is some good way to modify the above lapply so that eval finds both stuff in data and in the parent.frame? It appears that I can simply define pf <- parent.frame() and then add enclos = pf
to the above eval() call,  is this ok?

I think more likely you want enclos=environment(formula). This is the point, the formula-with-environment construction allows both

h <- function(x,y) mymodel(y~x)
h(u,v)

and

h <- function(f) mymodel(f)
h(u~v)

to find  their variables in the right place.




--
   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalga...@biostat.ku.dk)              FAX: (+45) 35327907

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to