Title: | Improved Score Tests for Generalized Linear Models |
---|---|
Description: | A set of functions to obtain modified score test for generalized linear models. |
Authors: | Antonio Hermes M. da Silva-Junior [aut, cre], Damiao N. da Silva [aut], Silvia L. P. Ferrari [ctb] |
Maintainer: | Antonio Hermes M. da Silva-Junior <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.1-3 |
Built: | 2024-12-12 06:48:56 UTC |
Source: | CRAN |
Computes the likelihood ratio test for the coefficients of a generalized linear model.
lr.test(fit1, fit2)
lr.test(fit1, fit2)
fit1 |
an object that stores the results of |
fit2 |
an object that stores the results of |
The objects fit1
and fit2
are obtained using the usual options passed to the glm
function.
The function lrt.test()
returns the following list of values:
LR |
the value of the likelihood ratio statistic. |
pvalue |
the p value of test under null hypothesis chi-square distribution. |
Both fit1
and fit2
must have the same family
and link function.
Damiao N. da Silva [email protected]
Antonio Hermes M. da Silva-Junior [email protected]
McCullagh P, Nelder J (1989). Generalized Linear Models. Chapman & Hall/CRC, London.
Da Silva DN, Cordeiro GM (2009). "A Computer Program to Improve LR Tests for Generalized Linear Models." Communications in Statistics – Simulation and Computation, 38(10), 2184–2197.
data(strength) fitf <- glm(y ~ cut * lot, data = strength,family = inverse.gaussian("inverse")) fit0 <- glm(y ~ cut + lot, data = strength, family = inverse.gaussian("inverse")) lr.test(fit0,fitf)
data(strength) fitf <- glm(y ~ cut * lot, data = strength,family = inverse.gaussian("inverse")) fit0 <- glm(y ~ cut + lot, data = strength, family = inverse.gaussian("inverse")) lr.test(fit0,fitf)
Computes the modified score test based for the coefficients of a generalized linear model.
mdscore(model = model, X1 = X1, phi = NULL)
mdscore(model = model, X1 = X1, phi = NULL)
model |
an object that stores the results of |
X1 |
the matrix with the columns of the model matrix X that correspond to the coefficients being specified in the null hypothesis. |
phi |
the precision parameter. |
The object fit.model
is obtained using the usual options passed to the glm
function.
The function mdscore()
returns the following list of values:
Sr |
the value of the score statistic. |
Srcor |
the value of the modified score statistic. |
coef |
a vector with the coefficients A1 , A2 and A3. |
n |
the total sample size. |
df |
the number of degrees of freedom of the chi–squared approximations for the tests. |
phi |
the precision parameter used in the computations |
Antonio Hermes M. da Silva-Junior [email protected]
Damiao N. da Silva [email protected]
Cordeiro GM, Ferrari SLP (1991). A Modified Score Test Statistic Having chi-squared Distribution to Order n–1 . Biometrika, 78(3), 573–582.
Cordeiro GM, Ferrari SLP, Paula GA (1993). Improved Score Tests for Generalized Linear Models. Journal of the Royal Statistical Society B, 55(3), 661–674.
Cribari-Neto F, Ferrari SLP (1995). Second Order Asymptotics for Score Tests in Generalised Linear Models. Biometrika, 82(2), 426–432.
da Silva-Junior AHM, da Silva DN, Ferrari SLP (2014). mdscore: An R Package to Compute Improved Score Tests in Generalized Linear Models. Journal of Statistical Software, 61(2), 1-16., http://www.jstatsoft.org/v61/c02/
data(strength) fitf <- glm(y ~ cut * lot, data = strength,family = inverse.gaussian("inverse")) summary(fitf) X <- model.matrix(fitf, data = strength) fit0 <- glm(y ~ cut + lot, data = strength, family = inverse.gaussian("inverse")) mdscore(fit0, X1=X[, 7:10])
data(strength) fitf <- glm(y ~ cut * lot, data = strength,family = inverse.gaussian("inverse")) summary(fitf) X <- model.matrix(fitf, data = strength) fit0 <- glm(y ~ cut + lot, data = strength, family = inverse.gaussian("inverse")) mdscore(fit0, X1=X[, 7:10])
The dataset is a subsample of the 5 x 2 factorial experiment given by Ostle and Mensing (1963).
data(strength)
data(strength)
A data frame with 30 observations on the following 3 variables.
cut
type of specimen cut.
lot
lof of the material – I
, II
, III
, IV
and V
.
y
observations of the impact strength.
Ostle B, Mensing RW (1963). Statistics in Research: Basic Concepts and Techniques for Research Workers. Iowa State University.
data(strength) fitf <- glm(y ~ cut * lot, data = strength,family = inverse.gaussian("inverse")) summary(fitf) X <- model.matrix(fitf, data = strength) fit0 <- glm(y ~ cut + lot, data = strength, family = inverse.gaussian("inverse")) test <- mdscore(fit0, X1=X[, 7:10]) summary(test)
data(strength) fitf <- glm(y ~ cut * lot, data = strength,family = inverse.gaussian("inverse")) summary(fitf) X <- model.matrix(fitf, data = strength) fit0 <- glm(y ~ cut + lot, data = strength, family = inverse.gaussian("inverse")) test <- mdscore(fit0, X1=X[, 7:10]) summary(test)
summary
methods for the mdscore
objects
## S3 method for class 'mdscore' summary(object, ...)
## S3 method for class 'mdscore' summary(object, ...)
object |
object resulting from a run of the |
... |
not currently used |
Damiao N. da Silva [email protected]
da Silva-Junior AHM, da Silva DN, Ferrari SLP (2014). mdscore: An R Package to Compute Improved Score Tests in Generalized Linear Models. Journal of Statistical Software, 61(2), 1-16., http://www.jstatsoft.org/v61/c02/
library(Sleuth3) d <- transform(case1102, TLrat = Brain/Liver, Ltime = log(Time), Lwrat = log((Weight + Loss)/Weight), Treat = factor(Treatment == "BD", labels=c("NS", "BD")) ) fitf <- glm(TLrat ~ Ltime * Treat + Days + Sex + Lwrat + Tumor + Treat*Lwrat, data = d, family = Gamma("log") ) X <- model.matrix(fitf) fit0 <- glm(TLrat ~ Ltime * Treat + Sex + Lwrat + Tumor + Days, data=d, family=Gamma("log")) test <- mdscore(fit0, X1=X[,9], phi=NULL) summary(test)
library(Sleuth3) d <- transform(case1102, TLrat = Brain/Liver, Ltime = log(Time), Lwrat = log((Weight + Loss)/Weight), Treat = factor(Treatment == "BD", labels=c("NS", "BD")) ) fitf <- glm(TLrat ~ Ltime * Treat + Days + Sex + Lwrat + Tumor + Treat*Lwrat, data = d, family = Gamma("log") ) X <- model.matrix(fitf) fit0 <- glm(TLrat ~ Ltime * Treat + Sex + Lwrat + Tumor + Days, data=d, family=Gamma("log")) test <- mdscore(fit0, X1=X[,9], phi=NULL) summary(test)
Computes the Wald score test for the coefficients of a generalized linear model.
wald.test(model = model, terms)
wald.test(model = model, terms)
model |
an object that stores the results of |
terms |
number of coefficients to be tested under null hypothesis |
The object model
is obtained using the usual options passed to the glm
function.
The function wald.test()
returns the following list of values:
W |
the value of the Wald statistic. |
pvalue |
the p value of test under null hypothesis chi-square distribution. |
Damiao N. da Silva [email protected]
Antonio Hermes M. da Silva-Junior [email protected]
McCullagh P, Nelder J (1989). Generalized Linear Models. Chapman & Hall/CRC, London.
data(strength) fitf <- glm(y ~ cut * lot, data = strength,family = inverse.gaussian("inverse")) wald.test(fitf,term=9)
data(strength) fitf <- glm(y ~ cut * lot, data = strength,family = inverse.gaussian("inverse")) wald.test(fitf,term=9)