mercRel: mercRel

View source: R/mercRel.R

mercRelR Documentation

mercRel

Description

This funciton calculates regression coefficients, their standard errors, and odds ratios, when relevant, and 95 biologically meaningful difference specified by model covariates. A reliability study is required to empirically charaterize the measurement error model. Details are given in Rosner et al.(1989), Rosner et al.(1990), and Rosner et al.(1992) including "real data" examples

Usage

mercRel(
  supplyEstimates = FALSE,
  relib,
  pointEstimates = NA,
  vcovEstimates = NA,
  sur,
  woe = NA,
  event = NA,
  time = NA,
  outcome = NA,
  weri,
  rr,
  ms,
  weights,
  r1 = 1,
  method = "lm",
  family = NA,
  link = NA
)

Arguments

supplyEstimates

Indicates whether uncorrected estimates will be supplied by the user.

relib

Name of the reliability dataset

pointEstimates

A numeric vector of point estimates from uncorrected standard regression analysis. It must be in the order of the variables indicated in sur and woe Intercept estimate must be removed. Only binary and numeric variables are accepted, all other classes of variables must be transformed (this is automatically done by most regression softwares). Must include names for each point estimates corresponding to the (transformed) names from 'covCalib' followed by 'covOutcome'. Must be supplied if supplyEstimates = TRUE.

vcovEstimates

A p by p Variance-covariance matrix estimates from uncorrected standard regression analysis. Intercept estimates must be removed. Only binary and numeric variables are accepted, all other classes of variables must be transformed (this is automatically done by most regression softwares). Must include column names (excluding intercept) for the estimates corresponding to the (transformed) names from 'covCalib' followed by 'covOutcome'. Must be supplied if supplyEstimates = TRUE.

sur

character vector of mismeasured exposure and covariates (i.e. surrogates) in the main study dataset

woe

Character vector of names of perfectly measured covariates

event

Required if method is cox. The event status indicator, normally 0=alive/censored, 1=dead/event. For interval censored data, the status indicator is 0=right censored, 1= event at time, 2=left censored, 3=interval censored.

time

Required if method is cox. For right censored data, this is the follow up time. For interval data, the first argument is the starting time for the interval.

outcome

Outcome variable, required if method is lm or glm.

weri

Character vector of names of variables which have reliability measures. These should have a set of variable names for each reliability measure (e.g. x1 y1 z1 x2 y2 z2 for measures). The variables must be in the same order as the names in the names and increments dataset specified in 'pointEstimates'

rr

Number of reliability measures taken (e.g. 2).

ms

name of main study data set

weights

Name of the dataset containing the variable names and increments for the odds ratio or regression slopes.Including mismeasured and perfectly measured variables

r1

Number of replicates in main study

method

Methods for modeling, currently only 'lm', 'glm' and 'cox' methods are available. Required.

family

Supply family parameter to pass to glm function. Not a character. Required if method="glm".

link

Supply link parameter to pass to glm function. Should be character. Required if method="glm".

Value

printable dataframe from standard regression results (when supplyEstimates==FALSE) as well as corrected results

Author(s)

Xiaofan Liu and Xin Zhou

References

Rosner B, Spiegelman D, Willett WC. Correction of logistic regression relative risk estimates and confidence intervals for measurement error: the case of multiple covariates measured with error. Am J Epidemiol. 1990 Oct;132(4):734-45. doi: 10.1093/oxfordjournals.aje.a115715. PMID: 2403114.

Examples

# # Only one mismeasured covariate, linear 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 linear model
outModel <- lm(y ~ x + s , 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)]
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, method = "lm" )
mercRel(supplyEstimates=FALSE, relib = relib, sur = c("x"), woe = c("s"),
         weri = c("x","x2","x3"), outcome = c("y"), rr=3,
         ms=test,method = "lm",weights=wts)

# # Only one mismeasured covariate, logistic model
### 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'
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" )
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)

vanessaxiaofan/merc documentation built on May 7, 2023, 6:17 p.m.