[R] glm link = logit, passing arguments

Thomas Lumley tlumley at u.washington.edu
Mon Apr 15 17:11:45 CEST 2002


On Mon, 15 Apr 2002, [iso-8859-1] Mäkinen Jussi wrote:

> Hello R-users.
>
> I haven't use R for a life time and this might be trivial - I hope you do
> not mind.
>
> I have a  questions about arguments in the Glm-function. There seems to be
> something that I cannot cope.
>
> The basics are ok:
> > y <- as.double(rnorm(20) > .5)
> >  logit.model <- glm(y ~ rnorm(20), family=binomial(link=logit), trace =
> TRUE)
> Deviance = 28.34255 Iterations - 1
> Deviance = 27.72554 Iterations - 2
> Deviance = 27.72527 Iterations - 3
> Warning message:
> non-integer #successes in a binomial glm! in: eval(expr, envir, enclos).

Even this isn't ideal -- if your data are really binomial it would be
better to pass them as a number of successes and failures, if they aren't
really binomial then family=quasibinomial() would probably be better.

> But trying to exclude intercept (or pass anything to glm.fit, especially
> mustart to improve convergence if I have understand the role of mustart
> correctly):
>
> glm(as.matrix(y) ~ as.matrix(X), family=binomial(link=logit), intercept =
> FALSE, TRACE = TRUE)
>
> seems not to be a correct since it returns:
>
> Error in glm.control(...) : unused argument(s) (intercept ...)		###

That's because intercept is not one of the arguments that glm() takes. You
can fit a model without intercept by using  y~x+0 or y~x-1 as the formula.

> Same apply to the mustart

Yes, there is no mustart argument to glm() either.

> But using instead
>
> glm(as.matrix(y) ~ as.matrix(X), family=binomial(link=logit), intercept =
> FALSE, TRACE = TRUE,
> 			control = glm.control(epsilon=1e-04, maxit = 1000))
>
> yields:
>
<snipped>

> which seems to work without explicite errors. For me its a little strange
> that including an argument does help to pass an other one. But trace doesn't
> show anything and also intercept is still included eventhough intercept =
> FALSE is set up (probably unwisely but the judgement should here be users I
> think). Obviously there is something wrong with my arguments passing. Is it
> alright to try to pass arguments to glm.fit at all?
>

No. If you want to call glm.fit() you have to call it directly. If you
look at the code for glm() you can see that it doesn't pass the ...
arguments to glm.fit.

The ... argument is passed to glm.control() if there is no explicit
glm.control= argument -- that's what caused the error and why it went away
when you supplied the glm.control argument.  Otherwise it's there for
future expansion.

>
> One more basic question crossed my mind - is this iterative weighted OLS
> with a link function practically same than Maximum Likelihood estimation
> which I would like to use? Can you recommend any reference to the
> probit/Logit within R/Splus (other than Modern Applied Statistics with
> S-PLUS which is in my list anyway).

It is exactly maximum likelihood.

	-thomas

Thomas Lumley			Asst. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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