diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 0f2fe08..562fe0f 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -4,9 +4,8 @@ on: push: branches: [main, master] pull_request: - branches: [main, master] -name: R-CMD-check +name: R-CMD-check.yaml permissions: read-all diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml new file mode 100644 index 0000000..bfc9f4d --- /dev/null +++ b/.github/workflows/pkgdown.yaml @@ -0,0 +1,49 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + release: + types: [published] + workflow_dispatch: + +name: pkgdown.yaml + +permissions: read-all + +jobs: + pkgdown: + runs-on: ubuntu-latest + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::pkgdown, local::. + needs: website + + - name: Build site + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) + shell: Rscript {0} + + - name: Deploy to GitHub pages 🚀 + if: github.event_name != 'pull_request' + uses: JamesIves/github-pages-deploy-action@v4.5.0 + with: + clean: false + branch: gh-pages + folder: docs diff --git a/.gitignore b/.gitignore index 2b9c057..1f1169f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ +*~ *.Rproj .Rproj.user .RData .Rhistory src/*.o src/*.so -inst/stuff \ No newline at end of file +inst/stuff +docs \ No newline at end of file diff --git a/DESCRIPTION b/DESCRIPTION index 14131ae..1cfec14 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -42,4 +42,4 @@ Copyright: inst/COPYRIGHTS Encoding: UTF-8 License: LGPL (>= 2) Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.3 diff --git a/NEWS.md b/NEWS.md index 3ec5a5c..978b5ab 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,15 @@ +# distcomp 1.3-4 + +- CRAN fixes (use of non-API `NAMED`) + +# distcomp 1.3-3 + +- CRAN fixes + +# distcomp 1.3-2 + +- CRAN fixes + # distcomp 1.3-1 - Add `rmarkdown` to suggests diff --git a/R/distcomp.R b/R/distcomp-package.R similarity index 99% rename from R/distcomp.R rename to R/distcomp-package.R index 265b7ba..e4908aa 100644 --- a/R/distcomp.R +++ b/R/distcomp-package.R @@ -41,14 +41,14 @@ #' examples and the reference. #' @seealso The examples in `system.file("doc", "examples.html", package="distcomp")` #' @seealso The source for the examples: `system.file("doc_src", "examples.Rmd", package="distcomp")`. -#' @docType package #' @references Software for Distributed Computation on Medical Databases: #' A Demonstration Project. Journal of Statistical Software, 77(13), 1-22. #' doi:10.18637/jss.v077.i13 #' @references Appendix E of Modeling Survival Data: Extending the Cox Model by #' Terry M. Therneau and Patricia Grambsch. Springer Verlag, 2000. -#' @name distcomp -NULL +#' @name distcomp-package +#' @aliases distcomp-package distcomp +"_PACKAGE" #' Make an appropriate opencpu URL for a specified function and url prefix for the #' distcomp package diff --git a/man/availableComputations.Rd b/man/availableComputations.Rd index 3fc88ba..9f193f3 100644 --- a/man/availableComputations.Rd +++ b/man/availableComputations.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{availableComputations} \alias{availableComputations} \title{Return the currently available (implemented) computations} diff --git a/man/availableDataSources.Rd b/man/availableDataSources.Rd index c6dd9cd..4c5f515 100644 --- a/man/availableDataSources.Rd +++ b/man/availableDataSources.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{availableDataSources} \alias{availableDataSources} \title{Return currently implemented data sources} diff --git a/man/createHEWorkerInstance.Rd b/man/createHEWorkerInstance.Rd index 8427662..b9f4909 100644 --- a/man/createHEWorkerInstance.Rd +++ b/man/createHEWorkerInstance.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{createHEWorkerInstance} \alias{createHEWorkerInstance} \title{Given the definition identifier of an object, instantiate and store diff --git a/man/createNCPInstance.Rd b/man/createNCPInstance.Rd index 19df7c0..85668e5 100644 --- a/man/createNCPInstance.Rd +++ b/man/createNCPInstance.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{createNCPInstance} \alias{createNCPInstance} \title{Given the definition identifier of an object, instantiate and store diff --git a/man/createWorkerInstance.Rd b/man/createWorkerInstance.Rd index fd953e5..162ecbb 100644 --- a/man/createWorkerInstance.Rd +++ b/man/createWorkerInstance.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{createWorkerInstance} \alias{createWorkerInstance} \title{Given the definition identifier of an object, instantiate and store object in workspace} diff --git a/man/defineNewComputation.Rd b/man/defineNewComputation.Rd index 8cffee8..2cc7665 100644 --- a/man/defineNewComputation.Rd +++ b/man/defineNewComputation.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{defineNewComputation} \alias{defineNewComputation} \title{Define a new computation} diff --git a/man/destroyInstanceObject.Rd b/man/destroyInstanceObject.Rd index dd24bd9..6cc0913 100644 --- a/man/destroyInstanceObject.Rd +++ b/man/destroyInstanceObject.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{destroyInstanceObject} \alias{destroyInstanceObject} \title{Destroy an instance object given its identifier} diff --git a/man/distcomp-internal.Rd b/man/distcomp-internal.Rd index f734228..1f630a2 100644 --- a/man/distcomp-internal.Rd +++ b/man/distcomp-internal.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{.makeOpencpuURL} \alias{.makeOpencpuURL} \alias{.defnOK} diff --git a/man/distcomp.Rd b/man/distcomp-package.Rd similarity index 88% rename from man/distcomp.Rd rename to man/distcomp-package.Rd index 6354953..81c0aa2 100644 --- a/man/distcomp.Rd +++ b/man/distcomp-package.Rd @@ -1,7 +1,8 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \docType{package} -\name{distcomp} +\name{distcomp-package} +\alias{distcomp-package} \alias{distcomp} \title{Distributed Computing with R} \description{ @@ -59,3 +60,19 @@ The examples in \code{system.file("doc", "examples.html", package="distcomp")} The source for the examples: \code{system.file("doc_src", "examples.Rmd", package="distcomp")}. } +\author{ +\strong{Maintainer}: Balasubramanian Narasimhan \email{naras@stat.Stanford.EDU} + +Authors: +\itemize{ + \item Marina Bendersky + \item Sam Gross +} + +Other contributors: +\itemize{ + \item Terry M. Therneau [contributor] + \item Thomas Lumley [contributor] +} + +} diff --git a/man/distcompSetup.Rd b/man/distcompSetup.Rd index f0f1a3a..298949e 100644 --- a/man/distcompSetup.Rd +++ b/man/distcompSetup.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{distcompSetup} \alias{distcompSetup} \title{Setup a workspace and configuration for a distributed computation} diff --git a/man/executeHEMethod.Rd b/man/executeHEMethod.Rd index 02ec24e..2a69c34 100644 --- a/man/executeHEMethod.Rd +++ b/man/executeHEMethod.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{executeHEMethod} \alias{executeHEMethod} \title{Given the id of a serialized object, invoke a method on the object diff --git a/man/executeMethod.Rd b/man/executeMethod.Rd index 6aef11b..edd3b1b 100644 --- a/man/executeMethod.Rd +++ b/man/executeMethod.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{executeMethod} \alias{executeMethod} \title{Given the id of a serialized object, invoke a method on the object diff --git a/man/generateId.Rd b/man/generateId.Rd index bdd9258..2e0328a 100644 --- a/man/generateId.Rd +++ b/man/generateId.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{generateId} \alias{generateId} \title{Generate an identifier for an object} diff --git a/man/getComputationInfo.Rd b/man/getComputationInfo.Rd index 06f5992..707196a 100644 --- a/man/getComputationInfo.Rd +++ b/man/getComputationInfo.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{getComputationInfo} \alias{getComputationInfo} \title{Get the value of a variable from the global store} diff --git a/man/getConfig.Rd b/man/getConfig.Rd index 6d6bb23..d4eb999 100644 --- a/man/getConfig.Rd +++ b/man/getConfig.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{getConfig} \alias{getConfig} \title{Return the workspace and configuration setup values} diff --git a/man/makeDefinition.Rd b/man/makeDefinition.Rd index 4e933e2..b143280 100644 --- a/man/makeDefinition.Rd +++ b/man/makeDefinition.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{makeDefinition} \alias{makeDefinition} \title{Make a computation definition given the computation type} diff --git a/man/makeHEMaster.Rd b/man/makeHEMaster.Rd index 8a40bf4..2a27cc7 100644 --- a/man/makeHEMaster.Rd +++ b/man/makeHEMaster.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{makeHEMaster} \alias{makeHEMaster} \title{Instantiate a master process for HE operations} diff --git a/man/makeMaster.Rd b/man/makeMaster.Rd index 631b9bf..a3cda47 100644 --- a/man/makeMaster.Rd +++ b/man/makeMaster.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{makeMaster} \alias{makeMaster} \title{Make a master object given a definition} diff --git a/man/makeNCP.Rd b/man/makeNCP.Rd index 2061f0e..7e183c4 100644 --- a/man/makeNCP.Rd +++ b/man/makeNCP.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{makeNCP} \alias{makeNCP} \title{Instantiate an noncooperating party} diff --git a/man/makeWorker.Rd b/man/makeWorker.Rd index a902c71..87c7fa5 100644 --- a/man/makeWorker.Rd +++ b/man/makeWorker.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{makeWorker} \alias{makeWorker} \title{Make a worker object given a definition and data} diff --git a/man/resetComputationInfo.Rd b/man/resetComputationInfo.Rd index 085843b..73e6237 100644 --- a/man/resetComputationInfo.Rd +++ b/man/resetComputationInfo.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{resetComputationInfo} \alias{resetComputationInfo} \title{Clear the contents of the global store} diff --git a/man/runDistcompApp.Rd b/man/runDistcompApp.Rd index f8ef82f..e0ee033 100644 --- a/man/runDistcompApp.Rd +++ b/man/runDistcompApp.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{runDistcompApp} \alias{runDistcompApp} \title{Run a specified distcomp web application} diff --git a/man/saveNewComputation.Rd b/man/saveNewComputation.Rd index 5f4b1f8..c619ff8 100644 --- a/man/saveNewComputation.Rd +++ b/man/saveNewComputation.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{saveNewComputation} \alias{saveNewComputation} \title{Save a computation instance, given the computation definition, associated data and diff --git a/man/saveNewNCP.Rd b/man/saveNewNCP.Rd index 12b85f3..f9dc697 100644 --- a/man/saveNewNCP.Rd +++ b/man/saveNewNCP.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{saveNewNCP} \alias{saveNewNCP} \title{Save an NCP instance, given the sites as associated data and diff --git a/man/setComputationInfo.Rd b/man/setComputationInfo.Rd index 3372d9c..f041d2a 100644 --- a/man/setComputationInfo.Rd +++ b/man/setComputationInfo.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{setComputationInfo} \alias{setComputationInfo} \title{Set a name to a value in a global variable} diff --git a/man/setupMaster.Rd b/man/setupMaster.Rd index 62258b8..c97f831 100644 --- a/man/setupMaster.Rd +++ b/man/setupMaster.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{setupMaster} \alias{setupMaster} \title{Setup a computation master} diff --git a/man/setupWorker.Rd b/man/setupWorker.Rd index e9b78ad..1db58b9 100644 --- a/man/setupWorker.Rd +++ b/man/setupWorker.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{setupWorker} \alias{setupWorker} \title{Setup a worker site} diff --git a/man/uploadNewComputation.Rd b/man/uploadNewComputation.Rd index 95c26c7..b97d0bf 100644 --- a/man/uploadNewComputation.Rd +++ b/man/uploadNewComputation.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{uploadNewComputation} \alias{uploadNewComputation} \title{Upload a new computation and data to an opencpu server} diff --git a/man/uploadNewNCP.Rd b/man/uploadNewNCP.Rd index 9a7ce52..7bf6f5c 100644 --- a/man/uploadNewNCP.Rd +++ b/man/uploadNewNCP.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{uploadNewNCP} \alias{uploadNewNCP} \title{Upload a new Non-Cooperating Party (NCP) information and sites to diff --git a/man/writeCode.Rd b/man/writeCode.Rd index e4d02d7..b18af49 100644 --- a/man/writeCode.Rd +++ b/man/writeCode.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distcomp.R +% Please edit documentation in R/distcomp-package.R \name{writeCode} \alias{writeCode} \title{Write the code necessary to run a master process} diff --git a/src/chinv2.c b/src/chinv2.c index 540d71c..898cc57 100644 --- a/src/chinv2.c +++ b/src/chinv2.c @@ -1,4 +1,4 @@ -/* $Id: chinv2.c 11357 2009-09-04 15:22:46Z therneau $ +/* ** ** matrix inversion, given the FDF' cholesky decomposition ** @@ -15,8 +15,8 @@ void chinv2(double **matrix , int n) { - register double temp; - register int i,j,k; + double temp; + int i,j,k; /* ** invert the cholesky in the lower triangle diff --git a/src/cholesky2.c b/src/cholesky2.c index 9b974dc..e451f95 100644 --- a/src/cholesky2.c +++ b/src/cholesky2.c @@ -1,4 +1,4 @@ -/* $Id: cholesky2.c 11357 2009-09-04 15:22:46Z therneau $ +/* ** ** subroutine to do Cholesky decompostion on a matrix: C = FDF' ** where F is lower triangular with 1's on the diagonal, and D is diagonal @@ -13,13 +13,14 @@ ** The lower triangle need not be filled in at the start. ** ** Return value: the rank of the matrix (non-negative definite), or -rank -** it not SPD or NND +** if it not SPD or NND ** ** If a column is deemed to be redundant, then that diagonal is set to zero. +** An nan or infinite diagonal is considered 0. ** ** Terry Therneau */ - +#include int cholesky2(double **matrix, int n, double toler) { double temp; @@ -34,12 +35,13 @@ int cholesky2(double **matrix, int n, double toler) if (matrix[i][i] > eps) eps = matrix[i][i]; for (j=(i+1); j= dtime; istart++) + /* remove those who start after this death */ + for (; j= dtime; j++) nrisk--; - for(j= i+1; j=dtime; istart++) { - atrisk[sort1[istart]]=0; - nrisk--; - } - for (j=1; j=dtime; j++) { + jptr = sort1[j]; /* who should be removed */ + k = atrisk[jptr]; /* is stored here in who[] */ + who[k] = who[--nrisk]; /* someone else takes their place */ + atrisk[who[k]] = k; /* update pointer for the usurper */ + } - atrisk[iptr] =1; - *rrstatus++ =1; - *rrindex++ = iptr +1; - for (j=i+1; j 0) temp = temp2/temp; /* scaling */ else temp=1.0; /* rare case of a constant covariate */ scale[i] = temp; - for (person=0; person=0; ) { - if (strata[person] == 1) { - nrisk =0 ; - denom = 0; - for (i=0; i=0 &&time[person]==dtime) { - /* walk through the this set of tied times */ - nrisk++; - zbeta = offset[person]; /* form the term beta*z (vector mult) */ - for (i=0; i0) { /* we need to add to the main terms */ - if (method==0) { /* Breslow */ - loglik[1] -= deadwt* log(denom); - - for (i=0; i=0; ) { - if (strata[person] == 1) { /* rezero temps for each strata */ - denom = 0; - nrisk =0; - for (i=0; i=0 && time[person]==dtime) { - nrisk++; - zbeta = offset[person]; - for (i=0; i0) { /* add up terms*/ - if (method==0) { /* Breslow */ - newlk -= deadwt* log(denom); - for (i=0; i0 || newlk < loglik[1]) { + /*it is not converging ! */ + halving++; /* get more agressive when it doesn't work */ + for (i=0; i maxbeta[i]) newbeta[i] = maxbeta[i]; - else if (newbeta[i] < -maxbeta[i]) newbeta[i] = -maxbeta[i]; - } - } - } /* return for another iteration */ + } + } + } /* return for another iteration */ /* - ** We end up here only if we ran out of iterations + ** We end up here only if we ran out of iterations + ** recompute the last good version of imat and u, + ** If maxiter =0 or 1, though, leave well enough alone. */ - loglik[1] = newlk; - /* Naras add */ - for (i = 0; i < nvar; i++) { - for (j = 0; j < nvar; j++) { - imatCopy[i][j] = imat[i][j]; - } - } - /* Naras add end */ - + if (maxiter > 1) + loglik[1] = coxfit6_iter(nvar, nused, method, beta); chinv2(imat, nvar); for (i=0; i=0; ) { + if (strata[person] == 1) { + nrisk =0 ; + denom = 0; + for (i=0; i=0 && xtime[person]==dtime) { + /* walk through the this set of tied times */ + nrisk++; + zbeta = offset[person]; /* form the term beta*z (vector mult) */ + for (i=0; i=0 && strata[person]==1) break; /*ties don't cross strata */ + } + + if (ndead >0) { /* we need to add to the main terms */ + if (method==0 || ndead==1) { /* Breslow */ + denom += denom2; + loglik -= deadwt* log(denom); + + for (i=0; i 2^31, although the numer of columns and rows must be <2^31. +** On a 64 bit machine the array variable is of type *double +** which is a 64 bit integer; using "array += nrow" rather than +** "pointer[i] = array + i*nrow" is critical to avoiding an integer +** overflow. */ #include "survS.h" #include "survproto.h" -double **dmatrix(double *array, int ncol, int nrow) +double **dmatrix(double *array, int nrow, int ncol) { - int i; double **pointer; - pointer = (double **) ALLOC(nrow, sizeof(double *)); - for (i=0; i -#ifdef USING_R - -#define S_EVALUATOR /* Turn this into a "blank line" in R */ -#else -/* -** Splus definitions, to use R type calls -*/ - -/* -** At this point in time (Splus 8.0.1) I need to add a little -** to the Insightful definitions. (They are in the process -** of improving Rinternals, so this may well go away.) The -** two functions below are defined as "not supported". I need -** only certain cases of defineVar and eval, so can safely map them. -** I am using the 8.1 R*.h files courtesy of Bill Dunlap -*/ -#ifdef defineVar -#undef defineVar -#endif -#define defineVar(a,b,c) ASSIGN_IN_FRAME(a,b, INTEGER_VALUE(c)) - -#ifdef eval -#undef eval -#endif -#define eval(a, b) EVAL_IN_FRAME(a, INTEGER_VALUE(b)) - -/* -** These two refer to undefined functions, so use the 8.0.1 defs -*/ -#ifdef asInteger -#undef asInteger -#endif -#define asInteger(a) INTEGER_VALUE(a) -#ifdef asReal -#undef asReal -#endif -#define asReal(a) NUMERIC_VALUE(a) - -#endif /* ** Memory defined with ALLOC is removed automatically by S. ** That with "Calloc" I have to remove myself. Use the ** latter for objects that need to to persist between calls. */ -#ifdef USING_R #define ALLOC(a,b) R_alloc(a,b) -#else -#define ALLOC(a,b) S_alloc(a,b) -#endif - -/* -** Prototype for callback function -** -*/ -#ifdef USING_R -void cox_callback(int which, double *coef, double *first, double *second, - double *penalty, int *flag, int p, SEXP fexpr, SEXP rho); -#endif +#define CALLOC(a,b) R_Calloc(a,b) +#define FREE(a) R_Free(a) diff --git a/src/survproto.h b/src/survproto.h index d368b68..d8e805c 100644 --- a/src/survproto.h +++ b/src/survproto.h @@ -2,79 +2,94 @@ ** Prototypes of all the survival functions ** Including this in each routine helps prevent mismatched argument errors */ -SEXP agfit4(SEXP surv2, SEXP covar2, SEXP strata2, + +SEXP agfit4(SEXP n2, + SEXP surv2, SEXP covar2, SEXP strata2, SEXP weights2, SEXP offset2, SEXP ibeta2, SEXP sort12, SEXP sort22, SEXP method2, - SEXP maxiter2, SEXP eps2, SEXP tolerance2); + SEXP maxiter2, SEXP eps2, SEXP tolerance2, + SEXP doscale2); -void agfit5a(int *nusedx, int *nvarx, double *yy, - double *covar2, double *offset2, double *weights2, - int *strata, int *sort, double *means, - double *beta, double *u, double *loglik, - int *methodx, int *ptype2, int *pdiag2, - int *nfrail, int *frail2, - void *fexpr1, void *fexpr2, void *rho) ; +void agfit5a(int *nusedx, int *nvarx, double *yy, + double *covar2, double *offset2, double *weights2, + int *strata, int *sort, double *means, + double *beta, double *u, double *loglik, + int *methodx, int *ptype2, int *pdiag2, + int *nfrail, int *frail2, + void *fexpr1, void *fexpr2, void *rho, + int *docenter) ; -void agfit5b( int *maxiter, int *nusedx, int *nvarx, - int *strata, double *beta, double *u, +void agfit5b( int *maxiter, int *nusedx, int *nvarx, + int *strata, double *beta, double *u, double *imat2, double *jmat2, double *loglik, - int *flag, double *eps, double *tolerch, - int *methodx, int *nfrail, double *fbeta, + int *flag, double *eps, double *tolerch, + int *methodx, int *nfrail, double *fbeta, double *fdiag, void *fexpr1, void *fexpr2, void *rho); -void agfit5c(int *nusedx, int *nvar, int *strata, - int *methodx, double *expect) ; - -void agexact(int *maxiter, int *nusedx, int *nvarx, double *start, - double *stop, int *event, double *covar2,double *offset, - int *strata, double *means, double *beta, double *u, - double *imat2, double loglik[2], int *flag, double *work, - int *work2, double *eps, double *tol_chol, double *sctest); - -void agmart(int *n, int *method, double *start, double *stop, - int *event, double *score, double *wt, int *strata, +void agfit5c( int *nvar); + +SEXP agmart3(SEXP nused2, SEXP surv2, SEXP score2, SEXP weight2, + SEXP strata2, SEXP sort12, SEXP sort22, SEXP method2); + +void agexact(int *maxiter, int *nusedx, int *nvarx, double *start, + double *stop, int *event, double *covar2,double *offset, + int *strata, double *means, double *beta, double *u, + double *imat2, double loglik[2], int *flag, double *work, + int *work2, double *eps, double *tol_chol, double *sctest, + int *nocenter); + +void agmart(int *n, int *method, double *start, double *stop, + int *event, double *score, double *wt, int *strata, double *resid); -void agmart2(int *n, int *method, double *start, double *stop, - int *event, int *nstrat, int *strata, int *sort1, - int *sort2, double *score, double *wt, - double *resid, double *haz); -void agscore(int *nx, int *nvarx, double *y, - double *covar2, int *strata, double *score, - double *weights, int *method, double *resid2, double *a); - -void agsurv3(int *sn, int *snvar, int *sncurve, - int *snpt, int *sse, double *score, - double *sy, int *grpx, double *r, double *coef, - double *var, double *xmean, int *scn, - double *cy, double *cx, double *ssurv, - double *varh, double *sused, int *smethod); - -void agsurv4(int *ndeath, double *risk, double *wt, - int *sn, double *denom, double *km); - -void agsurv5(int *n2, int *nvar2, int *dd, double *x1, +SEXP agscore2(SEXP y2, SEXP covar2, SEXP strata2, + SEXP score2, SEXP weights2, SEXP method2); +SEXP agscore3(SEXP y2, SEXP covar2, SEXP strata2, + SEXP score2, SEXP weights2, SEXP method2, SEXP sort12); + +void agsurv4(int *ndeath, double *risk, double *wt, + int *sn, double *denom, double *km); + +void agsurv5(int *n2, int *nvar2, int *dd, double *x1, double *x2, double *xsum, double *xsum2, double *sum1, double *sum2, double *xbar) ; +SEXP cdecomp(SEXP R2, SEXP time2); void chinv2 (double **matrix, int n); int cholesky2(double **matrix, int n, double toler); void chsolve2(double **matrix, int n, double *y); void chinv3(double **matrix , int n, int m, double *fdiag); +void chinv5(double **matrix , int n, int flag); int cholesky3(double **matrix, int n, int m, double *diag, double toler); +int cholesky5(double **matrix, int n, double toler); void chsolve3(double **matrix, int n, int m, double *diag, double *y); +void chsolve5(double **matrix, int n, double *y, int flag); +SEXP collapse(SEXP y2, SEXP x2, SEXP istate2, SEXP id2, SEXP wt2, + SEXP order2) ; SEXP concordance1(SEXP y, SEXP wt2, SEXP indx2, SEXP ntree2); SEXP concordance2(SEXP y, SEXP wt2, SEXP indx2, SEXP ntree2, SEXP sortstop, SEXP sortstart) ; +SEXP concordance3(SEXP y, SEXP x2, SEXP wt2, SEXP timewt2, + SEXP sortstop, SEXP doresid2); +SEXP concordance4(SEXP y, SEXP x2, SEXP wt2, SEXP timewt2, + SEXP sortstart, SEXP sortstop, SEXP doresid2); +SEXP concordance5(SEXP y, SEXP x2, SEXP wt2, SEXP timewt2, + SEXP sortstop); +SEXP concordance6(SEXP y, SEXP x2, SEXP wt2, SEXP timewt2, + SEXP sortstart, SEXP sortstop); + +void cox_callback(int which, double *coef, double *first, double *second, + double *penalty, int *flag, int p, SEXP fexpr, SEXP rho); SEXP coxcount1(SEXP y2, SEXP strat2) ; SEXP coxcount2(SEXP y2, SEXP isort1, SEXP isort2, SEXP strat2) ; -void coxdetail(int *nusedx, int *nvarx, int *ndeadx, +void coxdetail(int *nusedx, int *nvarx, int *ndeadx, + double *center, double *y, double *covar2, int *strata, double *score, double *weights, double *means2, double *u2, double *var, int *rmat, @@ -84,21 +99,22 @@ SEXP coxexact(SEXP maxiter2, SEXP y2, SEXP covar2, SEXP offset2, SEXP strata2, SEXP ibeta, SEXP eps2, SEXP toler2) ; -void coxfit5_a(int *nusedx, int *nvarx, double *yy, - double *covar2, double *offset2, double *weights2, - int *strata, int *sort, double *means, - double *beta, double *u, double *loglik, - int *methodx, int *ptype2, int *pdiag2, +void coxfit5_a(int *nusedx, int *nvarx, double *yy, + double *covar2, double *offset2, double *weights2, + int *strata, int *sort, double *means, + double *beta, double *u, double *loglik, + int *methodx, int *ptype2, int *pdiag2, int *nfrail, int *frail2, - void *fexpr1, void *fexpr2, void *rho) ; + void *fexpr1, void *fexpr2, void *rho, + int *docenter) ; -void coxfit5_b( int *maxiter, int *nusedx, int *nvarx, +void coxfit5_b( int *maxiter, int *nusedx, int *nvarx, int *strata, double *beta, double *u, - double *imat2, double *jmat2, double *loglik, + double *imat2, double *jmat2, double *loglik, int *flag, double *eps, double *tolerch, int *methodx, int *nfrail, double *fbeta, double *fdiag, - void *fexpr1, void *fexpr2, void *rho); + void *fexpr1, void *fexpr2, void *rho); void coxfit5_c(int *nusedx, int *nvar, int *strata, int *methodx, double *expect) ; @@ -110,7 +126,7 @@ SEXP coxfit6(SEXP maxiter2, SEXP time2, SEXP status2, void coxmart(int *sn, int *method, double *time, int *status, int * strata, double *score, - double *wt, double *expect); + double *wt, double *expect); void coxmart2(int *sn, double *time, int *status, int * strata, double *score, @@ -123,17 +139,46 @@ void coxscho(int *nusedx, int *nvarx, double *y, double *covar2, double *score, int *strata, int *method2, double *work); -void coxscore(int *nx, int *nvarx, double *y, - double *covar2, int *strata, double *score, - double *weights, int *method, double *resid2, - double *scratch); +SEXP coxscore2(SEXP y2, SEXP covar2, SEXP strata2, + SEXP score2, SEXP weights2, SEXP method2); double coxsafe(double x); -double **dmatrix(double *array, int ncol, int nrow); + +SEXP coxsurv1(SEXP otime, SEXP y2, SEXP weight2, SEXP sort22, + SEXP strata2, SEXP xmat2, SEXP risk2); + +SEXP coxsurv2(SEXP otime2, SEXP y2, SEXP weight2, SEXP sort12, SEXP sort22, + SEXP position2, SEXP strata2, SEXP xmat2, SEXP risk2); + +SEXP coxsurv3(SEXP y2, SEXP xmat2, SEXP strata2, + SEXP risk2, SEXP weight2, SEXP sort22, + SEXP efron2); + +SEXP coxsurv4(SEXP y2, SEXP weight2, SEXP sort12, SEXP sort22, + SEXP position2, SEXP strata2, SEXP xmat2, SEXP risk2); + +double **dmatrix(double *array, int nrow, int ncol); +int **imatrix(int *array, int nrow, int ncol); + +SEXP fastkm1(SEXP y2, SEXP wt2, SEXP sort2); +SEXP fastkm2(SEXP y2, SEXP wt2, SEXP sort12, SEXP sort22); + +SEXP finegray(SEXP tstart2, SEXP tstop2, SEXP ctime2, SEXP cprob2, + SEXP extend2, SEXP keep2); + +SEXP gchol(SEXP matrix2, SEXP toler2); +SEXP gchol_solve(SEXP x2, SEXP y2, SEXP flag2); +SEXP gchol_inv(SEXP matrix, SEXP flag2); void init_doloop(int min, int max); int doloop (int nloops, int *index); +SEXP multicheck(SEXP time12, SEXP time22, SEXP status2, SEXP id2, + SEXP istate2, SEXP sort2); + +int *norisk(int n, double *time1, double *time2, double *status, + int *sort1, int *sort2, int *strata); + void pyears1(int *sn, int *sny, int *sdoevent, double *sy, double *wt, int *sedim, int *efac, @@ -159,6 +204,14 @@ double pystep(int nc, int *index, int *index2, double *wt, double *data, int *fac, int *dims, double **cuts, double step, int edge); +SEXP residcsum(SEXP y2, SEXP strata2); + +typedef struct snode { + int value; + int depth; /* number of forward links */ + struct snode *forward[1]; /* the set of forward links*/ +} snode; + void survdiff2(int *nn, int *nngroup, int *nstrat, double *rho, double *time, int *status, int *group, int *strata, double *obs, @@ -167,10 +220,19 @@ void survdiff2(int *nn, int *nngroup, int *nstrat, void survfit4(int *n, int *dd, double *x1, double *x2) ; - SEXP survfitci(SEXP ftime2, SEXP sort12, SEXP sort22, SEXP ntime2, - SEXP status2, SEXP cstate2, SEXP wt2, SEXP id2, - SEXP p2, SEXP sefit2) ; - +SEXP survfitaj(SEXP y2, SEXP sort12, SEXP sort22, SEXP utime2, + SEXP cstate2, SEXP wt2, SEXP grp2, SEXP ngrp2, + SEXP p02, SEXP i02, SEXP sefit2, SEXP entry2, + SEXP position2,SEXP hindx2, SEXP trmat2, SEXP t0); + +SEXP survfitkm(SEXP y2, SEXP weight2, SEXP sort12, SEXP sort22, + SEXP type2, SEXP id2, SEXP nid2, SEXP position2, + SEXP influence2, SEXP reverse2, SEXP entry2) ; + +SEXP survfitresid(SEXP Y2, SEXP sort12, SEXP sort22, SEXP cstate2, + SEXP wt2, SEXP p02, SEXP i02, SEXP otime2, + SEXP lefttime2, SEXP doauc2); + SEXP survreg6(SEXP maxiter2, SEXP nvarx, SEXP y, SEXP ny2, SEXP covar2, SEXP wtx, SEXP offset2, SEXP beta2, SEXP nstratx, @@ -205,3 +267,20 @@ void survpenal(int whichcase, int nfrail, int nvar2, double **hmat, int ptype, int pdiag, SEXP pexpr1, double *cptr1, SEXP pexpr2, double *cptr2, SEXP rho); +SEXP survsplit(SEXP tstart2, SEXP tstop2, SEXP cut2); + +SEXP tmerge (SEXP id2, SEXP time1x, SEXP newx2, + SEXP nid2, SEXP ntime2, SEXP x2, SEXP indx2); +SEXP tmerge2(SEXP id2, SEXP time1x, SEXP nid2, SEXP ntime2); +SEXP tmerge3(SEXP id2, SEXP miss2); +SEXP twoclust(SEXP id2, SEXP cluster2, SEXP idord2); +void walkup(double *nwt, double* twt, int index, double sums[3], int ntree); +void addin(double *nwt, double *twt, int index, double wt); + +SEXP zph1(SEXP gt2, SEXP y2, + SEXP covar2, SEXP eta2, SEXP weights2, + SEXP strata2,SEXP method2, SEXP sort2); + +SEXP zph2(SEXP gt2, SEXP y2, + SEXP covar2, SEXP eta2, SEXP weights2, + SEXP strata2,SEXP method2, SEXP sort12, SEXP sort22);