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

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")
}
......
......@@ -38,6 +38,56 @@ SurvTimesCoxWeib = function(Z, beta, Y, pp, hazParams){
SurvTimesCoxLN = function(Z, beta, Y, pp, hazParams){
Ts<-exp(hazParams[1]*qnorm(1-exp((log(1-Y)/exp((1/(pp))*Z%*%beta))),mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)+hazParams[2])
# Ts<-exp(hazParams[1]*qnorm(1-exp((log(1-Y)/exp((1/(pp))*Z%*%beta))),mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)+hazParams[2])
return(Ts)
}
#' Simulation survival times from Cox/exponential model
#'
#' @param Z Matrix of covariates
#' @param beta regression parameter
#' @param Y random uniform
#' @param pp number of pertinent covariates
#' @param hazParams distribution parameters of baseline hazard risk
#'
#' @return Ts Observed times
#' @export
#'
#' @keywords internal
#'
#' @examples
#' library(survie)
SurvTimesCoxExp = function(Z, beta, Y, pp, hazParams){
Ts <- (-log(1-Y) / (hazParams[1] * exp((1/(pp))*Z%*%beta)))
# Ts<-exp(hazParams[1]*qnorm(1-exp((log(1-Y)/exp((1/(pp))*Z%*%beta))),mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)+hazParams[2])
# Ts<-exp(hazParams[1]*qnorm(1-exp((log(1-Y)/exp((1/(pp))*Z%*%beta))),mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)+hazParams[2])
return(Ts)
}
#' Simulation survival times from Cox/gompertz model
#'
#' @param Z Matrix of covariates
#' @param beta regression parameter
#' @param Y random uniform
#' @param pp number of pertinent covariates
#' @param hazParams distribution parameters of baseline hazard risk
#'
#' @return Ts Observed times
#' @export
#'
#' @keywords internal
#'
#' @examples
#' library(survie)
SurvTimesCoxGomp = function(Z, beta, Y, pp, hazParams){
check <- ((-hazParams[1]*log(1-Y)) / (hazParams[2]*exp((1/(pp))*Z%*%beta))) + 1
if (check < 0)
return(Inf)
Ts <- (1 / hazParams[1]) * log(check)
# Ts<-exp(hazParams[1]*qnorm(1-exp((log(1-Y)/exp((1/(pp))*Z%*%beta))),mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)+hazParams[2])
# Ts<-exp(hazParams[1]*qnorm(1-exp((log(1-Y)/exp((1/(pp))*Z%*%beta))),mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)+hazParams[2])
return(Ts)
}
......@@ -59,8 +109,12 @@ SurvTimesCoxLN = function(Z, beta, Y, pp, hazParams){
#' library(survie)
SurvTimesAHWeib = function(Z, beta, Y, pp, hazParams){
eta = exp((1/sqrt(pp))*(Z %*% beta))
Ts = (1/eta)*(((-log(1-Y)*eta)/hazParams[2])^(1/hazParams[1]))
# Ts=(-(1/hazParams[2])*exp((1/sqrt(pp))*(-Z %*% beta))*log(1-Y))^(1/hazParams[1]) #(1/(p*sum(beta)))* (1/(p))* (1/(p*sum(beta)))* (1/(sqrt(5*p)))* (1/sqrt(10000*p))*
stop("log-normale distribution must be used")
# stop("log-normale distribution must be used")
return(Ts)
}
......@@ -81,6 +135,7 @@ SurvTimesAHLN = function(Z, beta, Y, pp, hazParams){
eta = Z%*%beta
Ts<- (1/eta)*(exp(hazParams[1]*qnorm(1-exp((log(1-Y)*eta)),mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)+hazParams[2]) ) #+r*eta2
return(Ts)
}
#' Simulation survival times from AFT/Weibull model
......@@ -101,8 +156,11 @@ SurvTimesAHLN = function(Z, beta, Y, pp, hazParams){
SurvTimesAFTWeib = function(Z, beta, Y, pp, hazParams){
phi2 = 0
eta = exp((1/sqrt(pp))*(Z %*% beta))
Ts = (1/eta)*((-log(1-Y)/hazParams[2])^(1/hazParams[1])+phi2)
# Ts=(-(1/hazParams[2])*exp((1/sqrt(pp))*(-Z %*% beta))*log(1-Y))^(1/hazParams[1]) #(1/(p*sum(beta)))* (1/(p))* (1/(p*sum(beta)))* (1/(sqrt(5*p)))* (1/sqrt(10000*p))*
stop("log-normale distribution must be used")
# stop("log-normale distribution must be used")
return(Ts)
}
......@@ -124,8 +182,9 @@ SurvTimesAFTWeib = function(Z, beta, Y, pp, hazParams){
SurvTimesAFTLN = function(Z, beta, Y, pp, hazParams){
phi2 = 0
eta = Z%*%beta
eta = exp((1/sqrt(pp))*Z%*%beta)#
Ts<- (1/eta)* (exp(hazParams[1]*qnorm(1-Y,mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)+hazParams[2])+phi2) #runif(n,0,1) ((1/(p))* ((1/(p))* ((1/(p))*Z%*%b0) (1/(sqrt(p))* (1/p)*
return(Ts)
}
......@@ -148,8 +207,11 @@ SurvTimesAFTshiftWeib = function(Z, beta, Y, pp, hazParams){
b2 <- NULL
phi2 = 300* Z%*%b2
eta = exp((1/sqrt(pp))*(Z %*% beta))
Ts = (1/eta)*((-log(1-Y)/hazParams[2])^(1/hazParams[1])+phi2)
# Ts=(-(1/hazParams[2])*exp((1/sqrt(pp))*(-Z %*% beta))*log(1-Y))^(1/hazParams[1]) #(1/(p*sum(beta)))* (1/(p))* (1/(p*sum(beta)))* (1/(sqrt(5*p)))* (1/sqrt(10000*p))*
stop("log-normale distribution must be used")
# stop("log-normale distribution must be used")
return(Ts)
}
......@@ -172,8 +234,9 @@ SurvTimesAFTshiftLN = function(Z, beta, Y, pp, hazParams){
b2 <- NULL
phi2 = 300* Z%*%b2
eta = Z%*%beta
eta = exp((1/sqrt(pp))*Z%*%beta)#
Ts<- (1/eta)* (exp(hazParams[1]*qnorm(1-Y,mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)+hazParams[2])+phi2) #runif(n,0,1) ((1/(p))* ((1/(p))* ((1/(p))*Z%*%b0) (1/(sqrt(p))* (1/p)*
return(Ts)
}
......@@ -252,17 +315,17 @@ SurvFctCoxLN = function(Z, beta, pp, Ts, hazParams){
pas=100
grille_ti=tau*(1/pas)*c(1:(pas))
eta_i = exp((1/sqrt(pp))*(-Z %*% beta))
h0_t = hazParams[1]*hazParams[2]*(grille_ti^(hazParams[1]-1))
h0_t = ((1/hazParams[2])*dlnorm(grille_ti, meanlog = hazParams[1], sdlog = hazParams[2]))/(1-plnorm(grille_ti, meanlog = hazParams[1], sdlog = hazParams[2]))
h = matrix(h0_t, nrow = nrow(Z), ncol = pas, byrow = T) * as.vector(eta_i)
H0_t = matrix((tau/pas)*cumsum(h0_t), nrow = nrow(Z), ncol = length(grille_ti), byrow = T)
F_t = 1 - exp(-H0_t*as.vector(eta_i))
S_t = exp(-H0_t*as.vector(eta_i))
stop("to code")
return(list(St = S_t, Ft = F_t, H0t = H0_t, ht = h, grillet = grille_ti, tau))
}
#' Survival curves of simulated data with AFT/Log-normal model
#' Survival curves of simulated data with Cox/Gompertz model
#'
#' @param Z Matrix of covariates
#' @param beta regression parameter
......@@ -271,7 +334,7 @@ SurvFctCoxLN = function(Z, beta, pp, Ts, hazParams){
#' @param Ts observed times
#' @param hazParams distribution parameters of baseline hazard risk
#'
#' @return SurvFctCoxWeib returns a list containing: \itemize{
#' @return 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)}
......@@ -285,23 +348,25 @@ SurvFctCoxLN = function(Z, beta, pp, Ts, hazParams){
#'
#' @examples
#' library(survie)
SurvFctAFTLN = function(Z, beta, pp, Ts, hazParams){
SurvFctCoxGomp = function(Z, beta, pp, Ts, hazParams){
#lambda = hazParams[1]
#a = hazParams[2]
tau = max(Ts)
pas=100
a = hazParams[1]
lambda = hazParams[2]
grille_ti=tau*(1/pas)*c(1:(pas))
eta_i = exp((1/sqrt(pp))*(-Z %*% beta))
h0_t = a*lambda*(grille_ti^(a-1))
h0_t = hazParams[1]*exp(hazParams[2]*grille_ti)
h = matrix(h0_t, nrow = nrow(Z), ncol = pas, byrow = T) * as.vector(eta_i)
H0_t = matrix((tau/pas)*cumsum(h0_t), nrow = nrow(Z), ncol = length(grille_ti), byrow = T)
F_t = 1 - exp(-H0_t*as.vector(eta_i))
S_t = exp(-H0_t*as.vector(eta_i))
# stop("to code")
return(list(St = S_t, Ft = F_t, H0t = H0_t, ht = h, grillet = grille_ti, tau))
}
#' Survival curves of simulated data with AFT/Weibull model
#' Survival curves of simulated data with Cox/Exponential model
#'
#' @param Z Matrix of covariates
#' @param beta regression parameter
......@@ -310,7 +375,7 @@ SurvFctAFTLN = function(Z, beta, pp, Ts, hazParams){
#' @param Ts observed times
#' @param hazParams distribution parameters of baseline hazard risk
#'
#' @return SurvFctAFTWeib returns a list containing: \itemize{
#' @return 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)}
......@@ -324,23 +389,23 @@ SurvFctAFTLN = function(Z, beta, pp, Ts, hazParams){
#'
#' @examples
#' library(survie)
SurvFctAFTWeib = function(Z, beta, pp, Ts, hazParams){
SurvFctCoxExp = function(Z, beta, pp, Ts, hazParams){
tau = max(Ts)
pas=100
a = hazParams[1]
lambda = hazParams[2]
grille_ti=tau*(1/pas)*c(1:(pas))
eta_i = exp((1/sqrt(pp))*(-Z %*% beta))
h0_t = a*lambda*(grille_ti^(a-1))
h0_t = hazParams[1]
h = matrix(h0_t, nrow = nrow(Z), ncol = pas, byrow = T) * as.vector(eta_i)
H0_t = matrix((tau/pas)*cumsum(h0_t), nrow = nrow(Z), ncol = length(grille_ti), byrow = T)
F_t = 1 - exp(-H0_t*as.vector(eta_i))
S_t = exp(-H0_t*as.vector(eta_i))
# stop("to code")
return(list(St = S_t, Ft = F_t, H0t = H0_t, ht = h, grillet = grille_ti, tau))
}
#' Survival curves of simulated data with Shift AFT/Weibull model
#' Survival curves of simulated data with AFT/Log-normal model
#'
#' @param Z Matrix of covariates
#' @param beta regression parameter
......@@ -363,26 +428,113 @@ SurvFctAFTWeib = function(Z, beta, pp, Ts, hazParams){
#'
#' @examples
#' library(survie)
SurvFctAFTshiftWeib = function(Z, beta, pp, Ts, hazParams){
SurvFctAFTLN = function(Z, beta, pp, Ts, hazParams){
tau = max(Ts)
pas=100
stop("change equation")
# a = hazParams[1]
# lambda = hazParams[2]
grille_ti=tau*(1/pas)*c(1:(pas))
eta_i = exp((1/sqrt(pp))*(-Z %*% beta))
a = hazParams[1]
lambda = hazParams[2]
stop("ajout Phi2 !")
h0_t = a*lambda*(grille_ti^(a-1))
h0_t = ((1/hazParams[2])*dlnorm(grille_ti,
meanlog = hazParams[1],
sdlog = hazParams[2]))/(1-plnorm(grille_ti,
meanlog = hazParams[1],
sdlog = hazParams[2]))#hazParams[1]*hazParams[2]*(grille_ti^(hazParams[1]-1))
h = matrix(h0_t, nrow = nrow(Z), ncol = pas, byrow = T) * as.vector(eta_i)
H0_t = matrix((tau/pas)*cumsum(h0_t), nrow = nrow(Z), ncol = length(grille_ti), byrow = T)
F_t = 1 - exp(-H0_t*as.vector(eta_i))
S_t = exp(-H0_t*as.vector(eta_i))
H0_t = matrix(-log(1 - pnorm((log(grille_ti*eta_i)-hazParams[2])/hazParams[1])),
nrow = nrow(Z), ncol = length(grille_ti))
F_t = 1 - exp(-H0_t)
S_t = exp(-H0_t)
return(list(St = S_t, Ft = F_t, H0t = H0_t, ht = h, grillet = grille_ti, tau))
}
#' Survival curves of simulated data with AFT/Weibull model
#'
#' @param Z Matrix of covariates
#' @param beta regression parameter
#' @param Y random uniform
#' @param pp number of pertinent covariates
#' @param Ts observed times
#' @param hazParams distribution parameters of baseline hazard risk
#'
#' @return SurvFctAFTWeib 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}
#' }
#' @export
#'
#' @keywords internal
#'
#' @examples
#' library(survie)
SurvFctAFTWeib = function(Z, beta, pp, Ts, hazParams){
tau = max(Ts)
pas=100
# a = hazParams[1]
# lambda = hazParams[2]
grille_ti=tau*(1/pas)*c(1:(pas))
eta_i = exp((1/sqrt(pp))*(-Z %*% beta))
h0_t = hazParams[1]*hazParams[2]*(grille_ti^(hazParams[1]-1))
## to modify
h = NULL
# h = matrix(h0_t, nrow = nrow(Z), ncol = pas, byrow = T) * as.vector(eta_i)
H0_t = matrix(hazParams[2]*(grille_ti*eta_i)^hazParams[1],
nrow = nrow(Z), ncol = length(grille_ti), byrow = T)
F_t = 1 - exp(-H0_t)
S_t = exp(-H0_t)
return(list(St = S_t, Ft = F_t, H0t = H0_t, ht = h, grillet = grille_ti, tau))
}
#' Survival curves of simulated data with Shifted AFT/Weibull model
#'
#' @param Z Matrix of covariates
#' @param beta regression parameter
#' @param Y random uniform
#' @param pp number of pertinent covariates
#' @param Ts observed times
#' @param hazParams distribution parameters of baseline hazard risk
#'
#' @return SurvFctCoxWeib 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}
#' }
#' @export
#'
#' @keywords internal
#'
#' @examples
#' library(survie)
SurvFctAFTshiftWeib = function(Z, beta, pp, Ts, hazParams){
tau = max(Ts)
pas=100
eta_i = exp((1/sqrt(pp))*(-Z %*% beta))
phi2 = 300*eta_i
# a = hazParams[1]
# lambda = hazParams[2]
grille_ti=tau*(1/pas)*c(1:(pas))
h0_t = hazParams[1]*hazParams[2]*(grille_ti^(hazParams[1]-1))
## to modify
h = NULL
# h = matrix(h0_t, nrow = nrow(Z), ncol = pas, byrow = T) * as.vector(eta_i)
H0_t = matrix(hazParams[2]*(grille_ti*eta_i)^hazParams[1] + phi2,
nrow = nrow(Z), ncol = length(grille_ti), byrow = T)
F_t = 1 - exp(-H0_t)
S_t = exp(-H0_t)
return(list(St = S_t, Ft = F_t, H0t = H0_t, ht = h, grillet = grille_ti, tau))
}
#' Survival curves of simulated data with Shift AFT/Log-normal model
#' Survival curves of simulated data with Shifted AFT/Log-normal model
#'
#' @param Z Matrix of covariates
#' @param beta regression parameter
......@@ -406,19 +558,21 @@ SurvFctAFTshiftWeib = function(Z, beta, pp, Ts, hazParams){
#' @examples
#' library(survie)
SurvFctAFTshiftLN = function(Z, beta, pp, Ts, hazParams){
tau = max(Ts)
pas=100
# a = hazParams[1]
# lambda = hazParams[2]
grille_ti=tau*(1/pas)*c(1:(pas))
eta_i = exp((1/sqrt(pp))*(-Z %*% beta))
a = hazParams[1]
lambda = hazParams[2]
stop("ajout Phi2 !")
h0_t = a*lambda*(grille_ti^(a-1))
h = matrix(h0_t, nrow = nrow(Z), ncol = pas, byrow = T) * as.vector(eta_i)
H0_t = matrix((tau/pas)*cumsum(h0_t), nrow = nrow(Z), ncol = length(grille_ti), byrow = T)
F_t = 1 - exp(-H0_t*as.vector(eta_i))
S_t = exp(-H0_t*as.vector(eta_i))
phi2 = 300*eta_i
h0_t = ((1/hazParams[2])*dlnorm(grille_ti, meanlog = hazParams[1], sdlog = hazParams[2]))/(1-plnorm(grille_ti, meanlog = hazParams[1], sdlog = hazParams[2]))
# h = matrix(h0_t, nrow = nrow(Z), ncol = pas, byrow = T) * as.vector(eta_i)
h = NULL
H0_t = matrix(-log(1 - pnorm((log(grille_ti*eta_i)-hazParams[2])/hazParams[1])) + phi2,
nrow = nrow(Z), ncol = length(grille_ti))
F_t = 1 - exp(-H0_t)
S_t = exp(-H0_t)
return(list(St = S_t, Ft = F_t, H0t = H0_t, ht = h, grillet = grille_ti, tau))
}
......@@ -447,11 +601,23 @@ SurvFctAFTshiftLN = function(Z, beta, pp, Ts, hazParams){
#'
#' @examples
#' library(survie)
SurvFctAHWeib = function(Z, beta, pp, eta_i, Ts, hazParams){
SurvFctAHWeib = function(Z, beta, pp, Ts, hazParams){
tau = max(Ts)
pas=100
S_t <- F_t <- H0_t <- h <- grille_ti <- NULL
stop("to code")
# a = hazParams[1]
# lambda = hazParams[2]
grille_ti=tau*(1/pas)*c(1:(pas))
eta_i = exp((1/sqrt(pp))*(-Z %*% beta))
h0_t = hazParams[1]*hazParams[2]*(grille_ti^(hazParams[1]-1))
## to modify
h = NULL
# h = matrix(h0_t, nrow = nrow(Z), ncol = pas, byrow = T) * as.vector(eta_i)
H0_t = matrix(hazParams[2]*(grille_ti*eta_i)^hazParams[1],
nrow = nrow(Z), ncol = length(grille_ti), byrow = T)
F_t = 1 - exp(-H0_t*as.vector(eta_i))
S_t = exp(-H0_t*as.vector(eta_i))
# S_t <- F_t <- H0_t <- h <- grille_ti <- NULL
# stop("to code")
return(list(St = S_t, Ft = F_t, H0t = H0_t, ht = h, grillet = grille_ti, tau))
}
......@@ -481,7 +647,21 @@ SurvFctAHWeib = function(Z, beta, pp, eta_i, Ts, hazParams){
SurvFctAHLN = function(Z, beta, pp, eta_i, Ts, hazParams){
tau = max(Ts)
pas=100
S_t <- F_t <- H0_t <- h <- grille_ti <- NULL
stop("to code")
# a = hazParams[1]
# lambda = hazParams[2]
grille_ti=tau*(1/pas)*c(1:(pas))
eta_i = exp((1/sqrt(pp))*(-Z %*% beta))
h0_t = ((1/hazParams[2])*dlnorm(grille_ti,
meanlog = hazParams[1],
sdlog = hazParams[2]))/(1-plnorm(grille_ti,
meanlog = hazParams[1],
sdlog = hazParams[2]))#hazParams[1]*hazParams[2]*(grille_ti^(hazParams[1]-1))
h = matrix(h0_t, nrow = nrow(Z), ncol = pas, byrow = T) * as.vector(eta_i)
H0_t = matrix(-log(1 - pnorm((log(grille_ti*eta_i)-hazParams[2])/hazParams[1])),
nrow = nrow(Z), ncol = length(grille_ti))
F_t = 1 - exp(-H0_t*as.vector(eta_i))
S_t = exp(-H0_t*as.vector(eta_i))
# S_t <- F_t <- H0_t <- h <- grille_ti <- NULL
# stop("to code")
return(list(St = S_t, Ft = F_t, H0t = H0_t, ht = h, grillet = grille_ti, tau))
}
......@@ -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
}