Package 'mdscore'

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

Help Index


Likelihood ratio test for generalized linear models

Description

Computes the likelihood ratio test for the coefficients of a generalized linear model.

Usage

lr.test(fit1, fit2)

Arguments

fit1

an object that stores the results of glm fit of the model under the null hypothesis.

fit2

an object that stores the results of glm fit of the model under the alternative hypothesis.

Details

The objects fit1 and fit2 are obtained using the usual options passed to the glm function.

Value

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.

Note

Both fit1 and fit2 must have the same family and link function.

Author(s)

Damiao N. da Silva [email protected]

Antonio Hermes M. da Silva-Junior [email protected]

References

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.

See Also

mdscore

wald.test

Examples

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)

Modified score test for generalized linear models

Description

Computes the modified score test based for the coefficients of a generalized linear model.

Usage

mdscore(model = model, X1 = X1, phi = NULL)

Arguments

model

an object that stores the results of glm fit of the model under the null hypothesis.

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.

Details

The object fit.model is obtained using the usual options passed to the glm function.

Value

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

Author(s)

Antonio Hermes M. da Silva-Junior [email protected]

Damiao N. da Silva [email protected]

References

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/

See Also

summary.mdscore

Examples

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])

Impact Strength an Insulating Material

Description

The dataset is a subsample of the 5 x 2 factorial experiment given by Ostle and Mensing (1963).

Usage

data(strength)

Format

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.

Source

Ostle B, Mensing RW (1963). Statistics in Research: Basic Concepts and Techniques for Research Workers. Iowa State University.

Examples

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 mdscore objects

Description

summary methods for the mdscore objects

Usage

## S3 method for class 'mdscore'
summary(object, ...)

Arguments

object

object resulting from a run of the mdscore function.

...

not currently used

Author(s)

Damiao N. da Silva [email protected]

References

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/

See Also

mdscore

Examples

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)

Wald test for generalized linear models

Description

Computes the Wald score test for the coefficients of a generalized linear model.

Usage

wald.test(model = model, terms)

Arguments

model

an object that stores the results of glm fit of the model under the null hypothesis.

terms

number of coefficients to be tested under null hypothesis

Details

The object model is obtained using the usual options passed to the glm function.

Value

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.

Author(s)

Damiao N. da Silva [email protected]

Antonio Hermes M. da Silva-Junior [email protected]

References

McCullagh P, Nelder J (1989). Generalized Linear Models. Chapman & Hall/CRC, London.

See Also

lr.test

mdscore

Examples

data(strength)
fitf <- glm(y ~ cut * lot, data = strength,family = inverse.gaussian("inverse"))
wald.test(fitf,term=9)