[R] glm link = logit, passing arguments
Mäkinen Jussi
Jussi.Makinen at valtiokonttori.fi
Mon Apr 15 14:58:10 CEST 2002
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).
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 ...) ###
Same apply to the mustart
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:
Call: glm(formula = as.matrix(y) ~ as.matrix(X), family = binomial(link =
logit), control = glm.control(epsilon = 1e-04, maxit = 1000), intercept
= FALSE, TRACE = TRUE)
Coefficients:
(Intercept) as.matrix(X)due14 as.matrix(X)due45 as.matrix(X)due90
-22.05 -305.47 -283.72 -144.07
Degrees of Freedom: 7775 Total (i.e. Null); 7772 Residual
Null Deviance: 7959
Residual Deviance: 3.589e-06 AIC: 8
Warning message:
fitted probabilities numerically 0 or 1 occurred in: (if
(is.empty.model(mt)) glm.fit.null else glm.fit)(x = X, y = Y,
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?
The estimation process seems to have hard times (because of myriad of 0s, I
guess) with data and it is not able to reach convergence (even after maxit =
1000). Is there any other estimation methods available in the R-packages? Or
would you have any other idea to transform data a prior to make it possible.
Making explanatory also binary seems to be a remedy but that's something I
do not want to do (and I'm not sure is it even statistically correct way).
I have a binary response variable y: 0 1 1 1 1 1 1 0 0 0 (a sample)
and a matrix of continous (but includin a lot of zeros) explanatory
variables X1, X2, X3:
X1, X2, X3
198 0.0045861625 0.001717838 0.0000000
199 0.0000000000 0.000000000 -0.9992498
200 0.0000000000 0.000000000 -0.9988129
201 0.0000000000 0.000000000 -0.9984882
202 0.0000000000 0.000000000 -0.9983429
203 0.0000000000 0.000000000 -0.9980252
204 0.0003933059 0.000000000 -0.9980207
205 0.0000000000 0.000000000 0.0000000
206 0.0000000000 0.000000000 0.0000000
207 0.0000000000 0.000000000 0.0000000
version
_
platform i386-pc-mingw32
arch x86
os Win32
system x86, Win32
status
major 1
minor 4.1
year 2002
month 01
day 30
language R
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).
Regards and thank you for sharing your knowledge,
Jussi Makinen
Analyst
State Treasure of Finland
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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