Hello to all,

I have a problem using the Epi package and I would like your help.

my data set looks like this:

id           date of born          date of entry         date of first screen         date of exit

the date of entry is fixed for all obs to be a specific date. Now, I want to calculate person years of no screening, thus date first screen-date of entry and person years of screening therefore, date of exit-date of first screen.

I have created two lexis objects, one for the non-screening period calculating the age at entry (date of entry-date of birth) , and years of no screening and one for the screening period calculating again the same age and person years of screening.

Then I want to create an age/time matrix with person years, so I split the lexis object first on age and then on calendar year with splitLexis function.
Finally, I tabulate in a matrix and all seems fine for the person years for the non exposed period.

However, for the screening period I got a warning message saying that I have multiple time bands when I am trying to tabulate into the final matrix. 

this is how my algorithm looks like



########################################
####calculation of no-screening years###
########################################


library(foreign)

data1<-read.dta("T:\\person_no_screening_years.dta")

attach(data1)
names(data1)

bbb<-data.frame(data1)

# Convert the character dates into numerical variables (fractional years)#
library(Epi)
dobt <- cal.yr( bbb$date_born, format="%d/%m/%Y" )
doet <- cal.yr( bbb$date_entry, format="%d/%m/%Y" )
doxt <- cal.yr( bbb$min_scr_date , format="%d/%m/%Y" )



# Set up the dataset as a Lexis object #
# with age and calendar time as time-scales #

cohh <- Lexis( entry = list( per=doet,
                             age=doet-dobt ),
                exit = list( per=doxt  ),
                     exit.status = cases,
                         data = bbb )

# Split time along one time-axis #
La1  <-splitLexis( cohh, "aget", breaks=c(30,35,40,45,50,55,60,65,70,75,80,85,90,95))
# Split time along the calendar time-axes #
Lap1 <-splitLexis( La1  , "per", breaks=c(1975,1980,1985,1990,1995,2000,2005,2010))

# Tabulate events and person-years #
PYtab2 <-
with( Lap1, xtabs( cbind( C=lex.Xst, Y=lex.dur ) ~
                  timeBand(Lap1,"aget","left") +
                  timeBand(Lap1,"per","left") ) )
names(dimnames(PYtab2)) <- c("","Period","Aget")
T<-round(ftable( PYtab2, row.vars=c(3,1) ))
T



write.table(T,"T:\\Years_no_screening.txt")
#################################################################
#################################################################


######################################
####calculation of screening years####
######################################


library(foreign)

data2<-read.dta("T:\\person_screening_years_new.dta")

attach(data2)
names(data2)

vvvv<-data.frame(data2)

# Convert the character dates into numerical variables (fractional years)#
library(Epi)
dob <- cal.yr( vvvv$date_born, format="%d/%m/%Y" )
doe <- cal.yr( vvvv$date_entry, format="%d/%m/%Y" )
dox <- cal.yr( vvvv$date_exit , format="%d/%m/%Y" )
doz <- cal.yr( vvvv$min_scr_date, format="%d/%m/%Y" )


# Set up the dataset as a Lexis object #
# with age and calendar time as time-scales #

cohR <- Lexis( entry = list( per=doz,
                             age1=doe-dob ),
                exit = list( per=dox ),
                     exit.status = cases,
                         data = vvvv )

# Split time along one time-axis #
LaR  <-splitLexis( cohR, "age1", breaks=c(30,35,40,45,50,55,60,65,70,75,80,85,90,95) )


# Split time along the calendar time-axes #
LapR <-splitLexis( LaR  , "per", breaks=c(1975,1980,1985,1990,1995,2000,2005,2010))



# Tabulate events and person-years #
PYtab3R <-
with( LapR, xtabs( cbind( C=lex.Xst, Y=lex.dur ) ~
                  timeBand(LapR,"age1","left") +
                  timeBand(LapR,"per","left") ) )
names(dimnames(PYtab3R)) <- c("","Period","Age")
FR<-round(ftable( PYtab3R, row.vars=c(3,1) ))
FR



write.table(FR,"T:\\Years_screening.txt")

tapply( status(LapR,"exit")==1, list( timeBand(LapR,"age1","left"),
                                    timeBand(LapR,"per","left") ), sum )
tapply( dur(LapR),  list( timeBand(LapR,"age1","left"),
                        timeBand(LapR,"per","left") ), sum )



Could you please help me with that???
 		 	   		  
	[[alternative HTML version deleted]]

