MichaelChirico / r-bugs

A ⚠️read-only⚠️mirror of https://bugs.r-project.org/
20 stars 0 forks source link

[BUGZILLA #3180] standard errors from glm #1772

Open MichaelChirico opened 4 years ago

MichaelChirico commented 4 years ago

From: Brad McNeney <mcneney@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::>>

In the iterative weighted least squares loop of the glm.fit function, a QR decomposition of the matrix Xsqrt(w) is obtained at each iteration, using fitted values of the mean response mu from the previous interation. Here "X" is the design matrix, w = wt(d(mu)/d(eta))/variance(mu), "wt" is the vector of weights, and "d(mu)/d(eta)" is the derivative of mu wrt the linear predictor eta. Upon convergence, the most recent QR decomposition of X*sqrt(w) is returned and this is later used by the function summary.glm to compute standard errors.

The QR decomposition being returned by glm.fit uses the fitted values from parameter estimates at the (final-1)st iteration. But don't we want fitted values from parameter estimates at the final iteration?
I tried inserting the following lines upon completion of the iterative weighted least squares loop:

mu.eta.val <- mu.eta(eta)
w <- sqrt((weights[good] * mu.eta.val[good]^2)/variance(mu)[good])
newQR<-qr(x[good, ] * w)

My standard errors based on newQR$qr agree with the standard errors I had computed manually from the final fits. Has anyone else encountered this issue? Thanks in advance for any clarifications.

Brad

--please do not edit the information below--

Version: platform = i686-pc-linux-gnu arch = i686 os = linux-gnu system = i686, linux-gnu status = major = 1 minor = 7.0 year = 2003 month = 04 day = 16 language = R

Search Path: .GlobalEnv, package:methods, package:ctest, package:mva, package:modreg, package:nls, package:ts, Autoloads, package:base


METADATA

MichaelChirico commented 4 years ago

From: Thomas Lumley <tlumley@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::>> On Wed, 4 Jun 2003 mcneney@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::> wrote:


The QR decomposition being returned by glm.fit uses the fitted values from
parameter estimates at the (final-1)st iteration. But don't we want
fitted values from parameter estimates at the final iteration?
I tried inserting the following lines upon completion of the iterative
weighted least squares loop:

Well, yes, perhaps. OTOH it's a whole lot easier just to tighten the tolerance for convergence, which has been done for 1.7.1

-thomas

METADATA

MichaelChirico commented 4 years ago

NOTES: not at all clear this is better: it cannot be done if "glm" is to inherit from "lm"


METADATA

MichaelChirico commented 4 years ago

Audit (from Jitterbug): Wed Jun 4 17:52:23 2003 ripley changed notes Wed Jun 4 17:52:23 2003 ripley foobar Wed Jun 4 17:52:23 2003 ripley moved from incoming to wishlist


METADATA