testGLMGamma | R Documentation |
testGLMGamma
is used to check the validity of Gamma assumption for the
response variable when fitting generalized linear model. Common link functions
in glm
can be used here.
testGLMGamma(
x,
y,
fit = NULL,
l = "log",
discretize = FALSE,
ngrid = length(y),
gridpit = TRUE,
hessian = FALSE,
start.value = NULL,
control = NULL,
method = "cvm"
)
x |
is either a numeric vector or a design matrix. In the design matrix, rows indicate observations and columns presents covariats. |
y |
is a vector of numeric values with the same number of observations or number of rows as x. |
fit |
is an object of class |
l |
a character vector indicating the link function that should be used
for Gamma family. Acceptable link functions for Gamma family are inverse,
identity and log. For more details see |
discretize |
If |
ngrid |
the number of equally spaced points to discretize the (0,1) interval for computing the covariance function. |
gridpit |
logical. If |
hessian |
logical. If |
start.value |
a numeric value or vector. This is the same as |
control |
a list of parameters to control the fitting process in
|
method |
a character string indicating which goodness-of-fit statistic is to be computed. The default value is 'cvm' for the Cramer-von-Mises statistic. Other options include 'ad' for the Anderson-Darling statistic, and 'both' to compute both cvm and ad. |
A list of two containing the following components:
Statistic: the value of goodness-of-fit statistic.
p-value: the approximate p-value for the goodness-of-fit test. if method = 'cvm' or method = 'ad', it returns a numeric value for the statistic and p-value. If method = 'both', it returns a numeric vector with two elements and one for each statistic.
converged: logical to indicate if the IWLS algorithm have converged or not.
set.seed(123)
n <- 50
p <- 5
x <- matrix( rnorm(n*p, mean = 10, sd = 0.1), nrow = n, ncol = p)
b <- runif(p)
e <- rgamma(n, shape = 3)
y <- exp(x %*% b) * e
testGLMGamma(x, y, l = 'log')
myfit <- glm(y ~ x, family = Gamma('log'), x = TRUE, y = TRUE)
testGLMGamma(fit = myfit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.