Last data update: 2014.03.03

R: Likelihood Ratio (G test) for contingency tables
likelihood.testR Documentation

Likelihood Ratio (G test) for contingency tables

Description

Performs a likelihood ratio test of independence

Usage

likelihood.test(x,y=NULL,conservative=FALSE)

Arguments

x

A vector or a matrix

y

A vector that is ignored if x is a matrix and required if x is a vector

conservative

If TRUE, the Williams' continuity correction is used

Value

A list with class "htest" containing the following components:

statistic

the value the chi-squared test statistic.

parameter

the degrees of freedom of the approximate chi-squared distribution of the test statistic.

p.value

the p-value for the test.

method

a character string indicating the type of test performed, and whether the continuity correction was used.

data.name

a character string giving the name(s) of the data.

Author(s)

Pete Hurd and Ian Fellows

See Also

chisq.test

Examples

data(InsectSprays)
likelihood.test(InsectSprays$count>7,InsectSprays$spray)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(Deducer)
Loading required package: ggplot2
Loading required package: JGR
Loading required package: rJava
Loading required package: JavaGD
Loading required package: iplots

Please type JGR() to launch console. Platform specific launchers (.exe and .app) can also be obtained at http://www.rforge.net/JGR/files/.


Loading required package: car
Loading required package: MASS


Note Non-JGR console detected:
	Deducer is best used from within JGR (http://jgr.markushelbig.org/).
	To Bring up GUI dialogs, type deducer().

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Deducer/likelihood.test.Rd_%03d_medium.png", width=480, height=480)
> ### Name: likelihood.test
> ### Title: Likelihood Ratio (G test) for contingency tables
> ### Aliases: likelihood.test
> 
> ### ** Examples
> 
> data(InsectSprays)
> likelihood.test(InsectSprays$count>7,InsectSprays$spray)

	Log likelihood ratio (G-test) test of independence without correction

data:  InsectSprays$count > 7 and InsectSprays$spray
Log likelihood ratio statistic (G) = 79.105, X-squared df = 5, p-value
= 1.332e-15

> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>