lrt | R Documentation |
Function to perform a likelihood ratio test (LRT) between a reduced model (modA) versus a more complex model (modB), provided both models were fitted by maximum likelihood. The function requires to be filled with the needed values used to perform a LRT.
lrt(
llma = llma,
llmb = llmb,
qa = qa,
qb = qb,
nfit = nfit,
modA = "modA",
modB = "modB",
alpha = 0.05
)
llma |
maximized log-likelihood of the reduced model (or modA). |
llmb |
maximized log-likelihood of the more-complex model (or modB). |
qa |
the number of parameters of the reduced model. |
qb |
the number of parameters of the more-complex model. |
nfit |
the sample size used for fitted both models. |
modA |
is a character with a name to be assigned to object modA. |
modB |
is a character with a name to be assigned to object modB. |
alpha |
is the level of sifnificance to used for computing as a reference only, the tabulated value of the respective Chi-Squared statistic. By the defaul is set to 0.05. |
The resulting output offers statistical inference estimates of the LRT, as well as other maximum likelihood-based statistics. Notice that the function only works if the number of parameters for modA is lower than the ones of modB.
This function wraps two outputs: (i) a table that computes the AIC, BIC and AICc goodness-of-fit statistics for both models, and (ii) the result of the likelihood ratio test, such as the value of the statistic being computed, its respective p-value, and the tabulated value of the statistics using the a defined alpha significance of level.
Christian Salas-Eljatib.
Salas-Eljatib, C. 2025. Estadística Aplicada e Inferencial. Borrador de libro, Universidad de Chile, Santiago, Chile. https://eljatib.com/rlibro
#Maximized values for two probability mass functions
max.ll.pois<- -39.86337; max.ll.bneg<--33.823003
c(max.ll.pois,max.ll.bneg)
sample.size<-26
#Number of parameters
num.para.pois<- 1; num.para.bneg<- 3
c(num.para.pois, num.para.bneg)
#Names to be used for each model
modA="Poisson"; modB="hiper"
outall<-lrt(llma=max.ll.pois,llmb=max.ll.bneg,qa=num.para.pois,
qb=num.para.bneg,nfit = sample.size,modA = "Poisson",
modB = "Hipergeometrico")
#Output1: A comparative table
tab.out<-outall$tab.models
tab.out
#Output2: the results of the LRT
out<-outall$lrt.out
out$r.tab
out$Ldif
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.