iiw {IrregLong} | R Documentation |
Given a proportional hazards model for visit intensities, compute inverse-intensity weights.
Description
For a longitudinal dataset subject to irregular observation, use a Cox proportional hazards model for visit intensities to compute inverse intensity weights
Usage
iiw(phfit, data, id, time, first)
Arguments
phfit |
coxph object for the visit process |
data |
The dataset featuring longitudinal data subject to irregular observation for which inverse-intensity weights are desired |
id |
character string indicating which column of the data identifies subjects |
time |
character string indicating which column of the data contains the time at which the visit occurred |
first |
logical variable. If TRUE, the first observation for each individual is assigned an intensity of 1. This is appropriate if the first visit is a baseline visit at which recruitment to the study occurred; in this case the baseline visit is observed with probability 1. |
Value
A vector of inverse-intensity weights for each row of the dataset. The first observation for each subject is assumed to have an intensity of 1.
See Also
Other iiw:
iiw.weights()
,
iiwgee()
Examples
library(nlme)
library(survival)
library(geepack)
library(data.table)
data(Phenobarb)
Phenobarb$event <- 1-as.numeric(is.na(Phenobarb$conc))
data <- Phenobarb
data <- data[data$event==1,]
data$id <- as.numeric(data$Subject)
data <- data[data$time<16*24,]
data <- lagfn(data, lagvars=c("time","conc"), id="Subject", time="time", lagfirst = NA)
head(data)
mph <- coxph(Surv(time.lag,time,event)~I(conc.lag>0 & conc.lag<=20) + I(conc.lag>20 & conc.lag<=30)
+ I(conc.lag>30)+ cluster(id),,data=data)
summary(mph)
data$weight <- iiw(mph,data,"id","time",TRUE)
head(data)