brrr | R Documentation |
Improved and computationally stable relative risk estimation for a binary exposure
brrr( x, z = NULL, y, t, maxit = 150, start = NULL, param = "Richardson", method = "Mle" )
x |
matrix of explanatory variables for the nuisance parameter, the first column is the intercept of the model |
z |
matrix of explanatory variables for log-relative risk, the first column is the intercept of the model |
y |
binary response variable |
t |
binary risk factor |
maxit |
maximum number of iteration for the estimation algorithm |
start |
initial guess for the parameter. If null vector of zeros |
param |
nuisance parameter. Possible values are "Richardson" or "Alternative" |
method |
estimation method. Possible values are "Mle", "MeanBr" and "MedianBr" |
##################################################### ## Relative risk regression with brrr #### ##################################################### library(brrr) library(HSAUR3) ################################################## ### Respiratory dataset ### ### available on HSAUR3 R package ### ################################################## data <- HSAUR3::respiratory ## Creating response variable, binary risk factor and model matrices id <- seq.int(from = 5, to = 555, by = 5) data_matrix <- model.matrix(~., data[id, c(1,2,3,4,5)]) y <- data_matrix[,6] t <- data_matrix[,3] x <- z <- data_matrix[,-c(3,6)] ## maximum likelihood fit using R package brrr, model: Richardson et al. (2017) rr_mle <- brrr(x,z,y,t) summary(rr_mle) ## Mean bias-reduced fit using the R package brrr, model: Richardson et al. (2017) rr_meanBR <- brrr(x,z,y,t, method = "MeanBr") summary(rr_meanBR) ## Median bias-reduced fit using the R function brrr, model: Richardson et al. (2017) rr_medianBR <- brrr(x,z,y,t, method = "MedianBr") summary(rr_medianBR) ## maximum likelihood fit using R package brrr, model: Alternative rr_mleA <- brrr(x,z,y,t, param = "Alternative") summary(rr_mleA) ## Mean bias-reduced fit using the R package brrr, model: Alternative rr_meanBRA <- brrr(x,z,y,t, method = "MeanBr",param = "Alternative") summary(rr_meanBRA) ## Median bias-reduced fit using the R function brrr, model: Alternative rr_medianBRA <- brrr(x,z,y,t, method = "MedianBr",param = "Alternative") summary(rr_medianBRA)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.