R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("bayesSurv-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('bayesSurv') Loading required package: survival Loading required package: splines Loading required package: coda > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "bayessurvreg1" > > ### * bayessurvreg1 > > flush(stderr()); flush(stdout()) > > ### Name: bayessurvreg1 > ### Title: A Bayesian survival regression with a flexible error > ### distribution. > ### Aliases: bayessurvreg1 > ### Keywords: survival regression > > ### ** Examples > > ## There are two vignettes with this package that describe analyses presented > ## in Komarek and Lesaffre (2004). You should find them in /doc directory > ## of this library (cgd1.Rnw, tandmob.Rnw are sources to create the vignettes). > > ## I hope they give enough material to understand how the package works. > > > > cleanEx(); ..nameEx <- "files2coda" > > ### * files2coda > > flush(stderr()); flush(stdout()) > > ### Name: files2coda > ### Title: Read the sampled values from the Bayesian survival regression > ### model to a coda mcmc object. > ### Aliases: files2coda > ### Keywords: connection > > ### ** Examples > > ## *** illustration of usage of parameters 'data.frames' and 'chain' *** > ## ********************************************************************* > ## Two parallel chains with four variables, stored in data.frames > ## data.frames are further stored in lists > library(coda) > > group1 <- list(); group2 <- list(); group3 <- list() > ## first chain of first two variables: > group1[[1]] <- data.frame(var1 = rnorm(100, 0, 1), var2 = rnorm(100, 5, 4)) > ## second chain of first two variables: > group1[[2]] <- data.frame(var1 = rnorm(100, 0, 1), var2 = rnorm(100, 5, 4)) > ## first chain of the third variable: > group2[[1]] <- data.frame(var3 = rgamma(100, 1, 1)) > ## second chain of the third variable: > group2[[2]] <- data.frame(var3 = rgamma(100, 1, 1)) > ## first chain of the fourth variable: > group3[[1]] <- data.frame(var4 = rbinom(100, 1, 0.4)) > ## second chain of the fourth variable: > group3[[2]] <- data.frame(var4 = rbinom(100, 1, 0.4)) > > ## Create mcmc objects for each chain separately > mc.chain1 <- files2coda(data.frames = c("group1", "group2", "group3"), chain = 1) > mc.chain2 <- files2coda(data.frames = c("group1", "group2", "group3"), chain = 2) > > ## Create mcmc.list to represent two parallel chains > mc <- mcmc.list(mc.chain1, mc.chain2) > rm(mc.chain1, mc.chain2) > > ## *** illustration of usage of parameter 'data.frames' without 'chain' *** > ## ************************************************************************ > ## Only one chain for four variables was sampled and stored in three data.frames > ## chain of first two variables: > group1 <- data.frame(var1 = rnorm(100, 0, 1), var2 = rnorm(100, 5, 4)) > ## chain of the third variable: > group2 <- data.frame(var3 = rgamma(100, 1, 1)) > ## chain of the fourth variable: > group3 <- data.frame(var4 = rbinom(100, 1, 0.4)) > > ## Create an mcmc object > mc <- files2coda(data.frames = c("group1", "group2", "group3")) > > > > cleanEx(); ..nameEx <- "predictive" > > ### * predictive > > flush(stderr()); flush(stdout()) > > ### Name: predictive > ### Title: Compute predictive quantities based on a Bayesian survival > ### regression model. > ### Aliases: predictive predictive.control > ### Keywords: survival regression > > ### ** Examples > > ## See attached files. > > > > cleanEx(); ..nameEx <- "sampleCovMat" > > ### * sampleCovMat > > flush(stderr()); flush(stdout()) > > ### Name: sampleCovMat > ### Title: Compute a sample covariance matrix. > ### Aliases: sampleCovMat > ### Keywords: multivariate > > ### ** Examples > > ## Sample some values > z1 <- rnorm(100, 0, 1) ## first components of y > z2 <- rnorm(100, 5, 2) ## second components of y > z3 <- rnorm(100, 10, 0.5) ## third components of y > > ## Put them into a data.frame > sample <- data.frame(z1, z2, z3) > > ## Compute a sample covariance matrix > sampleCovMat(sample) z1 z2 z3 z1 0.806762090 -0.001710959 0.00853831 z2 -0.001710959 3.670129248 -0.04907559 z3 0.008538311 -0.049075590 0.26742628 > > > > ### *