diff --git a/docs/404.html b/docs/404.html new file mode 100644 index 0000000..2eed539 --- /dev/null +++ b/docs/404.html @@ -0,0 +1,93 @@ + + + + + + + +Page not found (404) • flipscores + + + + + + + + + + + +
+
+ + + + +
+
+ + +Content not found. Please use links in the navbar. + +
+ + + +
+ + + + +
+ + + + + + + + diff --git a/docs/authors.html b/docs/authors.html new file mode 100644 index 0000000..17ef918 --- /dev/null +++ b/docs/authors.html @@ -0,0 +1,88 @@ + +Authors and Citation • flipscores + + +
+
+ + + +
+
+
+ + + +
  • +

    Livio Finos. Maintainer. +

    +
  • +
+
+
+

Citation

+ +
+
+ + +

Finos L, Goeman J, Hemerik J, De Santis. wcoR (2023). +flipscores: Robust Score Testing in GLMs, by Sign-Flip Contributions. +R package version 1.3.1. +

+
@Manual{,
+  title = {flipscores: Robust Score Testing in GLMs, by Sign-Flip Contributions},
+  author = {Livio Finos and Jelle Goeman and Jesse Hemerik and with contribution of Riccardo {De Santis.}},
+  year = {2023},
+  note = {R package version 1.3.1},
+}
+ +
+ +
+ + + +
+ + + + + + + + diff --git a/docs/bootstrap-toc.css b/docs/bootstrap-toc.css new file mode 100644 index 0000000..5a85941 --- /dev/null +++ b/docs/bootstrap-toc.css @@ -0,0 +1,60 @@ +/*! + * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) + * Copyright 2015 Aidan Feldman + * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ + +/* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ + +/* All levels of nav */ +nav[data-toggle='toc'] .nav > li > a { + display: block; + padding: 4px 20px; + font-size: 13px; + font-weight: 500; + color: #767676; +} +nav[data-toggle='toc'] .nav > li > a:hover, +nav[data-toggle='toc'] .nav > li > a:focus { + padding-left: 19px; + color: #563d7c; + text-decoration: none; + background-color: transparent; + border-left: 1px solid #563d7c; +} +nav[data-toggle='toc'] .nav > .active > a, +nav[data-toggle='toc'] .nav > .active:hover > a, +nav[data-toggle='toc'] .nav > .active:focus > a { + padding-left: 18px; + font-weight: bold; + color: #563d7c; + background-color: transparent; + border-left: 2px solid #563d7c; +} + +/* Nav: second level (shown on .active) */ +nav[data-toggle='toc'] .nav .nav { + display: none; /* Hide by default, but at >768px, show it */ + padding-bottom: 10px; +} +nav[data-toggle='toc'] .nav .nav > li > a { + padding-top: 1px; + padding-bottom: 1px; + padding-left: 30px; + font-size: 12px; + font-weight: normal; +} +nav[data-toggle='toc'] .nav .nav > li > a:hover, +nav[data-toggle='toc'] .nav .nav > li > a:focus { + padding-left: 29px; +} +nav[data-toggle='toc'] .nav .nav > .active > a, +nav[data-toggle='toc'] .nav .nav > .active:hover > a, +nav[data-toggle='toc'] .nav .nav > .active:focus > a { + padding-left: 28px; + font-weight: 500; +} + +/* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ +nav[data-toggle='toc'] .nav > .active > ul { + display: block; +} diff --git a/docs/bootstrap-toc.js b/docs/bootstrap-toc.js new file mode 100644 index 0000000..1cdd573 --- /dev/null +++ b/docs/bootstrap-toc.js @@ -0,0 +1,159 @@ +/*! + * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) + * Copyright 2015 Aidan Feldman + * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ +(function() { + 'use strict'; + + window.Toc = { + helpers: { + // return all matching elements in the set, or their descendants + findOrFilter: function($el, selector) { + // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/ + // http://stackoverflow.com/a/12731439/358804 + var $descendants = $el.find(selector); + return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])'); + }, + + generateUniqueIdBase: function(el) { + var text = $(el).text(); + var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-'); + return anchor || el.tagName.toLowerCase(); + }, + + generateUniqueId: function(el) { + var anchorBase = this.generateUniqueIdBase(el); + for (var i = 0; ; i++) { + var anchor = anchorBase; + if (i > 0) { + // add suffix + anchor += '-' + i; + } + // check if ID already exists + if (!document.getElementById(anchor)) { + return anchor; + } + } + }, + + generateAnchor: function(el) { + if (el.id) { + return el.id; + } else { + var anchor = this.generateUniqueId(el); + el.id = anchor; + return anchor; + } + }, + + createNavList: function() { + return $(''); + }, + + createChildNavList: function($parent) { + var $childList = this.createNavList(); + $parent.append($childList); + return $childList; + }, + + generateNavEl: function(anchor, text) { + var $a = $(''); + $a.attr('href', '#' + anchor); + $a.text(text); + var $li = $('
  • '); + $li.append($a); + return $li; + }, + + generateNavItem: function(headingEl) { + var anchor = this.generateAnchor(headingEl); + var $heading = $(headingEl); + var text = $heading.data('toc-text') || $heading.text(); + return this.generateNavEl(anchor, text); + }, + + // Find the first heading level (`

    `, then `

    `, etc.) that has more than one element. Defaults to 1 (for `

    `). + getTopLevel: function($scope) { + for (var i = 1; i <= 6; i++) { + var $headings = this.findOrFilter($scope, 'h' + i); + if ($headings.length > 1) { + return i; + } + } + + return 1; + }, + + // returns the elements for the top level, and the next below it + getHeadings: function($scope, topLevel) { + var topSelector = 'h' + topLevel; + + var secondaryLevel = topLevel + 1; + var secondarySelector = 'h' + secondaryLevel; + + return this.findOrFilter($scope, topSelector + ',' + secondarySelector); + }, + + getNavLevel: function(el) { + return parseInt(el.tagName.charAt(1), 10); + }, + + populateNav: function($topContext, topLevel, $headings) { + var $context = $topContext; + var $prevNav; + + var helpers = this; + $headings.each(function(i, el) { + var $newNav = helpers.generateNavItem(el); + var navLevel = helpers.getNavLevel(el); + + // determine the proper $context + if (navLevel === topLevel) { + // use top level + $context = $topContext; + } else if ($prevNav && $context === $topContext) { + // create a new level of the tree and switch to it + $context = helpers.createChildNavList($prevNav); + } // else use the current $context + + $context.append($newNav); + + $prevNav = $newNav; + }); + }, + + parseOps: function(arg) { + var opts; + if (arg.jquery) { + opts = { + $nav: arg + }; + } else { + opts = arg; + } + opts.$scope = opts.$scope || $(document.body); + return opts; + } + }, + + // accepts a jQuery object, or an options object + init: function(opts) { + opts = this.helpers.parseOps(opts); + + // ensure that the data attribute is in place for styling + opts.$nav.attr('data-toggle', 'toc'); + + var $topContext = this.helpers.createChildNavList(opts.$nav); + var topLevel = this.helpers.getTopLevel(opts.$scope); + var $headings = this.helpers.getHeadings(opts.$scope, topLevel); + this.helpers.populateNav($topContext, topLevel, $headings); + } + }; + + $(function() { + $('nav[data-toggle="toc"]').each(function(i, el) { + var $nav = $(el); + Toc.init($nav); + }); + }); +})(); diff --git a/docs/docsearch.css b/docs/docsearch.css new file mode 100644 index 0000000..e5f1fe1 --- /dev/null +++ b/docs/docsearch.css @@ -0,0 +1,148 @@ +/* Docsearch -------------------------------------------------------------- */ +/* + Source: https://github.com/algolia/docsearch/ + License: MIT +*/ + +.algolia-autocomplete { + display: block; + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1 +} + +.algolia-autocomplete .ds-dropdown-menu { + width: 100%; + min-width: none; + max-width: none; + padding: .75rem 0; + background-color: #fff; + background-clip: padding-box; + border: 1px solid rgba(0, 0, 0, .1); + box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .175); +} + +@media (min-width:768px) { + .algolia-autocomplete .ds-dropdown-menu { + width: 175% + } +} + +.algolia-autocomplete .ds-dropdown-menu::before { + display: none +} + +.algolia-autocomplete .ds-dropdown-menu [class^=ds-dataset-] { + padding: 0; + background-color: rgb(255,255,255); + border: 0; + max-height: 80vh; +} + +.algolia-autocomplete .ds-dropdown-menu .ds-suggestions { + margin-top: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion { + padding: 0; + overflow: visible +} + +.algolia-autocomplete .algolia-docsearch-suggestion--category-header { + padding: .125rem 1rem; + margin-top: 0; + font-size: 1.3em; + font-weight: 500; + color: #00008B; + border-bottom: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--wrapper { + float: none; + padding-top: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column { + float: none; + width: auto; + padding: 0; + text-align: left +} + +.algolia-autocomplete .algolia-docsearch-suggestion--content { + float: none; + width: auto; + padding: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--content::before { + display: none +} + +.algolia-autocomplete .ds-suggestion:not(:first-child) .algolia-docsearch-suggestion--category-header { + padding-top: .75rem; + margin-top: .75rem; + border-top: 1px solid rgba(0, 0, 0, .1) +} + +.algolia-autocomplete .ds-suggestion .algolia-docsearch-suggestion--subcategory-column { + display: block; + padding: .1rem 1rem; + margin-bottom: 0.1; + font-size: 1.0em; + font-weight: 400 + /* display: none */ +} + +.algolia-autocomplete .algolia-docsearch-suggestion--title { + display: block; + padding: .25rem 1rem; + margin-bottom: 0; + font-size: 0.9em; + font-weight: 400 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--text { + padding: 0 1rem .5rem; + margin-top: -.25rem; + font-size: 0.8em; + font-weight: 400; + line-height: 1.25 +} + +.algolia-autocomplete .algolia-docsearch-footer { + width: 110px; + height: 20px; + z-index: 3; + margin-top: 10.66667px; + float: right; + font-size: 0; + line-height: 0; +} + +.algolia-autocomplete .algolia-docsearch-footer--logo { + background-image: url("data:image/svg+xml;utf8,"); + background-repeat: no-repeat; + background-position: 50%; + background-size: 100%; + overflow: hidden; + text-indent: -9000px; + width: 100%; + height: 100%; + display: block; + transform: translate(-8px); +} + +.algolia-autocomplete .algolia-docsearch-suggestion--highlight { + color: #FF8C00; + background: rgba(232, 189, 54, 0.1) +} + + +.algolia-autocomplete .algolia-docsearch-suggestion--text .algolia-docsearch-suggestion--highlight { + box-shadow: inset 0 -2px 0 0 rgba(105, 105, 105, .5) +} + +.algolia-autocomplete .ds-suggestion.ds-cursor .algolia-docsearch-suggestion--content { + background-color: rgba(192, 192, 192, .15) +} diff --git a/docs/docsearch.js b/docs/docsearch.js new file mode 100644 index 0000000..b35504c --- /dev/null +++ b/docs/docsearch.js @@ -0,0 +1,85 @@ +$(function() { + + // register a handler to move the focus to the search bar + // upon pressing shift + "/" (i.e. "?") + $(document).on('keydown', function(e) { + if (e.shiftKey && e.keyCode == 191) { + e.preventDefault(); + $("#search-input").focus(); + } + }); + + $(document).ready(function() { + // do keyword highlighting + /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ + var mark = function() { + + var referrer = document.URL ; + var paramKey = "q" ; + + if (referrer.indexOf("?") !== -1) { + var qs = referrer.substr(referrer.indexOf('?') + 1); + var qs_noanchor = qs.split('#')[0]; + var qsa = qs_noanchor.split('&'); + var keyword = ""; + + for (var i = 0; i < qsa.length; i++) { + var currentParam = qsa[i].split('='); + + if (currentParam.length !== 2) { + continue; + } + + if (currentParam[0] == paramKey) { + keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); + } + } + + if (keyword !== "") { + $(".contents").unmark({ + done: function() { + $(".contents").mark(keyword); + } + }); + } + } + }; + + mark(); + }); +}); + +/* Search term highlighting ------------------------------*/ + +function matchedWords(hit) { + var words = []; + + var hierarchy = hit._highlightResult.hierarchy; + // loop to fetch from lvl0, lvl1, etc. + for (var idx in hierarchy) { + words = words.concat(hierarchy[idx].matchedWords); + } + + var content = hit._highlightResult.content; + if (content) { + words = words.concat(content.matchedWords); + } + + // return unique words + var words_uniq = [...new Set(words)]; + return words_uniq; +} + +function updateHitURL(hit) { + + var words = matchedWords(hit); + var url = ""; + + if (hit.anchor) { + url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; + } else { + url = hit.url + '?q=' + escape(words.join(" ")); + } + + return url; +} diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..d2a7c01 --- /dev/null +++ b/docs/index.html @@ -0,0 +1,287 @@ + + + + + + + +Robust Score Testing in GLMs, by Sign-Flip Contributions • flipscores + + + + + + + + + + + + +
    +
    + + + + +
    +
    +
    + +

    On CRAN version

    +
    +
    +

    Set up +

    +

    To install this github version type (in R):

    +
    ##if devtools is not installed yet: 
    +## install.packages("devtools") 
    +library(devtools)
    +install_github("livioivil/flipscores")
    +
    +
    +

    References +

    +

    J Hemerik, JJ Goeman and L Finos (2019) Robust testing in generalized linear models by sign-flipping score contributions. Journal of the Royal Statistical Society Series B: Statistical Methodology, Volume 82, Issue 3, July 2020, Pages 841–864.
    https://doi.org/10.1111/rssb.12369

    +

    R De Santis, J Goeman, J Hemerik, L Finos (2022) Inference in generalized linear models with robustness to misspecified variances arXiv: 2209.13918.
    https://arxiv.org/abs/2209.13918

    +
    +
    +

    Some examples +

    +
    +library(flipscores)
    +set.seed(1)
    +dt=data.frame(X=rnorm(20),
    +   Z=factor(rep(LETTERS[1:3],length.out=20)))
    +dt$Y=rpois(n=20,lambda=exp(dt$X))
    +mod=flipscores(Y~Z+X,data=dt,family="poisson",x=TRUE)
    +summary(mod)
    +#> 
    +#> Call:
    +#> flipscores(formula = Y ~ Z + X, family = "poisson", data = dt, 
    +#>     x = TRUE)
    +#> 
    +#> Deviance Residuals: 
    +#>     Min       1Q   Median       3Q      Max  
    +#> -1.6910  -0.5792   0.1012   0.4900   1.0440  
    +#> 
    +#> Coefficients:
    +#>             Estimate   Score Std. Error z value Part. Cor Pr(>|z|)   
    +#> (Intercept)  -0.1026 -0.7229     2.7127 -0.2665    -0.088   0.7460   
    +#> ZB           -0.1501 -0.7125     2.1789 -0.3270    -0.104   0.6564   
    +#> ZC            0.1633  0.8106     2.2232  0.3646     0.117   0.6924   
    +#> X             0.9439 16.2062     4.7272  3.4283     0.671   0.0098 **
    +#> ---
    +#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
    +#> 
    +#> (Dispersion parameter for poisson family taken to be 1)
    +#> 
    +#>     Null deviance: 27.135  on 19  degrees of freedom
    +#> Residual deviance: 12.888  on 16  degrees of freedom
    +#> AIC: 57.459
    +#> 
    +#> Number of Fisher Scoring iterations: 5
    +
    +# Anova test
    +anova(mod)
    +#> Analysis of Deviance Table (Type III test)
    +#> 
    +#> Model: poisson, link: log
    +#> 
    +#> Inference is provided by FlipScores approach (5000 sign flips).
    +#> 
    +#> Model: Y ~ Z + X
    +#>   Df   Score Pr(>Score)   
    +#> Z  2 0.77184     0.6984   
    +#> X  1 0.02977     0.0098 **
    +#> ---
    +#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
    +# or
    +mod0=flipscores(Y~Z,data=dt,family="poisson",x=TRUE)
    +anova(mod0,mod)
    +#> Analysis of Deviance Table (Type III test)
    +#> 
    +#> Model: poisson, link: log
    +#> 
    +#> Inference is provided by FlipScores approach (5000 sign flips).
    +#> 
    +#> Model 1: Y ~ Z
    +#> Model 2: Y ~ Z + X
    +#>                    Df    Score Pr(>Score)  
    +#> Model 2 vs Model 1  1 0.029586     0.0108 *
    +#> ---
    +#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
    +# and
    +mod0=flipscores(Y~X,data=dt,family="poisson")
    +anova(mod0,mod)
    +#> Analysis of Deviance Table (Type III test)
    +#> 
    +#> Model: poisson, link: log
    +#> 
    +#> Inference is provided by FlipScores approach (5000 sign flips).
    +#> 
    +#> Model 1: Y ~ X
    +#> Model 2: Y ~ Z + X
    +#>                    Df  Score Pr(>Score)
    +#> Model 2 vs Model 1  2 1.4245     0.5244
    +
    +

    Negative Binomial +

    +
    +set.seed(1)
    +D=data.frame(x=(1:40)/20, z=rnorm(40))
    +D$y=rnbinom(40,mu=exp(D$x),size=3)
    +
    +library(MASS)
    +mod_par=glm.nb(y~x+z,data=D, link="log")
    +summary(mod_par)
    +#> 
    +#> Call:
    +#> glm.nb(formula = y ~ x + z, data = D, link = "log", init.theta = 7.972747099)
    +#> 
    +#> Deviance Residuals: 
    +#>     Min       1Q   Median       3Q      Max  
    +#> -2.0746  -0.7748  -0.1086   0.4617   2.0435  
    +#> 
    +#> Coefficients:
    +#>             Estimate Std. Error z value Pr(>|z|)    
    +#> (Intercept) -0.15365    0.29358  -0.523    0.601    
    +#> x            0.92089    0.21481   4.287 1.81e-05 ***
    +#> z           -0.01282    0.13606  -0.094    0.925    
    +#> ---
    +#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
    +#> 
    +#> (Dispersion parameter for Negative Binomial(7.9727) family taken to be 1)
    +#> 
    +#>     Null deviance: 61.217  on 39  degrees of freedom
    +#> Residual deviance: 41.312  on 37  degrees of freedom
    +#> AIC: 154.29
    +#> 
    +#> Number of Fisher Scoring iterations: 1
    +#> 
    +#> 
    +#>               Theta:  7.97 
    +#>           Std. Err.:  6.95 
    +#> 
    +#>  2 x log-likelihood:  -146.286
    +mod=flipscores(y~x+z, data=D, family = "negbinom") 
    +summary(mod)
    +#> 
    +#> Call:
    +#> flipscores(formula = y ~ x + z, family = "negbinom", data = D)
    +#> 
    +#> Deviance Residuals: 
    +#>     Min       1Q   Median       3Q      Max  
    +#> -2.0746  -0.7748  -0.1086   0.4617   2.0435  
    +#> 
    +#> Coefficients:
    +#>             Estimate    Score Std. Error  z value Part. Cor Pr(>|t|)   
    +#> (Intercept) -0.15365 -1.84162    3.42399 -0.53786    -0.087   0.5808   
    +#> x            0.92089 14.93128    4.42610  3.37346     0.547   0.0014 **
    +#> z           -0.01282 -0.72457    7.24491 -0.10001    -0.016   0.9612   
    +#> ---
    +#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
    +#> 
    +#> (Dispersion parameter for Negative Binomial(7.9727) family taken to be 0.9960228)
    +#> 
    +#>     Null deviance: 61.217  on 39  degrees of freedom
    +#> Residual deviance: 41.312  on 37  degrees of freedom
    +#> AIC: 154.29
    +#> 
    +#> Number of Fisher Scoring iterations: 1
    +
    +
    +
    +

    Bug reports +

    +

    If you encounter a bug, please file a reprex (minimal reproducible example) on github.

    +
    +
    +
    + + +
    + + +
    + +
    +

    +

    Site built with pkgdown 2.0.7.

    +
    + +
    +
    + + + + + + + + diff --git a/docs/link.svg b/docs/link.svg new file mode 100644 index 0000000..88ad827 --- /dev/null +++ b/docs/link.svg @@ -0,0 +1,12 @@ + + + + + + diff --git a/docs/pkgdown.css b/docs/pkgdown.css new file mode 100644 index 0000000..80ea5b8 --- /dev/null +++ b/docs/pkgdown.css @@ -0,0 +1,384 @@ +/* Sticky footer */ + +/** + * Basic idea: https://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/ + * Details: https://github.com/philipwalton/solved-by-flexbox/blob/master/assets/css/components/site.css + * + * .Site -> body > .container + * .Site-content -> body > .container .row + * .footer -> footer + * + * Key idea seems to be to ensure that .container and __all its parents__ + * have height set to 100% + * + */ + +html, body { + height: 100%; +} + +body { + position: relative; +} + +body > .container { + display: flex; + height: 100%; + flex-direction: column; +} + +body > .container .row { + flex: 1 0 auto; +} + +footer { + margin-top: 45px; + padding: 35px 0 36px; + border-top: 1px solid #e5e5e5; + color: #666; + display: flex; + flex-shrink: 0; +} +footer p { + margin-bottom: 0; +} +footer div { + flex: 1; +} +footer .pkgdown { + text-align: right; +} +footer p { + margin-bottom: 0; +} + +img.icon { + float: right; +} + +/* Ensure in-page images don't run outside their container */ +.contents img { + max-width: 100%; + height: auto; +} + +/* Fix bug in bootstrap (only seen in firefox) */ +summary { + display: list-item; +} + +/* Typographic tweaking ---------------------------------*/ + +.contents .page-header { + margin-top: calc(-60px + 1em); +} + +dd { + margin-left: 3em; +} + +/* Section anchors ---------------------------------*/ + +a.anchor { + display: none; + margin-left: 5px; + width: 20px; + height: 20px; + + background-image: url(./link.svg); + background-repeat: no-repeat; + background-size: 20px 20px; + background-position: center center; +} + +h1:hover .anchor, +h2:hover .anchor, +h3:hover .anchor, +h4:hover .anchor, +h5:hover .anchor, +h6:hover .anchor { + display: inline-block; +} + +/* Fixes for fixed navbar --------------------------*/ + +.contents h1, .contents h2, .contents h3, .contents h4 { + padding-top: 60px; + margin-top: -40px; +} + +/* Navbar submenu --------------------------*/ + +.dropdown-submenu { + position: relative; +} + +.dropdown-submenu>.dropdown-menu { + top: 0; + left: 100%; + margin-top: -6px; + margin-left: -1px; + border-radius: 0 6px 6px 6px; +} + +.dropdown-submenu:hover>.dropdown-menu { + display: block; +} + +.dropdown-submenu>a:after { + display: block; + content: " "; + float: right; + width: 0; + height: 0; + border-color: transparent; + border-style: solid; + border-width: 5px 0 5px 5px; + border-left-color: #cccccc; + margin-top: 5px; + margin-right: -10px; +} + +.dropdown-submenu:hover>a:after { + border-left-color: #ffffff; +} + +.dropdown-submenu.pull-left { + float: none; +} + +.dropdown-submenu.pull-left>.dropdown-menu { + left: -100%; + margin-left: 10px; + border-radius: 6px 0 6px 6px; +} + +/* Sidebar --------------------------*/ + +#pkgdown-sidebar { + margin-top: 30px; + position: -webkit-sticky; + position: sticky; + top: 70px; +} + +#pkgdown-sidebar h2 { + font-size: 1.5em; + margin-top: 1em; +} + +#pkgdown-sidebar h2:first-child { + margin-top: 0; +} + +#pkgdown-sidebar .list-unstyled li { + margin-bottom: 0.5em; +} + +/* bootstrap-toc tweaks ------------------------------------------------------*/ + +/* All levels of nav */ + +nav[data-toggle='toc'] .nav > li > a { + padding: 4px 20px 4px 6px; + font-size: 1.5rem; + font-weight: 400; + color: inherit; +} + +nav[data-toggle='toc'] .nav > li > a:hover, +nav[data-toggle='toc'] .nav > li > a:focus { + padding-left: 5px; + color: inherit; + border-left: 1px solid #878787; +} + +nav[data-toggle='toc'] .nav > .active > a, +nav[data-toggle='toc'] .nav > .active:hover > a, +nav[data-toggle='toc'] .nav > .active:focus > a { + padding-left: 5px; + font-size: 1.5rem; + font-weight: 400; + color: inherit; + border-left: 2px solid #878787; +} + +/* Nav: second level (shown on .active) */ + +nav[data-toggle='toc'] .nav .nav { + display: none; /* Hide by default, but at >768px, show it */ + padding-bottom: 10px; +} + +nav[data-toggle='toc'] .nav .nav > li > a { + padding-left: 16px; + font-size: 1.35rem; +} + +nav[data-toggle='toc'] .nav .nav > li > a:hover, +nav[data-toggle='toc'] .nav .nav > li > a:focus { + padding-left: 15px; +} + +nav[data-toggle='toc'] .nav .nav > .active > a, +nav[data-toggle='toc'] .nav .nav > .active:hover > a, +nav[data-toggle='toc'] .nav .nav > .active:focus > a { + padding-left: 15px; + font-weight: 500; + font-size: 1.35rem; +} + +/* orcid ------------------------------------------------------------------- */ + +.orcid { + font-size: 16px; + color: #A6CE39; + /* margins are required by official ORCID trademark and display guidelines */ + margin-left:4px; + margin-right:4px; + vertical-align: middle; +} + +/* Reference index & topics ----------------------------------------------- */ + +.ref-index th {font-weight: normal;} + +.ref-index td {vertical-align: top; min-width: 100px} +.ref-index .icon {width: 40px;} +.ref-index .alias {width: 40%;} +.ref-index-icons .alias {width: calc(40% - 40px);} +.ref-index .title {width: 60%;} + +.ref-arguments th {text-align: right; padding-right: 10px;} +.ref-arguments th, .ref-arguments td {vertical-align: top; min-width: 100px} +.ref-arguments .name {width: 20%;} +.ref-arguments .desc {width: 80%;} + +/* Nice scrolling for wide elements --------------------------------------- */ + +table { + display: block; + overflow: auto; +} + +/* Syntax highlighting ---------------------------------------------------- */ + +pre, code, pre code { + background-color: #f8f8f8; + color: #333; +} +pre, pre code { + white-space: pre-wrap; + word-break: break-all; + overflow-wrap: break-word; +} + +pre { + border: 1px solid #eee; +} + +pre .img, pre .r-plt { + margin: 5px 0; +} + +pre .img img, pre .r-plt img { + background-color: #fff; +} + +code a, pre a { + color: #375f84; +} + +a.sourceLine:hover { + text-decoration: none; +} + +.fl {color: #1514b5;} +.fu {color: #000000;} /* function */ +.ch,.st {color: #036a07;} /* string */ +.kw {color: #264D66;} /* keyword */ +.co {color: #888888;} /* comment */ + +.error {font-weight: bolder;} +.warning {font-weight: bolder;} + +/* Clipboard --------------------------*/ + +.hasCopyButton { + position: relative; +} + +.btn-copy-ex { + position: absolute; + right: 0; + top: 0; + visibility: hidden; +} + +.hasCopyButton:hover button.btn-copy-ex { + visibility: visible; +} + +/* headroom.js ------------------------ */ + +.headroom { + will-change: transform; + transition: transform 200ms linear; +} +.headroom--pinned { + transform: translateY(0%); +} +.headroom--unpinned { + transform: translateY(-100%); +} + +/* mark.js ----------------------------*/ + +mark { + background-color: rgba(255, 255, 51, 0.5); + border-bottom: 2px solid rgba(255, 153, 51, 0.3); + padding: 1px; +} + +/* vertical spacing after htmlwidgets */ +.html-widget { + margin-bottom: 10px; +} + +/* fontawesome ------------------------ */ + +.fab { + font-family: "Font Awesome 5 Brands" !important; +} + +/* don't display links in code chunks when printing */ +/* source: https://stackoverflow.com/a/10781533 */ +@media print { + code a:link:after, code a:visited:after { + content: ""; + } +} + +/* Section anchors --------------------------------- + Added in pandoc 2.11: https://github.com/jgm/pandoc-templates/commit/9904bf71 +*/ + +div.csl-bib-body { } +div.csl-entry { + clear: both; +} +.hanging-indent div.csl-entry { + margin-left:2em; + text-indent:-2em; +} +div.csl-left-margin { + min-width:2em; + float:left; +} +div.csl-right-inline { + margin-left:2em; + padding-left:1em; +} +div.csl-indent { + margin-left: 2em; +} diff --git a/docs/pkgdown.js b/docs/pkgdown.js new file mode 100644 index 0000000..6f0eee4 --- /dev/null +++ b/docs/pkgdown.js @@ -0,0 +1,108 @@ +/* http://gregfranko.com/blog/jquery-best-practices/ */ +(function($) { + $(function() { + + $('.navbar-fixed-top').headroom(); + + $('body').css('padding-top', $('.navbar').height() + 10); + $(window).resize(function(){ + $('body').css('padding-top', $('.navbar').height() + 10); + }); + + $('[data-toggle="tooltip"]').tooltip(); + + var cur_path = paths(location.pathname); + var links = $("#navbar ul li a"); + var max_length = -1; + var pos = -1; + for (var i = 0; i < links.length; i++) { + if (links[i].getAttribute("href") === "#") + continue; + // Ignore external links + if (links[i].host !== location.host) + continue; + + var nav_path = paths(links[i].pathname); + + var length = prefix_length(nav_path, cur_path); + if (length > max_length) { + max_length = length; + pos = i; + } + } + + // Add class to parent
  • , and enclosing
  • if in dropdown + if (pos >= 0) { + var menu_anchor = $(links[pos]); + menu_anchor.parent().addClass("active"); + menu_anchor.closest("li.dropdown").addClass("active"); + } + }); + + function paths(pathname) { + var pieces = pathname.split("/"); + pieces.shift(); // always starts with / + + var end = pieces[pieces.length - 1]; + if (end === "index.html" || end === "") + pieces.pop(); + return(pieces); + } + + // Returns -1 if not found + function prefix_length(needle, haystack) { + if (needle.length > haystack.length) + return(-1); + + // Special case for length-0 haystack, since for loop won't run + if (haystack.length === 0) { + return(needle.length === 0 ? 0 : -1); + } + + for (var i = 0; i < haystack.length; i++) { + if (needle[i] != haystack[i]) + return(i); + } + + return(haystack.length); + } + + /* Clipboard --------------------------*/ + + function changeTooltipMessage(element, msg) { + var tooltipOriginalTitle=element.getAttribute('data-original-title'); + element.setAttribute('data-original-title', msg); + $(element).tooltip('show'); + element.setAttribute('data-original-title', tooltipOriginalTitle); + } + + if(ClipboardJS.isSupported()) { + $(document).ready(function() { + var copyButton = ""; + + $("div.sourceCode").addClass("hasCopyButton"); + + // Insert copy buttons: + $(copyButton).prependTo(".hasCopyButton"); + + // Initialize tooltips: + $('.btn-copy-ex').tooltip({container: 'body'}); + + // Initialize clipboard: + var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { + text: function(trigger) { + return trigger.parentNode.textContent.replace(/\n#>[^\n]*/g, ""); + } + }); + + clipboardBtnCopies.on('success', function(e) { + changeTooltipMessage(e.trigger, 'Copied!'); + e.clearSelection(); + }); + + clipboardBtnCopies.on('error', function() { + changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); + }); + }); + } +})(window.jQuery || window.$) diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml new file mode 100644 index 0000000..66e919b --- /dev/null +++ b/docs/pkgdown.yml @@ -0,0 +1,6 @@ +pandoc: 2.19.2 +pkgdown: 2.0.7 +pkgdown_sha: ~ +articles: {} +last_built: 2023-11-04T23:44Z + diff --git a/docs/reference/Rplot001.png b/docs/reference/Rplot001.png new file mode 100644 index 0000000..17a3580 Binary files /dev/null and b/docs/reference/Rplot001.png differ diff --git a/docs/reference/anova.flipscores.html b/docs/reference/anova.flipscores.html new file mode 100644 index 0000000..851bef0 --- /dev/null +++ b/docs/reference/anova.flipscores.html @@ -0,0 +1,197 @@ + +anova.flipscores — anova.flipscores • flipscores + + +
    +
    + + + +
    +
    + + +
    +

    This is the anova method for flipscores object. Remark: it performs type III deviance decomposition as in car::Anova.

    +
    + +
    +
    # S3 method for flipscores
    +anova(object, model1 = NULL, score_type = NULL, n_flips = 5000, id = NULL, ...)
    +
    + +
    +

    Arguments

    +
    object
    +

    (the object) glm (or flipscores) object with the model under the null hypothesis (i.e. the covariates, the nuisance parameters).

    + + +
    model1
    +

    a glm (or flipscores) or a matrix (or vector). If it is a glm object, it has the model under the alternative hypothesis. The variables in model1 are the same variables in object plus one or more variables to be tested. Alternatively, if +model1 is a matrix, it contains the tested variables column-wise.

    + + +
    score_type
    +

    The type of score that is computed. It can be "orthogonalized", "effective" or "basic". +Default is "orthogonalized". "effective" and "orthogonalized" take into account the nuisance estimation. The default is NULL, in this case the value is taken from object.

    + + +
    n_flips
    +

    The number of random flips of the score contributions. +When n_flips is equal or larger than the maximum number of possible flips (i.e. n^2), all possible flips are performed. +Default is 5000.

    + + +
    id
    +

    a vector identifying the clustered observations. If NULL (default) observations are assumed to be independent. NOTE: if object is a flipscores and model$flip_param_call$id is not NULL, this is considered in the inference.

    + + +
    ...
    +

    other parameters allowed in stats::anova.

    + +
    + +
    +

    Examples

    +
    set.seed(1)
    +dt=data.frame(X=scale(rnorm(50)),
    +   Z=factor(rep(LETTERS[1:3],length.out=50)))
    +dt$Y=rpois(n=nrow(dt),lambda=exp(dt$X*(dt$Z=="C")))
    +mod0=flipscores(Y~Z+X,data=dt,family="poisson")
    +summary(mod0)
    +#> 
    +#> Call:
    +#> flipscores(formula = Y ~ Z + X, family = "poisson", data = dt)
    +#> 
    +#> Deviance Residuals: 
    +#>     Min       1Q   Median       3Q      Max  
    +#> -2.0810  -1.0541  -0.1611   0.3069   2.9506  
    +#> 
    +#> Coefficients:
    +#>             Estimate   Score Std. Error z value Part. Cor Pr(>|z|)   
    +#> (Intercept)  -0.3513 -5.4234     4.2404 -1.2790    -0.169   0.1136   
    +#> ZB            0.2276  1.8049     2.8140  0.6414     0.079   0.4564   
    +#> ZC            0.9034 10.3392     3.4527  2.9945     0.348   0.0218 * 
    +#> X             0.6381 33.1170     8.0470  4.1155     0.478   0.0092 **
    +#> ---
    +#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
    +#> 
    +#> (Dispersion parameter for poisson family taken to be 1)
    +#> 
    +#>     Null deviance: 82.225  on 49  degrees of freedom
    +#> Residual deviance: 52.798  on 46  degrees of freedom
    +#> AIC: 143.12
    +#> 
    +#> Number of Fisher Scoring iterations: 5
    +#> 
    +anova(mod0)
    +#> Analysis of Deviance Table (Type III test)
    +#> 
    +#> Model: poisson, link: log
    +#> 
    +#> Inference is provided by FlipScores approach (5000 sign flips).
    +#> 
    +#> Model: Y ~ Z + X
    +#>   Df  Score Pr(>Score)   
    +#> Z  2 4.4082     0.0964 . 
    +#> X  1 0.0341     0.0092 **
    +#> ---
    +#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
    +
    +mod1=flipscores(Y~Z*X,data=dt,family="poisson")
    +summary(mod1)
    +#> 
    +#> Call:
    +#> flipscores(formula = Y ~ Z * X, family = "poisson", data = dt)
    +#> 
    +#> Deviance Residuals: 
    +#>      Min        1Q    Median        3Q       Max  
    +#> -1.94518  -0.88566  -0.00768   0.56160   1.70791  
    +#> 
    +#> Coefficients:
    +#>             Estimate   Score Std. Error z value Part. Cor Pr(>|z|)  
    +#> (Intercept)  -0.3549 -4.3865     3.8867 -1.1286    -0.189   0.1008  
    +#> ZB            0.3570  2.3488     2.6093  0.9002     0.145   0.3038  
    +#> ZC            0.6023  3.3952     2.3099  1.4698     0.235   0.0716 .
    +#> X             0.6439  8.1773     3.6816  2.2211     0.331   0.1260  
    +#> ZB:X         -0.5979 -3.8934     2.5112 -1.5504    -0.238   0.3410  
    +#> ZC:X          0.4856  2.8440     2.4290  1.1709     0.184   0.2216  
    +#> ---
    +#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
    +#> 
    +#> (Dispersion parameter for poisson family taken to be 1)
    +#> 
    +#>     Null deviance: 82.225  on 49  degrees of freedom
    +#> Residual deviance: 44.750  on 44  degrees of freedom
    +#> AIC: 139.07
    +#> 
    +#> Number of Fisher Scoring iterations: 5
    +#> 
    +anova(mod0,model1 = mod1)
    +#> Analysis of Deviance Table (Type III test)
    +#> 
    +#> Model: poisson, link: log
    +#> 
    +#> Inference is provided by FlipScores approach (5000 sign flips).
    +#> 
    +#> Model 1: Y ~ Z + X
    +#> Model 2: Y ~ Z * X
    +#>                    Df Score Pr(>Score)  
    +#> Model 2 vs Model 1  2 4.589     0.0628 .
    +#> ---
    +#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
    +
    +
    +
    +
    + +
    + + +
    + +
    +

    Site built with pkgdown 2.0.7.

    +
    + +
    + + + + + + + + diff --git a/docs/reference/compute_scores.html b/docs/reference/compute_scores.html new file mode 100644 index 0000000..9ff2d81 --- /dev/null +++ b/docs/reference/compute_scores.html @@ -0,0 +1,117 @@ + +compute_scores — compute_scores • flipscores + + +
    +
    + + + +
    +
    + + +
    +

    Same usage as anova.glm. +The parameter id is used too, +if present in model0 (with priority) or in model1.

    +
    + +
    +
    compute_scores(model0, model1, score_type = "standardized")
    +
    + +
    +

    Arguments

    +
    model0
    +

    a glm object with the model under the null hypothesis (i.e. the covariates, the nuisance parameters).

    + + +
    model1
    +

    a glm or a matrix (or vector). If it is a glm object, it has the model under the alternative hypothesis. The variables in model1 are the same variables in model0 plus one or more variables to be tested. Alternatively, if +model1 is a matrix, it contains the tested variables column-wise.

    + + +
    score_type
    +

    The type of score that is computed. It is "orthogonalized", "effective" or "basic". +"effective" and "orthogonalized" take into account the nuisance estimation.

    + +
    +
    +

    Author

    +

    Jesse Hemerik, Riccardo De Santis, Vittorio Giatti, Jelle Goeman and Livio Finos

    +
    + +
    +

    Examples

    +
    set.seed(1)
    +Z=rnorm(20)
    +X=Z+rnorm(20)
    +Y=rpois(n=20,lambda=exp(Z+X))
    +mod0=glm(Y~Z,family="poisson")
    +X=data.frame(X=X)
    +scr0=compute_scores(model0 = mod0, model1 = X)
    +head(scr0)
    +#>             X
    +#> 1 -0.09157255
    +#> 2  1.29487548
    +#> 3  0.14949028
    +#> 4 46.19093994
    +#> 5  1.30167541
    +#> 6  0.18155826
    +
    +
    +
    + +
    + + +
    + +
    +

    Site built with pkgdown 2.0.7.

    +
    + +
    + + + + + + + + diff --git a/docs/reference/flipscores-method.html b/docs/reference/flipscores-method.html new file mode 100644 index 0000000..da34977 --- /dev/null +++ b/docs/reference/flipscores-method.html @@ -0,0 +1,96 @@ + +Methods for flipscores objects — flipscores-method • flipscores + + +
    +
    + + + +
    +
    + + +
    +

    Methods for flipscores objects. +The following are methods to extract and manipulate relevant information from +a flipscores object.

    +
    + +
    +
    # S3 method for flipscores
    +print(x, ...)
    +
    +# S3 method for flipscores
    +summary(object, ...)
    +
    + +
    +

    Arguments

    +
    x
    +

    a flipscores object

    + + +
    ...
    +

    additional arguments to be passed

    + + +
    object
    +

    a flipscores object

    + +
    + +
    + +
    + + +
    + +
    +

    Site built with pkgdown 2.0.7.

    +
    + +
    + + + + + + + + diff --git a/docs/reference/flipscores-package.html b/docs/reference/flipscores-package.html new file mode 100644 index 0000000..f8edbaf --- /dev/null +++ b/docs/reference/flipscores-package.html @@ -0,0 +1,145 @@ + +Robust Score Testing in GLMs, by Sign-Flip Contributions — flipscores-package • flipscores + + +
    +
    + + + +
    +
    + + +
    +

    It provides robust tests for testing in GLMs, by sign-flipping score contributions. The tests are often robust against overdispersion, heteroscedasticity and, in some cases, ignored nuisance variables.

    +
    + + +
    +

    Author

    +

    Livio Finos, Jelle Goeman and Jesse Hemerik, with contribution of Riccardo De Santis.

    +
    + +
    +

    Examples

    +
    set.seed(1)
    +dt=data.frame(X=rnorm(20),
    +   Z=factor(rep(LETTERS[1:3],length.out=20)))
    +dt$Y=rpois(n=20,lambda=exp(dt$X))
    +mod=flipscores(Y~Z+X,data=dt,family="poisson",x=TRUE)
    +summary(mod)
    +#> 
    +#> Call:
    +#> flipscores(formula = Y ~ Z + X, family = "poisson", data = dt, 
    +#>     x = TRUE)
    +#> 
    +#> Deviance Residuals: 
    +#>     Min       1Q   Median       3Q      Max  
    +#> -1.6910  -0.5792   0.1012   0.4900   1.0440  
    +#> 
    +#> Coefficients:
    +#>             Estimate   Score Std. Error z value Part. Cor Pr(>|z|)  
    +#> (Intercept)  -0.1026 -0.7229     2.7127 -0.2665    -0.088   0.7472  
    +#> ZB           -0.1501 -0.7125     2.1789 -0.3270    -0.104   0.6514  
    +#> ZC            0.1633  0.8106     2.2232  0.3646     0.117   0.6964  
    +#> X             0.9439 16.2062     4.7272  3.4283     0.671   0.0104 *
    +#> ---
    +#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
    +#> 
    +#> (Dispersion parameter for poisson family taken to be 1)
    +#> 
    +#>     Null deviance: 27.135  on 19  degrees of freedom
    +#> Residual deviance: 12.888  on 16  degrees of freedom
    +#> AIC: 57.459
    +#> 
    +#> Number of Fisher Scoring iterations: 5
    +#> 
    +
    +# Anova test
    +anova(mod)
    +#> Analysis of Deviance Table (Type III test)
    +#> 
    +#> Model: poisson, link: log
    +#> 
    +#> Inference is provided by FlipScores approach (5000 sign flips).
    +#> 
    +#> Model: Y ~ Z + X
    +#>   Df   Score Pr(>Score)  
    +#> Z  2 0.72827     0.7152  
    +#> X  1 0.02949     0.0104 *
    +#> ---
    +#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
    +# or
    +mod0=flipscores(Y~Z,data=dt,family="poisson",x=TRUE)
    +anova(mod0,mod)
    +#> Analysis of Deviance Table (Type III test)
    +#> 
    +#> Model: poisson, link: log
    +#> 
    +#> Inference is provided by FlipScores approach (5000 sign flips).
    +#> 
    +#> Model 1: Y ~ Z
    +#> Model 2: Y ~ Z + X
    +#>                    Df    Score Pr(>Score)   
    +#> Model 2 vs Model 1  1 0.029203     0.0098 **
    +#> ---
    +#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
    +# and
    +mod0=flipscores(Y~X,data=dt,family="poisson")
    +anova(mod0,mod)
    +#> Error in model.frame.default(formula = Y ~ X, data = dt, drop.unused.levels = TRUE): 'data' must be a data.frame, environment, or list
    +
    +
    +
    + +
    + + +
    + +
    +

    Site built with pkgdown 2.0.7.

    +
    + +
    + + + + + + + + diff --git a/docs/reference/flipscores.html b/docs/reference/flipscores.html new file mode 100644 index 0000000..cd17716 --- /dev/null +++ b/docs/reference/flipscores.html @@ -0,0 +1,206 @@ + +Robust testing in GLMs, by sign-flipping score contributions — flipscores • flipscores + + +
    +
    + + + +
    +
    + + +
    +

    Provides robust tests for testing in GLMs, by sign-flipping score contributions. The tests are often robust against overdispersion, heteroscedasticity and, in some cases, ignored nuisance variables.

    +
    + +
    +
    flipscores(formula, family, data, score_type = "standardized",
    +n_flips = 5000, alternative = "two.sided", id = NULL,
    +seed = NULL, to_be_tested = NULL, flips = NULL,
    +precompute_flips = TRUE, output_flips = FALSE, ...)
    +
    + +
    +

    Arguments

    +
    formula
    +

    see glm function. It can also be a model (usually generated by a call to glm); in this case, any other glm-related parameter (e.g. family, data, etc.) are discarded, the function will make use of the ones used to generate the model. +(i.e. formula, family, data, etc) are not considered. It is NULL by default (i.e. not used).

    + + +
    family
    +

    see glm function.

    + + +
    data
    +

    see glm function.

    + + +
    score_type
    +

    The type of score that is computed. It can be "standardized" "orthogonalized", "effective" or "basic". +Both "orthogonalized" and "effective" take into account the nuisance estimation and they provide the same +test statistic. In case of small samples "effective score" might have a slight anti-conservative behaviour. +"standardized effective score" gives a solution for this issue. +"orthogonalized" has a similar intent, note however that in case of a big model matrix, it may be slow.

    + + +
    n_flips
    +

    The number of random flips of the score contributions. Overwritten with the nrow(flips) when flips is not NULL (see parameter flips for more details). +When n_flips is equal or larger than the maximum number of possible flips (i.e. n^2), all possible flips are performed.

    + + +
    alternative
    +

    It can be "greater", "less" or "two.sided" (default)

    + + +
    id
    +

    a vector identifying the clustered observations. If NULL (default) observations are assumed to be independent. If id is not NULL, only score_type=="effective" is allowed, yet.

    + + +
    seed
    +

    NULL by default.

    + + +
    to_be_tested
    +

    vector of indices or names of coefficients of the glm model to be tested (it is faster than computing every scores and p-values of course).

    + + +
    flips
    +

    matrix fo +1 or -1, the matrix has n_flips rows and n (number of observations) columns

    + + +
    precompute_flips
    +

    TRUE by default. Overwritten if flips is not NULL. If FALSE the matrix of flips is not computed and the flips are made 'on-the-fly' before computing the test statistics; it may be usefull when flips is very large (see parameter flips for more details).

    + + +
    output_flips
    +

    FALSE by default. If TRUE the flips matrix is returned. Useful when the same flips are needed for more glms, for example in the case of multivariate glms where the joint distribution of test statistis if used for multivariate inference.

    + + +
    ...
    +

    see glm function.

    + +
    +
    +

    Value

    + + +

    an object of class flipscores. +See also its methods (summary.flipscores, anova.flipscores, print.flipscores).

    +
    +
    +

    Details

    +

    flipscores borrows the same parameters from function glm (and glm.nb). See these helps for more details about parameters such as formula, +data, family. Note: in order to use Negative Binomial family, family reference must have quotes (i.e. family="negbinom"). + Furthermore, flipscores object contains two extra elements: scores -- i.e. a matrix of n score contributions, one column for each tested coefficient -- and Tspace -- i.e. a matrix of size n_flips times ncol(scores). The fist row of Tspace contains column-wise the test statistics generated by randomly flipping the score contributions, each column refers to the same column of scores, the vector of observed test statistics (i.e. no flips) is in the first row of Tspace.

    +
    +
    +

    References

    +

    "Robust testing in generalized linear models by sign-flipping score contributions" by J.Hemerik, J.Goeman and L.Finos.

    +
    + +
    +

    Author

    +

    Livio Finos, Riccardo De Santis, Jesse Hemerik and Jelle Goeman

    +
    + +
    +

    Examples

    +
    set.seed(1)
    +dt=data.frame(X=rnorm(20),
    +   Z=factor(rep(LETTERS[1:3],length.out=20)))
    +dt$Y=rpois(n=20,lambda=exp(dt$Z=="C"))
    +mod=flipscores(Y~Z+X,data=dt,family="poisson",n_flips=1000)
    +summary(mod)
    +#> 
    +#> Call:
    +#> flipscores(formula = Y ~ Z + X, family = "poisson", data = dt, 
    +#>     n_flips = 1000)
    +#> 
    +#> Deviance Residuals: 
    +#>     Min       1Q   Median       3Q      Max  
    +#> -1.4796  -0.4363   0.1579   0.3358   0.9899  
    +#> 
    +#> Coefficients:
    +#>             Estimate    Score Std. Error  z value Part. Cor Pr(>|z|)   
    +#> (Intercept) -0.14256 -0.91360    2.62144 -0.34851    -0.127    0.744   
    +#> ZB          -0.18558 -0.50868    1.65785 -0.30683    -0.108    0.657   
    +#> ZC           1.40981  8.55380    2.58950  3.30326     0.765    0.008 **
    +#> X           -0.06964 -1.56935    4.70999 -0.33320    -0.117    0.665   
    +#> ---
    +#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
    +#> 
    +#> (Dispersion parameter for poisson family taken to be 1)
    +#> 
    +#>     Null deviance: 28.649  on 19  degrees of freedom
    +#> Residual deviance: 11.218  on 16  degrees of freedom
    +#> AIC: 58.102
    +#> 
    +#> Number of Fisher Scoring iterations: 5
    +#> 
    +
    +# Equivalent to:
    +model=glm(Y~Z+X,data=dt,family="poisson")
    +mod2=flipscores(model)
    +#> Error in model.frame.default(formula = Y ~ Z + X, data = dt, drop.unused.levels = TRUE): 'data' must be a data.frame, environment, or list
    +summary(mod2)
    +#> Error in summary(mod2): object 'mod2' not found
    +
    +
    +
    +
    + +
    + + +
    + +
    +

    Site built with pkgdown 2.0.7.

    +
    + +
    + + + + + + + + diff --git a/docs/reference/index.html b/docs/reference/index.html new file mode 100644 index 0000000..70f7d38 --- /dev/null +++ b/docs/reference/index.html @@ -0,0 +1,88 @@ + +Function reference • flipscores + + +
    +
    + + + +
    +
    + + + + + + + + + + + + + +
    +

    All functions

    +

    +
    +

    anova(<flipscores>)

    +

    anova.flipscores

    +

    compute_scores()

    +

    compute_scores

    +

    print(<flipscores>) summary(<flipscores>)

    +

    Methods for flipscores objects

    +

    flipscores-package

    +

    Robust Score Testing in GLMs, by Sign-Flip Contributions

    +

    flipscores()

    +

    Robust testing in GLMs, by sign-flipping score contributions

    + + +
    + + +
    + +
    +

    Site built with pkgdown 2.0.7.

    +
    + +
    + + + + + + + + diff --git a/docs/sitemap.xml b/docs/sitemap.xml new file mode 100644 index 0000000..96a3ed9 --- /dev/null +++ b/docs/sitemap.xml @@ -0,0 +1,30 @@ + + + + /404.html + + + /authors.html + + + /index.html + + + /reference/anova.flipscores.html + + + /reference/compute_scores.html + + + /reference/flipscores-method.html + + + /reference/flipscores-package.html + + + /reference/flipscores.html + + + /reference/index.html + +