O'Reilly logo

R Statistical Application Development by Example Beginner's Guide by Prabhanjan Narayanachar Tattar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – understanding the bootstrap technique

The boot package, which comes shipped with R base, will be used for bootstrapping the odds ratio.

  1. Get the boot package using library(boot).

    The boot package is shipped with the R software itself, and thus it does not require separate installation. The main components for the boot function will be soon explained.

  2. Define the odds-ratio function:
    OR <- function(data,i)  	{
    x <- data[,1]; y <- data[,2]
    odds.ratio <- (sum(x[i]==1,na.rm=TRUE)/length(na.omit(x[i])))/ (sum(y[i]==1,na.rm=TRUE)/length(na.omit(y[i])))
    return(odds.ratio)
          }

    The OR name stands, of course, for odds-ratio. data for this function consists of two columns, one of which may have more observations than the other. The option na.rm is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required