Skip to content

Commit

Permalink
version 1.13
Browse files Browse the repository at this point in the history
  • Loading branch information
statapps authored and cran-robot committed Dec 20, 2017
1 parent 3c72e7d commit a161b23
Show file tree
Hide file tree
Showing 15 changed files with 764 additions and 161 deletions.
10 changes: 5 additions & 5 deletions DESCRIPTION
@@ -1,16 +1,16 @@
Package: bhm
Type: Package
Title: Biomarker Threshold Models
Version: 1.11
Date: 2017-05-06
Version: 1.13
Date: 2017-12-19
Author: Bingshu E. Chen
Maintainer: Bingshu E. Chen <bingshu.chen@queensu.ca>
Depends: R (>= 2.10.0), coda, survival
Imports: methods
Description: Biomarker threshold models are tools to fit both predictive and prognostic biomarker effects.
Description: Contains tools to fit both predictive and prognostic biomarker effects using biomarker threshold models. Evaluate the treatment effect, biomarker effect and treatment-biomarker interaction using probability index measurement. Test for treatment-biomarker interaction using residual bootstrap method.
License: GPL (>= 2)
LazyLoad: yes
NeedsCompilation: no
Packaged: 2017-05-08 19:04:01 UTC; chenbe
Packaged: 2017-12-20 21:02:13 UTC; b3chen
Repository: CRAN
Date/Publication: 2017-05-11 16:28:14 UTC
Date/Publication: 2017-12-20 21:15:00 UTC
25 changes: 14 additions & 11 deletions MD5
@@ -1,16 +1,19 @@
0b2e4f31671ff8402302ba9b6b7c9023 *DESCRIPTION
1337f751fbbb0a94bc713cca64fcbd6d *NAMESPACE
3e3445f8e4c2ec919ce391a4c1b1fe9c *DESCRIPTION
164e567e1c3f543c2d33e97a64cdefe6 *NAMESPACE
d3046ce94c557ca4e021de5f990948eb *R/bhm.R
154c78c7a4b19a4cdc4828ada6157070 *R/bhm_fit.R
bbbabbd6283f8a861619e707e2cb8b55 *R/bhm_lib.R
cbeff78ff76e1408f164a15b4f71d227 *R/pIndex.R
a4263b1e6b22eb511ffd60fe1222f4e5 *R/prolik.R
1a4c222d1ad7a728f6c8573626d7589b *R/bhm_lib.R
74fbe0cc51e80e494aca48a8a4df6fb7 *R/pIndex.R
38d9937f78588fbafa667ae135d77056 *R/prolik.R
55a7ff1833b9b38e910263d9f76d0cf4 *R/resboot.R
c84d68567329ac77192b098af2c2c943 *data/data.rda
d273eb7c975522763535e8e7fb5149ae *inst/CITATION
20eb14d3a5885ea9c06354996423ea84 *man/bhm-package.Rd
e0cbdda870e449b4b095863ffc540faa *man/bhm.Rd
bed635491c04690a15ee10610dd15156 *man/control.Rd
cb263f3b36c659c86ecb6ef66211baf2 *man/bhm-package.Rd
09f155377871452c53345fddd4db1324 *man/bhm.Rd
1b8ecaf4c48c2f22d0a3a062fe83eb8c *man/control.Rd
b0cc661060af77834ef1c1a0ba09d0ba *man/data.Rd
bdde2f311ebfac278ad5fb79561ea0a9 *man/pIndex.Rd
29de3cf98f378f2d94aa59254eac93e7 *man/pIndexControl.Rd
5ee5937f65d07e4435547acb3f9fba1a *man/print.Rd
7c0a1804e8a4e4e204228c8864a71632 *man/pIndex.Rd
9c0eb1cc58a57d2f6c5c16ae514e6264 *man/pIndexControl.Rd
7e2f3a4866d28dd129755e2ec82ccc6f *man/plot.Rd
7596c5caf1eb3a609464f11b09b4ed04 *man/print.Rd
386efc1029c1ea6de3bbd4d0fe8f9f2f *man/resboot.Rd
23 changes: 18 additions & 5 deletions NAMESPACE
Expand Up @@ -3,17 +3,30 @@ exportPattern("^[^\\.]")

import(coda)
import(survival)
importFrom("graphics", "abline", "hist", "lines", "plot")
importFrom("methods", "is")
importFrom("stats", "cov", "dbeta", "glm", "logLik", "model.frame",
"model.matrix", "model.response", "nlm", "printCoefmat",
"quantile", "rbinom", "rexp", "rgamma", "rnorm", "runif", "vcov")
importFrom("stats", "aggregate", "cov", "dbeta", "dnorm", "glm", "logLik",
"model.frame",
"model.matrix", "model.response", "nlm", "optim", "printCoefmat",
"quantile", "qnorm", "rbinom", "rexp", "rgamma", "rnorm", "runif",
"sd", "vcov")

S3method(bhm, default)
S3method(bhm, formula)
S3method(summary, bhm)

S3method(print, bhm)
S3method(print, pIndex)
S3method(print, resboot)
S3method(print, summary.bhm)

S3method(pIndex, default)
S3method(pIndex, formula)
S3method(print, pIndex)

S3method(plot, pIndex)
S3method(plot, resboot)

S3method(resboot, default)
S3method(resboot, formula)

S3method(summary, bhm)

28 changes: 24 additions & 4 deletions R/bhm_lib.R
Expand Up @@ -84,13 +84,14 @@ surv.gendat = function(n, c0, beta){
zx = z*x1
x0 = rep(1, n)
X = cbind(z, x1, zx)
h0 = 1
h0 = 0.5
h = h0*exp(X%*%beta)
stime = rexp(n, h) #Failure time.
endstudy = runif(n, 2, 4)
endstudy = runif(n, 0, 5)
cstatus = ifelse(stime>endstudy, 0, 1) ##Censored at end of study time.
cat('\nCensoring: ', 1-mean(cstatus), '\n')
stime = ifelse(stime>endstudy, endstudy, stime)
dat = cbind(stime, cstatus, z, x)
dat = cbind(time=stime, status=cstatus, z=z, x=x)
return(dat)
}

Expand Down Expand Up @@ -119,8 +120,27 @@ x.cdf = function(x){
n = length(x)
p = rep(0, n)
for (i in 1:n) {
p[i] = sum(x<x[i])
p[i] = sum(x<=x[i])
}
p = (p-0.5)/n
return(p)
}

## Kernel function
.K_func = function(w, u, h, kernel = c("gaussian", "epanechnikov", "rectangular",
"triangular", "biweight", "cosine", "optcosine")) {
kernel = match.arg(kernel)
x = w-u
ax = abs(x)
esp = 1e-40

kh = switch(kernel, gaussian = dnorm(x, sd = h/2),
rectangular = ifelse(ax < h, 0.5/h, esp),
triangular = ifelse(ax < h, (1 - ax/h)/h, esp),
epanechnikov = ifelse(ax < h, 3/4 * (1 - (ax/h)^2)/h, esp),
biweight = ifelse(ax < h, 15/16 * (1 - (ax/h)^2)^2/h, esp),
cosine = ifelse(ax < h, (1 + cos(pi * x/h))/(2*h), esp),
optcosine = ifelse(ax < h, pi/4 * cos(pi * x/(2*h))/h, esp))
return(kh)
}

0 comments on commit a161b23

Please sign in to comment.