Learn R Programming

gldrm (version 1.6)

gldrmLRT: Likelihood ratio test for nested models

Description

Performs a likelihood ratio F-test between nested gldrm models. The F-statistic is calculated as \(2 \times (llik - llik_0) / r\), where \(r\) is the difference is the number of parameters between the full and null models. The F-statistic has degrees of freedom \(r\) and \(n-p\), where \(n\) is the number of observations and \(p\) is the number of parameters in the full model.

Usage

gldrmLRT(gldrmFit, gldrmNull)

Value

An S3 object of class 'gldrmLRT', containing numerator and denominator degrees of freedom, an F-statistic, and a p-value.

Arguments

gldrmFit

The full model. Must be an object of S3 class 'gldrm' returned from the gldrm function.

gldrmNull

The sub-model being tested under the null hypotheses. Must be an object of S3 class 'gldrm' returned from the gldrm function.

Examples

Run this code
data(iris, package="datasets")

### Fit gldrm with all variables
fit <- gldrm(Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width + Species,
             data=iris, link="log")

### Fit gldrm without the categorical variable "Species"
fit0 <- gldrm(Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width,
              data=iris, link="log")

### Likelihood ratio test for the nested models
lrt <- gldrmLRT(fit, fit0)
lrt

Run the code above in your browser using DataLab