EVOLUTION-MANAGER
Edit File: permute.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Generate 'n' permutation replicates.</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for permute {modelr}"><tr><td>permute {modelr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Generate <code>n</code> permutation replicates.</h2> <h3>Description</h3> <p>A permutation test involves permuting one or more variables in a data set before performing the test, in order to break any existing relationships and simulate the null hypothesis. One can then compare the true statistic to the generated distribution of null statistics. </p> <h3>Usage</h3> <pre> permute(data, n, ..., .id = ".id") permute_(data, n, columns, .id = ".id") </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>data</code></td> <td> <p>A data frame</p> </td></tr> <tr valign="top"><td><code>n</code></td> <td> <p>Number of permutations to generate.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Columns to permute. This supports bare column names or dplyr <a href="../../dplyr/html/select_helpers.html">dplyr::select_helpers</a></p> </td></tr> <tr valign="top"><td><code>.id</code></td> <td> <p>Name of variable that gives each model a unique integer id.</p> </td></tr> <tr valign="top"><td><code>columns</code></td> <td> <p>In <code>permute_</code>, vector of column names to permute.</p> </td></tr> </table> <h3>Value</h3> <p>A data frame with <code>n</code> rows and one column: <code>perm</code> </p> <h3>Examples</h3> <pre> library(purrr) perms <- permute(mtcars, 1000, mpg) models <- map(perms$perm, ~ lm(mpg ~ wt, data = .)) glanced <- map_df(models, broom::glance, .id = "id") # distribution of null permutation statistics hist(glanced$statistic) # confirm these are roughly uniform p-values hist(glanced$p.value) # test against the unpermuted model to get a permutation p-value mod <- lm(mpg ~ wt, mtcars) mean(glanced$statistic > broom::glance(mod)$statistic) </pre> <hr /><div style="text-align: center;">[Package <em>modelr</em> version 0.1.8 <a href="00Index.html">Index</a>]</div> </body></html>