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("cslogistic-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('cslogistic') ## ## Conditionally Specified Logistic Regression Model Package (cslogistic) ## Copyright (C) 2005, Alejandro Jara and Maria Jose Garcia-Zattera ## ## Support provided by the Katholieke Universiteit Leuven ## (Research Grant OT / 00 / 35) ## > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "BayesCslogistic" > > ### * BayesCslogistic > > flush(stderr()); flush(stdout()) > > ### Name: BayesCslogistic > ### Title: Perform a Bayesian Analysis of a conditionally specified > ### logistic regression model > ### Aliases: BayesCslogistic > ### Keywords: regression > > ### ** Examples > > # simulated data set > > library(mvtnorm) > > n<-400 > mu1<-c(-1.5,-0.5) > Sigma1<-matrix(c(1, -0.175,-0.175,1),ncol=2) > age<-as.vector(sample(seq(5,6,0.1),n,replace=TRUE)) > beta1<-0.2 > > z<-rmvnorm(n,mu1,Sigma1) > zz<-cbind(z[,1]+beta1*age,z[,2]+beta1*age) > datos<-cbind(zz[,1]>0,zz[,2]>0,age) > colnames(datos)<-c("y1","y2","age") > data0<-data.frame(datos) > attach(data0) > > # equal effect of age for all the covariates > > y<-cbind(y1,y2) > > fit0<-BayesCslogistic(y~age) > fit0 Bayesian conditionally specified logistic regression model Call: BayesCslogistic(formula = y ~ age) Posterior Inference of Coefficients: (Intercept) age alpha12 1.1537 -0.1092 -0.8997 Acceptation Rate for the Metropolis Algorihtm = 0.4125454 > summary(fit0) Bayesian conditionally specified logistic regression model Call: BayesCslogistic(formula = y ~ age) Posterior Inference of Coefficients: Mean Median Std. Dev. Naive Std.Error 95%HPD-Lower (Intercept) 1.153750 1.103653 1.466536 0.014665 -1.658475 age -0.109169 -0.104871 0.264629 0.002646 -0.598000 alpha12 -0.899655 -0.901984 0.207043 0.002070 -1.289015 95%HPD-Upper (Intercept) 4.001806 age 0.426883 alpha12 -0.482565 Acceptation Rate for the Metropolis Algorihtm = 0.4125454 > plot(fit0) > > # different effects: only intercept > > fit1<-BayesCslogistic(y~age,type=FALSE) > fit1 Bayesian conditionally specified logistic regression model Call: BayesCslogistic(formula = y ~ age, type = FALSE) Posterior Inference of Coefficients: (Intercept):1 (Intercept):2 age alpha12 0.4022 1.7068 -0.1256 -0.5082 Acceptation Rate for the Metropolis Algorihtm = 0.3363636 > summary(fit1) Bayesian conditionally specified logistic regression model Call: BayesCslogistic(formula = y ~ age, type = FALSE) Posterior Inference of Coefficients: Mean Median Std. Dev. Naive Std.Error 95%HPD-Lower (Intercept):1 0.402209 0.433551 1.451459 0.014515 -2.436625 (Intercept):2 1.706809 1.723342 1.457825 0.014578 -1.138741 age -0.125607 -0.125326 0.263141 0.002631 -0.656657 alpha12 -0.508222 -0.511533 0.223883 0.002239 -0.936403 95%HPD-Upper (Intercept):1 3.265027 (Intercept):2 4.561795 age 0.369043 alpha12 -0.079823 Acceptation Rate for the Metropolis Algorihtm = 0.3363636 > plot(fit1) > > # different effects: all the covariates > > fit2<-BayesCslogistic(y~age,type=FALSE,intercept=FALSE) > fit2 Bayesian conditionally specified logistic regression model Call: BayesCslogistic(formula = y ~ age, type = FALSE, intercept = FALSE) Posterior Inference of Coefficients: (Intercept):1 age:1 (Intercept):2 age:2 alpha12 -1.9285 0.2947 3.9624 -0.5378 -0.4749 Acceptation Rate for the Metropolis Algorihtm = 0.2665454 > summary(fit2) Bayesian conditionally specified logistic regression model Call: BayesCslogistic(formula = y ~ age, type = FALSE, intercept = FALSE) Posterior Inference of Coefficients: Mean Median Std. Dev. Naive Std.Error 95%HPD-Lower (Intercept):1 -1.928458 -1.956585 1.866771 0.018668 -5.492961 age:1 0.294735 0.302644 0.336342 0.003363 -0.349955 (Intercept):2 3.962418 3.967766 1.916736 0.019167 -0.032147 age:2 -0.537760 -0.539059 0.348100 0.003481 -1.164818 alpha12 -0.474909 -0.471921 0.219259 0.002193 -0.891810 95%HPD-Upper (Intercept):1 1.662431 age:1 0.943325 (Intercept):2 7.390904 age:2 0.176313 alpha12 -0.027869 Acceptation Rate for the Metropolis Algorihtm = 0.2665454 > plot(fit2) > > > > > cleanEx(); ..nameEx <- "MleCslogistic" > > ### * MleCslogistic > > flush(stderr()); flush(stdout()) > > ### Name: MleCslogistic > ### Title: Perform a Maximum Likelihood Analysis of a conditionally > ### specified logistic regression model > ### Aliases: MleCslogistic > ### Keywords: regression > > ### ** Examples > > # simulated data set > > library(mvtnorm) > > n<-400 > mu1<-c(-1.5,-0.5) > Sigma1<-matrix(c(1, -0.175,-0.175,1),ncol=2) > age<-as.vector(sample(seq(5,6,0.1),n,replace=TRUE)) > beta1<-0.2 > > z<-rmvnorm(n,mu1,Sigma1) > zz<-cbind(z[,1]+beta1*age,z[,2]+beta1*age) > datos<-cbind(zz[,1]>0,zz[,2]>0,age) > colnames(datos)<-c("y1","y2","age") > data0<-data.frame(datos) > attach(data0) > > # equal effect of age for all the covariates > > y<-cbind(y1,y2) > > fit0<-MleCslogistic(y~age) > fit0 Conditional specified logistic regression model Call: MleCslogistic(formula = y ~ age) Coefficients: (Intercept) age alpha12 1.1309 -0.1054 -0.8865 log-likelihood -544.1964 > summary(fit0) Conditional specified logistic regression model Call: MleCslogistic(formula = y ~ age) Coefficients: Estimate Std. Error OR Lower Upper (Intercept) 1.131e+00 1.443e+00 3.098e+00 1.831e-01 5.243e+01 age -1.054e-01 2.612e-01 8.999e-01 5.394e-01 1.501e+00 alpha12 -8.865e-01 2.056e-01 4.121e-01 2.754e-01 6.166e-01 Pr(>|z|) (Intercept) 4.333e-01 age 6.864e-01 alpha12 1.619e-05 log-likelihood -544.1964 > > # different effects: only intercept > > fit1<-MleCslogistic(y~age,type=FALSE) > fit1 Conditional specified logistic regression model Call: MleCslogistic(formula = y ~ age, type = FALSE) Coefficients: (Intercept):1 (Intercept):2 age alpha12 0.2823 1.5833 -0.1054 -0.4902 log-likelihood -501.9267 > summary(fit1) Conditional specified logistic regression model Call: MleCslogistic(formula = y ~ age, type = FALSE) Coefficients: Estimate Std. Error OR Lower Upper Pr(>|z|) (Intercept):1 0.28226 1.44844 1.32613 0.07757 22.67242 0.84549 (Intercept):2 1.58329 1.44360 4.87096 0.28762 82.49119 0.27274 age -0.10544 0.26116 0.89993 0.53940 1.50144 0.68642 alpha12 -0.49016 0.22422 0.61253 0.39471 0.95056 0.02881 log-likelihood -501.9267 > > # different effects: all the covariates > > fit2<-MleCslogistic(y~age,type=FALSE,intercept=FALSE) > fit2 Conditional specified logistic regression model Call: MleCslogistic(formula = y ~ age, type = FALSE, intercept = FALSE) Coefficients: (Intercept):1 age:1 (Intercept):2 age:2 alpha12 -1.9113 0.2919 3.9293 -0.5328 -0.4746 log-likelihood -500.3825 > summary(fit2) Conditional specified logistic regression model Call: MleCslogistic(formula = y ~ age, type = FALSE, intercept = FALSE) Coefficients: Estimate Std. Error OR Lower Upper (Intercept):1 -1.911e+00 1.921e+00 1.479e-01 3.426e-03 6.384e+00 age:1 2.919e-01 3.457e-01 1.339e+00 6.800e-01 2.636e+00 (Intercept):2 3.929e+00 1.973e+00 5.087e+01 1.065e+00 2.431e+03 age:2 -5.328e-01 3.576e-01 5.870e-01 2.912e-01 1.183e+00 alpha12 -4.746e-01 2.250e-01 6.221e-01 4.003e-01 9.669e-01 Pr(>|z|) (Intercept):1 3.198e-01 age:1 3.984e-01 (Intercept):2 4.641e-02 age:2 1.363e-01 alpha12 3.488e-02 log-likelihood -500.3825 > > > > > ### *