diff -Nru r-cran-epi-1.1.24/CHANGES r-cran-epi-1.1.33/CHANGES --- r-cran-epi-1.1.24/CHANGES 2011-07-22 20:34:07.000000000 +0000 +++ r-cran-epi-1.1.33/CHANGES 2012-01-11 12:59:29.000000000 +0000 @@ -1,11 +1,79 @@ +Changes in 1.1.32 + +o gen.exp was re-written and simplified. + +o Small cosmetic changes to the code for N2Y + +Changes in 1.1.31 + +o The extractor functions entry, exit, status and dur have now an + argument by.id=FALSE. If set to TRUE, only one record per lex.id is + returned and the resulting object has lex.id as (row)names attribute. + +Changes in 1.1.30 + +o DMlate expanded with the column dooad + +o Documentation for as.Date.cal.yr fixed + +o Bug in gen.exp fixed (It was assuming a data frame called dfr + existed was wrong, but not spotted by the example because in the + example one actually did exist!) + +Changes in 1.1.29 + +o New function gen.exp for generating time-varying exposure variables + from drug purchase records. + +Changes in 1.1.28 + +o splitLexis now allows NAs in the timescale on which you split. + Records with NAs are simply left untouched, but a warning is + printed. + +o A bug in boxes.Lexis preventing rates to be printed was issued. + +Changes in 1.1.27 + +o A few typos corrected + +o Functions a.lines, a.points, cp.lines and cp.points added to + facilitate plotting points and curves from APC-models. + +o apc.fit did not return the reference cohort/period if it was not + supplied in a model with explicit drift. + +Changes in 1.1.26 + +o A new function N2Y added which computes person-years in Lexis + triangles from population prevalence data. + +o Demographic example data from Denmark added: + N.dk - population size at 1 Jan + Y.dk - risk time in Lexis triangles + M.dk - mortality data + B.dk - births in Denmark 1902 ff. + +Changes in 1.1.25 + +o Added sd() function to stat.table() + +o tmat.Lexis has an argument Y=FALSE which if set to TRUE will return + the person-years in the diagonal. + +o boxes() now explicitly defined with methods boxes.Lexis and + boxes.matrix that explicitly call boxes.default (which is the function + doing the work (almost identical to the former boxes.Lexis). + Changes in 1.1.24 -o countLexis did not take the "timescales" and "breaks" attribute across to the - resulting Lexis object. +o countLexis did not take the "timescales" and "breaks" attribute + across to the resulting Lexis object. Changes in 1.1.23 o A missing defualt value for new.scale in doCutLexis caused a crash +o A missing default value for new.scale in doCutLexis caused a crash when using the count=TRUE argument to cutLexis. Changes in 1.1.23 @@ -14,7 +82,7 @@ a sample from the normal distribution with mean equal to the estimates and variance equal to the estimated variance of the estimates. To be used to do "parametric bootstrap" of complicated - functions of the parameters, such as state occupancey probabilities + functions of the parameters, such as state occupancy probabilities from multistate models. o ci.lin now supports objects of class mipo (Multiple Imputation @@ -90,7 +158,7 @@ but also useful on its own. o lls() and clear() added, to ease overview and clearing of workspace - (and attachements!) + (and attachments!) o apc.frame now sets the option "apc.frame.par" with the offset and scaling of calendar time part of the apc frame. This is recognised @@ -120,7 +188,7 @@ Changes in 1.1.7 -o boxes.Lexis has been furter enhanced with the facility to plot rates +o boxes.Lexis has been further enhanced with the facility to plot rates instead of no. transitions on the arrows if required. The code has been tidied a bit too. @@ -129,8 +197,8 @@ Changes in 1.1.5 -o boxes.Lexis have been enhanced to accomodate two-way transitions between - states. Annotation by number of transitions has been improved to accomodate +o boxes.Lexis have been enhanced to accommodate two-way transitions between + states. Annotation by number of transitions has been improved to accommodate this too by always putting the number on the left side of the arrow. Changes in 1.1.3 @@ -149,7 +217,7 @@ Changes in 1.1.1 o Functions stack.Lexis, tmat.Lexis and mstate.Lexis have been added - to facilitate practical multistate modelling. The two latter provides an + to facilitate practical multistate modeling. The two latter provides an interface to the mstate package. o Functions tbox, dbox, fillarr, boxarr and boxes.Lexis added to facilitate @@ -197,7 +265,7 @@ o Thanks to Mike Murphy, Professor of Demography, Department of Social Policy, London School of Economics, a bug causing a crash of apc.fit if only - one row in the model matrix correponds to the reference level was fixed. + one row in the model matrix corresponds to the reference level was fixed. o Also thanks to Mike Murphy, a much more efficient calculation of median period and cohort is now used. @@ -232,7 +300,7 @@ In split.lexis.1D was the problem with the factor states, they were coerced to numeric when stuffed into the new.Xst matrix. Now states are turned to numeric before the call to split.lexis.1D and the factor - attributes reinstituted after the split. + attributes re-instituted after the split. o Added transform method for Lexis objects. diff -Nru r-cran-epi-1.1.24/DESCRIPTION r-cran-epi-1.1.33/DESCRIPTION --- r-cran-epi-1.1.24/DESCRIPTION 2011-07-25 19:46:16.000000000 +0000 +++ r-cran-epi-1.1.33/DESCRIPTION 2012-01-24 13:57:47.000000000 +0000 @@ -1,6 +1,6 @@ Package: Epi -Version: 1.1.24 -Date: 2011-07-19 +Version: 1.1.33 +Date: 2011-01-11 Title: A package for statistical analysis in epidemiology. Author: Bendix Carstensen, Martyn Plummer, Esa Laara, Michael Hills et. al. @@ -13,9 +13,9 @@ multistate data. Also some useful functions for tabulation and plotting. Contains some epidemiological datasets. License: GPL-2 -URL: http://www.pubhealth.ku.dk/~bxc/Epi/ +URL: http://BendixCarstensen.com/Epi/ Repository: CRAN Repository/R-Forge/Project: epi -Repository/R-Forge/Revision: 115 -Date/Publication: 2011-07-25 19:46:16 -Packaged: 2011-07-22 20:34:19 UTC; rforge +Repository/R-Forge/Revision: 129 +Date/Publication: 2012-01-24 13:57:47 +Packaged: 2012-01-17 22:01:46 UTC; rforge diff -Nru r-cran-epi-1.1.24/MD5 r-cran-epi-1.1.33/MD5 --- r-cran-epi-1.1.24/MD5 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-epi-1.1.33/MD5 2012-01-24 13:57:47.000000000 +0000 @@ -0,0 +1,171 @@ +5e57a533fc9b9bf4a36bff2b4670f0d2 *CHANGES +1c5293d9de100ada719b708dec97f983 *DESCRIPTION +5debf3866332c0f5d1e2823e40b4e01b *Examples/apc.fit-ex.R +8200991cba19d6262a7692ae67250855 *Examples/stat.table.R +5064ce0e0bb9f6de3a1dc0342600a560 *NAMESPACE +fac3c7f01ab0bd6930cf3cbea20e6bcc *R/Aplot.R +75d172080863bd6e3b2286a0c94b0d34 *R/Cplot.R +6a1c4f4cbbf509d1f3c40b9f0adb6399 *R/Icens.R +d6427af53cf584343ca1b1828728567c *R/Lexis.diagram.R +33b3c373e77a522ff2d11e0cc491f976 *R/Lexis.lines.R +05c38381cc48ab25b681e8615ac31ea8 *R/Life.lines.R +74f313bbcd8a1421b5d07173b877eaaf *R/MS.boxes.R +0d1ccedfe8cb5036f2baa8efd35f47b5 *R/N2Y.r +e9f582b5dc17d07bf2df96de74441963 *R/Pplot.R +5062f9e0c2e4c8a794b40711f30998ee *R/ROC.R +743d87e73b473375e1720f43b0e2e071 *R/Relevel.R +28a0ec0c8584e22759b516ff69e5bd78 *R/Wald.R +3c53d198bf5084d2168066e2dd16a6ff *R/apc.fit.R +16fb210cea20989377f0863dd8a200e9 *R/apc.frame.R +e284c7e95305fa3b22ef5fa76287ef56 *R/apc.plot.R +8ce5a4c989947cb9d93becdecfde642c *R/as.Date.cal.yr.R +11d3966379eacdc164f2d50c4da8bb70 *R/cal.yr.R +83a620b3335423632e36abdb0f844c4e *R/ccwc.R +58de307ab6ea80df72ce29037d392602 *R/ci.cum.R +cbcbd51a7f5973e541735e5a1e7cce95 *R/ci.lin.R +6f80c7b2b2120068cd16c043fbc29db3 *R/ci.mat.R +f5f9f348845b0f378d6ae5760a6a8b63 *R/ci.pd.R +acab8b478be5a44a36561e65d70f2b78 *R/clear.R +0893c1a63a7f48eb97441caa147ca834 *R/clogistic.R +d365bc4739ebb104b0318c1c9ee226fd *R/contr.2nd.R +bcd4142d3bf3e4517397387fe43fdf95 *R/contr.cum.R +8064804ee2b1cfa0cea2b44a58106b0a *R/contr.diff.R +8ffc3eabb90b6b9b710109015779d853 *R/contr.orth.R +28a5c5e65984c126590e61468bbb5f22 *R/cutLexis.R +fec0dc23d1a224dbe4fa55893bc28bf4 *R/detrend.R +a86250cce524f9fa2215c0c0cac4c6e7 *R/effx.match.r +eb3a391427cf3f99851ec0d5780b97c4 *R/effx.r +822e02862de39625e5ed9ef6f84bdf39 *R/expand.data.r +a544276ab58537c184893f09f4f70d23 *R/factorize.R +67ce5a28408f42c7b65084195897b995 *R/fit.add.r +44eec3e5b106ee3f518beed49b4e0f9b *R/fit.baseline.R +8ffaebb81a92649b137ff8a4911841da *R/fit.mult.r +7c7059bf47c6421d6412a4bc53fc5950 *R/float.R +da7b5d41fe7876ef6bab01839b613939 *R/ftrend.R +a3676957e1ca1092c81b11e47f6070c6 *R/gen.exp.R +b8270c0aeebb20d5c9c7c42b7188169f *R/lexis.R +9c575049aa6c3841e7e92f563a6fc450 *R/lls.R +79d6e0b02a2c4e98fbbfcd936b21d377 *R/mh.R +9e48e47769874a34f63a2e2d4e6ffffc *R/ncut.r +2a44a66ac4fe7eccab191f94957265e2 *R/pctab.R +97df9fd6adb120838502aaa2ee17a65e *R/plotEst.R +57eecdd415b7d0f7dfad39825644add5 *R/plotevent.r +c0229c2819d977a8c557a22dea1dd5fa *R/print.Icens.r +cca51283f637927702fbe217367011eb *R/print.floated.R +98111ca3d269248b2797f89b257b7361 *R/projection.ip.r +0c2a2e493c190c4e74587b5127e9bef6 *R/rateplot.R +3b40bdedc3edef29d89750875a0297ee *R/splitLexis.R +c295faa30968d454e37d7b1ae942ba47 *R/stack.Lexis.R +4100061b1a3b3e79c33fa0ce5ac0064d *R/stattable.R +889282ea37a5a9d9bf7155d790cd9036 *R/summary.Icens.r +be8fe6c5a74b9f772d6800d154e32b29 *R/summary.Lexis.r +88983ba8314a37910993d469a982d800 *R/twoby2.R +497daef89f1ea705cd2c755132bec69d *R/zzz.R +24766dc83b582b8f6286920ab14a7524 *data/B.dk.rda +c6e5d0efa986ed7e5f5676585d52f1b5 *data/DMconv.rda +32946a397abe36d147d99393a9af3b74 *data/DMlate.rda +25f67061aadb398eade71d4d5a77ae39 *data/DMrand.rda +40117f7239b6a7d975480a4fb4c44d88 *data/M.dk.rda +ca9edcf7132819c8add18b3427d80b4b *data/N.dk.rda +ddd571194a96a60ff08dcab66a86ae54 *data/S.typh.rda +615e42654b57b6361972735e52ef4981 *data/Y.dk.rda +195627ecf84f9bb151ec47668412e312 *data/bdendo.rda +c826c04550e5a23b787354c9c4c2ca63 *data/bdendo11.rda +5580acccecfb5e43b52626a9cd43e00d *data/births.rda +a722a97ba448f786bf60f8197d2b750b *data/blcaIT.rda +060eb665e8f0788b3e38ddef5b081d4c *data/brv.rda +3d54d1e88c48fc9fb005fe54267aa00f *data/diet.rda +11c35e9c10fb94a321eb8c627990fc7b *data/ewrates.rda +6172a3738663e5b82cdcca2c235ef00f *data/gmortDK.rda +3a15ba8323c76d9e17914003338e7def *data/hivDK.rda +1c54772090340391946650c1a3f59f9b *data/lep.rda +b4be2a43e96a2f819dda1f224a3832a3 *data/lungDK.rda +eccae38dde865a78d4e436fa00deec7a *data/mortDK.rda +277dde4e7a92cdcd4f707caea48e577f *data/nickel.rda +f0118c42c7500df606f984dbfc4a9692 *data/occup.rda +6ebf872e8c8d7e6fb7924b61d0b6ed42 *data/thoro.rda +e0f7d0bbeb4f050e41a55dd412548816 *inst/CITATION +79a9779263ea9ffbeb9f1e915be947be *inst/doc/Follow-up.pdf +bc350349661120c39543661d3070c72e *inst/doc/Follow-up.rnw +c1b446d8c83750aaa84a920cc7eafcd5 *inst/doc/index.html +317bb6ebeaec5e7376b609d7e382c166 *man/B.dk.Rd +3abc5c20e62c874d70dcb2688ad2cce5 *man/DMconv.Rd +f9bd8f0c657632d80e2dff2d0abbe218 *man/DMlate.Rd +38f9ae52c47f70d01f46eb437fca0f16 *man/Icens.Rd +1b9f345e61f304589322c1d51b66a05d *man/Lexis.Rd +4b1b72cb2e044e329edef0222717624f *man/Lexis.diagram.Rd +6e2f1f94637dec816015774f978cafb2 *man/Lexis.lines.Rd +b4b2ca144feacece204f86bc6640d51a *man/Life.lines.Rd +6fcfeb922f2e2f2baefab0d82702304f *man/M.dk.Rd +303388a95f429be40a7f1b9c1b716b66 *man/MS.boxes.Rd +6ae7494a426801b9944c37190c09b3ee *man/N.dk.Rd +f9faa39904b30f3c191c250c42f3f6e4 *man/N2Y.Rd +b4a0dbaa95044da929c9d3efda193dd3 *man/ROC.Rd +42f2d6eb83d1c2bb2613905a64c475d3 *man/Relevel.Rd +bb2162d557dfb7685edac64ac3213b6c *man/S.typh.Rd +ae2da305f867b52135d28a5ef2cae7d4 *man/Y.dk.Rd +086844e26842cd0cd79e57b9ce1a9c20 *man/apc.fit.Rd +19a4e06fdbdd01f7ee85aafa5834a8c9 *man/apc.frame.Rd +cb907c7df3f4c729041ccbb71f53dc01 *man/apc.lines.Rd +e72b167655a1da4bdc072b58ea7b5caf *man/apc.plot.Rd +92b663829915395cdabf3e5d37cdd2b4 *man/bdendo.Rd +968ba8cef65153e9c9c521dd1541123e *man/bdendo11.Rd +d74a4f6e66ce91c73cd2817bb690446a *man/births.Rd +8dc11840302a388e4f26892335d5d888 *man/blcaIT.Rd +76aef95e914a3d800f7bbfc9ce968ea0 *man/brv.Rd +e9c61c6c7a9c4c81e4d2d254625bed9b *man/cal.yr.Rd +877c1df6b5c4504150741699a8d5c513 *man/ccwc.Rd +59829afc87b80702104677ca9d19201a *man/ci.cum.Rd +2bbeaeab6588bf0504f458295340ec3c *man/ci.lin.Rd +009dbad3c1e8b9d5502754282055f28c *man/ci.pd.Rd +23f65e361e47229172d33f0a43609db6 *man/clogistic.Rd +cf5e5a6e18e07b7bb8d70dc0417e6166 *man/contr.cum.Rd +7c791426a1b3f202a1542eec0a1428bc *man/cutLexis.Rd +0f09eb23fad917844225fcde049e95ea *man/detrend.Rd +386d0a4aa3515cf754ef458e1f32089c *man/diet.Rd +90663dfc64fb4829854eb88b6179a7f8 *man/effx.Rd +3c3cc3b1ecabece6b7709c1b147bab4e *man/effx.match.Rd +0dc62e726cdff6694774fab66595ee81 *man/ewrates.Rd +eb0c50c4a2572fd514c475358165fa57 *man/expand.data.rd +344adb137962cfa8fc7c2cf2858de3a3 *man/fit.add.Rd +3b44fed4ae70541c965c4cfbed966a68 *man/fit.baseline.rd +a318bd705eddc9d721e59c95a6932ef0 *man/fit.mult.Rd +28950f1b7e9400c42a82a97a33f40113 *man/float.Rd +e5a57a203cb91e9680dedc9023779e59 *man/ftrend.Rd +769794163c21755cb041cb66ef171679 *man/gen.exp.Rd +cbbc2a23f902d83ba2527b27b5ed3adb *man/gmortDK.Rd +d9f1d31e109d6058a2160ca0aa49bf81 *man/hivDK.Rd +9c3b059921d728298ccff73298b4dd31 *man/lep.Rd +c17abc408d69d11bb660d92788056f77 *man/lls.Rd +636647628df44ca1a853759d159cb514 *man/lungDK.Rd +3c462c4ce7ca1ce4b8c6fef50b3c7623 *man/merge.Lexis.Rd +4c26c9edf5d64b0af3e63ad791b2a280 *man/merge.data.frame.Rd +34c530c36a3a1a7447ff8eea58f42084 *man/mh.Rd +2ecfec2d86e80b9bbcc2c3a253348edd *man/mortDK.Rd +11ee76903acb4b83b2dca9f51b0ab9b3 *man/msdata.Lexis.Rd +e3e8dc30db562be6dc7bd87439a8af6f *man/ncut.Rd +9af0093a82297924da8263f73217c8f0 *man/nice.Rd +05bd25340716d0805cbc7eb433896206 *man/nickel.Rd +febaa46e11a7458c23ed0513a594a8da *man/occup.Rd +867e67099bdd7f32e8e81144783e552c *man/pctab.Rd +50c0516a536004d7f4ce91ef1bbfd8c9 *man/plot.Lexis.Rd +3e60ba3b586dc051d878ab45eb4980f3 *man/plotEst.Rd +b0047a7bab6a20b153485db9bd338394 *man/plotevent.rd +f0fa1e0ed75e71bd74d807d743488488 *man/projection.ip.rd +2b40d9bf46209de0e2ec1a8ab833ac9e *man/rateplot.Rd +d397ebec12521fce49ee461de3dae858 *man/splitLexis.Rd +d585d69a4441500e23522e9536f21d03 *man/stack.Lexis.Rd +a61f5be7f3ca37598079641c4674bbed *man/start.Lexis.Rd +4f43436fc863747dad4fcdd566948039 *man/stattable.Rd +73cf4597fcb4a9d019bda47431b095be *man/stattable.funs.Rd +4ce1341f6b0d9d5796550015bbe9371e *man/subset.Lexis.Rd +b46f996f7439ca49248b067ede4f76be *man/summary.Lexis.rd +3706fe264d14ae04a5e6e98130afeee7 *man/thoro.Rd +6ea9cf64475187fa2f402275c40573a7 *man/time.band.Rd +2edb93539fa7b9f47a3083b624443f9d *man/time.scales.Rd +2afba764c34419327ff8ae8d17aec3d3 *man/transform.Lexis.Rd +02fc311541fae16a5d3a580a04925050 *man/twoby2.Rd +3b649b94df7f0c0863bb4ef0a7129855 *src/chinv2.c +c21af4e77e577fae093bb3dfc6cbe9a9 *src/cholesky2.c +33be867717f019d03821e58b662a94c4 *src/chsolve2.c +ce9e73f4028463cf8b84a7783f282ac3 *src/clogit.c diff -Nru r-cran-epi-1.1.24/NAMESPACE r-cran-epi-1.1.33/NAMESPACE --- r-cran-epi-1.1.24/NAMESPACE 2011-07-22 20:34:07.000000000 +0000 +++ r-cran-epi-1.1.33/NAMESPACE 2012-01-12 07:16:07.000000000 +0000 @@ -26,6 +26,7 @@ effx.match, float, print.floated, + gen.exp, Icens, print.Icens, plotevent, @@ -53,6 +54,7 @@ msdata.Lexis, tmat.Lexis, boxes.Lexis, + boxes.matrix, entry, exit, status, @@ -67,6 +69,7 @@ boxes, factorize, PY.ann, + N2Y, msdata, tmat, mh, @@ -105,6 +108,7 @@ S3method(msdata, Lexis) S3method(tmat, Lexis) S3method(boxes, Lexis) +S3method(boxes, matrix) S3method(merge, data.frame) S3method(print, stat.table) S3method(print, clogistic) diff -Nru r-cran-epi-1.1.24/R/MS.boxes.R r-cran-epi-1.1.33/R/MS.boxes.R --- r-cran-epi-1.1.24/R/MS.boxes.R 2011-07-22 20:34:07.000000000 +0000 +++ r-cran-epi-1.1.33/R/MS.boxes.R 2011-12-08 17:37:55.000000000 +0000 @@ -5,7 +5,8 @@ col.border="black", col.bg="transparent" ) { -rect( x-wd/2, y-ht/2, x+wd/2, y+ht/2, lwd=lwd, border=col.border, col=col.bg ) +rect( x-wd/2, y-ht/2, x+wd/2, y+ht/2, + lwd=lwd, border=col.border, col=col.bg ) text( x, y, txt, font=font, col=col.txt ) invisible( c( x, y, wd, ht ) ) } @@ -88,6 +89,12 @@ boxes <- function (obj, ...) UseMethod("boxes") +boxes.matrix <- +function( obj, ... ) + { + Epi:::boxes.Lexis( obj, ... ) + } + boxes.Lexis <- function( obj, file, detailed=FALSE, boxpos = FALSE, @@ -122,22 +129,19 @@ if( inherits(obj,"Lexis") ) { obj <- factorize( obj ) - tm <- tmat( obj ) + tm <- tmat( obj, Y=TRUE ) } else if( is.matrix(obj) & diff(dim(obj))==0 ) - { - tm <- obj - # Put the transitions into D (only potentially used). - D <- tm - # Numbers in boxes ? - if( is.numeric(show.Y) ) - { - Y <- show.Y - show.Y <- TRUE - } - } + { + tm <- obj + } else stop( "First argument must be a Lexis object or a square matrix.\n" ) +# Put the transitions into D and the diagnonal into Y. +D <- tm +diag( D ) <- NA +Y <- diag( tm ) + # Derive state names, no. states and no. transitions st.nam <- colnames( tm ) if( is.null(st.nam) ) st.nam <- paste(1:ncol(tm)) @@ -156,6 +160,13 @@ } } +# Explicitly given numbers in boxes ? +if( is.numeric(show.Y) ) + { + Y <- show.Y + show.Y <- TRUE + } + # No extra line with person-years when they are NA if( show.Y ) pl.nam <- gsub( "\\\nNA", "", @@ -282,7 +293,8 @@ } } # Redraw the boxes with white background to remove any arrows -for( i in subset ) tbox( pl.nam[i], xx[i], yy[i], wd[i], ht[i], col.bg="white" ) +for( i in subset ) tbox( pl.nam[i], xx[i], yy[i], wd[i], ht[i], + lwd=lwd[i], col.bg="white" ) # Then redraw the boxes again for( i in subset ) tbox( pl.nam[i], xx[i], yy[i], wd[i], ht[i], font=font[i], diff -Nru r-cran-epi-1.1.24/R/N2Y.r r-cran-epi-1.1.33/R/N2Y.r --- r-cran-epi-1.1.24/R/N2Y.r 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-epi-1.1.33/R/N2Y.r 2012-01-11 12:59:29.000000000 +0000 @@ -0,0 +1,58 @@ +N2Y <- +function( A, P, N, + data=NULL, + return.dfr=TRUE ) +{ +# Make local versions of variables if a dataframe is supplied +if( !is.null(data) ) + { + A <- if( !missing(A) ) eval( substitute(A), data, parent.frame() ) + else data$A + P <- if( !missing(P) ) eval( substitute(P), data, parent.frame() ) + else data$P + N <- if( !missing(N) ) eval( substitute(N), data, parent.frame() ) + else data$N + } +# Derive the interval lengths from supplied data +A.int <- unique( diff(sort(unique(A))) ) +P.int <- unique( diff(sort(unique(P))) ) +# Check if something is fishy +if( length(A.int)!=1 ) stop( "Non-uniform age interval lengths:\n", A.int ) +if( length(P.int)!=1 ) stop( "Non-uniform period interval lengths:\n", P.int ) +if( A.int!=P.int ) stop( "Unequal age and period interval lengths:\n", + "age: ", A.int, ", period: ", P.int ) +# Put population prevalence data in a table +Ntab <- xtabs( N ~ A + P ) +# Devise a table for the risk times +Ydim <- c(dimnames(Ntab),list(wh=c("lo","up"))) +# note one less age and period category +Ytab <- array( NA, dim=sapply(Ydim,length), + dimnames = Ydim )[-dim(Ntab)[1],-dim(Ntab)[2],] +# How manu age and period classes +na <- nrow(Ytab) +np <- ncol(Ytab) +for(a in 1:na) for(p in 1:np) + { + Ytab[a,p,"up"] <- Ntab[a ,p]/3 + Ntab[a+1,p+1]/6 + if( a > 1) Ytab[a,p,"lo"] <- Ntab[a-1,p]/6 + Ntab[a ,p+1]/3 + else Ytab[a,p,"lo"] <- Ntab[a ,p]/2 + Ntab[a ,p+1]/2 - Ytab[a,p,"up"] + } +# Remember to check the follow-up time +Ytab <- Ytab * A.int +# Convert to a data frame if required (the default) +if( return.dfr ) + { + # If a dataframe is requires as resturn + Ytab <- as.data.frame(as.table(Ytab)) + # Retrieve the numerical values of left endpoints of intervals + Ytab <- transform( Ytab, + A = as.numeric(as.character(Ytab[,1])), + P = as.numeric(as.character(Ytab[,2])) ) + # Compute the correct midpoints from the supplied data + Ytab <- transform( Ytab, + A = A + A.int*(1+(wh=="up"))/3, + P = P + P.int*(2-(wh=="up"))/3, + Y = Freq )[,c("A","P","Y")] + } +Ytab +} diff -Nru r-cran-epi-1.1.24/R/apc.fit.R r-cran-epi-1.1.33/R/apc.fit.R --- r-cran-epi-1.1.24/R/apc.fit.R 2011-07-22 20:34:07.000000000 +0000 +++ r-cran-epi-1.1.33/R/apc.fit.R 2011-12-08 17:37:55.000000000 +0000 @@ -297,9 +297,17 @@ Type <- paste("Sequential modelling", Dist, ": (", parm, "):\n") } - res <- list(Type = Type, Age = Age, Per = Per, Coh = Coh, - Drift = drift, Ref = c(Per = if (ref.p) p0 else NA, Coh = if (ref.c) c0 else NA), - Anova = AOV) + res <- list(Type = Type, + Age = Age, + Per = Per, + Coh = Coh, + Drift = drift, + Ref = c(Per = if ( parm %in% + c("APC","ADPC","Ad-P-C","AP-C") ) p0 else NA, + Coh = if ( parm %in% + c("ACP","ADCP","Ad-C-P","AC-P") ) c0 else NA ), + Anova = AOV) + # If a spline model is used, add a "Knots" component to the apc-object if (model %in% c("ns", "bs")) res <- c(res, list(Knots = Knots)) res$Age[, -1] <- res$Age[, -1] * scale @@ -307,6 +315,15 @@ print(res$Type) print(res$Anova) } + # Print warnings about reference points: + if( !ref.p & parm %in% c("APC","ADPC") ) + cat( "No reference period given:\n", + "Reference period for age-effects is chosen as\n", + "the median date of event: ", p0 ) + if( !ref.c & parm %in% c("ACP","ADCP") ) + cat( "No reference period given:\n", + "Reference period for age-effects is chosen as\n", + "the median date of birth for persons with event: ", c0 ) class(res) <- "apc" invisible(res) } diff -Nru r-cran-epi-1.1.24/R/apc.lines.R r-cran-epi-1.1.33/R/apc.lines.R --- r-cran-epi-1.1.24/R/apc.lines.R 2011-07-22 20:34:07.000000000 +0000 +++ r-cran-epi-1.1.33/R/apc.lines.R 1970-01-01 00:00:00.000000000 +0000 @@ -1,120 +0,0 @@ -apc.lines <- -function( A, - P, - C, - scale = c("log","ln","rates","inc","RR"), - frame.par = options()[["apc.frame.par"]], - drift = 0, - c0 = median( C[,1] ), - a0 = median( A[,1] ), - p0 = c0 + a0, - ci = rep( FALSE, 3 ), - lwd = c(3,1,1), - lty = 1, - col = "black", - type = "l", - knots = FALSE, - ... - ) -{ -# What scale are we using: -log.scale <- ( match.arg( scale ) %in% c("log","ln") ) -# Are confidence intervals requested ? -# Expand ci to three components if only one is given -if( is.logical( ci ) ) ci <- rep( ci, 3 )[1:3] -# Allow ci to be any character string or vector with "a", "p" or "c" in it -if( is.character( ci ) ) - { - ci <- paste( ci, collapse="" ) - ci <- unlist( strsplit( toupper( ci ), split="" ) ) - ci <- !is.na( match( c("A","P","C"), ci ) ) - } -# Check the format of the various inputs are correct -if( inherits( A, "apc" ) ) - { - obj <- A - p0 <- ifelse( is.na( A$Ref[1] ), median( A$Per[,1] ), A$Ref[1] ) - c0 <- ifelse( is.na( A$Ref[2] ), median( A$Coh[,1] ), A$Ref[2] ) - a0 <- p0 - c0 - C <- A$Coh - P <- A$Per - A <- A$Age - log.scale <- FALSE - } -if( ( ci[1] & dim( A )[2] < 4 ) | dim( A )[2] < 2 ) - stop( "A, ", deparse( substitute( A ) ), ") must be a ", 2+2*ci[1]," column matrix" ) -if( ( ci[2] & dim( P )[2] < 4 ) | dim( P )[2] < 2 ) - stop( "P, ", deparse( substitute( P ) ), ") must be a ", 2+2*ci[2]," column matrix" ) -if( ( ci[3] & dim( C )[2] < 4 ) | dim( C )[2] < 2 ) - stop( "C, ", deparse( substitute( C ) ), ") must be a ", 2+2*ci[3]," column matrix" ) -if( p0 != c0+a0 ) - stop( "p0=", p0, " differs from c0 + a0 = ", c0, " + ", a0, " = ", c0+a0 ) -# Expand single graphics parameters to length 3 - col <- rep( col, 3 ) - lty <- rep( lty, 3 ) - type <- rep( type, 3 ) -# Transform to log-scale if input is as rates and RRs - if( !log.scale ) - { - if( missing( drift ) ) drift <- 1 - drift <- log( drift ) - A[,2:4] <- log( A[,2:4] ) - P[,2:4] <- log( P[,2:4] ) - C[,2:4] <- log( C[,2:4] ) - } - A[,2:4] <- exp( A[,2:4] - drift * ( A[,1] - a0 ) ) - P[,2:4] <- exp( P[,2:4] + drift * ( P[,1] - p0 ) ) - C[,2:4] <- exp( C[,2:4] - drift * ( C[,1] - c0 ) ) - # If no frame parameters are given - if( is.null( frame.par ) ) - frame.par <- c( min( C[,1] ) + max( A[,1] ), - ifelse( scale=="log", - exp( mean( A[,2] ) ), - exp( mean( log( A[,2] ) ) ) ) ) - # Now we can plot the lines - matlines( A[,1], A[,ifelse( ci[1], -1, 2)], - col=col[1], lwd=lwd, lty=lty[1], type=type[1], ... ) - matlines( P[,1] - frame.par[1], P[,ifelse( ci[2], -1, 2)] * frame.par[2], - col=col[2], lwd=lwd, lty=lty[2], type=type[2], ... ) - matlines( C[,1] - frame.par[1], C[,ifelse( ci[3], -1, 2)] * frame.par[2], - col=col[3], lwd=lwd, lty=lty[3], type=type[3], ... ) - points( obj$Ref - frame.par[1], frame.par[c(2,2)], pch=16, col="white" ) - points( obj$Ref - frame.par[1], frame.par[c(2,2)], pch=1, lwd=2, col=col[2:3] ) - if( knots & inherits( obj, "apc" ) ) - { - rug( obj$Knots$Age, side=1, col=col[1] ) - rug( obj$Knots$Per - frame.par[1], side=1, col=col[2] ) - rug( obj$Knots$Coh - frame.par[1], side=3, col=col[3] ) - } - box() - invisible( list( A=A, P=P, C=C ) ) -} - -# Useful functions to plot in the calendar time part of an apc frame. -pc.points <- -function( x, y, ... ) -{ -fp <- options()[["apc.frame.par"]] -points( x - fp[1], y * fp[2], ... ) -} - -pc.lines <- -function( x, y, ... ) -{ -fp <- options()[["apc.frame.par"]] -lines( x - fp[1], y * fp[2], ... ) -} - -pc.matpoints <- -function( x, y, ... ) -{ -fp <- options()[["apc.frame.par"]] -matpoints( x - fp[1], y * fp[2], ... ) -} - -pc.matlines <- -function( x, y, ... ) -{ -fp <- options()[["apc.frame.par"]] -matlines( x - fp[1], y * fp[2], ... ) -} diff -Nru r-cran-epi-1.1.24/R/apc.plot.R r-cran-epi-1.1.33/R/apc.plot.R --- r-cran-epi-1.1.24/R/apc.plot.R 2011-07-22 20:34:07.000000000 +0000 +++ r-cran-epi-1.1.33/R/apc.plot.R 2011-12-08 17:37:55.000000000 +0000 @@ -32,8 +32,137 @@ rr.tic=rr.tic, rr.ref=rr.ref, r.txt=r.txt ) -# - and the reference line +# - and the reference line segments( min(cp.lab)-fpar[1], fpar[2], max(cp.lab)-fpar[1], fpar[2] ) apc.lines( obj, frame.par=fpar, ... ) fpar } + +apc.lines <- +function( A, + P, + C, + scale = c("log","ln","rates","inc","RR"), + frame.par = options()[["apc.frame.par"]], + drift = 0, + c0 = median( C[,1] ), + a0 = median( A[,1] ), + p0 = c0 + a0, + ci = rep( FALSE, 3 ), + lwd = c(3,1,1), + lty = 1, + col = "black", + type = "l", + knots = FALSE, + ... + ) +{ +# What scale are we using: +log.scale <- ( match.arg( scale ) %in% c("log","ln") ) +# Are confidence intervals requested ? +# Expand ci to three components if only one is given +if( is.logical( ci ) ) ci <- rep( ci, 3 )[1:3] +# Allow ci to be any character string or vector with "a", "p" or "c" in it +if( is.character( ci ) ) + { + ci <- paste( ci, collapse="" ) + ci <- unlist( strsplit( toupper( ci ), split="" ) ) + ci <- !is.na( match( c("A","P","C"), ci ) ) + } +# Check the format of the various inputs are correct +if( inherits( A, "apc" ) ) + { + obj <- A + p0 <- ifelse( is.na( A$Ref[1] ), median( A$Per[,1] ), A$Ref[1] ) + c0 <- ifelse( is.na( A$Ref[2] ), median( A$Coh[,1] ), A$Ref[2] ) + a0 <- p0 - c0 + C <- A$Coh + P <- A$Per + A <- A$Age + log.scale <- FALSE + } +if( ( ci[1] & dim( A )[2] < 4 ) | dim( A )[2] < 2 ) + stop( "A, ", deparse( substitute( A ) ), ") must be a ", 2+2*ci[1]," column matrix" ) +if( ( ci[2] & dim( P )[2] < 4 ) | dim( P )[2] < 2 ) + stop( "P, ", deparse( substitute( P ) ), ") must be a ", 2+2*ci[2]," column matrix" ) +if( ( ci[3] & dim( C )[2] < 4 ) | dim( C )[2] < 2 ) + stop( "C, ", deparse( substitute( C ) ), ") must be a ", 2+2*ci[3]," column matrix" ) +if( p0 != c0+a0 ) + stop( "p0=", p0, " differs from c0 + a0 = ", c0, " + ", a0, " = ", c0+a0 ) +# Expand single graphics parameters to length 3 + col <- rep( col, 3 ) + lty <- rep( lty, 3 ) + type <- rep( type, 3 ) +# Transform to log-scale if input is as rates and RRs + if( !log.scale ) + { + if( missing( drift ) ) drift <- 1 + drift <- log( drift ) + A[,2:4] <- log( A[,2:4] ) + P[,2:4] <- log( P[,2:4] ) + C[,2:4] <- log( C[,2:4] ) + } + A[,2:4] <- exp( A[,2:4] - drift * ( A[,1] - a0 ) ) + P[,2:4] <- exp( P[,2:4] + drift * ( P[,1] - p0 ) ) + C[,2:4] <- exp( C[,2:4] - drift * ( C[,1] - c0 ) ) + # If no frame parameters are given + if( is.null( frame.par ) ) + frame.par <- c( min( C[,1] ) + max( A[,1] ), + ifelse( scale=="log", + exp( mean( A[,2] ) ), + exp( mean( log( A[,2] ) ) ) ) ) + # Now we can plot the lines + matlines( A[,1], A[,ifelse( ci[1], -1, 2)], + col=col[1], lwd=lwd, lty=lty[1], type=type[1], ... ) + matlines( P[,1] - frame.par[1], P[,ifelse( ci[2], -1, 2)] * frame.par[2], + col=col[2], lwd=lwd, lty=lty[2], type=type[2], ... ) + matlines( C[,1] - frame.par[1], C[,ifelse( ci[3], -1, 2)] * frame.par[2], + col=col[3], lwd=lwd, lty=lty[3], type=type[3], ... ) + points( obj$Ref - frame.par[1], frame.par[c(2,2)], pch=16, col="white" ) + points( obj$Ref - frame.par[1], frame.par[c(2,2)], pch=1, lwd=2, col=col[2:3] ) + if( knots & inherits( obj, "apc" ) ) + { + rug( obj$Knots$Age, side=1, col=col[1] ) + rug( obj$Knots$Per - frame.par[1], side=1, col=col[2] ) + rug( obj$Knots$Coh - frame.par[1], side=3, col=col[3] ) + } + box() + invisible( list( A=A, P=P, C=C ) ) +} + +a.points <- points +a.lines <- lines +a.matpoints <- matpoints +a.matlines <- matlines +# Useful functions to plot in the calendar time part of an apc frame. +cp.points <- +pc.points <- +function( x, y, ... ) +{ +fp <- options()[["apc.frame.par"]] +points( x - fp[1], y * fp[2], ... ) +} + +cp.lines <- +pc.lines <- +function( x, y, ... ) +{ +fp <- options()[["apc.frame.par"]] +lines( x - fp[1], y * fp[2], ... ) +} + +cp.matpoints <- +pc.matpoints <- +function( x, y, ... ) +{ +fp <- options()[["apc.frame.par"]] +matpoints( x - fp[1], y * fp[2], ... ) +} + +cp.matlines <- +pc.matlines <- +function( x, y, ... ) +{ +fp <- options()[["apc.frame.par"]] +matlines( x - fp[1], y * fp[2], ... ) +} diff -Nru r-cran-epi-1.1.24/R/cutLexis.R r-cran-epi-1.1.33/R/cutLexis.R --- r-cran-epi-1.1.24/R/cutLexis.R 2011-07-22 20:34:07.000000000 +0000 +++ r-cran-epi-1.1.33/R/cutLexis.R 2011-09-18 11:53:38.000000000 +0000 @@ -166,7 +166,7 @@ stop("Multiple time scales") } - ## If we want to add a new timescale, contruct the name + ## If we want to add a new timescale, construct the name if( is.logical(new.scale) ) { if( new.scale ) scale.name <- paste( new.state[1], "dur", sep="." ) } @@ -241,7 +241,7 @@ tn <- c( match( attr( data, "time.scales" ), names( lx ) ), ncol(lx) ) oth <- setdiff( 1:ncol(lx), tn ) - ## Reorder columns (lx will then lose attributes) + ## Reorder columns (lx will then lose attributes) and sort rows lx <- lx[order(lx$lex.id,lx[,timescale]),c(tn,oth)] ## Update the attributes new.br <- c( attr( data, "breaks" ), list(NULL) ) @@ -252,8 +252,8 @@ } else { - # Remove the new timescale - lx <- lx[,-match("lex.new.scale",names(lx))] + # Remove the new timescale and sort rows + lx <- lx[order(lx$lex.id,lx[,timescale]),-match("lex.new.scale",names(lx))] # and transfer all the other attributes attr( lx, "time.scales" ) <- attr( data, "time.scales" ) attr( lx, "breaks" ) <- attr( data, "breaks" ) diff -Nru r-cran-epi-1.1.24/R/factorize.R r-cran-epi-1.1.33/R/factorize.R --- r-cran-epi-1.1.24/R/factorize.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-epi-1.1.33/R/factorize.R 2011-09-18 11:53:38.000000000 +0000 @@ -0,0 +1,65 @@ +# The factorize method +factorize <- function (obj, ...) UseMethod("factorize") + +# The Lexis version of this +factorize.Lexis <- +function (obj, states=NULL, print=TRUE, ...) +{ +# Is this really a Lexis object +if( !inherits(obj,"Lexis") ) stop( "First argument must be a Lexis object" ) + +# Make the state variables into factors with the same levels set +Cst <- factor(obj$lex.Cst) +Xst <- factor(obj$lex.Xst) +all.levels = union(levels(Cst), levels(Xst)) +Cst <- factor(Cst, levels = all.levels) +Xst <- factor(Xst, levels = all.levels) +obj$lex.Cst <- Cst +obj$lex.Xst <- Xst + +# If new state names as a list it implies merging of them +if( !is.null( states ) & is.list( states ) ) + { + # Collapsing levesl requires the input factor to have levels that + # are given in the elements of the list + levels( obj$lex.Cst ) <- unlist(states) + levels( obj$lex.Xst ) <- unlist(states) + obj$lex.Cst <- Relevel( obj$lex.Cst, states, ... ) + obj$lex.Xst <- Relevel( obj$lex.Xst, states, ... ) + if( print ) + { + # Construct translation table between old and grouped states to print + tC <- table( Cst, obj$lex.Cst ) + tX <- table( Xst, obj$lex.Xst ) + cC <- matrix( colnames(tC), nrow(tC), ncol(tC), byrow=T ) + cX <- matrix( colnames(tX), nrow(tX), ncol(tX), byrow=T ) + cC[tC==0] <- "" + cX[tX==0] <- "" + print( data.frame( type=rep( c("lex.Cst","lex.Xst"), + c(nrow(tC),nrow(tX)) ), + old=c(rownames(tC),rownames(tX)), + new=c( apply( cC, 1, paste, collapse="" ), + apply( cX, 1, paste, collapse="" ) ) ) ) + } + return( obj ) + } + +# If states are just given as a vector we assume that it's just new names +if( !is.null( states ) & !is.list( states ) ) + { + if( length( states ) != nlevels(Cst) ) + stop( "Second argument is a vector of length ", length(states), + ", but it should be the joint no. of states, ", + length(all.levels), + "\ncorresponding to ", all.levels ) + levels( obj$lex.Cst ) <- + levels( obj$lex.Xst ) <- states + if( print ) + { + cat( "New levels for lex.Xst and lex.Cst generated:\n" ) + print( data.frame( old=all.levels, new=levels(obj$lex.Cst) ) ) + } + } + +return( obj ) +} diff -Nru r-cran-epi-1.1.24/R/gen.exp.R r-cran-epi-1.1.33/R/gen.exp.R --- r-cran-epi-1.1.24/R/gen.exp.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-epi-1.1.33/R/gen.exp.R 2012-01-03 14:52:23.000000000 +0000 @@ -0,0 +1,157 @@ +use.amt.dpt <- +function( purchase, + push.max = Inf, + breaks, + lags = NULL, + lag.dec = 1 ) +{ +do.call( "rbind", +lapply( split( purchase, purchase$id ), + function(set) + { + np <- nrow(set) + if( np==1 ) return( NULL ) + set <- set[order(set$dop),] + # Compute length of exposure periods + drug.dur <- set$amt / set$dpt + # Put the exposed period head to foot + new.start <- min( set$dop ) + c(0,cumsum(drug.dur[-np])) + # Move them out so that the start of a period is never earlier than + # the dop + exp.start <- new.start + cummax( pmax(set$dop-new.start,0) ) + # Compute the pushes + push.one <- exp.start - set$dop + # Revise them to the maximally acceptable + push.adj <- pmin( push.one, push.max ) + # Revise the starting dates of exposure + exp.start <- exp.start - push.one + push.adj + # Revise the durations to be at most equal to differences between the + # revised starting dates + drug.dur <- pmin( drug.dur, c(diff(exp.start),Inf) ) + # Compute the end of the intervals + exp.end <- exp.start + drug.dur + # Intervals in the middle not covered by the drug exposures - note + # also that we make a record for the last follow-date + followed.by.gap <- c( exp.start[-1]-exp.end[-length(exp.end)] > 0, TRUE ) + # To facilitate + dfR <- rbind( data.frame( id = set$id[1], + dof = exp.start, + dpt = set$dpt ), + data.frame( id = set$id[1], + dof = exp.end[followed.by.gap], + dpt = 0 ) ) + dfR <- dfR[order(dfR$dof),] + # We now compute the cumulative dose at the end of the interval using + # interval length and dpt: + dfR$cum.amt <- with( dfR, cumsum( c(0, diff(dof)*dpt[-length(dpt)]) ) ) + return( dfR ) + } ) ) +} + +use.only.amt <- +function( purchase, + pred.win = Inf, + breaks, + lags = NULL, + lag.dec = 1 ) +{ +# Compute the cumulative dose at all purcase dates and at the last +# (unknown) future expiry date, computed based on previous +# consumption. The resulting data frame has one more line per person +# than no. of purchases. +do.call( "rbind", +lapply( split( purchase, purchase$id ), + function(set) + { + np <- nrow(set) + if( np==1 ) return( NULL ) + set <- set[order(set$dop),] + # The points to include in the calculation: + # All dates after pred.win before last purchase, + # but at least the last two purchase dates, + wp <- ( set$dop > pmin( max(set$dop)-pred.win, + sort(set$dop,decreasing=TRUE)[2] ) ) + # Cumulative amount consumed at each dop + cum.amt <- cumsum(c(0,set$amt)) + # Average slope to use to project the duration last purchase + avg.slp <- diff(range(cum.amt[c(wp,FALSE)]))/ + diff(range(set$dop[wp])) + # Purchase dates and the date of last consumption + dof <- c( set$dop, set$dop[np]+set$amt[np]/avg.slp ) + return( data.frame( id = set$id[1], + dof = dof, + cum.amt = cum.amt ) ) + } ) ) +} + +gen.exp <- +function( purchase, id="id", dop="dop", amt="amt", dpt="dpt", + fu, doe="doe", dox="dox", + breaks, + use.dpt = ( dpt %in% names(purchase) ), + lags = NULL, + push.max = Inf, + pred.win = Inf, + lag.dec = 1 ) +{ +# Make sure that the data fames have the right column names +wh <- match( c(id,dop,amt), names(purchase) ) +if( any( is.na(wh) ) ) stop("Wrong column names for the purchase data frame") +names( purchase )[wh] <- c("id","dop","amt") +wh <- match( c(id,doe,dox), names(fu) ) +if( any( is.na(wh) ) ) stop("Wrong column names for the follow-up data frame") +names( fu )[wh] <- c("id","doe","dox") + +if( use.dpt ) + { + # This is to allow dpt to be entered as numerical scalar common for all + if( is.numeric(dpt) ) + { + if( length(dpt) > 1 ) stop( "If dpt is numeric it must have lenght 1" ) + purchase$dpt <- dpt + } + else + names( purchase )[match(c(dpt),names(purchase))] <- "dpt" + tmp.dfr <- Epi:::use.amt.dpt( purchase, + lags = lags, + push.max = push.max, + lag.dec = lag.dec ) + } +else + tmp.dfr <- Epi:::use.only.amt( purchase, + lags = lags, + pred.win = pred.win, + lag.dec = lag.dec ) + + +# Merge in the follow-up period for the persons +tmp.dfr <- merge( tmp.dfr, fu, all=T ) + +# Interpolate to find the cumulative doses at the dates in breaks +do.call( "rbind", +lapply( split( tmp.dfr, tmp.dfr$id ), + function(set) + { + # All values of these are identical within each set (=person) + doe <- set$doe[1] + dox <- set$dox[1] + # The first and last date of exposure according to the assumption + doi <- min(set$dof) + doc <- max(set$dof) + # Get the breakpoints and the entry end exit dates + breaks <- sort( unique( c(breaks,doe,dox) ) ) + xval <- breaks[breaks>=doe & breaks<=dox] + dfr <- data.frame( id = set$id[1], + dof = xval ) + dfr$tfi <- pmax(0,xval-doi) + dfr$tfc <- pmax(0,xval-doc) + dfr$cdos <- approx( set$dof, set$cum.amt, xout=xval, rule=2 )$y + for( lg in lags ) + dfr[,paste( "ldos", + formatC(lg,format="f",digits=lag.dec), + sep="." )] <- + approx( set$dof, set$cum.amt, xout=xval-lg, rule=2 )$y + dfr + } ) ) +} + diff -Nru r-cran-epi-1.1.24/R/lexis.R r-cran-epi-1.1.33/R/lexis.R --- r-cran-epi-1.1.24/R/lexis.R 2011-07-22 20:34:07.000000000 +0000 +++ r-cran-epi-1.1.33/R/lexis.R 2012-01-11 12:59:29.000000000 +0000 @@ -80,7 +80,7 @@ stop("Incompatible mode for entry and exit status") } } - + ## If entry is missing and one of the others is given as a list of length ## one, entry is assumed to be 0 on this only timescale. if( nmissing==2 ) @@ -111,7 +111,7 @@ } ## Coerce entry and exit lists to data frames - + if(!missing(entry)) { entry <- as.data.frame(entry) if (is.null(names(entry))) @@ -140,9 +140,9 @@ ## Impute entry entry <- exit - duration } - + if (missing(duration)) { - ## Impute duration + ## Impute duration full.time.scales <- intersect(names(entry), names(exit)) if (length(full.time.scales) == 0) { stop("Cannot calculate duration from entry and exit times") @@ -180,9 +180,9 @@ if (any(duration<0)) { stop("Duration must be non-negative") } - + ## Make sure id value - if supplied - is valid. Otherwise supply default id - + if (missing(id)) { id <- 1:nrow(entry) } @@ -237,10 +237,10 @@ ##Utility function, returns the names of the time scales in a Lexis object ##lex - a Lexis object ##time.scale - a numeric or character vector. The function checks that - ## these are valid time scales for the Lexis object. + ## these are valid time scales for the Lexis object. ##Return value is a character vector containing the names of the requested ##time scales - + all.names <- timeScales(lex) if (is.null(time.scale)) return(all.names) @@ -270,9 +270,9 @@ # A utility function that returns a data.frame / Lexis object with # rows with missing timescales removed x[complete.cases(x[,check.time.scale(x,time.scale)]),] - } + } -plot.Lexis.1D <- function(x, time.scale=1, breaks="lightgray", +plot.Lexis.1D <- function(x, time.scale=1, breaks="lightgray", type="l", col="darkgray", xlim, ylim, xlab, ylab, ...) { @@ -295,7 +295,7 @@ xlab <- time.scale if (missing(ylab)) ylab <- "id number" - + plot(time.entry, id, type="n", xlab=xlab, ylab=ylab, xlim=xlim, ylim=ylim, ...) if (type=="b" || type=="l") { @@ -311,7 +311,7 @@ points.Lexis.1D <- function(x, time.scale, ...) { - x <- valid.times(x,time.scale) + x <- valid.times(x,time.scale) time.exit <- x[,time.scale] + x$lex.dur points(time.exit, x$lex.id, ...) } @@ -343,7 +343,7 @@ stop("Two time scales are required") x <- valid.times(x,time.scale) - + time.entry <- time.exit <- vector("list",2) for (i in 1:2) { time.entry[[i]] <- x[,time.scale[i]] @@ -368,12 +368,12 @@ else if (missing(ylim)) { ylim <- c(min(time.entry[[2]]), max(time.exit[[2]])) } - + if (missing(xlab)) xlab <- time.scale[1] if (missing(ylab)) ylab <- time.scale[2] - + plot(time.entry[[1]], time.entry[[2]], type="n", xlab=xlab, ylab=ylab, xlim=xlim, ylim=ylim, ...) @@ -465,7 +465,7 @@ time.scale <- check.time.scale(x, time.scale) if (length(time.scale) > 2) time.scale <- time.scale[1:2] - + if (length(time.scale) == 1) lines.Lexis.1D(x, time.scale=time.scale, ...) else if (length(time.scale) == 2) @@ -516,7 +516,7 @@ { if (is.Lexis(x)) merge.Lexis(x, y, ...) - else if (is.Lexis(y)) + else if (is.Lexis(y)) merge.Lexis(y, x, ...) else base::merge.data.frame(x, y, ...) @@ -539,7 +539,7 @@ stop("x and y have no variable names in common") } } - + z <- base::merge.data.frame(x, y, ...) attr(z,"breaks") <- attr(x, "breaks") attr(z,"time.scales") <- attr(x, "time.scales") @@ -550,47 +550,65 @@ ## Extractor functions -entry <- function(x, time.scale = NULL) +entry <- function(x, time.scale = NULL, by.id = FALSE ) { time.scale <- check.time.scale(x, time.scale) + wh <- x[,time.scale[1]] == + ave( x[,time.scale[1]], x$lex.id, FUN=if( by.id ) min else I ) if (length(time.scale) > 1) { - return(as.matrix(x[, time.scale])) + res <- as.matrix(x[wh, time.scale]) + if( by.id ) colnames( res ) <- x$lex.id[wh] + return( res ) } else { - return(x[, time.scale]) + res <- x[wh, time.scale] + if( by.id ) names( res ) <- x$lex.id[wh] + return( res ) } } -exit <- function(x, time.scale = NULL) +exit <- function(x, time.scale = NULL, by.id = FALSE ) { time.scale <- check.time.scale(x, time.scale) + wh <- x[,time.scale[1]] == + ave( x[,time.scale[1]], x$lex.id, FUN=if( by.id ) max else I ) if (length(time.scale) > 1) { - return(as.matrix(x[, time.scale]) + x$lex.dur) + res <- as.matrix(x[wh, time.scale]) + x$lex.dur[wh] + if( by.id ) rownames( res ) <- x$lex.id[wh] + return( res ) } else { - return(x[, time.scale] + x$lex.dur) + res <- x[wh, time.scale] + x$lex.dur[wh] + if( by.id ) names( res ) <- x$lex.id[wh] + return( res ) } } -dur <- function(x) +dur <- function(x, by.id=FALSE) { - return(x$lex.dur) + if( by.id ) return( tapply(x$lex.dur,x$lex.id,sum) ) + else return( x$lex.dur ) } - -status <- function(x, at="exit") +status <- function(x, at="exit", by.id = FALSE) { at <- match.arg(at, c("entry","exit")) - switch(at, "entry"=x$lex.Cst, "exit"=x$lex.Xst) + wh <- x[,timeScales(x)[1]] == + ave( x[,timeScales(x)[1]], x$lex.id, FUN=if(by.id) + switch(at, + "entry"=min, + "exit"=max) + else I ) + res <- switch(at, "entry"=x$lex.Cst, "exit"=x$lex.Xst)[wh] + if( by.id ) names( res ) <- x$lex.id[wh] + res } -time.scales <- timeScales <- function(x) { return (attr(x,"time.scales")) } -time.band <- timeBand <- function(lex, time.scale, type="integer") { time.scale <- check.time.scale(lex, time.scale)[1] @@ -619,7 +637,7 @@ "left" = I1, "right" = I2, "middle" = (I1 + I2)/2) - + if(type=="factor") { return(factor(band, levels=0:length(breaks), labels=labels)) } diff -Nru r-cran-epi-1.1.24/R/splitLexis.R r-cran-epi-1.1.33/R/splitLexis.R --- r-cran-epi-1.1.24/R/splitLexis.R 2011-07-22 20:34:07.000000000 +0000 +++ r-cran-epi-1.1.33/R/splitLexis.R 2011-12-08 17:37:55.000000000 +0000 @@ -2,7 +2,7 @@ function(lex, breaks, time.scale, tol) { time.scale <- Epi:::check.time.scale(lex, time.scale) - + ## Entry and exit times on the time scale that we are splitting time1 <- lex[,time.scale, drop=FALSE] time2 <- time1 + lex$lex.dur @@ -11,7 +11,7 @@ breaks <- sort( unique( breaks ) ) I1 <- c(-Inf, breaks) I2 <- c(breaks,Inf) - + ## Arrays containing data on each interval (rows) for each subject (cols) en <- apply(time1, 1, pmax, I1) # Entry time ex <- apply(time2, 1, pmin, I2) # Exit time @@ -25,7 +25,7 @@ ## Cumulative time since entry at the start of each interval time.since.entry <- rbind(0, apply(dur,2,cumsum)[-NR,,drop=FALSE]) - + cal.new.entry <- function(entry.time) { sweep(time.since.entry, 2, entry.time, "+")[valid] } @@ -47,7 +47,7 @@ "id" = rep(lex$lex.id, n.interval), "entry.status" = rep(lex$lex.Cst, n.interval), "exit.status" = new.Xst[valid]) - + ## Update breaks attribute breaks.attr <- attr(lex, "breaks") breaks.attr[[time.scale]] <- sort(c(breaks.attr[[time.scale]], breaks)) @@ -64,15 +64,26 @@ stop( "It makes no sense to time-split after stacking ---\n", "split your original Lexis object and stack that to get what you want.\n") + ## Set temporary, unique, id variable lex$lex.tempid <- lex$lex.id - lex$lex.id <- 1:nrow(lex) - + lex$lex.id <- 1:nrow(lex) + ## Save auxiliary data aux.data.names <- setdiff(names(lex), timeScales(lex)) aux.data.names <- aux.data.names[substr(aux.data.names,1,4) != "lex."] aux.data <- lex[, c("lex.id","lex.tempid", aux.data.names), drop=FALSE] + ## Check for NAs in the timescale + ts <- Epi:::check.time.scale(lex, time.scale) + ts.miss <- any(is.na(lex[,ts])) + if( ts.miss ) + { + na.lex <- lex[ is.na(lex[,ts]),] + lex <- lex[!is.na(lex[,ts]),] + cat( "Note: NAs in the time-scale \"", ts, "\", you split on\n") + } + ## If states are factors convert to numeric while splitting factor.states <- is.factor( lex$lex.Cst ) if( factor.states ) @@ -82,7 +93,7 @@ lex$lex.Cst <- as.integer( lex$lex.Cst ) lex$lex.Xst <- as.integer( lex$lex.Xst ) } - + ## Split the data lex <- split.lexis.1D(lex, breaks, time.scale, tol) @@ -93,9 +104,12 @@ lex$lex.Xst <- factor( lex$lex.Xst, levels=1:nstates, labels=state.levels ) } + ## Put the NA-rows back + if( ts.miss ) lex <- rbind( lex, na.lex[,colnames(lex)] ) + ## Save attributes lex.attr <- attributes(lex) - ## Merge + ## Merge lex <- merge.data.frame(lex, aux.data, by="lex.id") ## Restore attributes attr(lex,"breaks") <- lex.attr$breaks diff -Nru r-cran-epi-1.1.24/R/stack.Lexis.R r-cran-epi-1.1.33/R/stack.Lexis.R --- r-cran-epi-1.1.24/R/stack.Lexis.R 2011-07-22 20:34:07.000000000 +0000 +++ r-cran-epi-1.1.33/R/stack.Lexis.R 2011-09-18 11:53:38.000000000 +0000 @@ -31,29 +31,19 @@ tmat <- function (x, ...) UseMethod("tmat") tmat.Lexis <- -function( x, ... ) +function( x, Y=FALSE, ... ) { zz <- table(x$lex.Cst,x$lex.Xst) class(zz) <- "matrix" -diag(zz) <- NA +if( Y ) + { + diag(zz) <- summary( x, simplify=FALSE )[[1]][1:nrow(zz),"Risk time:"] + } +else diag(zz) <- NA zz[zz==0] <- NA zz } -# The factorize method -factorize <- function (obj, ...) UseMethod("factorize") - -factorize.Lexis <- -function( obj, ... ) -{ - Cst <- factor( obj$lex.Cst ) - Xst <- factor( obj$lex.Xst ) - all.levels = union(levels(Cst),levels(Xst)) - obj$lex.Cst <- factor( Cst, levels=all.levels ) - obj$lex.Xst <- factor( Xst, levels=all.levels ) - obj -} - # The msdata method msdata <- function (obj, ...) UseMethod("msdata") @@ -68,7 +58,7 @@ tmp <- stack.Lexis( factorize.Lexis(obj) ) lv <- c( match(timeScales(obj), names(tmp) ), grep("lex\\.", names(tmp) ) ) -# The transitions that we refer to are extracted form lex.Tr: +# The transitions that we refer to are extracted from lex.Tr: ss <- strsplit( as.character(tmp$lex.Tr), "->" ) # The resulting dataframe is created by renaming columns in the stacked Lexis object data.frame( id = tmp$lex.id, diff -Nru r-cran-epi-1.1.24/R/stattable.R r-cran-epi-1.1.33/R/stattable.R --- r-cran-epi-1.1.24/R/stattable.R 2011-07-22 20:34:07.000000000 +0000 +++ r-cran-epi-1.1.33/R/stattable.R 2011-08-05 12:36:57.000000000 +0000 @@ -54,7 +54,7 @@ ## Check that functions in the contents list are valid valid.functions <- c("count","mean","weighted.mean","sum","quantile", - "median","IQR","max","min","ratio","percent") + "median","IQR","max","min","ratio","percent","sd") table.fun <- character(length(contents) - 1) for (i in 2:length(contents)) { if (!is.call(contents[[i]])) @@ -148,6 +148,10 @@ return(100*sweep(n, which(sweep.index), margin,"/")) } } + sd <- function (..., na.rm = TRUE) + { + tapply(..., INDEX=subindex, FUN = stats::sd, na.rm=na.rm) + } ##Calculate dimension of the main table, excluding margins n.dim <- length(index) @@ -448,7 +452,8 @@ print.stat.table <- function(x, width=7,digits,...) { fun.digits <- c("count"=0,"mean"=2,"weighted.mean"=2,"sum"=2,"quantile"=2, - "median"=2,"IQR"=2,"max"=2,"min"=2,"ratio"=2,"percent"=1) + "median"=2,"IQR"=2,"max"=2,"min"=2,"ratio"=2,"percent"=1, + "sd"=2) if (!missing(digits)) { if (is.null(names(digits))) { if (length(digits) > 1) Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/data/B.dk.rda and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/data/B.dk.rda differ Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/data/DMconv.rda and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/data/DMconv.rda differ Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/data/DMlate.rda and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/data/DMlate.rda differ Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/data/DMrand.rda and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/data/DMrand.rda differ Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/data/M.dk.rda and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/data/M.dk.rda differ Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/data/N.dk.rda and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/data/N.dk.rda differ Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/data/S.typh.rda and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/data/S.typh.rda differ Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/data/Y.dk.rda and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/data/Y.dk.rda differ Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/data/bdendo.rda and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/data/bdendo.rda differ Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/data/bdendo11.rda and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/data/bdendo11.rda differ Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/data/births.rda and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/data/births.rda differ Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/data/blcaIT.rda and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/data/blcaIT.rda differ Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/data/brv.rda and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/data/brv.rda differ diff -Nru r-cran-epi-1.1.24/data/datalist r-cran-epi-1.1.33/data/datalist --- r-cran-epi-1.1.24/data/datalist 2011-07-22 20:34:20.000000000 +0000 +++ r-cran-epi-1.1.33/data/datalist 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -DMconv -DMlate -DMrand -S.typh -bdendo -bdendo11 -births -blcaIT -brv -diet -ewrates -gmortDK -hivDK -lep -lungDK -mortDK -nickel -occup -thoro Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/data/diet.rda and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/data/diet.rda differ Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/data/ewrates.rda and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/data/ewrates.rda differ Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/data/gmortDK.rda and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/data/gmortDK.rda differ Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/data/hivDK.rda and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/data/hivDK.rda differ Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/data/lep.rda and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/data/lep.rda differ Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/data/lungDK.rda and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/data/lungDK.rda differ Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/data/mortDK.rda and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/data/mortDK.rda differ Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/data/nickel.rda and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/data/nickel.rda differ Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/data/occup.rda and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/data/occup.rda differ Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/data/thoro.rda and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/data/thoro.rda differ diff -Nru r-cran-epi-1.1.24/debian/README.Debian r-cran-epi-1.1.33/debian/README.Debian --- r-cran-epi-1.1.24/debian/README.Debian 2010-06-04 11:12:30.000000000 +0000 +++ r-cran-epi-1.1.33/debian/README.Debian 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -Notes on how this package can be tested. -──────────────────────────────────────── - -This package can be tested by loading it into R with the command -‘library(Epi)’ in order to confirm its integrity. diff -Nru r-cran-epi-1.1.24/debian/README.test r-cran-epi-1.1.33/debian/README.test --- r-cran-epi-1.1.24/debian/README.test 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-epi-1.1.33/debian/README.test 2010-06-04 11:12:30.000000000 +0000 @@ -0,0 +1,5 @@ +Notes on how this package can be tested. +──────────────────────────────────────── + +This package can be tested by loading it into R with the command +‘library(Epi)’ in order to confirm its integrity. diff -Nru r-cran-epi-1.1.24/debian/changelog r-cran-epi-1.1.33/debian/changelog --- r-cran-epi-1.1.24/debian/changelog 2011-10-25 14:49:56.000000000 +0000 +++ r-cran-epi-1.1.33/debian/changelog 2013-05-05 16:11:08.000000000 +0000 @@ -1,3 +1,26 @@ +r-cran-epi (1.1.33-1precise0) precise; urgency=low + + * Compilation for Ubuntu 12.04.2 LTS + + -- Michael Rutter Sun, 05 May 2013 16:11:08 +0000 + +r-cran-epi (1.1.33-1) unstable; urgency=low + + * New upstream version + * debian/upstream: Add References + * debian/control: + - Standards-Version: 3.9.3 (no changes needed) + - Build-Depends: r-base-dev (>= 2.14.2~20120222) + * debian/rules: + - Remove R:Depends substitution variable which is now + included in /usr/share/R/debian/r-cran.mk + * debian/README.Debian is rather README.test + * debian/docs: Install README.test + * debian/copyright: Enhances DEP5 compatibility and verified using + cme fix dpkg-copyright + + -- Andreas Tille Mon, 26 Mar 2012 15:04:33 +0200 + r-cran-epi (1.1.24-1) unstable; urgency=low * New upstream version diff -Nru r-cran-epi-1.1.24/debian/control r-cran-epi-1.1.33/debian/control --- r-cran-epi-1.1.24/debian/control 2011-07-05 12:32:53.000000000 +0000 +++ r-cran-epi-1.1.33/debian/control 2012-03-26 13:20:30.000000000 +0000 @@ -4,8 +4,8 @@ Maintainer: Debian Med Packaging Team Uploaders: Andreas Tille DM-Upload-Allowed: yes -Build-Depends: debhelper (>= 8), cdbs, r-base-dev -Standards-Version: 3.9.2 +Build-Depends: debhelper (>= 8), cdbs, r-base-dev (>= 2.14.2~20120222) +Standards-Version: 3.9.3 Homepage: http://staff.pubhealth.ku.dk/~bxc/Epi/ Vcs-Browser: http://svn.debian.org/wsvn/debian-med/trunk/packages/R/r-cran-epi/trunk/ Vcs-Svn: svn://svn.debian.org/debian-med/trunk/packages/R/r-cran-epi/trunk/ diff -Nru r-cran-epi-1.1.24/debian/copyright r-cran-epi-1.1.33/debian/copyright --- r-cran-epi-1.1.24/debian/copyright 2009-09-03 10:49:38.000000000 +0000 +++ r-cran-epi-1.1.33/debian/copyright 2012-03-26 13:24:54.000000000 +0000 @@ -1,12 +1,11 @@ -Format-Specification: http://wiki.debian.org/Proposals/CopyrightFormat -Upstream-Author: Bendix Carstensen -Packaged-By: Andreas Tille -Packaged-Date: Mon, 24 Nov 2008 13:12:38 +0100 -Upstream-Source: http://cran.r-project.org/src/contrib/ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: Epi +Upstream-Contact: Bendix Carstensen +Source: http://cran.r-project.org/src/contrib/ Files: * +Copyright: 2008-2012 Bendix Carstensen, Martyn Plummer, Esa Laara, Michael Hills et. al. License: GPL2+ -Copyright: 2008 Bendix Carstensen, Martyn Plummer, Esa Laara, Michael Hills et. al. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or @@ -19,10 +18,12 @@ . You should have received a copy of the GNU General Public License along with this program. If not, see . -X-Comment: On Debian systems, the complete text of the GNU Public + . + On Debian systems, the complete text of the GNU Public License can be found in `/usr/share/common-licenses/GPL'. Files: debian/* -Copyright: © 2008 Andreas Tille -License: Same as r-cran-epitools itelf - (see above) +Copyright: 2008-2012 Andreas Tille +License: GPL2+ + Same as r-cran-epitools itelf + diff -Nru r-cran-epi-1.1.24/debian/docs r-cran-epi-1.1.33/debian/docs --- r-cran-epi-1.1.24/debian/docs 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-epi-1.1.33/debian/docs 2012-03-23 22:41:02.000000000 +0000 @@ -0,0 +1 @@ +debian/README.test diff -Nru r-cran-epi-1.1.24/debian/rules r-cran-epi-1.1.33/debian/rules --- r-cran-epi-1.1.24/debian/rules 2011-02-10 12:28:45.000000000 +0000 +++ r-cran-epi-1.1.33/debian/rules 2012-03-26 13:20:12.000000000 +0000 @@ -8,9 +8,6 @@ DEB_COMPRESS_EXCLUDE_ALL := .pdf install/$(package):: - # Require a number equal or superior than the R version the package was built with. - echo "R:Depends=r-base-core (>= $(shell R --version | head -n1 | perl -ne 'print / +([0-9]\.[0-9]+\.[0-9])/')~)" >> debian/r-$(debRreposname)-$(cranName).substvars - # mv debian/$(package)/usr/lib/R/site-library/Epi/doc/* debian/$(package)/usr/share/doc/$(package) rmdir debian/$(package)/usr/lib/R/site-library/Epi/doc # install examples and unset executable flag (which is the reason why no debian/examples diff -Nru r-cran-epi-1.1.24/debian/upstream r-cran-epi-1.1.33/debian/upstream --- r-cran-epi-1.1.24/debian/upstream 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-epi-1.1.33/debian/upstream 2012-03-26 13:13:50.000000000 +0000 @@ -0,0 +1,9 @@ +Reference: + Title: "Lexis: An R Class for Epidemiological Studies with Long-Term Follow-Up" + Author: Martyn Plummer, Bendix Carstensen + Journal: Journal of Statistical Software + Year: 2011 + Volume: 38 + Number: 5 + Pages: 1--12 + URL: http://www.jstatsoft.org/v38/i05/ Binary files /tmp/LnXvNJJfs5/r-cran-epi-1.1.24/inst/doc/Follow-up.pdf and /tmp/JY5kcPKb0b/r-cran-epi-1.1.33/inst/doc/Follow-up.pdf differ diff -Nru r-cran-epi-1.1.24/man/B.dk.Rd r-cran-epi-1.1.33/man/B.dk.Rd --- r-cran-epi-1.1.24/man/B.dk.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-epi-1.1.33/man/B.dk.Rd 2011-09-18 11:53:38.000000000 +0000 @@ -0,0 +1,59 @@ +\name{B.dk} +\alias{B.dk} +\docType{data} +\title{Births in Denmark by year and month of birth and sex} +\description{ + The number of live births as entered from printed publications from + Statistics Denmark. +} +\usage{data(B.dk)} +\format{ + A data frame with 1248 observations on the following 4 variables. + \describe{ + \item{\code{year}}{Year of birth} + \item{\code{month}}{Month of birth} + \item{\code{m}}{Number of male births} + \item{\code{f}}{Number of female births} + } +} +\details{ + Division of births by month and sex is only avaialble for the years 1957--69 + and 2002ff. For the remaining period, the total no. births in each month is + divided between the sexes so that the fraction of boys is equal to the overall + fraction for the years where the sex information is available. + + There is a break in the series at 1920, when Sonderjylland was joined to Denmark. +} +\source{ + Statistiske Undersogelser nr. 19: Befolkningsudvikling og sundhedsforhold + 1901-60, Copenhagen 1966. + Befolkningens bevaegelser 1957. + Befolkningens bevaegelser 1958. + ... + Befolkningens bevaegelser 2003. + Befolkningens bevaegelser 2004. + Vital Statistics 2005. + Vital Statistics 2006. +} +\examples{ +data( B.dk ) +str( B.dk ) +attach( B.dk ) +# Plot the no of births and the M/F-ratio +par( las=1, mar=c(4,4,2,4) ) +matplot( year+(month-0.5)/12, + cbind( m, f ), + bty="n", col=c("blue","red"), lty=1, lwd=1, type="l", + ylim=c(0,5000), + xlab="Date of birth", ylab="" ) +usr <- par()$usr +mtext( "Monthly no. births in Denmark", side=3, adj=0, at=usr[1], line=1/1.6 ) +text( usr[1:2] \%*\% cbind(c(19,1),c(19,1))/20, + usr[3:4] \%*\% cbind(c(1,19),c(2,18))/20, c("Boys","Girls"), col=c("blue","red"), adj=0 ) +lines( year+(month-0.5)/12, (m/(m+f)-0.5)*30000, lwd=1 ) +axis( side=4, at=(seq(0.505,0.525,0.005)-0.5)*30000, labels=c("","","","",""), tcl=-0.3 ) +axis( side=4, at=(50:53/100-0.5)*30000, labels=50:53, tcl=-0.5 ) +axis( side=4, at=(0.54-0.5)*30000, labels="\% boys", tick=FALSE, mgp=c(3,0.1,0) ) +abline( v=1920, col=gray(0.8) ) +} +\keyword{datasets} diff -Nru r-cran-epi-1.1.24/man/DMlate.Rd r-cran-epi-1.1.33/man/DMlate.Rd --- r-cran-epi-1.1.24/man/DMlate.Rd 2011-07-22 20:34:07.000000000 +0000 +++ r-cran-epi-1.1.33/man/DMlate.Rd 2011-12-19 17:05:31.000000000 +0000 @@ -15,13 +15,14 @@ \usage{data(DMrand) data(DMlate)} \format{ - A data frame with 10000 observations on the following 6 variables. + A data frame with 10000 observations on the following 7 variables. \describe{ \item{\code{sex}}{Sex, a factor with levels \code{M} \code{F}} \item{\code{dobth}}{Date of birth} \item{\code{dodm}}{Date of inclusion in the register} \item{\code{dodth}}{Date of death} - \item{\code{doins}}{Date of first insulin prescription} + \item{\code{dooad}}{Date of 2nd prescription of OAD} + \item{\code{doins}}{Date of 2nd insulin prescription} \item{\code{dox}}{Date of exit from follow-up.} } } diff -Nru r-cran-epi-1.1.24/man/Lexis.Rd r-cran-epi-1.1.33/man/Lexis.Rd --- r-cran-epi-1.1.24/man/Lexis.Rd 2011-07-22 20:34:07.000000000 +0000 +++ r-cran-epi-1.1.33/man/Lexis.Rd 2011-09-18 11:53:38.000000000 +0000 @@ -2,8 +2,8 @@ \alias{Lexis} \title{Create a Lexis object} \description{ - Create an object of class \code{Lexis} to represent follow-up on - multiple time scales. + Create an object of class \code{Lexis} to represent follow-up in + multiple states on multiple time scales. } \usage{ Lexis(entry, exit, duration, entry.status = 0, exit.status = 0, id, data, @@ -14,7 +14,7 @@ a numeric variable representing the entry time on the named time scale. All time scales must have the same units (e.g. years). The names of the timescales must be different from any column name in - \code{date}.} + \code{data}.} \item{exit}{a named list of exit times.} \item{duration}{a numeric vector giving the duration of follow-up.} \item{entry.status}{a vector or a factor giving the status at @@ -61,8 +61,7 @@ \note{ Only two of the three arguments \code{entry}, \code{exit} and \code{duration} need to be given. If the third parameter is missing, - it is imputed. If duration is given, it must be the same on - all time scales. + it is imputed. \code{entry}, \code{exit} must be numeric, using \code{\link{Date}} variables will cause some of the utilites to crash. Transformation by @@ -75,32 +74,35 @@ If any of \code{entry.status} or \code{exit.status} are of mode character, they will both be converted to factors. - If \code{entry.status} is not given, then - its class is automatically set to that of \code{exit.status}. If - \code{exit.status} is factor, the value of \code{entry.status} is set to the - first level. This may be highly undesirable, and therefore noted. For example, - if \code{exit.status} is character the first level will be the first in the - alphabetical ordering; slightly unfortunate if values are - \code{c("Well","Diseased")}. If \code{exit.status} is logical, the value of - \code{entry.status} set to \code{FALSE}. - - If \code{entry.status} or \code{exit.status} are factors or character, the - corresponding state variables in the returned \code{Lexis} object, - \code{lex.Cst} and \code{lex.Xst} will be - (unordered) factors with identical levels, namely the union of the levels - of \code{entry.status} and \code{exit.status}. + If \code{entry.status} is not given, then its class is automatically + set to that of \code{exit.status}. If \code{exit.status} is factor, + the value of \code{entry.status} is set to the first level. This may + be highly undesirable, and therefore noted. For example, if + \code{exit.status} is character the first level will be the first in + the alphabetical ordering; slightly unfortunate if values are + \code{c("Well","Diseased")}. If \code{exit.status} is logical, the + value of \code{entry.status} set to \code{FALSE}. If + \code{exit.status} is numeric, the value of \code{entry.status} set to + 0. + + If \code{entry.status} or \code{exit.status} are factors or character, + the corresponding state variables in the returned \code{Lexis} object, + \code{lex.Cst} and \code{lex.Xst} will be (unordered) factors with + identical set of levels, namely the union of the levels of + \code{entry.status} and \code{exit.status}. } \value{ An object of class \code{Lexis}. This is represented as a data frame with a column for each time scale, and additional columns with the following names: - \item{lex.id}{Identification of the inidvidual} - \item{lex.dur}{Duration of follow-up} + \item{lex.id}{Identification of the inidvidual (record in \code{data}, + that is).} + \item{lex.dur}{Duration of follow-up.} \item{lex.Cst}{Entry status (Current state), i.e. the state in which the follow up takes place.} \item{lex.Xst}{Exit status (eXit state), i.e. that state taken up after \code{dur} in \code{lex.Cst}.} - If \code{merge=TRUE} then the \code{Lexis} object will also contain + If \code{merge=TRUE} (the default) then the \code{Lexis} object will also contain all variables from the \code{data} argument. } \author{Martyn Plummer} @@ -142,17 +144,17 @@ data = xcoh ) } \seealso{ - \code{\link{plot.Lexis}}, - \code{\link{splitLexis}}, - \code{\link{cutLexis}}, - \code{\link{merge.Lexis}}, - \code{\link{subset.Lexis}}, - \code{\link{transform.Lexis}}, - \code{\link{summary.Lexis}}, - \code{\link{timeScales}}, - \code{\link{timeBand}}, - \code{\link{entry}}, - \code{\link{exit}}, + \code{\link{plot.Lexis}}, + \code{\link{splitLexis}}, + \code{\link{cutLexis}}, + \code{\link{merge.Lexis}}, + \code{\link{subset.Lexis}}, + \code{\link{transform.Lexis}}, + \code{\link{summary.Lexis}}, + \code{\link{timeScales}}, + \code{\link{timeBand}}, + \code{\link{entry}}, + \code{\link{exit}}, \code{\link{dur}} } \keyword{survival} diff -Nru r-cran-epi-1.1.24/man/M.dk.Rd r-cran-epi-1.1.33/man/M.dk.Rd --- r-cran-epi-1.1.24/man/M.dk.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-epi-1.1.33/man/M.dk.Rd 2011-09-18 11:53:38.000000000 +0000 @@ -0,0 +1,33 @@ +\name{M.dk} +\alias{M.dk} +\docType{data} +\title{Mortality in Denmark 1974 ff.} +\description{ + Mortality in one-year classes of age (0-98,99+) and period (1974 ff.) in Denmark. +} +\usage{data(M.dk)} +\format{ + A data frame with 6400 observations on the following 6 variables. + \describe{ + \item{\code{A}}{Age-class, 0-98, 99:99+} + \item{\code{sex}}{Sex. 1:males, 2:females} + \item{\code{P}}{Period (year) of death} + \item{\code{D}}{Number of deaths} + \item{\code{Y}}{Number of person-years} + \item{\code{rate}}{Mortality rate per 1000 person-years} + } +} +\details{ + Deaths in ages over 100 are in the class labelled 99. Risk time is + computed by tabulation of the risk time in \code{\link{Y.dk}, except + for the class 99+ where the average of the population size in ages + 99+ at the first and last date of the year is used.} +} +\source{ + \url{http://www.statistikbanken.dk/statbank5a/SelectTable/omrade0.asp?SubjectCode=02&PLanguage=1&ShowNews=OFF} +} +\examples{ +data(M.dk) +str(M.dk) +} +\keyword{datasets} diff -Nru r-cran-epi-1.1.24/man/MS.boxes.Rd r-cran-epi-1.1.33/man/MS.boxes.Rd --- r-cran-epi-1.1.24/man/MS.boxes.Rd 2011-07-22 20:34:07.000000000 +0000 +++ r-cran-epi-1.1.33/man/MS.boxes.Rd 2011-09-18 11:53:38.000000000 +0000 @@ -6,14 +6,16 @@ \alias{boxarr} \alias{boxes} \alias{boxes.Lexis} +\alias{boxes.matrix} \title{ Draw boxes and arrows for illustration of multistate models. } -\description{ - Boxes can be drawn with text (\code{tbox}) or a cross (\code{dbox}), and - arrows pointing between the boxes (\code{boxarr}) can be drawn - automatically not overlapping the boxes. \code{\link{Lexis}} objects - can be used to generate displays with person-years and events. + \description{ + Boxes can be drawn with text (\code{tbox}) or a cross (\code{dbox}), + and arrows pointing between the boxes (\code{boxarr}) can be drawn + automatically not overlapping the boxes. The \code{boxes} method for + \code{\link{Lexis}} objects generates displays of states with + person-years and transitions with events or rates. } \usage{ tbox( txt, x, y, wd, ht, @@ -27,8 +29,7 @@ col.border="black", col.bg="transparent" ) boxarr( b1, b2, offset=FALSE, pos=0.45, ... ) - boxes( obj, ... ) - \method{boxes}{Lexis}( obj, file, +\method{boxes}{Lexis}( obj, file, detailed = FALSE, boxpos = FALSE, wmult = 1.5, @@ -58,6 +59,7 @@ txt.arr = NULL, col.txt.arr = col.arr, offset.arr = 2, ... ) +\method{boxes}{matrix}( obj, ... ) fillarr( x1, y1, x2, y2, gap=2, fr=0.8, angle=17, lwd=2, length=par("pin")[1]/30, ... ) } @@ -80,9 +82,14 @@ \item{b2}{Coordinates of the "to" box; like \code{b1}.} \item{offset}{Logical. Should the arrow be offset a bit to the left.} \item{pos}{Numerical between 0 and 1, determines the position of the point - on the arrow which is returned.} - \item{obj}{A \code{\link{Lexis}} object, or a transition matrix; that - is a matrix} + on the arrow which is returned.} + \item{obj}{A \code{\link{Lexis}} object or a transition matrix; that + is a square matrix indexed by state in both dimensions, and the + \eqn{(i,j)}th entry different from \code{NA} if a transition \eqn{i} + to \eqn{j} can occur. If \code{show.D=TRUE}, the arrows between + states are annotated by these numbers. If \code{show.Y=TRUE}, the + boxes representing states are annotated by the numbers in the + diagonal of \code{obj}.} \item{file}{Name of the file with the code reproducing the plot.} \item{detailed}{Should the output of R-code be detailed, showing all parameters?} \item{boxpos}{If \code{TRUE} the boxes are positioned equidistantly on a @@ -98,8 +105,8 @@ \item{cex}{Character expansion for text in the box.} \item{show}{Should person-years and transitions be put in the plot. Ignored if \code{obj} is not a \code{Lexis} object.} - \item{show.Y}{Should person-years be put in the boxes. - Ignored if \code{obj} is not a \code{Lexis} object.} + \item{show.Y}{If logical: Should person-years be put in the boxes. + If numeric: Numbers to put in boxes.} \item{scale.Y}{What scale should be used for annotation of person-years.} \item{digits.Y}{How many digits after the decimal point should be used for the person-years.} @@ -157,7 +164,8 @@ actual transitions in the \code{Lexis} object. A transition matrix can also be supplied, in which case the row/column - names are used as state names. + names are used as state names, diagnonal elements taken as + person-years, and off-diagnonal elements as number of transitions. Optionally returns the R-code reproducing the plot in a file, which can be useful if you want to produce exactly the same plot with @@ -227,14 +235,17 @@ # Split follow-up at Insulin dmi <- cutLexis( dml, cut=dml$doins, new.state="Ins", pre="DM" ) summary( dmi ) -boxes( dmi, boxpos=TRUE, file="" ) +boxes( dmi, boxpos=TRUE ) # Set up a bogus recovery date dmi$dorec <- dmi$doins + runif(nrow(dmi),0.5,10) dmi$dorec[dmi$dorec>dmi$dox] <- NA dmR <- cutLexis( dmi, cut=dmi$dorec, new.state="DM", pre="Ins" ) summary( dmR ) -boxes( dmR, boxpos=TRUE, file="" ) +boxes( dmR, boxpos=TRUE ) } +\seealso{ + \code{\link{tmat.Lexis}} + } \keyword{survival} \keyword{hplot} \keyword{iplot} diff -Nru r-cran-epi-1.1.24/man/N.dk.Rd r-cran-epi-1.1.33/man/N.dk.Rd --- r-cran-epi-1.1.24/man/N.dk.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-epi-1.1.33/man/N.dk.Rd 2011-09-18 11:53:38.000000000 +0000 @@ -0,0 +1,27 @@ +\name{N.dk} +\alias{N.dk} +\docType{data} +\title{Population size in Denmark} +\description{ + The population size at 1st January in ages 0-99. +} +\usage{data(N.dk)} +\format{ + A data frame with 7200 observations on the following 4 variables. + \describe{ + \item{\code{sex}}{Sex, 1:males, 2:females} + \item{\code{A}}{Age. 0:0, 1:1, ..., 98:98, 99:99+} + \item{\code{P}}{Year} + \item{\code{N}}{Number of persons alive at 1st January year \code{P}} + } +} +\source{ + \url{http://www.statistikbanken.dk/statbank5a/SelectTable/omrade0.asp?SubjectCode=02&PLanguage=1&ShowNews=OFF} +} +\examples{ +data(N.dk) +str(N.dk) +with(N.dk,addmargins(tapply(N,list(P,sex),sum),2)) +with(subset(N.dk,P==max(P)),addmargins(tapply(N,list(A,sex),sum))) +} +\keyword{datasets} diff -Nru r-cran-epi-1.1.24/man/N2Y.Rd r-cran-epi-1.1.33/man/N2Y.Rd --- r-cran-epi-1.1.24/man/N2Y.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-epi-1.1.33/man/N2Y.Rd 2012-01-11 12:59:29.000000000 +0000 @@ -0,0 +1,61 @@ +\name{N2Y} +\alias{N2Y} +\title{ +Create risk time (Person-Years) in Lexis triangles from population data. +} +\description{ +Data on population size at equidistant dates and age-classes are +used to estimate person-time at risk in Lexis-triangles, i.e. classes +classified by age, period AND cohort. +} +\usage{ +N2Y( A, P, N, + data = NULL, + return.dfr = TRUE) +} +\arguments{ + \item{A}{Name of the age-variable, which should be numeric, + corresponding to the left endpoints of the age intervals.} + \item{P}{Name of the period-variable, which should be numeric, + corresponding to the date of population count.} + \item{N}{The population size at date \code{P} in age class \code{A}.} + \item{data}{A data frame in which arguments are interpreted.} + \item{return.dfr}{Logical. Should the results be returned as a data frame + (default \code{TRUE}) or as a table.} +} +\details{The calculation of the risk time from the population figures is + done as described in: B. Carstensen: Age-Period-Cohort models for the + Lexis diagram. Statistics in Medicine, 26: 3018-3045, 2007. +} +\value{A data frame with variables \code{A}, \code{P} and \code{Y}, + representing the mean age and period in the Lexis triangles and the + person-time in them. + + If \code{res.dfr=FALSE} a three-way table classified by the left end + point of the age-classes and the periods and a factor \code{wh} taking + the values \code{up} and \code{lo} corresponding to upper (early + cohort) and lower (late cohort) Lexis triangles. +} +\references{ + B. Carstensen: Age-Period-Cohort models for the + Lexis diagram. Statistics in Medicine, 26: 3018-3045, 2007. +} +\author{ Bendix Carstensen, + \url{BendixCarstensen.com} } +\seealso{ +\code{\link{splitLexis}}, \code{\link{apc.fit}} +} +\examples{ +# Danish population at 1 Jan each year by sex and age +data( N.dk ) +# An illustrative subset +( Nx <- subset( N.dk, sex==1 & A<5 & P<1975 ) ) +# Show the data in tabular form +xtabs( N ~ A + P, data=Nx ) +# Lexis triangles as data frame +Nt <- N2Y( data=Nx, return.dfr=TRUE ) +xtabs( Y ~ round(A,2) + round(P,2), data=Nt ) +# Lexis triangles as a 3-dim array +ftable( N2Y( data=Nx, return.dfr=FALSE ) ) +} +\keyword{Data} diff -Nru r-cran-epi-1.1.24/man/Y.dk.Rd r-cran-epi-1.1.33/man/Y.dk.Rd --- r-cran-epi-1.1.24/man/Y.dk.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-epi-1.1.33/man/Y.dk.Rd 2011-09-18 11:53:38.000000000 +0000 @@ -0,0 +1,45 @@ +\name{Y.dk} +\alias{Y.dk} +\docType{data} +\title{Population risk time in Denmark} +\description{ + Risk time (person-years) in the Danish population, classified by sex, age, period and + date of birth in 1-year classes. This corresponds to triangles in a Lexis diagram. +} +\usage{data(Y.dk)} +\format{ + A data frame with 13860 observations on the following 6 variables. + \describe{ + \item{\code{sex}}{Sex. 1:males, 2:females} + \item{\code{A}}{One-year age class} + \item{\code{P}}{Period} + \item{\code{C}}{Birth cohort} + \item{\code{Y}}{Person-years} + \item{\code{upper}}{Indicator of upper triangle in the Lexis diagram} + } +} +\details{ + The risk time is computed from the population size figures in \code{\link{N.dk}}, + using the formulae devised in B. Carstensen: + "Demography and epidemiology: Age-Period-Cohort models in the computer age", + \url{http://www.pubhealth.ku.dk/bs/publikationer/rr-06-1.pdf/} +} +\source{ + \url{http://www.statistikbanken.dk/statbank5a/SelectTable/omrade0.asp?SubjectCode=02&PLanguage=1&ShowNews=OFF} +} +\examples{ +data(Y.dk) +str(Y.dk) +# Compute mean age, period for the triangles +attach( Y.dk ) +age <- A + (1+upper)/3 +per <- P + (2-upper)/3 +# Plot a Lexis diagram +library( Epi ) +Lexis.diagram( age=c(0,10), date=c(1990,2000), coh.grid=TRUE, int=1 ) +box() +# Print the person-years for males there +text( per[sex==1], age[sex==1], + formatC( Y[sex==1]/1000, format="f", digits=1 ) ) +} +\keyword{datasets} diff -Nru r-cran-epi-1.1.24/man/apc.lines.Rd r-cran-epi-1.1.33/man/apc.lines.Rd --- r-cran-epi-1.1.24/man/apc.lines.Rd 2011-07-22 20:34:07.000000000 +0000 +++ r-cran-epi-1.1.33/man/apc.lines.Rd 2011-12-08 17:37:55.000000000 +0000 @@ -4,6 +4,10 @@ \alias{pc.lines} \alias{pc.matpoints} \alias{pc.matlines} +\alias{cp.points} +\alias{cp.lines} +\alias{cp.matpoints} +\alias{cp.matlines} \title{ Plot APC-estimates (and other things) in an APC-frame. } @@ -32,6 +36,10 @@ pc.lines( x, y, ... ) pc.matpoints( x, y, ... ) pc.matlines( x, y, ... ) + cp.points( x, y, ... ) + cp.lines( x, y, ... ) + cp.matpoints( x, y, ... ) + cp.matlines( x, y, ... ) } \arguments{ \item{A}{Age effects. A 4-column matrix with columns age, age-specific @@ -46,14 +54,14 @@ \code{"RR"}. If \code{"log"} or \code{"ln"} it is assumed that effects are log(rates) and log(RRs) otherwise the actual effects are assumed given in \code{A}, \code{P} and \code{C}. If \code{A} is of - class \code{apc}, it is assumed to be \code{"rates"}.} + class \code{apc}, it is assumed to be \code{"rates"}.} \item{frame.par}{2-element vector with the cohort-period offset and RR multiplicator. This will typically be the result from the call of - \code{\link{apc.frame}}. See this for details.} + \code{\link{apc.frame}}. See this for details.} \item{drift}{The drift parameter to be added to the period effect. If \code{scale="log"} this is assumed to be on the log-scale, otherwise it is assumed to be a multiplicative factor per unit of the first - columns of \code{A}, \code{P} and \code{C} } + columns of \code{A}, \code{P} and \code{C} } \item{c0}{The cohort where the drift is assumed to be 0; the subtracted drift effect is \code{drift*(C[,1]-c0)}.} \item{a0}{The age where the drift is assumed to be 0.} @@ -78,20 +86,22 @@ and the main purpose of the utility is to provide a function that easily adds the functionality of adding a drift so that several sets of lines can be easily produced in the same frame. - + Since the Age-part of the frame is referred to by its real coordinates plotting in the calendar time part requires translation and scaling to - put things correctly there, that is done by the functions \code{pc.points} - etc. + put things correctly there, that is done by the functions + \code{pc.points} etc. The functions \code{cp.points} etc. are just + synonyms for these, in recognition of the fact that you can never + remember whether it is "pc" pr "cp". } \value{ - A list of three matrices with the effects plotted is - returned invisibly. + \code{APC.lines} returns (invisibly) a list of three matrices with the + effects plotted. The functions \code{cp.points} etc. return nothing. } \author{ Bendix Carstensen, Steno Diabetes Center, \url{http://www.pubhealth.ku.dk/~bxc} -} +} \seealso{ \code{\link{apc.frame}}, \code{\link{apc.fit}}, \code{\link{apc.plot}} } diff -Nru r-cran-epi-1.1.24/man/cal.yr.Rd r-cran-epi-1.1.33/man/cal.yr.Rd --- r-cran-epi-1.1.24/man/cal.yr.Rd 2011-07-22 20:34:07.000000000 +0000 +++ r-cran-epi-1.1.33/man/cal.yr.Rd 2011-12-19 17:05:31.000000000 +0000 @@ -15,7 +15,7 @@ } \usage{ cal.yr( x, format="\%Y-\%m-\%d", wh=NULL ) - as.Date.cal.yr( x, ... ) + \method{as.Date}{cal.yr}( x, ... ) } \arguments{ \item{x}{A factor or character vector, representing a date in format diff -Nru r-cran-epi-1.1.24/man/ci.lin.Rd r-cran-epi-1.1.33/man/ci.lin.Rd --- r-cran-epi-1.1.24/man/ci.lin.Rd 2011-07-22 20:34:07.000000000 +0000 +++ r-cran-epi-1.1.33/man/ci.lin.Rd 2011-09-18 11:53:38.000000000 +0000 @@ -96,7 +96,7 @@ } \author{ Bendix Carstensen, - \url{http://www.pubhealth.ku.dk/~bxc} & + \url{BendixCarstensen.com} & Michaal Hills \url{http://www.mhills.pwp.blueyonder.co.uk/} } diff -Nru r-cran-epi-1.1.24/man/cutLexis.Rd r-cran-epi-1.1.33/man/cutLexis.Rd --- r-cran-epi-1.1.24/man/cutLexis.Rd 2011-07-22 20:34:07.000000000 +0000 +++ r-cran-epi-1.1.33/man/cutLexis.Rd 2011-09-18 11:53:38.000000000 +0000 @@ -116,7 +116,10 @@ Martyn Plummer, IARC, \email{plummer@iarc.fr}. } \seealso{ - \code{\link{splitLexis}}, \code{\link{Lexis}}, \code{\link{summary.Lexis}} + \code{\link{splitLexis}}, + \code{\link{Lexis}}, + \code{\link{summary.Lexis}}, + \code{\link{boxes.Lexis}} } \examples{ # A small artificial example diff -Nru r-cran-epi-1.1.24/man/gen.exp.Rd r-cran-epi-1.1.33/man/gen.exp.Rd --- r-cran-epi-1.1.24/man/gen.exp.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-epi-1.1.33/man/gen.exp.Rd 2012-01-11 12:59:29.000000000 +0000 @@ -0,0 +1,147 @@ +\name{gen.exp} +\alias{gen.exp} +\title{ +Generate covariates for drug-exposure follow-up from drug purchase records. +} +\description{ +From records of drug purchase and possibly known treatment intensity, +the time since first drug use and cumulative dose at prespecified times +is computed. Optionally, lagged exposures are computed too, +i.e. cumulative exposure a prespecified time ago. +} +\usage{ +gen.exp(purchase, id = "id", dop = "dop", amt = "amt", dpt = "dpt", + fu, doe = "doe", dox = "dox", + breaks, + use.dpt = ( dpt \%in\% names(purchase) ), + lags = NULL, + push.max = Inf, + pred.win = Inf, + lag.dec = 1 ) +} +\arguments{ + \item{purchase}{Data frame with columns \code{id}-person id, + \code{dop}-date of purchase, \code{amt}-amount purchased, and + optionally \code{dpt}-defined daily dose, that is how much is assumed + to be ingested per unit time. The time unit used here is assumed to be +the same as that used in \code{dop}, so despite the name it is not +necessarily measured per day.} + \item{id}{Name of the id variable in the data frame.} + \item{dop}{Name of the date of purchase variable in the data frame.} + \item{amt}{Name of the amount purchased variable in the data frame.} + \item{dpt}{Name of the dose-per-time variable in the data frame.} + \item{fu}{Data frame with follow-up period for each person, the person + id variable must have the same name as in the \code{purchase} data frame.} + \item{doe}{Name of the date of entry variable.} + \item{dox}{Name of the date of exit variable.} + \item{use.dpt}{Logical, should we use information on dose per time.} + \item{breaks}{Numerical vector of time points where the time since exposure and the + cumulative dose are computed.} + \item{lags}{Numerical vector of lag-times used in computing lagged cumulative + doses.} + \item{push.max}{How much can purchases maximally be pushed forward in + time. See details.} + \item{pred.win}{The length of the window used for constructing the + average dose per time used to compute the duration of the last purchase} + \item{lag.dec}{How many decimals to use in the construction of + names for the lagged exposure variables} +} + +\details{ + Each purchase record is converted into a time-interval of exposure. + + If \code{use.dpt} is \code{TRUE} then the dose per time information is + used to compute the exposure interval associated with each purchase. +Exposure intervals are stacked, that is each interval is put +after any previous. This means that the start of exposure to a given +purchase can be pushed into the future. The parameter \code{push.max} +indicates the maximally tolerated push. If this is reached by a person, +the assumption is that some of the purchased drug is not counted in the +exposure calculations. + +The \code{dpt} can either be a constant, basically translating the +purchased amount into exposure time the same way for all persons, or it +can be a vector with different treatment intensities for each purchase. +In any case the cumulative dose is computed taking this into account. + + If \code{use.dpt} is \code{FALSE} then the exposure from one purchase + is assumed to stretch over the time to the next purchase, so we are + effectively assuming different rates of dose per time between any two + adjacent purchases. Moreover, with this approach, periods of + non-exposure does not exist. + +The intention of this function is to generate covariates for a +particular drug for the entire follow-up of each person. The reason that +the follow-up prior to drug purchase and post-exposure is included is +that the covariates must be defined for these periods too, in order to +be useful for analysis of disease outcomes. +} + +\value{A data frame with one record per follow-up interval between + \code{breaks}, with columns: +\describe{ + \item{\code{id}}{person id.} + \item{\code{dof}}{date of follow up, i.e. start of interval. Apart + from possibly the first interval for each person, this will assume values in the set of + the values in \code{breaks}.} + \item{\code{Y}}{the length of interval.} + \item{\code{tfi}}{time from first initiation of drug.} + \item{\code{tfc}}{time from latest cessation of drug.} + \item{\code{cdur}}{cumulative time on the drug.} + \item{\code{cdos}}{cumulative dose.} + \item{\code{ldos}}{suffixed with one value per element in + \code{lags}, the latter giving the cumulative doses \code{lags} before + \code{dof}.} +} +} +\author{Bendix Carstensen, \email{bxc@steno.dk}} +\seealso{\code{\link{Lexis}}, \code{\link{splitLexis}}} +\examples{ +# Construct a simple data frame of purchases for 3 persons +# The purchase units (in variable dose) correspond to +n <- c( 10, 17, 8 ) +dop <- c( 1995.2+cumsum(sample(1:4/10,n[1],replace=TRUE)), + 1997.3+cumsum(sample(1:4/10,n[2],replace=TRUE)), + 1997.3+cumsum(sample(1:4/10,n[3],replace=TRUE)) ) +amt <- sample( 1:3/15, sum(n), replace=TRUE ) +dpt <- sample( 15:20/25, sum(n), replace=TRUE ) +dfr <- data.frame( id = rep(1:3,n), + dop, + amt = amt, + dpt = dpt ) +round( dfr, 3 ) +# Construct a simple dataframe for follow-up periods for these 3 persons +fu <- data.frame( id = 1:3, + doe = c(1995,1997,1996)+1:3/4, + dox = c(2001,2003,2002)+1:3/5 ) +round( fu, 3 ) +dpos <- gen.exp( dfr, + fu = fu, + breaks = seq(1990,2015,0.5), + lags = 2:3/5 ) +xpos <- gen.exp( dfr, + fu = fu, + use.dpt = FALSE, + breaks = seq(1990,2015,0.5), + lags = 2:3/5 ) +cbind( xpos, dpos ) + +# How many relevant columns +nvar <- ncol(xpos)-3 +clrs <- rainbow(nvar) + +# Show how the variables relate to the follow-up time +par( mfrow=c(3,1), mar=c(3,3,1,1), mgp=c(3,1,0)/1.6, bty="n" ) +for( i in unique(xpos$id) ) +matplot( xpos[xpos$id==i,"dof"], + xpos[xpos$id==i,-(1:3)], + xlim=range(xpos$dof), ylim=range(xpos[,-(1:3)]), + type="l", lwd=2, lty=1, col=clrs, + ylab="", xlab="Date of follow-up" ) +ytxt <- par("usr")[3:4] +ytxt <- ytxt[1] + (nvar:1)*diff(ytxt)/(nvar+2) +xtxt <- rep( sum(par("usr")[1:2]*c(0.98,0.02)), nvar ) +text( xtxt, ytxt, colnames(xpos)[-(1:3)], font=2, + col=clrs, cex=1.5, adj=0 ) +} +\keyword{data manipulation} diff -Nru r-cran-epi-1.1.24/man/stack.Lexis.Rd r-cran-epi-1.1.33/man/stack.Lexis.Rd --- r-cran-epi-1.1.24/man/stack.Lexis.Rd 2011-07-22 20:34:07.000000000 +0000 +++ r-cran-epi-1.1.33/man/stack.Lexis.Rd 2011-09-18 11:53:38.000000000 +0000 @@ -13,17 +13,20 @@ \usage{ \method{stack}{Lexis}(x, ...) tmat( x, ... ) -\method{tmat}{Lexis}(x, ...) +\method{tmat}{Lexis}(x, Y=FALSE, ...) } \arguments{ - \item{x}{A \code{\link{Lexis}} object. -} + \item{x}{A \code{\link{Lexis}} object.} + \item{Y}{Logical. Should the risk time be put in the diagonal? This is + a facility which is used by \code{\link{boxes.Lexis}}.} \item{\dots}{Not used.} } \value{ \code{tmat.Lexis} returns a square transition matrix, classified by the -levels of \code{lex.Cst} and \code{lex.Xst}, it has a 1 for every -transition occurring and \code{NA} in all oter entries. +levels of \code{lex.Cst} and \code{lex.Xst}, for every transition +occurring the entry is the number of transitions occurring and \code{NA} +in all oter entries. If \code{Y=TRUE}, the diagonal will contain the +risk time in each of the states. \code{stack.Lexis} returns a dataframe to be used for analysis of multistate data when all transitions are modelled together, for example diff -Nru r-cran-epi-1.1.24/man/start.Lexis.Rd r-cran-epi-1.1.33/man/start.Lexis.Rd --- r-cran-epi-1.1.24/man/start.Lexis.Rd 2011-07-22 20:34:07.000000000 +0000 +++ r-cran-epi-1.1.33/man/start.Lexis.Rd 2012-01-03 14:52:23.000000000 +0000 @@ -9,22 +9,26 @@ \code{Lexis} object. } \usage{ -entry(x, time.scale = NULL) -exit(x, time.scale = NULL) -status(x, at="exit") -dur(x) + entry(x, time.scale = NULL, by.id=FALSE) + exit(x, time.scale = NULL, by.id=FALSE) +status(x, at="exit" , by.id=FALSE) + dur(x, by.id=FALSE) } \arguments{ \item{x}{an object of class \code{Lexis}.} \item{time.scale}{a string or integer indicating the time scale. If omitted, all times scales are used.} + \item{by.id}{Logical, if \code{TRUE}, only one record per unique value + of \code{lex.id} is returned; either the first, the last or for + \code{dur}, the sum of \code{lex.dur}. If \code{TRUE}, the returned + object have the \code{lex.id} as (row)nmes attribute.} \item{at}{string indicating the time point(s) at which status is to be measured.} } \value{ - The \code{entry} and \code{exit} functions return a vector of + The \code{entry} and \code{exit} functions return a vector of entry times and exit times, respectively, on the requested time - scale. If multiple time scales are requested, then a matrix is + scale. If multiple time scales are requested, then a matrix is returned. The \code{status} function returns a vector giving the status diff -Nru r-cran-epi-1.1.24/man/stattable.Rd r-cran-epi-1.1.33/man/stattable.Rd --- r-cran-epi-1.1.24/man/stattable.Rd 2011-07-22 20:34:07.000000000 +0000 +++ r-cran-epi-1.1.33/man/stattable.Rd 2011-08-05 12:36:57.000000000 +0000 @@ -47,8 +47,8 @@ \code{contents} argument are: \code{\link{count}}, \code{\link{mean}}, \code{\link{weighted.mean}}, \code{\link{sum}}, \code{\link{quantile}}, \code{\link{median}}, \code{\link{IQR}}, - \code{\link{max}}, \code{\link{min}}, \code{\link{ratio}}, and - \code{\link{percent}}. + \code{\link{max}}, \code{\link{min}}, \code{\link{ratio}}, + \code{\link{percent}}, and \code{\link{sd}}. The \code{count()} function, which is the default, simply creates a contingency table of counts. The other functions are applied to @@ -74,7 +74,7 @@ \code{\link{sum}}, \code{\link{quantile}}, \code{\link{median}}, \code{\link{IQR}}, \code{\link{max}}, \code{\link{min}}, \code{\link{ratio}}, -\code{\link{percent}}, \code{\link{count}}} +\code{\link{percent}}, \code{\link{count}}, \code{\link{sd}}.} \examples{ data(warpbreaks) # A one-way table diff -Nru r-cran-epi-1.1.24/man/time.scales.Rd r-cran-epi-1.1.33/man/time.scales.Rd --- r-cran-epi-1.1.24/man/time.scales.Rd 2011-07-22 20:34:07.000000000 +0000 +++ r-cran-epi-1.1.33/man/time.scales.Rd 2012-01-11 12:59:29.000000000 +0000 @@ -8,11 +8,12 @@ timeScales(x) } \arguments{ - \item{x}{an object of class \code{Lexis}} + \item{x}{an object of class \code{Lexis}.} } \value{ A character vector containing the names of the variables in \code{x} - that represent the time scales + that represent the time scales. Extracted from the \code{time.scales} + attribute of the object. } \author{Martyn Plummer} \seealso{\code{\link{Lexis}}, \code{\link{splitLexis}}} diff -Nru r-cran-epi-1.1.24/man/transform.Lexis.Rd r-cran-epi-1.1.33/man/transform.Lexis.Rd --- r-cran-epi-1.1.24/man/transform.Lexis.Rd 2011-07-22 20:34:07.000000000 +0000 +++ r-cran-epi-1.1.33/man/transform.Lexis.Rd 2011-12-08 17:37:55.000000000 +0000 @@ -4,30 +4,57 @@ \alias{factorize.Lexis} \title{Transform a Lexis objects} \description{ - Transform a Lexis object + Modify a Lexis object. } \usage{ %transform(`_data`, \dots) -\method{transform}{Lexis}(`_data`, \dots) -\method{factorize}{Lexis}(obj, \dots) +\method{transform}{Lexis}( `_data`, \dots) +\method{factorize}{Lexis}( obj, states, print = TRUE, \dots ) } \arguments{ \item{_data}{an object of class \code{Lexis}.} \item{obj}{an object of class \code{Lexis}.} - \item{\dots}{additional arguments to be passed to \code{transform.data.frame}.} + \item{states}{Names of the factor levels (states) for \code{lex.Cst} + and \code{lex.Xst}. Can be a list, in which case some levels are + collapsed, see the documentation for \code{\link{Relevel}}. No + sanity check for the latter operation is undertaken.} + \item{print}{Should a conversion between old and new levels be printed?} + \item{\dots}{Additional arguments to be passed to + \code{\link{transform.data.frame}} or \code{\link{Relevel}}.} } \details{ The transform method for \code{Lexis} objects works exactly as the - method for data frames. - - \code{factorize} simply transforms the variables \code{lex.Cst} and - \code{lex.Xst} to factors with the same set of levels. -} + method for data frames. \code{factorize} transforms the variables + \code{lex.Cst} and \code{lex.Xst} to factors with identical set of + levels, optionally with names given in \code{states}, and optionally + collapsing states. The default is to produce a table of old states + versus new states if \code{states} is a list. + } \value{ A transformed \code{Lexis} object. -} + } \author{Martyn Plummer, Bendix Carstensen} \seealso{\code{\link{Lexis}}, \code{\link{merge.Lexis}}, \code{\link{subset.Lexis}}} +\examples{ +data( nickel ) +nic <- Lexis( data = nickel, + id = id, + entry = list(age=agein), + exit = list(age=ageout,cal=ageout+dob,tfh=ageout-age1st), + ## Lung cancer deaths are coded 2 and other deaths are coded 1 + exit.status = ( (icd > 0) + (icd \%in\% c(162,163)) ) ) +str( nic ) +nit <- transform( nic, cumex = exposure*(agein-age1st) ) +str( nit ) +## It is still a Lexis object! +summary( nic ) +nix <- factorize.Lexis( nic, c("Alive","Lung","Dead")) +niw <- factorize.Lexis( nix, c("Alive","Pulm","Mort")) +niz <- factorize.Lexis( nic, states=list("Alive",c("Pulm","Mort")), coll=" \n& ") +boxes( niw, boxpos=TRUE ) +par( new=TRUE ) +boxes( niz, boxpos=TRUE ) +} \keyword{manip}