knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of merc is to implement regression calibration methods for validation study and reliability study.
You can install the released version of merc from CRAN with:
install.packages("merc")
And the development version from GitHub with:
# install.packages("devtools") devtools::install_github("vanessaxiaofan/merc")
This is a basic example which shows you how to solve a common problem:
library(merc) ## basic example code # # Only one mismeasured covariate, logistic model y <- c(1,1,2,3,2,3) x <- c(2,2.1,3,4,2.9,4.1) s <- c(2,5,4,3,3,5) case <- c(0,1,0,1,0,0) age <- c(10,10,11,12,13,13) test <- data.frame(y,x,s,case,age) x <- c(1.1,1.2,0.8) x2 <- c(1.2,1.2,0.9) x3 <- c(0.9,1.0,1.3) relib <- data.frame(x,x2,x3) wts <- data.frame(x=1,s=1) ### Fit main study logistic model outModel <- glm(case ~ x + s , family = binomial(link="logit"), data = test) outcomeParam=coef(outModel) outcomeParamVCOV=vcov(outModel) outcomeModelResults<-(list(outcomeParam,outcomeParamVCOV)) Bstar<-outcomeParam[2:length(outcomeParam)] #p' x 1 VBstar<-outcomeParamVCOV[2:length(outcomeParam),2:length(outcomeParam)] # p' x p' # Provide point estimate fit1 <- mercRel(supplyEstimates=TRUE, relib=relib, pointEstimates = Bstar, vcovEstimates = VBstar, sur = c("x"), woe = c("s"), weri = c("x","x2","x3"), rr=3, ms=test, weights=wts,link = "logit",method = "glm" ) fit1 # Without point estimate fit2 <- mercRel(supplyEstimates=FALSE, relib = relib, sur = c("x"), woe = c("s"), weri = c("x","x2","x3"), outcome = c("case"), rr=3, ms=test,method = "glm", family = binomial, link = "logit", weights=wts) fit2
You'll still need to render README.Rmd
regularly, to keep README.md
up-to-date. devtools::build_readme()
is handy for this. You could also use GitHub Actions to re-render README.Rmd
every time you push. An example workflow can be found here: https://github.com/r-lib/actions/tree/master/examples.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.