Title: | Set-Based Inference for Multiple Interval-Censored Outcomes |
---|---|
Description: | Contains tests for association between a set of genetic variants and multiple correlated outcomes that are interval censored. Interval-censored data arises when the exact time of the onset of an outcome of interest is unknown but known to fall between two time points. |
Authors: | Jaihee Choi [aut, cre], Ryan Sun [aut] |
Maintainer: | Jaihee Choi <[email protected]> |
License: | GPL-3 |
Version: | 0.2.0 |
Built: | 2024-12-25 06:57:05 UTC |
Source: | CRAN |
Calculate the first derivative of the theta terms for outcome l.
fd_term(l, temp_beta, phen,d, apply_diffs, A_i, no_l_all,HL_array, HR_array)
fd_term(l, temp_beta, phen,d, apply_diffs, A_i, no_l_all,HL_array, HR_array)
l |
Outcome of interest. |
temp_beta |
Vector of fitted coefficients. |
phen |
list containing the covariate design matrices. |
d |
Number of quadrature nodes. |
apply_diffs |
Matrix containing the differences between survival functions of the left and right time intervals. |
A_i |
Product of apply_diffs across all outcomes k summed over all quadrature nodes d. |
no_l_all |
n x (k - 1) matrix containing the product of apply_diffs across all outcomes k excluding the current outcome l. |
HL_array |
n x k matrix containing all the hazard values for the left times. |
HR_array |
n x k matrix containing all the hazard values for the right times. |
The output is a 1 x (p + 2) vector of the first derivative terms for outcome l.
Calculates the gradient term for U_g for the score statistic.
gamma_fd(l, HL_array, HR_array, tpos_all, obs_all, temp_beta, A_i, no_l_all, gMat, a1, a2, d)
gamma_fd(l, HL_array, HR_array, tpos_all, obs_all, temp_beta, A_i, no_l_all, gMat, a1, a2, d)
l |
Index of first outcome of interest. |
HL_array |
n x k matrix containing all the hazard values for the left times. |
HR_array |
n x k matrix containing all the hazard values for the right times. |
tpos_all |
n x k matrix containing a indictor for whether that time is left-censored or not. |
obs_all |
n x k matrix containing a indictor for whether that time is right-censored or not. |
temp_beta |
Vector of fitted coefficients. |
A_i |
Product of apply_diffs across all outcomes k summed over all quadrature nodes d. |
no_l_all |
n x (K - 1) matrix containing the product of apply_diffs across all outcomes K excluding the current outcome l. |
gMat |
n x q matrix of genetic information. |
a1 |
First shape parameter of beta parameter. |
a2 |
Second shape parameter of beta parameter. |
d |
Number of quadrature nodes. |
The output is a vector containing the first derivative with respect to gamma.
Calculates the [off-diagonal] Information matrix term for I_gamma gamma with respect to outcome l and outcome m.
gamma_off(l, m, HL_array, HR_array, tpos_all, obs_all, temp_beta, A_i, no_l_all, no_two_all, gMat, a1, a2, k, d)
gamma_off(l, m, HL_array, HR_array, tpos_all, obs_all, temp_beta, A_i, no_l_all, no_two_all, gMat, a1, a2, k, d)
l |
Index of first outcome of interest. |
m |
Index of second outcome of interest. |
HL_array |
n x k matrix containing all the hazard values for the left times. |
HR_array |
n x k matrix containing all the hazard values for the right times. |
tpos_all |
n x k matrix containing a indictor for whether that time is left-censored or not. |
obs_all |
n x k matrix containing a indictor for whether that time is right-censored or not. |
temp_beta |
Vector of fitted coefficients. |
A_i |
Product of apply_diffs across all outcomes k summed over all quadrature nodes d. |
no_l_all |
n x (k - 1) matrix containing the product of apply_diffs across all outcomes k excluding the current outcome l. |
no_two_all |
n x (k - 2) matrix containing the product of apply_diffs across all outcomes k excluding the outcomes l and m. |
gMat |
n x q matrix of genetic information. |
a1 |
First shape parameter of beta parameter. |
a2 |
Second shape parameter of beta parameter. |
k |
Total number of outcomes. |
d |
Number of quadrature nodes. |
The output is a matrix containing the component of the information matrix of the gamma parameter for outcomes l and m.
Calculates the [on-diagonal] Information matrix term for I_gamma gamma with respect to outcome l.
gamma_on(l, HL_array, HR_array, tpos_all, obs_all, temp_beta, A_i, no_l_all, gMat, a1, a2, d)
gamma_on(l, HL_array, HR_array, tpos_all, obs_all, temp_beta, A_i, no_l_all, gMat, a1, a2, d)
l |
Index of first outcome of interest. |
HL_array |
n x k matrix containing all the hazard values for the left times. |
HR_array |
n x k matrix containing all the hazard values for the right times. |
tpos_all |
n x k matrix containing a indictor for whether that time is left-censored or not. |
obs_all |
n x k matrix containing a indictor for whether that time is right-censored or not. |
temp_beta |
Vector of fitted coefficients. |
A_i |
Product of apply_diffs across all outcomes k summed over all quadrature nodes d. |
no_l_all |
n x (k - 1) matrix containing the product of apply_diffs across all outcomes k excluding the current outcome l. |
gMat |
n x q matrix of genetic information. |
a1 |
First shape parameter of beta parameter. |
a2 |
Second shape parameter of beta parameter. |
d |
Number of quadrature nodes. |
The output is a matrix containing the component of the information matrix of the gamma parameter for outcome l.
Calculates the Information matrix term of I_eta gamma for one outcome of interest l.
gammasigma( l, HL_array, HR_array, tpos_all, obs_all, apply_diffs, temp_beta, A_i, xDats, no_l_all, no_two_all, gMat, a1, a2, k, d)
gammasigma( l, HL_array, HR_array, tpos_all, obs_all, apply_diffs, temp_beta, A_i, xDats, no_l_all, no_two_all, gMat, a1, a2, k, d)
l |
Index of first outcome of interest. |
HL_array |
n x K matrix containing all the hazard values for the left times. |
HR_array |
n x K matrix containing all the hazard values for the right times. |
tpos_all |
n x k matrix containing a indictor for whether that time is left-censored or not. |
obs_all |
n x k matrix containing a indictor for whether that time is right-censored or not. |
apply_diffs |
Matrix containing the differences between survival functions of the left and right time intervals. |
temp_beta |
vector of fitted coefficients. |
A_i |
Product of apply_diffs across all outcomes K summed over all quadrature nodes D. |
xDats |
List of design matrices. |
no_l_all |
n x (k - 1) matrix containing the product of apply_diffs across all outcomes K excluding the current outcome l. |
no_two_all |
n x (k - 2) matrix containing the product of apply_diffs across all outcomes k excluding the outcomes l and m. |
gMat |
n x q matrix of genetic information. |
a1 |
First shape parameter of beta parameter. |
a2 |
Second shape parameter of beta parameter. |
k |
Total number of outcomes. |
d |
Number of quadrature nodes. |
The output is a matrix containing the component of the information matrix of the gamma and sigma^2 parameters for outcome l.
Calculates the Information matrix term of I_eta gamma for outcome k.
gammatheta(l, HL_array, HR_array, tpos_all, obs_all, apply_diffs, temp_beta, A_i, xDats, no_l_all, gMat, a1, a2, d)
gammatheta(l, HL_array, HR_array, tpos_all, obs_all, apply_diffs, temp_beta, A_i, xDats, no_l_all, gMat, a1, a2, d)
l |
Index of first outcome of interest. |
HL_array |
n x k matrix containing all the hazard values for the left times. |
HR_array |
n x k matrix containing all the hazard values for the right times. |
tpos_all |
n x k matrix containing a indictor for whether that time is left-censored or not. |
obs_all |
n x k matrix containing a indictor for whether that time is right-censored or not. |
apply_diffs |
Matrix containing the differences between survival functions of the left and right time intervals. |
temp_beta |
vector of fitted coefficients. |
A_i |
Product of apply_diffs across all outcomes k summed over all quadrature nodes d. |
xDats |
List of design matrices for all outcomes. |
no_l_all |
n x (k - 1) matrix containing the product of apply_diffs across all outcomes k excluding the current outcome l. |
gMat |
n x q matrix of genetic information. |
a1 |
First shape parameter of beta parameter. |
a2 |
Second shape parameter of beta parameter. |
d |
Number of quadrature nodes. |
The output is a matrix containing the component of the information matrix of the gamma and theta parameters for outcome l.
Calculates the Information matrix term of I_eta gamma for outcomes l and m
gammatheta_off(l,m, HL_array, HR_array, xAll, apply_diffs, temp_beta, A_i, no_l_all, no_two_all, gMat, a1, a2, k, d)
gammatheta_off(l,m, HL_array, HR_array, xAll, apply_diffs, temp_beta, A_i, no_l_all, no_two_all, gMat, a1, a2, k, d)
l |
Index of first outcome of interest. |
m |
Index of second outcome of interest. |
HL_array |
n x k matrix containing all the hazard values for the left times. |
HR_array |
n x k matrix containing all the hazard values for the right times. |
xAll |
List of design matrices and censoring terms. |
apply_diffs |
Matrix containing the differences between survival functions of the left and right time intervals. |
temp_beta |
vector of fitted coefficients. |
A_i |
Product of apply_diffs across all outcomes K summed over all quadrature nodes d. |
no_l_all |
n x (k - 1) matrix containing the product of apply_diffs across all outcomes k excluding the current outcome l. |
no_two_all |
n x (k - 2) matrix containing the product of apply_diffs across all outcomes k excluding the outcomes l and m. |
gMat |
n x q matrix of genetic information. |
a1 |
First shape parameter of beta parameter. |
a2 |
Second shape parameter of beta parameter. |
k |
Total number of outcomes. |
d |
Number of quadrature nodes. |
The output is a matrix containing the component of the information matrix of the gamma and theta parameters for outcomes l and m.
Product of difference of survival terms of the left and right interval times, across all outcomes k, summed over all quadrature nodes d.
get_A(store, weights, d, n)
get_A(store, weights, d, n)
store |
Matrix of difference of survival values of the left and right time intervals. |
weights |
Gaussian quadrature weights. |
d |
Total number of Gaussian quadrature nodes. |
n |
Total number of observations. |
The output is a vector used to compute the derivative terms.
Matrix of subsetted genetic information.
Get_CausalSNPs_bynum(gMat, num, Causal.MAF.Cutoff)
Get_CausalSNPs_bynum(gMat, num, Causal.MAF.Cutoff)
gMat |
Matrix of SNPs. |
num |
Number of causal variants. |
Causal.MAF.Cutoff |
Minor allele frequency value cutoff for causal SNPs. |
Output is a vector of indices to subset the full genetic matrix.
Calculates the hazard function of the left time interval for outcome l.
haz_left(l, d, temp_beta, phen, r1, k)
haz_left(l, d, temp_beta, phen, r1, k)
l |
Outcome of interest. |
d |
Total number of Gaussian quadrature nodes. |
temp_beta |
vector of fitted coefficients. |
phen |
list of data matrices containing both left and right information. |
r1 |
Gaussian quadrature nodes. |
k |
Total number of outcomes. |
The output is a vector of the hazard values of the left times.
Calculates the hazard function of the right time interval for outcome l.
haz_right(l, d, temp_beta, phen, r1, k)
haz_right(l, d, temp_beta, phen, r1, k)
l |
Outcome of interest. |
d |
Total number of Gaussian quadrature nodes. |
temp_beta |
vector of fitted coefficients. |
phen |
list of data matrices containing both left and right information. |
r1 |
Gaussian quadrature nodes. |
k |
Total number of outcomes. |
The output is a vector of the hazard values of the right times.
Calculates the Information matrix term of I_theta sigma^2 for outcomes l and m.
sd_off(l, m, phen_l, phen_m, temp_beta, d, apply_diffs, A_i, HL_array, HR_array, no_l_all, no_two_all, tpos_all, obs_all, k)
sd_off(l, m, phen_l, phen_m, temp_beta, d, apply_diffs, A_i, HL_array, HR_array, no_l_all, no_two_all, tpos_all, obs_all, k)
l |
Index of first outcome of interest. |
m |
Index of second outcome of interest. |
phen_l |
List containing the left and right design matrices and interval times for outcome l. |
phen_m |
List containing the left and right design matrices and interval times for outcome m. |
temp_beta |
vector of fitted coefficients. |
d |
Total number of quadrature nodes. |
apply_diffs |
Matrix containing the differences between survival functions of the left and right time intervals. |
A_i |
Product of apply_diffs across all outcomes k summed over all quadrature nodes d. |
HL_array |
n x k matrix containing all the hazard values for the left times. |
HR_array |
n x k matrix containing all the hazard values for the right times. |
no_l_all |
n x (k - 1) matrix containing the product of apply_diffs across all outcomes k excluding the current outcome l. |
no_two_all |
n x (k - 2) matrix containing the product of apply_diffs across all outcomes K excluding outcomes l and m. |
tpos_all |
n x k matrix containing a indictor for whether that time is left-censored or not. |
obs_all |
n x k matrix containing a indictor for whether that time is right-censored or not. |
k |
Total number of outcomes. |
The output is a matrix containing the component of the information matrix of the sigma and theta parameters.
Calculates the Information matrix term of I_sigma^2 sigma^2 for outcome l.
sd_on(l, k, temp_beta, phen, d, apply_diffs, A_i, no_l_all, HL_array, HR_array)
sd_on(l, k, temp_beta, phen, d, apply_diffs, A_i, no_l_all, HL_array, HR_array)
l |
Index of first outcome of interest. |
k |
Total number of outcomes. |
temp_beta |
vector of fitted coefficients. |
phen |
List containing the left and right design matrices and interval times for outcome l. |
d |
Total number of quadrature nodes. |
apply_diffs |
Matrix containing the differences between survival functions of the left and right time intervals. |
A_i |
Product of apply_diffs across all outcomes K summed over all quadrature nodes D. |
no_l_all |
n x (k - 1) matrix containing the product of apply_diffs across all outcomes k excluding the current outcome l. |
HL_array |
n x k matrix containing all the hazard values for the left times. |
HR_array |
n x k matrix containing all the hazard values for the right times. |
The output is a single value for the second derivative with respect to sigma.
Simulates a n x q genetic matrix with the option to specify the common pairwise correlation.
sim_gmat(n,q,rho)
sim_gmat(n,q,rho)
n |
Total number of observations. |
q |
Total number of SNPs. |
rho |
Common pairwise correlation parameter. |
The result of a n x q genetic matrix of q SNPs.
# Set sample size n = 100 # Set number of SNPs q = 5 # Set common pairwise correlation rho = 0.1 # Simulate genetic matrix gMat <- sim_gmat(n, q, rho)
# Set sample size n = 100 # Set number of SNPs q = 5 # Set common pairwise correlation rho = 0.1 # Simulate genetic matrix gMat <- sim_gmat(n, q, rho)
Fit the null model via newton raphson for multiple outcomes interval-censored skat.
simico_fit_null(init_beta, epsilon, xDats, lt_all, rt_all, k, d)
simico_fit_null(init_beta, epsilon, xDats, lt_all, rt_all, k, d)
init_beta |
Starting values for NR. |
epsilon |
Stopping criterion for NR. |
xDats |
List of left and right design matrices. |
lt_all |
n x k matrix of left times. |
rt_all |
n x k matrix of right times. |
k |
Total number of outcomes. |
d |
Total number of quadrature nodes. |
beta_fit |
Vector of fitted coefficients. |
iter |
Number of iterations needed for the Newton-Raphson to converge. |
diff |
Difference between the current values of temp_beta and the previous iteration of temp_beta. |
jmat |
Information matrix of the theta parameters. |
grad |
Vector of the first derivaive of the theta parameters. |
# Set number of outcomes k = 2 # Set number of observations n = 100 # Set number of covariates p = 2 # Set number of SNPs q = 50 # Set number of causal SNPs num = 5 # Set number of quadrature nodes d = 100 # Variance of subject-specific random effect tauSq = 1 # Define the effect sizes effectSizes <- c(.03, .15) # Set MAF cutoff for causal SNPs Causal.MAF.Cutoff = 0.1 # the baseline cumulative hazard function bhFunInv <- function(x) {x} set.seed(1) # Generate covariate matrix xMat <- cbind(rnorm(n), rbinom(n=n, size=1, prob=0.5)) # Generate genetic matrix gMat <- matrix(data=rbinom(n=n*q, size=2, prob=0.1), nrow=n) # Get indices to specific select causal variants idx <- Get_CausalSNPs_bynum(gMat, num, Causal.MAF.Cutoff) # Subset the gMat gMatCausal <- gMat[,idx] # Generate the multiple outcomes exampleDat <- simico_gen_dat(bhFunInv = bhFunInv, obsTimes = 1:3, windowHalf = 0.1, n, p, k, tauSq, gMatCausal, xMat, effectSizes) # Set the initial estimate values init_beta <-c (rep(c(0, 0, 0, 1, 0), k), 1) # Run the Newton-Raphson nullFit <- simico_fit_null(init_beta = init_beta, epsilon = 10^-5, xDats = exampleDat$fullDat$xDats, lt_all = exampleDat$leftTimesMat, rt_all = exampleDat$rightTimesMat, k = k, d = d)
# Set number of outcomes k = 2 # Set number of observations n = 100 # Set number of covariates p = 2 # Set number of SNPs q = 50 # Set number of causal SNPs num = 5 # Set number of quadrature nodes d = 100 # Variance of subject-specific random effect tauSq = 1 # Define the effect sizes effectSizes <- c(.03, .15) # Set MAF cutoff for causal SNPs Causal.MAF.Cutoff = 0.1 # the baseline cumulative hazard function bhFunInv <- function(x) {x} set.seed(1) # Generate covariate matrix xMat <- cbind(rnorm(n), rbinom(n=n, size=1, prob=0.5)) # Generate genetic matrix gMat <- matrix(data=rbinom(n=n*q, size=2, prob=0.1), nrow=n) # Get indices to specific select causal variants idx <- Get_CausalSNPs_bynum(gMat, num, Causal.MAF.Cutoff) # Subset the gMat gMatCausal <- gMat[,idx] # Generate the multiple outcomes exampleDat <- simico_gen_dat(bhFunInv = bhFunInv, obsTimes = 1:3, windowHalf = 0.1, n, p, k, tauSq, gMatCausal, xMat, effectSizes) # Set the initial estimate values init_beta <-c (rep(c(0, 0, 0, 1, 0), k), 1) # Run the Newton-Raphson nullFit <- simico_fit_null(init_beta = init_beta, epsilon = 10^-5, xDats = exampleDat$fullDat$xDats, lt_all = exampleDat$leftTimesMat, rt_all = exampleDat$rightTimesMat, k = k, d = d)
Generate multiple interval-censored data under proportional hazards model.
simico_gen_dat(bhFunInv, obsTimes = 1:3, windowHalf = 0.1, n, p, k, tauSq, gMatCausal, xMat, effectSizes)
simico_gen_dat(bhFunInv, obsTimes = 1:3, windowHalf = 0.1, n, p, k, tauSq, gMatCausal, xMat, effectSizes)
bhFunInv |
The inverse of the baseline hazard function. |
obsTimes |
Vector of the intended observation times. |
windowHalf |
The amount of time before or after the intended obsTimes that a visit might take place. |
n |
Total number of observations. |
p |
Total number of covariates. |
k |
Total number of outcomes. |
tauSq |
Variance of the subject specific random effect. |
gMatCausal |
Matrix of subsetted genetic information for only a select causal SNPs. |
xMat |
Matrix of covariates. |
effectSizes |
Vector of genetic effect sizes. Should be entered as a vector the same length as the number of outcomes. |
exactTimesMat |
n x k matrix containing the simulated exact times that the event occurred. |
leftTimesMat |
n x k matrix containing the left time interval that is observed. |
rightTimesMat |
n x k matrix containing the right time interval that is observed. |
obsInd |
n x k matrix containing a indictor for whether that time is right-censored or not. |
tposInd |
n x k matrix containing a indictor for whether that time is left-censored or not. |
fullDat |
Data in complete form to enter into SIMICO functions. |
# Set number of outcomes k = 2 # Set number of observations n = 100 # Set number of covariates p = 2 # Set number of SNPs q = 50 # Set number of causal SNPs num = 5 # Set number of quadrature nodes d = 100 # Variance of subject-specific random effect tauSq = 1 # Define the effect sizes effectSizes <- c(.03, .15) # Set MAF cutoff for causal SNPs Causal.MAF.Cutoff = 0.1 # the baseline cumulative hazard function bhFunInv <- function(x) {x} set.seed(1) # Generate covariate matrix xMat <- cbind(rnorm(n), rbinom(n=n, size=1, prob=0.5)) # Generate genetic matrix gMat <- matrix(data=rbinom(n=n*q, size=2, prob=0.1), nrow=n) # Get indices to specific select causal variants idx <- Get_CausalSNPs_bynum(gMat, num, Causal.MAF.Cutoff) # Subset the gMat gMatCausal <- gMat[,idx] # Generate the multiple outcomes exampleDat <- simico_gen_dat(bhFunInv = bhFunInv, obsTimes = 1:3, windowHalf = 0.1, n, p, k, tauSq, gMatCausal, xMat, effectSizes)
# Set number of outcomes k = 2 # Set number of observations n = 100 # Set number of covariates p = 2 # Set number of SNPs q = 50 # Set number of causal SNPs num = 5 # Set number of quadrature nodes d = 100 # Variance of subject-specific random effect tauSq = 1 # Define the effect sizes effectSizes <- c(.03, .15) # Set MAF cutoff for causal SNPs Causal.MAF.Cutoff = 0.1 # the baseline cumulative hazard function bhFunInv <- function(x) {x} set.seed(1) # Generate covariate matrix xMat <- cbind(rnorm(n), rbinom(n=n, size=1, prob=0.5)) # Generate genetic matrix gMat <- matrix(data=rbinom(n=n*q, size=2, prob=0.1), nrow=n) # Get indices to specific select causal variants idx <- Get_CausalSNPs_bynum(gMat, num, Causal.MAF.Cutoff) # Subset the gMat gMatCausal <- gMat[,idx] # Generate the multiple outcomes exampleDat <- simico_gen_dat(bhFunInv = bhFunInv, obsTimes = 1:3, windowHalf = 0.1, n, p, k, tauSq, gMatCausal, xMat, effectSizes)
Calculate test statistic and p-values for multiple outcome test and multiple burden test.
simico_out(nullFit, xDats, lt_all, rt_all, Itt, a1, a2, G, k, d)
simico_out(nullFit, xDats, lt_all, rt_all, Itt, a1, a2, G, k, d)
nullFit |
Results of the Newton-Raphson: estimates of the beta coefficients. |
xDats |
List of design matrices. |
lt_all |
Matrix containing the generated left interval times. |
rt_all |
Matrix containing the generated right interval times. |
Itt |
I_theta theta - Information matrix of theta. |
G |
n x q matrix of genetic information. |
a1 |
First shape parameter of beta parameter. |
a2 |
Second shape parameter of beta parameter. |
k |
Total number of outcomes. |
d |
Number of quadrature nodes. |
multQ |
Score statistic for multiple outcome test. |
multP |
P-value for multiple outcome test. |
burdQ |
Score statistic for multiple burden test. |
burdP |
P-value for multiple burden test. |
# Set number of outcomes k = 2 # Set number of observations n = 100 # Set number of covariates p = 2 # Set number of SNPs q = 50 # Set number of causal SNPs num = 5 # Set number of quadrature nodes d = 100 # Variance of subject-specific random effect tauSq = 1 # Define the effect sizes effectSizes <- c(.03, .15) # Set MAF cutoff for causal SNPs Causal.MAF.Cutoff = 0.1 # the baseline cumulative hazard function bhFunInv <- function(x) {x} set.seed(1) # Generate covariate matrix xMat <- cbind(rnorm(n), rbinom(n=n, size=1, prob=0.5)) # Generate genetic matrix gMat <- matrix(data=rbinom(n=n*q, size=2, prob=0.1), nrow=n) # Get indices to specific select causal variants idx <- Get_CausalSNPs_bynum(gMat, num, Causal.MAF.Cutoff) # Subset the gMat gMatCausal <- gMat[,idx] # Generate the multiple outcomes exampleDat <- simico_gen_dat(bhFunInv = bhFunInv, obsTimes = 1:3, windowHalf = 0.1, n, p, k, tauSq, gMatCausal, xMat, effectSizes) # Set the initial estimate values init_beta <-c (rep(c(0, 0, 0, 1, 0), k), 1) # Run the newton-raphson nullFit <- simico_fit_null(init_beta = init_beta, epsilon = 10^-5, xDats = exampleDat$fullDat$xDats, lt_all = exampleDat$leftTimesMat, rt_all = exampleDat$rightTimesMat, k = k, d = d) # Get the test statistics p-values out <- simico_out(nullFit = nullFit$beta_fit, xDats = exampleDat$fullDat$xDats, lt_all = exampleDat$leftTimesMat, rt_all = exampleDat$rightTimesMat, Itt = nullFit$jmat, a1 = 1, a2 = 25, G = gMat, k = k, d = d) # Print results # Score statistic out$multQ # P-values out$multP
# Set number of outcomes k = 2 # Set number of observations n = 100 # Set number of covariates p = 2 # Set number of SNPs q = 50 # Set number of causal SNPs num = 5 # Set number of quadrature nodes d = 100 # Variance of subject-specific random effect tauSq = 1 # Define the effect sizes effectSizes <- c(.03, .15) # Set MAF cutoff for causal SNPs Causal.MAF.Cutoff = 0.1 # the baseline cumulative hazard function bhFunInv <- function(x) {x} set.seed(1) # Generate covariate matrix xMat <- cbind(rnorm(n), rbinom(n=n, size=1, prob=0.5)) # Generate genetic matrix gMat <- matrix(data=rbinom(n=n*q, size=2, prob=0.1), nrow=n) # Get indices to specific select causal variants idx <- Get_CausalSNPs_bynum(gMat, num, Causal.MAF.Cutoff) # Subset the gMat gMatCausal <- gMat[,idx] # Generate the multiple outcomes exampleDat <- simico_gen_dat(bhFunInv = bhFunInv, obsTimes = 1:3, windowHalf = 0.1, n, p, k, tauSq, gMatCausal, xMat, effectSizes) # Set the initial estimate values init_beta <-c (rep(c(0, 0, 0, 1, 0), k), 1) # Run the newton-raphson nullFit <- simico_fit_null(init_beta = init_beta, epsilon = 10^-5, xDats = exampleDat$fullDat$xDats, lt_all = exampleDat$leftTimesMat, rt_all = exampleDat$rightTimesMat, k = k, d = d) # Get the test statistics p-values out <- simico_out(nullFit = nullFit$beta_fit, xDats = exampleDat$fullDat$xDats, lt_all = exampleDat$leftTimesMat, rt_all = exampleDat$rightTimesMat, Itt = nullFit$jmat, a1 = 1, a2 = 25, G = gMat, k = k, d = d) # Print results # Score statistic out$multQ # P-values out$multP
Calculates the first derivative term with respect to sigma^2.
ss_fd(l, phen, HL_array, HR_array, tpos_all, obs_all, apply_diffs, temp_beta, A_i, no_l_all, k, d)
ss_fd(l, phen, HL_array, HR_array, tpos_all, obs_all, apply_diffs, temp_beta, A_i, no_l_all, k, d)
l |
Index of first outcome of interest. |
phen |
List containing all the left and right design matrices. |
HL_array |
n x k matrix containing all the hazard values for the left times. |
HR_array |
n x k matrix containing all the hazard values for the right times. |
tpos_all |
n x k matrix containing a indictor for whether that time is left-censored or not. |
obs_all |
n x k matrix containing a indictor for whether that time is right-censored or not. |
apply_diffs |
Matrix containing the differences between survival functions of the left and right time intervals. |
temp_beta |
vector of fitted coefficients. |
A_i |
Product of apply_diffs across all outcomes k summed over all quadrature nodes d. |
no_l_all |
n x (k - 1) matrix containing the product of apply_diffs across all outcomes k excluding the current outcome l. |
k |
Total number of outcomes. |
d |
Number of quadrature nodes. |
The output is a single value for the first derivative with respect to sigma.
Calculates the second derivative term with respect to sigma^2.
ss_sd(HL_array, HR_array, xAll, apply_diffs, temp_beta, A_i, no_l_all, no_two_all, k, d)
ss_sd(HL_array, HR_array, xAll, apply_diffs, temp_beta, A_i, no_l_all, no_two_all, k, d)
HL_array |
n x k matrix containing all the hazard values for the left times. |
HR_array |
n x k matrix containing all the hazard values for the right times. |
xAll |
List containing the left and right matrices and event times. |
apply_diffs |
Matrix containing the differences between survival functions of the left and right time intervals. |
temp_beta |
vector of fitted coefficients. |
A_i |
Product of apply_diffs across all outcomes K summed over all quadrature nodes D. |
no_l_all |
n x (k - 1) matrix containing the product of apply_diffs across all outcomes k excluding the current outcome l. |
no_two_all |
n x (k - 2) matrix containing the product of apply_diffs across all outcomes k excluding outcomes l and m. |
k |
Total number of outcomes. |
d |
Number of quadrature nodes. |
The output is a single value for the second derivative with respect to sigma^2.
Calculates the Information matrix term of I_eta theta for one outcome of interest l.
st_off(l, HL_array, HR_array, xAll, apply_diffs, temp_beta, A_i, no_l_all, no_two_all, k, d)
st_off(l, HL_array, HR_array, xAll, apply_diffs, temp_beta, A_i, no_l_all, no_two_all, k, d)
l |
Index of first outcome of interest. |
HL_array |
n x k matrix containing all the hazard values for the left times. |
HR_array |
n x k matrix containing all the hazard values for the right times. |
xAll |
List containing the left and right matrices and event times. |
apply_diffs |
Matrix containing the differences between survival functions of the left and right time intervals. |
temp_beta |
vector of fitted coefficients. |
A_i |
Product of apply_diffs across all outcomes K summed over all quadrature nodes D. |
no_l_all |
n x (k - 1) matrix containing the product of apply_diffs across all outcomes k excluding the current outcome l. |
no_two_all |
n x (k - 2) matrix containing the product of apply_diffs across all outcomes k excluding outcomes l and m. |
k |
Total number of outcomes. |
d |
Number of quadrature nodes. |
The output is a matrix containing the component of the information matrix of the theta eta parameters for outcome l.
Calculates the difference between the survival functions of the left and right time intervals for outcome k for quadrature node d.
surv_diff(l, d, temp_beta, phen, r1, k)
surv_diff(l, d, temp_beta, phen, r1, k)
l |
Outcome of interest. |
d |
Total number of Gaussian quadrature nodes. |
temp_beta |
Vector of fitted coefficients. |
phen |
List of data matrices containing both left and right information. |
r1 |
Gaussian quadrature nodes. |
k |
Total number of outcomes. |
The output is a vector of the difference of the survival values of the left times and right times.
Calculates the survival function of the left time interval for outcome k for quadrature node d.
surv_left(l, d, temp_beta, phen, r1, k)
surv_left(l, d, temp_beta, phen, r1, k)
l |
Outcome of interest. |
d |
Total number of Gaussian quadrature nodes. |
temp_beta |
Vector of fitted coefficients. |
phen |
List of data matrices containing both left and right information. |
r1 |
Gaussian quadrature nodes. |
k |
Total number of outcomes. |
The output is a vector of the survival values of the left times.
Calculates the survival function of the right time interval for outcome k for quadrature node d.
surv_right(l, d, temp_beta, phen, r1, k)
surv_right(l, d, temp_beta, phen, r1, k)
l |
Outcome of interest. |
d |
Total number of Gaussian quadrature nodes. |
temp_beta |
Vector of fitted coefficients. |
phen |
List of data matrices containing both left and right information. |
r1 |
Gaussian quadrature nodes. |
k |
Total number of outcomes. |
The output is a vector of the survival values of the left times.
Calculate the product of the difference between survival terms excluding that of the outcome of interest.
without_one_phen(l, k, store)
without_one_phen(l, k, store)
l |
Outcome of interest. |
k |
Total number of outcomes. |
store |
Array of difference between left and right survival values. |
A n x (k-1) matrix where each column is the product of all the differences of left and right survival values across all outcomes excluding the column index outcome.
Differnence of survival functions multiplied across all outcomes excluding outcomes l and m.
without_two_phen(l, m, k, store, n, d)
without_two_phen(l, m, k, store, n, d)
l |
The first outcome of interest. |
m |
The second outcome of interest. |
k |
Total number of outcomes. |
store |
Array of difference between left and right survival values. |
n |
Total number of observation. |
d |
Total number of quadrature nodes. |
A n x (k-2) matrix containing the product of all the differences of left and right survival values across all outcomes excluding outcomes l and m.