On Aug 20, 2010, at 8:25 AM, Iasonas Lamprianou wrote:
Thanks, I'll try to put my hands on the reference
By the way, would it be easier if I just checked out the code by
which the glm function computes the residuals? Or maybe this is not
a very good idea. And if it is, how can I check out the source, I
never really found out!
the glm functions calls glm.fit and in the middle of the glm.fit
function is this call to a Fortran routine:
fit <- .Fortran("dqrls", qr = x[good, ] * w, n = ngoodobs,
p = nvars, y = w * z, ny = 1L, tol = min(1e-07,
control$epsilon/1000), coefficients = double(nvars),
residuals = double(ngoodobs), effects =
double(ngoodobs),
rank = integer(1L), pivot = 1L:nvars, qraux =
double(nvars),
work = double(2 * nvars), PACKAGE = "base")
So unless you read Fortran, you may be out of luck, and generally
those who do read Fortran already know how to get at source code
without asking on mailing list. But if you want to pursue an effort at
viewing the source, try reading Ligges' article, "Accessing the
sources", in:
http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf
--
David
jason
Dr. Iasonas Lamprianou
Assistant Professor (Educational Research and Evaluation)
Department of Education Sciences
European University-Cyprus
P.O. Box 22006
1516 Nicosia
Cyprus
Tel.: +357-22-713178
Fax: +357-22-590539
Honorary Research Fellow
Department of Education
The University of Manchester
Oxford Road, Manchester M13 9PL, UK
Tel. 0044 161 275 3485
iasonas.lampria...@manchester.ac.uk
--- On Fri, 20/8/10, David Winsemius <dwinsem...@comcast.net> wrote:
From: David Winsemius <dwinsem...@comcast.net>
Subject: Re: [R] Deviance Residuals
To: "Iasonas Lamprianou" <lampria...@yahoo.com>
Cc: r-help@r-project.org
Date: Friday, 20 August, 2010, 13:20
On Aug 20, 2010, at 5:54 AM, Iasonas Lamprianou wrote:
Dear all,
I am running a logistic regression and this is the
output:
glm(formula = educationUniv ~ brncntr, family =
binomial)
Deviance Residuals:
Min
1Q Median
3Q Max #
αυτά είναι τα υπόλοιπα
-0.8825 -0.7684
-0.7684 1.5044 1.6516
Coefficients:
Estimate Std.
Error z value Pr(>|z|)
(Intercept) -1.06869 0.01155
-92.487 <2e-16 ***
brncntrNo 0.32654
0.03742 8.726 <2e-16
***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05
'.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be
1)
Null deviance: 49363 on 42969 degrees of
freedom
Residual deviance: 49289 on 42968 degrees
of freedom
AIC: 49293
I thought that the residuals should all be restricted
in the range 0 to 1 (since I am predicting a binary
outcome).
The internal regression calculations are done on the
log-odds scale so the working residuals are on that scale.
Those are stored in the glm.obj as the "residuals" item. I
believe that if you tried mean(glm.obj$residuals) you should
get 0. Presumably the deviance residuals are offered
in preference to the working residuals because the deviance
residual's use as an influence measure is made readily
interpretable by reference to chi-square statistics. Page
205 of the Hastie and Pregibon citation has all the
definitions.
--David.
I read many posts on this list and I realized that
there are four(!?) different types of residuals. I need a
simple account of these four types of residuals, if anyone
can help it will be great.
residuals(glm1, "response")
residuals(glm1, "pearson")
residuals(glm1, "deviance")
residuals(glm1, "working") - especially this one
confuses me a lot!
What is the "working" option and how is this
different?
Thank you
Jason
Dr. Iasonas Lamprianou
--
David Winsemius, MD
West Hartford, CT
David Winsemius, MD
West Hartford, CT
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.