Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205399

ipwtm function in R: First argument a vector

$
0
0

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?


Viewing all articles
Browse latest Browse all 205399

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>