# Example: Low Birth Weight Data from Hosmer Jr, D. W. & Lemeshow, S.(2000).
# low : low birth rate (0 >= 2500 grams, 1 < 2500 grams)
# race: 1 = white, 2 = black, 3 = other
# ftv : number of physician visits during the first trimester
library(MASS)
attach(birthwt)
race <- factor(race, labels = c("white", "black", "other"))
predictors <- cbind(lwt, model.matrix(~ race)[, -1])
# compute mle estimates
BWght.out <- glm(low ~ lwt + race, family = "binomial")
# compute fungible coefficients
fungible.LLM <- fungibleL(X = predictors, y = low, method = "LLM",
Nsets = 10, RsqDelta = .005, s = .3)
# Compare with Table 2.3 (page 38) Hosmer Jr, D. W. & Lemeshow, S.(2000).
# Applied logistic regression. New York, Wiley.
print(summary(BWght.out))
print(fungible.LLM$call)
print(fungible.LLM$ftable)
cat("\nMLE log likelihod = ", fungible.LLM$lnLML,
"\nfungible log likelihood = ", fungible.LLM$lnLf)
cat("\nPseudo Rsq = ", round(fungible.LLM$pseudoRsq, 3))
cat("\nfungible Pseudo Rsq = ", round(fungible.LLM$fungibleRsq, 3))
fungible.EM <- fungibleL(X = predictors, y = low, method = "EM" ,
Nsets = 10, rLaLb = 0.99)
print(fungible.EM$call)
print(fungible.EM$ftable)
cat("\nrLaLb = ", round(fungible.EM$rLaLb, 3))
Run the code above in your browser using DataLab