nnt_x: Laupacis' conditional (adjusted) and harmonic mean (marginal)...

View source: R/nntx.R

nnt_xR Documentation

Laupacis' conditional (adjusted) and harmonic mean (marginal) NNT calculator in linear and generalized regression models.

Description

Calculates Laupacis' unadjusted, conditional (adjusted) and harmonic mean (marginal) NNT. Takes a data-set suitable for a regression analysis and returns the estimated conditional (adjusted) NNT(x), the estimated unadjusted, and the estimated harmonic mean (marginal) NNT given the explanatory variable, and a specified model.

Usage

nnt_x(model, response, x, cutoff, base, group, adj, decrease, data)

Arguments

model

specification of the regression model; anova for the one-way ANOVA model, linreg for the linear regression, and logreg for the logistic regression with the logit link-function.

response

vector of the response variable (i.e., the dependent variable).

x

vector of the explanatory variable.

cutoff

the MCID threshold. This argument is suitable for continuous response variables, namely for ANOVA and linear regression.

base

control group of the x variable in the one-way ANOVA model.

group

allocated arm variable where 1 corresponds to the treatment arm, and 0 to the control arm. Suitable for linear and logistic regression.

adj

value that the NNT need to be condtioned on (adjusted for). The default value is mean of x.

decrease

logical TRUE or FALSE. Indicates whether the MCID change is decrease in the response variable

data

data frame that contains the required variables for the computations.

Value

The estimated unadjusted, harmonic mean (marginal) and conditional (adjusted) NNT with their corresponding 95 percent confidence intervals given a specified model, and conditioned on (adjusted for) a specified value of the explanatory variables.

Examples

data(anova_data)

### SUCCESS = INCREASE
nnt_x(         model     = "anova",
               response  = anova_data$y,
               x         = anova_data$gr,
               cutoff    = 0,
               base      = 1,
               decrease  = FALSE,
               data      = anova_data)

### SUCCESS = DECREASE
nnt_x(         model     = "anova",
               response  = anova_data$y,
               x         = anova_data$gr,
               cutoff    = 2,
               base      = 4,
               decrease  = TRUE,
               data      = anova_data)

data(linreg_data)

### SUCCESS = INCREASE
nnt_x(         model    = "linreg",
               response = linreg_data$y,
               x        = linreg_data$x_var,
               cutoff   = 3,
               group    = linreg_data$gr,
               decrease = FALSE,
               adj      = 2.6,
               data     = linreg_data )

### SUCCESS = DECREASE
inv_data = data.frame( y = linreg_data$y, x_var = linreg_data$x_var, gr = 1 - linreg_data$gr )

nnt_x(  model    = "linreg",
       response  = inv_data$y,
        x        = inv_data$x_var,
        cutoff   = 3,
        group    = inv_data$gr,
        decrease = TRUE,
        adj      = 2.6,
        data     = inv_data )

data(logreg_data)

nnt_x( model    = "logreg",
       response = logreg_data$y,
       x        = logreg_data$x_var,
       group    = logreg_data$gr,
       adj      = 1.5,
       data     = logreg_data )


vancak/NNTcalculator documentation built on April 7, 2022, 3:48 a.m.