Commit 1beb4e5c authored by Sautreuil Mathilde's avatar Sautreuil Mathilde

Package presque fonctionnel -> vérifier les courbes de survie AFT et AH

parent 0393f5a3
......@@ -9,6 +9,8 @@ export(SurvFctAFTshiftLN)
export(SurvFctAFTshiftWeib)
export(SurvFctAHLN)
export(SurvFctAHWeib)
export(SurvFctCoxExp)
export(SurvFctCoxGomp)
export(SurvFctCoxLN)
export(SurvFctCoxWeib)
export(SurvTimesAFTLN)
......@@ -17,6 +19,8 @@ export(SurvTimesAFTshiftLN)
export(SurvTimesAFTshiftWeib)
export(SurvTimesAHLN)
export(SurvTimesAHWeib)
export(SurvTimesCoxExp)
export(SurvTimesCoxGomp)
export(SurvTimesCoxLN)
export(SurvTimesCoxWeib)
export(get_param_exp)
......
......@@ -23,8 +23,10 @@
#' Two distributions are considered for the baseline risk:
#' \itemize{
#' \item Weibull: \eqn{\alpha_0(t) = \lambda a t^{(a-1)}};
#' \item Log-normal: \eqn{\alpha_0(t) = (1/(\sigma\sqrt(2\pi t) \exp[-(\log t - \mu)^2 /2 \sigma^2]))/(1 - \Phi[(\log t - \mu)/\sigma}])}.
#'
#' \item Log-normal: \eqn{\alpha_0(t) = (1/(\sigma\sqrt(2\pi t) \exp[-(\log t - \mu)^2 /2 \sigma^2]))/(1 - \Phi[(\log t - \mu)/\sigma}]);
#' \item Exponential: \eqn{\alpha_0(t) = \lambda};
#' \item Gompertz: \eqn{\alpha_0(t) = \lambda \exp(\alpha t)}.
#' }
#' To Simulate the covariates, two distributions are also proposed:
#' \itemize{
#' \item Uniform
......@@ -214,7 +216,7 @@ modelSim = function(model = "cox", matDistr, matParam, n, p, pnonull, betaDistr,
}
## Distribution of the baseline hazard
TYPES_hazDistr<-c("weibull", "log-normal")
TYPES_hazDistr<-c("weibull", "log-normal", "gompertz", "exponential")
hdistr<-pmatch(hazDistr,TYPES_hazDistr)
if( p == pnonull){
......@@ -270,6 +272,14 @@ modelSim = function(model = "cox", matDistr, matParam, n, p, pnonull, betaDistr,
Ts = SurvTimesCoxLN(Z, beta, Y, pp, hazParams)
fcts = SurvFctCoxLN(Z, beta, pp, Ts, hazParams)
}
else if (hdistr == 3){
Ts = SurvTimesCoxGomp(Z, beta, Y, pp, hazParams)
fcts = SurvFctCoxGomp(Z, beta, pp, Ts, hazParams)
}else if (hdistr == 4){
Ts = SurvTimesCoxExp(Z, beta, Y, pp, hazParams)
fcts = SurvFctCoxExp(Z, beta, pp, Ts, hazParams)
}
else{
stop("Distribution not defined")
}
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
% Please edit documentation in R/internal.R
\name{SurvFctAFTshiftLN}
\alias{SurvFctAFTshiftLN}
\title{Survival curves of simulated data with Shift AFT/Log-normal model}
\title{Survival curves of simulated data with Shifted AFT/Log-normal model}
\usage{
SurvFctAFTshiftLN(Z, beta, pp, Ts, hazParams)
}
......@@ -30,7 +30,7 @@ SurvFctCoxWeib returns a list containing: \itemize{
}
}
\description{
Survival curves of simulated data with Shift AFT/Log-normal model
Survival curves of simulated data with Shifted AFT/Log-normal model
}
\examples{
library(survie)
......
......@@ -2,7 +2,7 @@
% Please edit documentation in R/internal.R
\name{SurvFctAFTshiftWeib}
\alias{SurvFctAFTshiftWeib}
\title{Survival curves of simulated data with Shift AFT/Weibull model}
\title{Survival curves of simulated data with Shifted AFT/Weibull model}
\usage{
SurvFctAFTshiftWeib(Z, beta, pp, Ts, hazParams)
}
......@@ -30,7 +30,7 @@ SurvFctCoxWeib returns a list containing: \itemize{
}
}
\description{
Survival curves of simulated data with Shift AFT/Weibull model
Survival curves of simulated data with Shifted AFT/Weibull model
}
\examples{
library(survie)
......
......@@ -4,7 +4,7 @@
\alias{SurvFctAHWeib}
\title{Survival curves of simulated data with AH/Weibull model}
\usage{
SurvFctAHWeib(Z, beta, pp, eta_i, Ts, hazParams)
SurvFctAHWeib(Z, beta, pp, Ts, hazParams)
}
\arguments{
\item{Z}{Matrix of covariates}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/internal.R
\name{SurvFctCoxExp}
\alias{SurvFctCoxExp}
\title{Survival curves of simulated data with Cox/Exponential model}
\usage{
SurvFctCoxExp(Z, beta, pp, Ts, hazParams)
}
\arguments{
\item{Z}{Matrix of covariates}
\item{beta}{regression parameter}
\item{pp}{number of pertinent covariates}
\item{Ts}{observed times}
\item{hazParams}{distribution parameters of baseline hazard risk}
\item{Y}{random uniform}
}
\value{
SurvFctCoxExp returns a list containing: \itemize{
\item{St}{ Matrix of survival functions (rows: individuals, columns: time grid)}
\item{Ft}{ Matrix of cumulative functions (rows: individuals, columns: time grid)}
\item{H0t}{ Matrix of cumulative hazard functions (rows: individuals, columns: time grid)}
\item{ht}{ Matrix of hazard risk functions (rows: individuals, columns: time grid)}
\item{grillet}{ Time grid}
\item{tau}{ maximum of observed times}
}
}
\description{
Survival curves of simulated data with Cox/Exponential model
}
\examples{
library(survie)
}
\keyword{internal}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/internal.R
\name{SurvFctCoxGomp}
\alias{SurvFctCoxGomp}
\title{Survival curves of simulated data with Cox/Gompertz model}
\usage{
SurvFctCoxGomp(Z, beta, pp, Ts, hazParams)
}
\arguments{
\item{Z}{Matrix of covariates}
\item{beta}{regression parameter}
\item{pp}{number of pertinent covariates}
\item{Ts}{observed times}
\item{hazParams}{distribution parameters of baseline hazard risk}
\item{Y}{random uniform}
}
\value{
SurvFctCoxGomp returns a list containing: \itemize{
\item{St}{ Matrix of survival functions (rows: individuals, columns: time grid)}
\item{Ft}{ Matrix of cumulative functions (rows: individuals, columns: time grid)}
\item{H0t}{ Matrix of cumulative hazard functions (rows: individuals, columns: time grid)}
\item{ht}{ Matrix of hazard risk functions (rows: individuals, columns: time grid)}
\item{grillet}{ Time grid}
\item{tau}{ maximum of observed times}
}
}
\description{
Survival curves of simulated data with Cox/Gompertz model
}
\examples{
library(survie)
}
\keyword{internal}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/internal.R
\name{SurvTimesCoxExp}
\alias{SurvTimesCoxExp}
\title{Simulation survival times from Cox/exponential model}
\usage{
SurvTimesCoxExp(Z, beta, Y, pp, hazParams)
}
\arguments{
\item{Z}{Matrix of covariates}
\item{beta}{regression parameter}
\item{Y}{random uniform}
\item{pp}{number of pertinent covariates}
\item{hazParams}{distribution parameters of baseline hazard risk}
}
\value{
Ts Observed times
}
\description{
Simulation survival times from Cox/exponential model
}
\examples{
library(survie)
}
\keyword{internal}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/internal.R
\name{SurvTimesCoxGomp}
\alias{SurvTimesCoxGomp}
\title{Simulation survival times from Cox/gompertz model}
\usage{
SurvTimesCoxGomp(Z, beta, Y, pp, hazParams)
}
\arguments{
\item{Z}{Matrix of covariates}
\item{beta}{regression parameter}
\item{Y}{random uniform}
\item{pp}{number of pertinent covariates}
\item{hazParams}{distribution parameters of baseline hazard risk}
}
\value{
Ts Observed times
}
\description{
Simulation survival times from Cox/gompertz model
}
\examples{
library(survie)
}
\keyword{internal}
......@@ -78,8 +78,10 @@ with \eqn{\alpha_0(t)} is the baseline risk and \eqn{\beta} is the vector of coe
Two distributions are considered for the baseline risk:
\itemize{
\item Weibull: \eqn{\alpha_0(t) = \lambda a t^{(a-1)}};
\item Log-normal: \eqn{\alpha_0(t) = (1/(\sigma\sqrt(2\pi t) \exp[-(\log t - \mu)^2 /2 \sigma^2]))/(1 - \Phi[(\log t - \mu)/\sigma}])}.
\item Log-normal: \eqn{\alpha_0(t) = (1/(\sigma\sqrt(2\pi t) \exp[-(\log t - \mu)^2 /2 \sigma^2]))/(1 - \Phi[(\log t - \mu)/\sigma}]);
\item Exponential: \eqn{\alpha_0(t) = \lambda};
\item Gompertz: \eqn{\alpha_0(t) = \lambda \exp(\alpha t)}.
}
To Simulate the covariates, two distributions are also proposed:
\itemize{
\item Uniform
......
......@@ -40,6 +40,19 @@ df_p1000_n500 = data.frame(time = listAFTSim_n500_p1000$TC,
listAFTSim_n500_p1000$Z)
df_p1000_n500[1:6,1:10]
dim(df_p1000_n500)
res_paramW = get_param_weib(med = 1062, mu = 1134)
listAFTSim_n500_p1000 <- modelSim(model = "AFT", matDistr = "unif", matParam = c(-1,1), n = 500,
p = 1000, pnonull = 20, betaDistr = 1, hazDistr = "weibull",
hazParams = c(res_paramW$a, res_paramW$lambda),
Phi = 0, seed = 1, d = 0)
print(listAFTSim_n500_p1000)
hist(listAFTSim_n500_p1000)
plot(listAFTSim_n500_p1000, ind = sample(1:500, 5))
df_p1000_n500 = data.frame(time = listAFTSim_n500_p1000$TC,
event = listAFTSim_n500_p1000$delta,
listAFTSim_n500_p1000$Z)
df_p1000_n500[1:6,1:10]
dim(df_p1000_n500)
# write.csv(df_p1000_n500, file = paste0(path, "DF_RegScreen_n500_p1000.csv"), row.names = F)
# listAFTSim_n500_p25000 <- AFTSim(matDistr = "unif", matParam = c(-1,1), n = 500, p = 25000,
# pnonull = 20, betaDistr = 1, hazDistr = "weibull",
......@@ -50,3 +63,17 @@ dim(df_p1000_n500)
# event = listAFTSim_n500_p25000$delta,
# listAFTSim_n500_p25000$Z)
# df_p25m_n500[1:6,1:10]
res_paramW = get_param_weib(med = 1062, mu = 1134)
listAHSim_n500_p1000 <- modelSim(model = "AH", matDistr = "unif", matParam = c(-1,1), n = 500,
p = 1000, pnonull = 20, betaDistr = 1, hazDistr = "weibull",
hazParams = c(res_paramW$a, res_paramW$lambda),
Phi = 0, seed = 1, d = 0)
print(listAHSim_n500_p1000)
hist(listAHSim_n500_p1000)
plot(listAHSim_n500_p1000, ind = sample(1:500, 5))
df_p1000_n500 = data.frame(time = listAHSim_n500_p1000$TC,
event = listAHSim_n500_p1000$delta,
listAHSim_n500_p1000$Z)
df_p1000_n500[1:6,1:10]
dim(df_p1000_n500)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment