I want to use ipwtm function in IPW package in r to estimate inverse probability weights,
Here are the data
dat=data.frame(newid=c("A","A","A","A","B","B","B"),b6smk=c(0,0,1,1,0,0,0),sex=c(0,0,0,0,1,1,1),age=c(50,51,52,53,60,61,62),e7=c(1,1,2,2,3,2,2),starttime=c(-1,0,1,2,-1,0,1),fuptime=c(0,1,2,3,0,1,2)
temp <- ipwtm(
exposure = b6smk,
family = "survival",
numerator = ~ sex+age,
denominator = ~ sex+age+e7,
id = newid,
tstart = starttime,
timevar = fuptime,
type = "first",
data = dat)
and I get the following error message:
Error in split.default(tempdat$exposure, tempdat$id) :
first argument must be a vector
The type of "b6smk" is numeric, and I do not know why it is an error.
How can I solve this error?