glim in R?
Great suggestions, and it looks like either suggestion should work, although the output from glm may not conform to those from glim, thus some more code there perhaps. Many thanks, Tim ---- Original message ----
Date: Mon, 15 Nov 2004 14:28:50 -0400 (AST) From: Rolf Turner <rolf at math.unb.ca> Subject: Re: [R] glim in R? To: tfliao at uiuc.edu Cc: r-help at stat.math.ethz.ch Tim Liao wrote:
After some futile searches, I decided to ask the list to
see if any
of the sages out there would have an answer: I have a function I wrote a few years ago in S, which
calls glim
numerous times. I'd like to port it to R, but glm works
differently
from glim, which takes as part of its input an X design
matrix. I
probably could write a function to convert glim to glm,
but hope this
wouldn't be necessary...
I doubt that you will get any joy in locating a glim()
function for
R. No-one would write one; that would be wheel-re-
invention given the
existence of glm(). The glim() function is antiquated and is or should be
deprecated.
The technology has moved beyond that. What you really
should do is
re-write your code to call glm(). If it is ***really*** necessary to pass the design matrix,
you should
be able to o convert that matrix to a data frame, say ``ddd'' o call glm(formula,data=ddd) o the formula would presumably be simply something like ``y ~ .'' since the predictors would simply be all of the individual columns of your data
frame.
I can't see this as being particularly difficult recoding.
Or if you
insist, you could do just create your glim() function as:
glim <- function(y,X,...) {
X <- as.data.frame(X)
glm(y~.,data=X,...)
}
(I can't really remember the glim syntax, but ``glim
(y,X,...)'' is
a reasonable facsimile.) If your design matrix has a constant column you would want
to strip
it out before passing the matrix to you glim() function. cheers, Rolf Turner rolf at math.unb.ca