if (FALSE) {
# Example1: Simulate family data
set.seed(4321)
fam <- simfam(N.fam = 100, design = "pop+", variation = "none", base.dist = "Weibull",
base.parms = c(0.01, 3), vbeta = c(-1.13, 2.35), allelefreq = 0.02)
# summary of simulated family data
summary(fam)
# Pedigree plots for family 1 and 2
plot(fam, famid = c(1,2))
# penetrance function plots given model parameter values for Weibull baseline
penplot(base.parms = c(0.01, 3), vbeta = c(-1.3, 2.35), base.dist = "Weibull",
variation = "none", agemin = 20)
# model fit of family data
fit <- penmodel(Surv(time, status) ~ gender + mgene, cluster = "famID", design = "pop+",
parms=c(0.01, 3, -1.13, 2.35), data = fam, base.dist = "Weibull", robust = TRUE)
# summary of estimated model parameters and penetrance estimates
summary(fit)
# penetrance curves useful for model checking
plot(fit)
## Example 2: Simulate family data from a correlated frailty model
# with Kinship and IBD matrices given pedigree data.
# Inputdata and IBD matrix should be provided;
# Inputdata was generated as an example using simfam.
data <- simfam(N.fam = 10, design = "noasc", variation = "none",
base.dist = "Weibull", base.parms = c(0.016, 3), vbeta = c(1, 1))
IBDmatrix <- diag(1, dim(data)[1])
data <- data[ , c(1:7, 11, 14)]
fam2 <- simfam2(inputdata = data, IBD = IBDmatrix, design = "pop",
variation = c("kinship","IBD"), depend = c(1, 1),
base.dist = "Weibull", base.parms = c(0.016, 3),
var_names = c("gender", "mgene"), vbeta = c(1,1),
agemin=20)
summary(fam2)
### Example 3: Simulate correlated competing risks family data
set.seed(4321)
fam3 <- simfam_cmp(N.fam = 200, design = "pop+", variation = "frailty",
base.dist = "Weibull", frailty.dist = "cgamma", depend=c(1, 2, 0.5),
allelefreq = 0.02, base.parms = list(c(0.01, 3), c(0.01, 3)),
vbeta = list(c(-1.13, 2.35), c(-1, 2)))
# summary of simulated family data
summary(fam3)
# Pedigree plots for family 1
plot(fam3, famid = 1)
# penetrance function plot for event 1 given model parameter values for Weibull baseline
penplot_cmp(event = 1, base.parms = list(c(0.01, 3), c(0.01, 3)),
vbeta = list(c(-1.3, 2.35), c(-1, 2)), base.dist = "Weibull",
variation = "frailty", frailty.dist = "cgamma",
depend=c(1,2,0.5), agemin = 20)
# Fitting shared correlated gamma frailty Penetrance model for simulated competing risk data
fit3 <- penmodel_cmp(
formula1 = Surv(time, status==1) ~ gender + mgene,
formula2 = Surv(time, status==2) ~ gender + mgene,
cluster = "famID", gvar = "mgene", design = "pop+",
parms = list(c(0.01, 3, -1, 2), c(0.01, 3, -1, 2), c(0.5, 1, 0.5)),
base.dist = "Weibull", frailty.dist = "cgamma", data = fam2, robust = TRUE)
# Summary of the model parameter estimates from the model fit
summary(fit3)
# Plot the lifetime penetrance curves with 95
# gender and mutation status groups along with their nonparametric penetrance curves
# based on data excluding probands.
plot(fit3, add.CIF = TRUE, conf.int = TRUE, MC = 100)
### Example 4: Simulate family data with a time-varying covariate
set.seed(4321)
fam4 <- simfam_tvc(N.fam = 10, design = "pop", variation = "frailty",
base.dist = "Weibull", frailty.dist = "gamma", depend = 1,
add.tvc = TRUE, tvc.type = "CO", tvc.range = c(30,60),
tvc.parms = c(1, 0.1, 0), allelefreq = 0.02,
base.parms = c(0.01, 3), vbeta = c(-1.13, 2.35))
summary(fam4)
}
Run the code above in your browser using DataLab