mirror of
https://github.com/msberends/AMR.git
synced 2024-12-25 20:06:12 +01:00
245 lines
25 KiB
HTML
245 lines
25 KiB
HTML
<!DOCTYPE html>
|
|
<!-- Generated by pkgdown: do not edit by hand --><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><title>G-test for Count Data — g.test • AMR (for R)</title><!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png"><link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png"><link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png"><link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png"><link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png"><link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png"><script src="../deps/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><link href="../deps/bootstrap-5.3.1/bootstrap.min.css" rel="stylesheet"><script src="../deps/bootstrap-5.3.1/bootstrap.bundle.min.js"></script><link href="../deps/Lato-0.4.9/font.css" rel="stylesheet"><link href="../deps/Fira_Code-0.4.9/font.css" rel="stylesheet"><link href="../deps/font-awesome-6.5.2/css/all.min.css" rel="stylesheet"><link href="../deps/font-awesome-6.5.2/css/v4-shims.min.css" rel="stylesheet"><script src="../deps/headroom-0.11.0/headroom.min.js"></script><script src="../deps/headroom-0.11.0/jQuery.headroom.min.js"></script><script src="../deps/bootstrap-toc-1.0.1/bootstrap-toc.min.js"></script><script src="../deps/clipboard.js-2.0.11/clipboard.min.js"></script><script src="../deps/search-1.0.0/autocomplete.jquery.min.js"></script><script src="../deps/search-1.0.0/fuse.min.js"></script><script src="../deps/search-1.0.0/mark.min.js"></script><!-- pkgdown --><script src="../pkgdown.js"></script><link href="../extra.css" rel="stylesheet"><script src="../extra.js"></script><meta property="og:title" content="G-test for Count Data — g.test"><meta name="description" content="g.test() performs chi-squared contingency table tests and goodness-of-fit tests, just like chisq.test() but is more reliable (1). A G-test can be used to see whether the number of observations in each category fits a theoretical expectation (called a G-test of goodness-of-fit), or to see whether the proportions of one variable are different for different values of the other variable (called a G-test of independence)."><meta property="og:description" content="g.test() performs chi-squared contingency table tests and goodness-of-fit tests, just like chisq.test() but is more reliable (1). A G-test can be used to see whether the number of observations in each category fits a theoretical expectation (called a G-test of goodness-of-fit), or to see whether the proportions of one variable are different for different values of the other variable (called a G-test of independence)."><meta property="og:image" content="https://msberends.github.io/AMR/logo.svg"></head><body>
|
|
<a href="#main" class="visually-hidden-focusable">Skip to contents</a>
|
|
|
|
|
|
<nav class="navbar navbar-expand-lg fixed-top bg-primary" data-bs-theme="dark" aria-label="Site navigation"><div class="container">
|
|
|
|
<a class="navbar-brand me-2" href="../index.html">AMR (for R)</a>
|
|
|
|
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">2.1.1.9122</small>
|
|
|
|
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
|
|
<div id="navbar" class="collapse navbar-collapse ms-3">
|
|
<ul class="navbar-nav me-auto"><li class="nav-item dropdown">
|
|
<button class="nav-link dropdown-toggle" type="button" id="dropdown-how-to" data-bs-toggle="dropdown" aria-expanded="false" aria-haspopup="true"><span class="fa fa-question-circle"></span> How to</button>
|
|
<ul class="dropdown-menu" aria-labelledby="dropdown-how-to"><li><a class="dropdown-item" href="../articles/AMR.html"><span class="fa fa-directions"></span> Conduct AMR Analysis</a></li>
|
|
<li><a class="dropdown-item" href="../reference/antibiogram.html"><span class="fa fa-file-prescription"></span> Generate Antibiogram (Trad./Syndromic/WISCA)</a></li>
|
|
<li><a class="dropdown-item" href="../articles/resistance_predict.html"><span class="fa fa-dice"></span> Predict Antimicrobial Resistance</a></li>
|
|
<li><a class="dropdown-item" href="../articles/datasets.html"><span class="fa fa-database"></span> Download Data Sets for Own Use</a></li>
|
|
<li><a class="dropdown-item" href="../articles/AMR_with_tidymodels.html"><span class="fa fa-square-root-variable"></span> Use AMR for Predictive Modelling (tidymodels)</a></li>
|
|
<li><a class="dropdown-item" href="../reference/AMR-options.html"><span class="fa fa-gear"></span> Set User- Or Team-specific Package Settings</a></li>
|
|
<li><a class="dropdown-item" href="../articles/PCA.html"><span class="fa fa-compress"></span> Conduct Principal Component Analysis for AMR</a></li>
|
|
<li><a class="dropdown-item" href="../articles/MDR.html"><span class="fa fa-skull-crossbones"></span> Determine Multi-Drug Resistance (MDR)</a></li>
|
|
<li><a class="dropdown-item" href="../articles/WHONET.html"><span class="fa fa-globe-americas"></span> Work with WHONET Data</a></li>
|
|
<li><a class="dropdown-item" href="../articles/EUCAST.html"><span class="fa fa-exchange-alt"></span> Apply Eucast Rules</a></li>
|
|
<li><a class="dropdown-item" href="../reference/mo_property.html"><span class="fa fa-bug"></span> Get Taxonomy of a Microorganism</a></li>
|
|
<li><a class="dropdown-item" href="../reference/ab_property.html"><span class="fa fa-capsules"></span> Get Properties of an Antibiotic Drug</a></li>
|
|
<li><a class="dropdown-item" href="../reference/av_property.html"><span class="fa fa-capsules"></span> Get Properties of an Antiviral Drug</a></li>
|
|
</ul></li>
|
|
<li class="nav-item"><a class="nav-link" href="../articles/AMR_for_Python.html"><span class="fa fab fa-python"></span> AMR for Python</a></li>
|
|
<li class="active nav-item"><a class="nav-link" href="../reference/index.html"><span class="fa fa-book-open"></span> Manual</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="../authors.html"><span class="fa fa-users"></span> Authors</a></li>
|
|
</ul><ul class="navbar-nav"><li class="nav-item"><a class="nav-link" href="../news/index.html"><span class="fa far fa-newspaper"></span> Changelog</a></li>
|
|
<li class="nav-item"><a class="external-link nav-link" href="https://github.com/msberends/AMR"><span class="fa fab fa-github"></span> Source Code</a></li>
|
|
</ul></div>
|
|
|
|
|
|
</div>
|
|
</nav><div class="container template-reference-topic">
|
|
<div class="row">
|
|
<main id="main" class="col-md-9"><div class="page-header">
|
|
<img src="../logo.svg" class="logo" alt=""><h1><em>G</em>-test for Count Data</h1>
|
|
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/main/R/g.test.R" class="external-link"><code>R/g.test.R</code></a></small>
|
|
<div class="d-none name"><code>g.test.Rd</code></div>
|
|
</div>
|
|
|
|
<div class="ref-description section level2">
|
|
<p><code>g.test()</code> performs chi-squared contingency table tests and goodness-of-fit tests, just like <code><a href="https://rdrr.io/r/stats/chisq.test.html" class="external-link">chisq.test()</a></code> but is more reliable (1). A <em>G</em>-test can be used to see whether the number of observations in each category fits a theoretical expectation (called a <strong><em>G</em>-test of goodness-of-fit</strong>), or to see whether the proportions of one variable are different for different values of the other variable (called a <strong><em>G</em>-test of independence</strong>).</p>
|
|
</div>
|
|
|
|
<div class="section level2">
|
|
<h2 id="ref-usage">Usage<a class="anchor" aria-label="anchor" href="#ref-usage"></a></h2>
|
|
<div class="sourceCode"><pre class="sourceCode r"><code><span><span class="fu">g.test</span><span class="op">(</span><span class="va">x</span>, y <span class="op">=</span> <span class="cn">NULL</span>, p <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/rep.html" class="external-link">rep</a></span><span class="op">(</span><span class="fl">1</span><span class="op">/</span><span class="fu"><a href="https://rdrr.io/r/base/length.html" class="external-link">length</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span>, <span class="fu"><a href="https://rdrr.io/r/base/length.html" class="external-link">length</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span><span class="op">)</span>, rescale.p <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></span></code></pre></div>
|
|
</div>
|
|
|
|
<div class="section level2">
|
|
<h2 id="source">Source<a class="anchor" aria-label="anchor" href="#source"></a></h2>
|
|
<p>The code for this function is identical to that of <code><a href="https://rdrr.io/r/stats/chisq.test.html" class="external-link">chisq.test()</a></code>, except that:</p><ul><li><p>The calculation of the statistic was changed to \(2 * sum(x * log(x / E))\)</p></li>
|
|
<li><p>Yates' continuity correction was removed as it does not apply to a <em>G</em>-test</p></li>
|
|
<li><p>The possibility to simulate p values with <code>simulate.p.value</code> was removed</p></li>
|
|
</ul></div>
|
|
<div class="section level2">
|
|
<h2 id="arguments">Arguments<a class="anchor" aria-label="anchor" href="#arguments"></a></h2>
|
|
|
|
|
|
<dl><dt id="arg-x">x<a class="anchor" aria-label="anchor" href="#arg-x"></a></dt>
|
|
<dd><p>a numeric vector or matrix. <code>x</code> and <code>y</code> can also
|
|
both be factors.</p></dd>
|
|
|
|
|
|
<dt id="arg-y">y<a class="anchor" aria-label="anchor" href="#arg-y"></a></dt>
|
|
<dd><p>a numeric vector; ignored if <code>x</code> is a matrix. If
|
|
<code>x</code> is a factor, <code>y</code> should be a factor of the same length.</p></dd>
|
|
|
|
|
|
<dt id="arg-p">p<a class="anchor" aria-label="anchor" href="#arg-p"></a></dt>
|
|
<dd><p>a vector of probabilities of the same length as <code>x</code>.
|
|
An error is given if any entry of <code>p</code> is negative.</p></dd>
|
|
|
|
|
|
<dt id="arg-rescale-p">rescale.p<a class="anchor" aria-label="anchor" href="#arg-rescale-p"></a></dt>
|
|
<dd><p>a logical scalar; if TRUE then <code>p</code> is rescaled
|
|
(if necessary) to sum to 1. If <code>rescale.p</code> is FALSE, and
|
|
<code>p</code> does not sum to 1, an error is given.</p></dd>
|
|
|
|
</dl></div>
|
|
<div class="section level2">
|
|
<h2 id="value">Value<a class="anchor" aria-label="anchor" href="#value"></a></h2>
|
|
<p>A list with class <code>"htest"</code> containing the following
|
|
components:</p>
|
|
<dl><dt>statistic</dt>
|
|
<dd><p>the value the chi-squared test statistic.</p></dd>
|
|
|
|
<dt>parameter</dt>
|
|
<dd><p>the degrees of freedom of the approximate
|
|
chi-squared distribution of the test statistic, <code>NA</code> if the
|
|
p-value is computed by Monte Carlo simulation.</p></dd>
|
|
|
|
<dt>p.value</dt>
|
|
<dd><p>the p-value for the test.</p></dd>
|
|
|
|
<dt>method</dt>
|
|
<dd><p>a character string indicating the type of test
|
|
performed, and whether Monte Carlo simulation or continuity
|
|
correction was used.</p></dd>
|
|
|
|
<dt>data.name</dt>
|
|
<dd><p>a character string giving the name(s) of the data.</p></dd>
|
|
|
|
<dt>observed</dt>
|
|
<dd><p>the observed counts.</p></dd>
|
|
|
|
<dt>expected</dt>
|
|
<dd><p>the expected counts under the null hypothesis.</p></dd>
|
|
|
|
<dt>residuals</dt>
|
|
<dd><p>the Pearson residuals,
|
|
<code>(observed - expected) / sqrt(expected)</code>.</p></dd>
|
|
|
|
<dt>stdres</dt>
|
|
<dd><p>standardized residuals,
|
|
<code>(observed - expected) / sqrt(V)</code>, where <code>V</code> is the
|
|
residual cell variance (Agresti, 2007, section 2.4.5
|
|
for the case where <code>x</code> is a matrix, <code>n * p * (1 - p)</code> otherwise).</p></dd>
|
|
|
|
</dl></div>
|
|
<div class="section level2">
|
|
<h2 id="details">Details<a class="anchor" aria-label="anchor" href="#details"></a></h2>
|
|
<p>If <code>x</code> is a <a href="https://rdrr.io/r/base/matrix.html" class="external-link">matrix</a> with one row or column, or if <code>x</code> is a vector and <code>y</code> is not given, then a <em>goodness-of-fit test</em> is performed (<code>x</code> is treated as a one-dimensional contingency table). The entries of <code>x</code> must be non-negative integers. In this case, the hypothesis tested is whether the population probabilities equal those in <code>p</code>, or are all equal if <code>p</code> is not given.</p>
|
|
<p>If <code>x</code> is a <a href="https://rdrr.io/r/base/matrix.html" class="external-link">matrix</a> with at least two rows and columns, it is taken as a two-dimensional contingency table: the entries of <code>x</code> must be non-negative integers. Otherwise, <code>x</code> and <code>y</code> must be vectors or factors of the same length; cases with missing values are removed, the objects are coerced to factors, and the contingency table is computed from these. Then Pearson's chi-squared test is performed of the null hypothesis that the joint distribution of the cell counts in a 2-dimensional contingency table is the product of the row and column marginals.</p>
|
|
<p>The p-value is computed from the asymptotic chi-squared distribution of the test statistic.</p>
|
|
<p>In the contingency table case simulation is done by random sampling from the set of all contingency tables with given marginals, and works only if the marginals are strictly positive. Note that this is not the usual sampling situation assumed for a chi-squared test (such as the <em>G</em>-test) but rather that for Fisher's exact test.</p>
|
|
<p>In the goodness-of-fit case simulation is done by random sampling from the discrete distribution specified by <code>p</code>, each sample being of size <code>n = sum(x)</code>. This simulation is done in <span style="R">R</span> and may be slow.</p><div class="section">
|
|
<h3 id="g-test-of-goodness-of-fit-likelihood-ratio-test-"><em>G</em>-test Of Goodness-of-Fit (Likelihood Ratio Test)<a class="anchor" aria-label="anchor" href="#g-test-of-goodness-of-fit-likelihood-ratio-test-"></a></h3>
|
|
|
|
|
|
<p>Use the <em>G</em>-test of goodness-of-fit when you have one nominal variable with two or more values (such as male and female, or red, pink and white flowers). You compare the observed counts of numbers of observations in each category with the expected counts, which you calculate using some kind of theoretical expectation (such as a 1:1 sex ratio or a 1:2:1 ratio in a genetic cross).</p>
|
|
<p>If the expected number of observations in any category is too small, the <em>G</em>-test may give inaccurate results, and you should use an exact test instead (<code><a href="https://rdrr.io/r/stats/fisher.test.html" class="external-link">fisher.test()</a></code>).</p>
|
|
<p>The <em>G</em>-test of goodness-of-fit is an alternative to the chi-square test of goodness-of-fit (<code><a href="https://rdrr.io/r/stats/chisq.test.html" class="external-link">chisq.test()</a></code>); each of these tests has some advantages and some disadvantages, and the results of the two tests are usually very similar.</p>
|
|
</div>
|
|
|
|
<div class="section">
|
|
<h3 id="g-test-of-independence"><em>G</em>-test of Independence<a class="anchor" aria-label="anchor" href="#g-test-of-independence"></a></h3>
|
|
|
|
|
|
<p>Use the <em>G</em>-test of independence when you have two nominal variables, each with two or more possible values. You want to know whether the proportions for one variable are different among values of the other variable.</p>
|
|
<p>It is also possible to do a <em>G</em>-test of independence with more than two nominal variables. For example, Jackson et al. (2013) also had data for children under 3, so you could do an analysis of old vs. young, thigh vs. arm, and reaction vs. no reaction, all analyzed together.</p>
|
|
<p>Fisher's exact test (<code><a href="https://rdrr.io/r/stats/fisher.test.html" class="external-link">fisher.test()</a></code>) is an <strong>exact</strong> test, where the <em>G</em>-test is still only an <strong>approximation</strong>. For any 2x2 table, Fisher's Exact test may be slower but will still run in seconds, even if the sum of your observations is multiple millions.</p>
|
|
<p>The <em>G</em>-test of independence is an alternative to the chi-square test of independence (<code><a href="https://rdrr.io/r/stats/chisq.test.html" class="external-link">chisq.test()</a></code>), and they will give approximately the same results.</p>
|
|
</div>
|
|
|
|
<div class="section">
|
|
<h3 id="how-the-test-works">How the Test Works<a class="anchor" aria-label="anchor" href="#how-the-test-works"></a></h3>
|
|
|
|
|
|
<p>Unlike the exact test of goodness-of-fit (<code><a href="https://rdrr.io/r/stats/fisher.test.html" class="external-link">fisher.test()</a></code>), the <em>G</em>-test does not directly calculate the probability of obtaining the observed results or something more extreme. Instead, like almost all statistical tests, the <em>G</em>-test has an intermediate step; it uses the data to calculate a test statistic that measures how far the observed data are from the null expectation. You then use a mathematical relationship, in this case the chi-square distribution, to estimate the probability of obtaining that value of the test statistic.</p>
|
|
<p>The <em>G</em>-test uses the log of the ratio of two likelihoods as the test statistic, which is why it is also called a likelihood ratio test or log-likelihood ratio test. The formula to calculate a <em>G</em>-statistic is:</p>
|
|
<p>\(G = 2 * sum(x * log(x / E))\)</p>
|
|
<p>where <code>E</code> are the expected values. Since this is chi-square distributed, the p value can be calculated in <span style="R">R</span> with:</p>
|
|
<p></p><div class="sourceCode"><pre><code><span id="cb1-1"><a href="#cb1-1" tabindex="-1"></a>p <span class="ot"><-</span> stats<span class="sc">::</span><span class="fu">pchisq</span>(G, df, <span class="at">lower.tail =</span> <span class="cn">FALSE</span>)</span></code></pre><p></p></div>
|
|
<p>where <code>df</code> are the degrees of freedom.</p>
|
|
<p>If there are more than two categories and you want to find out which ones are significantly different from their null expectation, you can use the same method of testing each category vs. the sum of all categories, with the Bonferroni correction. You use <em>G</em>-tests for each category, of course.</p>
|
|
</div>
|
|
|
|
</div>
|
|
<div class="section level2">
|
|
<h2 id="references">References<a class="anchor" aria-label="anchor" href="#references"></a></h2>
|
|
|
|
<ol><li><p>McDonald, J.H. 2014. <strong>Handbook of Biological Statistics (3rd ed.)</strong>. Sparky House Publishing, Baltimore, Maryland. <a href="http://www.biostathandbook.com/gtestgof.html" class="external-link">http://www.biostathandbook.com/gtestgof.html</a>.</p></li>
|
|
</ol></div>
|
|
<div class="section level2">
|
|
<h2 id="see-also">See also<a class="anchor" aria-label="anchor" href="#see-also"></a></h2>
|
|
<div class="dont-index"><p><code><a href="https://rdrr.io/r/stats/chisq.test.html" class="external-link">chisq.test()</a></code></p></div>
|
|
</div>
|
|
|
|
<div class="section level2">
|
|
<h2 id="ref-examples">Examples<a class="anchor" aria-label="anchor" href="#ref-examples"></a></h2>
|
|
<div class="sourceCode"><pre class="sourceCode r"><code><span class="r-in"><span><span class="co"># = EXAMPLE 1 =</span></span></span>
|
|
<span class="r-in"><span><span class="co"># Shivrain et al. (2006) crossed clearfield rice (which are resistant</span></span></span>
|
|
<span class="r-in"><span><span class="co"># to the herbicide imazethapyr) with red rice (which are susceptible to</span></span></span>
|
|
<span class="r-in"><span><span class="co"># imazethapyr). They then crossed the hybrid offspring and examined the</span></span></span>
|
|
<span class="r-in"><span><span class="co"># F2 generation, where they found 772 resistant plants, 1611 moderately</span></span></span>
|
|
<span class="r-in"><span><span class="co"># resistant plants, and 737 susceptible plants. If resistance is controlled</span></span></span>
|
|
<span class="r-in"><span><span class="co"># by a single gene with two co-dominant alleles, you would expect a 1:2:1</span></span></span>
|
|
<span class="r-in"><span><span class="co"># ratio.</span></span></span>
|
|
<span class="r-in"><span></span></span>
|
|
<span class="r-in"><span><span class="va">x</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">772</span>, <span class="fl">1611</span>, <span class="fl">737</span><span class="op">)</span></span></span>
|
|
<span class="r-in"><span><span class="fu">g.test</span><span class="op">(</span><span class="va">x</span>, p <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">1</span>, <span class="fl">2</span>, <span class="fl">1</span><span class="op">)</span> <span class="op">/</span> <span class="fl">4</span><span class="op">)</span></span></span>
|
|
<span class="r-out co"><span class="r-pr">#></span> </span>
|
|
<span class="r-out co"><span class="r-pr">#></span> G-test of goodness-of-fit (likelihood ratio test)</span>
|
|
<span class="r-out co"><span class="r-pr">#></span> </span>
|
|
<span class="r-out co"><span class="r-pr">#></span> data: x</span>
|
|
<span class="r-out co"><span class="r-pr">#></span> X-squared = 4.1471, p-value = 0.1257</span>
|
|
<span class="r-out co"><span class="r-pr">#></span> </span>
|
|
<span class="r-in"><span></span></span>
|
|
<span class="r-in"><span><span class="co"># There is no significant difference from a 1:2:1 ratio.</span></span></span>
|
|
<span class="r-in"><span><span class="co"># Meaning: resistance controlled by a single gene with two co-dominant</span></span></span>
|
|
<span class="r-in"><span><span class="co"># alleles, is plausible.</span></span></span>
|
|
<span class="r-in"><span></span></span>
|
|
<span class="r-in"><span></span></span>
|
|
<span class="r-in"><span><span class="co"># = EXAMPLE 2 =</span></span></span>
|
|
<span class="r-in"><span><span class="co"># Red crossbills (Loxia curvirostra) have the tip of the upper bill either</span></span></span>
|
|
<span class="r-in"><span><span class="co"># right or left of the lower bill, which helps them extract seeds from pine</span></span></span>
|
|
<span class="r-in"><span><span class="co"># cones. Some have hypothesized that frequency-dependent selection would</span></span></span>
|
|
<span class="r-in"><span><span class="co"># keep the number of right and left-billed birds at a 1:1 ratio. Groth (1992)</span></span></span>
|
|
<span class="r-in"><span><span class="co"># observed 1752 right-billed and 1895 left-billed crossbills.</span></span></span>
|
|
<span class="r-in"><span></span></span>
|
|
<span class="r-in"><span><span class="va">x</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">1752</span>, <span class="fl">1895</span><span class="op">)</span></span></span>
|
|
<span class="r-in"><span><span class="fu">g.test</span><span class="op">(</span><span class="va">x</span><span class="op">)</span></span></span>
|
|
<span class="r-out co"><span class="r-pr">#></span> </span>
|
|
<span class="r-out co"><span class="r-pr">#></span> G-test of goodness-of-fit (likelihood ratio test)</span>
|
|
<span class="r-out co"><span class="r-pr">#></span> </span>
|
|
<span class="r-out co"><span class="r-pr">#></span> data: x</span>
|
|
<span class="r-out co"><span class="r-pr">#></span> X-squared = 5.6085, p-value = 0.01787</span>
|
|
<span class="r-out co"><span class="r-pr">#></span> </span>
|
|
<span class="r-in"><span></span></span>
|
|
<span class="r-in"><span><span class="co"># There is a significant difference from a 1:1 ratio.</span></span></span>
|
|
<span class="r-in"><span><span class="co"># Meaning: there are significantly more left-billed birds.</span></span></span>
|
|
</code></pre></div>
|
|
</div>
|
|
</main><aside class="col-md-3"><nav id="toc" aria-label="Table of contents"><h2>On this page</h2>
|
|
</nav></aside></div>
|
|
|
|
|
|
<footer><div class="pkgdown-footer-left">
|
|
<p><code>AMR</code> (for R). Free and open-source, licenced under the <a target="_blank" href="https://github.com/msberends/AMR/blob/main/LICENSE" class="external-link">GNU General Public License version 2.0 (GPL-2)</a>.<br>Developed at the <a target="_blank" href="https://www.rug.nl" class="external-link">University of Groningen</a> and <a target="_blank" href="https://www.umcg.nl" class="external-link">University Medical Center Groningen</a> in The Netherlands.</p>
|
|
</div>
|
|
|
|
<div class="pkgdown-footer-right">
|
|
<p><a target="_blank" href="https://www.rug.nl" class="external-link"><img src="https://github.com/msberends/AMR/raw/main/pkgdown/assets/logo_rug.svg" style="max-width: 150px;"></a><a target="_blank" href="https://www.umcg.nl" class="external-link"><img src="https://github.com/msberends/AMR/raw/main/pkgdown/assets/logo_umcg.svg" style="max-width: 150px;"></a></p>
|
|
</div>
|
|
|
|
</footer></div>
|
|
|
|
|
|
|
|
|
|
|
|
</body></html>
|
|
|