Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8a8d7f4
Showing
7 changed files
with
1,144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ | ||
^\.travis\.yml$ | ||
^\.git$ | ||
^test$ | ||
^Makefile$ | ||
^COPYRIGHT$ | ||
^LICENSE$ | ||
^TODO.org$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
*.tar.gz | ||
*.Rcheck/ | ||
*.*~ | ||
*~ | ||
|
||
# History files | ||
.Rhistory | ||
.Rapp.history | ||
|
||
# Example code in package build process | ||
*-Ex.R | ||
|
||
# RStudio files | ||
*.Rproj | ||
.Rproj.user | ||
|
||
# produced vignettes | ||
vignettes/*.html | ||
vignettes/*.pdf | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
dir = $(shell pwd) | ||
pkg = survem | ||
cprt = COPYRIGHT | ||
|
||
Rpkg: build | ||
make check | ||
|
||
Rd: R/ | ||
Rscript -e "library(methods); roxygen2::roxygenise();" | ||
|
||
build: Rd | ||
R CMD build --compact-vignettes $(dir) | ||
|
||
check: $(pkg)_*.tar.gz | ||
R CMD check --as-cran $(pkg)_*.tar.gz | ||
|
||
INSTALL: build | ||
R CMD INSTALL --build $(pkg)_*.tar.gz | ||
|
||
preview: | ||
Rscript -e "rmarkdown::render('vignettes/$(pkg)-intro.Rmd')" | ||
|
||
## update copyright year in HEADER, R script and date in DESCRIPTION | ||
updateHeader: | ||
yr=$$(date +"%Y");\ | ||
sed -i "s/Copyright (C) 2016-[0-9]\{4\}/Copyright (C) 2016-$$yr/" $(cprt);\ | ||
# add HEADER file if there is no header | ||
for Rfile in R/*.R; do \ | ||
if ! grep -e 'Copyright (C)' $$Rfile ;\ | ||
then cat $(cprt) $$Rfile > tmp ;\ | ||
mv tmp $$Rfile;\ | ||
fi;\ | ||
yr=$$(date +"%Y");\ | ||
sed -i "s/Copyright (C) 2016-[0-9]*/Copyright (C) 2016-$$yr/" $$Rfile;\ | ||
done;\ | ||
dt=$$(date +"%Y-%m-%d");\ | ||
sed -i "s/Date: [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}/Date: $$dt/" DESCRIPTION; | ||
|
||
clean: | ||
rm -rf *~ */*~ *.Rhistroy *.tar.gz *.Rcheck/ .\#* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#' Formula Response for survival data with uncertain records | ||
#' | ||
#' \code{Surve} is an S3 class that represents | ||
#' formula response for survival data with | ||
#' uncertain records. | ||
#' The last letter 'e' in 'Surve' represents 'EM'. | ||
#' | ||
#' @param ID Identificator of each subject. | ||
#' @param time Time of reccurence event or censoring. | ||
#' @param event The status indicator, 0 = censored, 1 = event. | ||
#' @aliases Surve | ||
#' @export | ||
Surve <- function (ID, time, event) { | ||
## inpDat <- data.frame(ID, time, event) | ||
## FIXME: function to check the date structure of | ||
## uncertained records | ||
## dat <- checkSurve(inpDat) | ||
## outDat <- with(dat, as.matrix(cbind(ID, time, event))) | ||
outDat <- as.matrix(cbind(ID, time, event)) | ||
## attr(outDat, "ID") <- attr(dat, "ID") | ||
oldClass(outDat) <- "Surve" | ||
invisible(outDat) | ||
} | ||
|
||
|
||
#' An S4 Class to Represent a Fitted Model | ||
#' | ||
#' \code{survEm-class} is an S4 class that represents a fitted model. | ||
#' Function \code{\link{survEm}} produces objects of this class. | ||
#' See ``Slots'' for details. | ||
#' | ||
#' @slot call Function call. | ||
#' @slot formula Formula. | ||
#' @slot data A data frame. | ||
#' @slot nObs A positive integer. | ||
#' @slot estimates A list. | ||
#' @slot control A list. | ||
#' @slot start A list. | ||
#' @slot na.action A length-one character vector. | ||
#' @slot xlevels A list. | ||
#' @slot contrasts A list. | ||
#' @slot convergCode A nonnegative integer. | ||
#' @slot partLogL A numeric value. | ||
#' @slot logL A numeric value. | ||
#' @slot fisher A numeric matrix. | ||
#' @aliases survEm-class | ||
#' @seealso \code{\link{survEm}} for details of slots. | ||
#' @export | ||
setClass(Class = "coxEm", | ||
slots = c(call = "call", | ||
formula = "formula", | ||
data = "data.frame", | ||
nObs = "integer", | ||
estimates = "list", | ||
control = "list", | ||
start = "list", | ||
na.action = "character", | ||
xlevels = "list", | ||
contrasts = "list", | ||
convergCode = "integer", | ||
partLogL = "numeric", | ||
logL = "numeric", | ||
fisher = "matrix")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
## collation after class.R | ||
#' @include class.R | ||
NULL | ||
|
||
|
||
#' Estimated Coefficients of Covariates | ||
#' | ||
#' \code{coef,coxEm-method} is a S4 class method that extracts | ||
#' estimated coefficients of covariates from | ||
#' \code{\link{coxEm-class}} object produced by | ||
#' function \code{\link{coxEm}}. | ||
#' | ||
#' @param object \code{\link{coxEm-class}} object. | ||
#' @param ... Other arguments for future usage. | ||
#' @return A named numeric vector. | ||
#' @aliases coef,coxEm-method | ||
#' @seealso | ||
#' \code{\link{coxEm}} for model fitting; | ||
#' \code{\link{confint,coxEm-method}} for confidence intervals | ||
#' for covariate coefficients; | ||
#' \code{\link{summary,coxEm-method}} for summary of a fitted model. | ||
#' @examples | ||
#' ## See examples given in function coxEm. | ||
#' @importFrom stats coef | ||
#' @export | ||
setMethod(f = "coef", signature = "coxEm", | ||
definition = function(object, ...) { | ||
object@estimates$beta[, 1] | ||
}) | ||
|
||
|
Oops, something went wrong.