Skip to main content
added 1 character in body
Source Link
Gordon Smyth
  • 13.5k
  • 1
  • 40
  • 56

I could easily add some numerical refinementsrefine the code to prevent subtractive cancelation when $p$p is close to 1 by defining

w <- linkderiv <- plogis(eta) * plogis(eta, lower.tail=FALSE),

but the simplemore readable code above stillalready handles the example well enough.

I could easily add some numerical refinements to prevent subtractive cancelation when $p$ is close to 1 by defining

w <- linkderiv <- plogis(eta) * plogis(eta, lower.tail=FALSE),

but the simple code above still handles the example well enough.

I could easily refine the code to prevent subtractive cancelation when p is close to 1 by defining

w <- linkderiv <- plogis(eta) * plogis(eta, lower.tail=FALSE)

but the more readable code above already handles the example well enough.

added 284 characters in body
Source Link
Gordon Smyth
  • 13.5k
  • 1
  • 40
  • 56

I could easily add some numerical refinements to prevent subtractive cancelation when $p$ is close to 1 by defining

w <- linkderiv <- plogis(eta) * plogis(eta, lower.tail=FALSE),

but the simple code above still handles the example well enough.

I could easily add some numerical refinements to prevent subtractive cancelation when $p$ is close to 1 by defining

w <- linkderiv <- plogis(eta) * plogis(eta, lower.tail=FALSE),

but the simple code above still handles the example well enough.

added 26 characters in body
Source Link
Gordon Smyth
  • 13.5k
  • 1
  • 40
  • 56

Example with direct code implementation of glm algorithm``manual'' calculations

p <- rep(0.5,n)
eta <- qlogis(p)
for (i in 1:10) {
  w <- p*(1-p)
  linkderiv <- p*(1-p)
  z <- (y-p)/linkderiv + qlogis(p)eta
  fit <- lm.wfit(X,z,w)
  peta <- plogis(fit$fitted.value
  p <- plogis(eta)
  cat(p,"\n")
}

Example with direct code implementation of glm algorithm

p <- rep(0.5,n)
for (i in 1:10) {
  w <- p*(1-p)
  linkderiv <- p*(1-p)
  z <- (y-p)/linkderiv + qlogis(p)
  fit <- lm.wfit(X,z,w)
  p <- plogis(fit$fitted.value)
  cat(p,"\n")
}

Example with ``manual'' calculations

p <- rep(0.5,n)
eta <- qlogis(p)
for (i in 1:10) {
  w <- p*(1-p)
  linkderiv <- p*(1-p)
  z <- (y-p)/linkderiv + eta
  fit <- lm.wfit(X,z,w)
  eta <- fit$fitted.value
  p <- plogis(eta)
  cat(p,"\n")
}
added 5 characters in body
Source Link
Gordon Smyth
  • 13.5k
  • 1
  • 40
  • 56
Loading
added 4 characters in body
Source Link
Gordon Smyth
  • 13.5k
  • 1
  • 40
  • 56
Loading
added 1435 characters in body
Source Link
Gordon Smyth
  • 13.5k
  • 1
  • 40
  • 56
Loading
deleted 157 characters in body
Source Link
Gordon Smyth
  • 13.5k
  • 1
  • 40
  • 56
Loading
edited body
Source Link
Nick Cox
  • 59.5k
  • 8
  • 136
  • 212
Loading
added 125 characters in body
Source Link
Gordon Smyth
  • 13.5k
  • 1
  • 40
  • 56
Loading
deleted 1 character in body
Source Link
Gordon Smyth
  • 13.5k
  • 1
  • 40
  • 56
Loading
added 9 characters in body
Source Link
Gordon Smyth
  • 13.5k
  • 1
  • 40
  • 56
Loading
added 122 characters in body
Source Link
Gordon Smyth
  • 13.5k
  • 1
  • 40
  • 56
Loading
added 30 characters in body
Source Link
Gordon Smyth
  • 13.5k
  • 1
  • 40
  • 56
Loading
added 254 characters in body
Source Link
Gordon Smyth
  • 13.5k
  • 1
  • 40
  • 56
Loading
added 520 characters in body
Source Link
Gordon Smyth
  • 13.5k
  • 1
  • 40
  • 56
Loading
Source Link
Gordon Smyth
  • 13.5k
  • 1
  • 40
  • 56
Loading