gImpute: Uses the G-imputation method to impute the HIV sero date...

View source: R/intCens.R

gImputeR Documentation

Uses the G-imputation method to impute the HIV sero date times.

Description

Uses the G-imputation method to impute the infection times.

Usage

gImpute(
  dat,
  Results,
  nSim = 1,
  start_date = NULL,
  tscale = 1,
  trans_back = TRUE,
  mcores = 1
)

Arguments

dat

A dataset of the covaraiate values by individual and time period. dat must have an ID variable called IIntID, a start date obs_statr, a latest-negative date late_neg and earliest-positive date early_pos.

Results

Results from readUniRegResults.

nSim

The number of imputations to perform.

start_date

If null, start_date is the first obs_start date of ID, else it is same start_date for everyone. Must be a string in the following YYYY-MM-DD format: e.g. "2005-01-23".

tscale

Scalar by which to scale time. The default is 1, which means that the time-scale is in days. The tscale used must correspond with the time scale of your Time variable. So if Time is in days, tscale=1 else if Time is in months tscale = 30.44.

trans_back

If tscale != 1, transform the infection times back into days. Default is TRUE.

mcores

The number of cores to use for parallel processing using mclapply.

Value

data.frame

Examples

# See full examples at https://github.com/vando026/ahri/wiki/6-G-Imputation
# install.packages(system.file("IntCens_0.2.tar.gz", package = "ahri"), repos = NULL, type = 'source')
library(IntCens)
data(gdat_demo)
home <- file.path('/home/alain/Seafile/AHRI_Data')
write.table(gdat_demo, file=file.path(home, "intcens/input_data.txt"),
  row.names=FALSE, quote=FALSE)
unireg(input = file.path(home, "intcens/input_data.txt"),
  output = file.path(home, "intcens/res_dat.txt"),
  model = "(Time, sero_event) = Age0 + Age2 + EverCircum",
  subject_id = "IIntID", convergence_threshold=0.01, r = 1.0)
ureg_res <- readUniRegResults(
  File=file.path(home, "intcens/res_dat.txt"))
Args <- setArgs(
  Years=c(2005:2018), nSim=50,
  Age=list(Mal=c(15, 54)))
gdates <- gImpute(gdat_demo, ureg_res, nSim=Args$nSim)

vando026/ahri documentation built on Aug. 10, 2024, 3:20 p.m.