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("mfp-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('mfp') Loading required package: survival Loading required package: splines > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "GBSG" > > ### * GBSG > > flush(stderr()); flush(stdout()) > > ### Name: GBSG > ### Title: German Breast Cancer Study Group > ### Aliases: GBSG > ### Keywords: datasets > > ### ** Examples > > data(GBSG) > mfp(Surv(rfst, cens) ~ fp(age, df = 2, select = 0.05) + + fp(prm, df = 4, select = 0.05), family = cox, data = GBSG) Call: mfp(formula = Surv(rfst, cens) ~ fp(age, df = 2, select = 0.05) + fp(prm, df = 4, select = 0.05), data = GBSG, family = cox) Fractional polynomials: df.initial select alpha df.final power1 power2 prm 4 0.05 0.05 2 0 . age 2 0.05 0.05 0 . . coef exp(coef) se(coef) z p prm.1 -0.215 0.807 0.0297 -7.23 4.8e-13 Likelihood ratio test=50.9 on 1 df, p=9.68e-13 n= 686 > > > > > cleanEx(); ..nameEx <- "bodyfat" > > ### * bodyfat > > flush(stderr()); flush(stdout()) > > ### Name: bodyfat > ### Title: percentage of body fat determined by underwater weighing > ### Aliases: bodyfat > ### Keywords: datasets > > ### ** Examples > > data(bodyfat) > bodyfat$height[bodyfat$case==42] <- 69.5 # apparent error > bodyfat <- bodyfat[-which(bodyfat$case==39),] # cp. Royston $\amp$ Sauerbrei, 2004 > mfp(siri ~ fp(age, df = 4, select = 0.1) + fp(weight, df = 4, select = 0.1) + + fp(height, df = 4, select = 0.1), family = gaussian, data = bodyfat) Call: mfp(formula = siri ~ fp(age, df = 4, select = 0.1) + fp(weight, df = 4, select = 0.1) + fp(height, df = 4, select = 0.1), data = bodyfat, family = gaussian) Fractional polynomials: df.initial select alpha df.final power1 power2 weight 4 0.1 0.05 2 -0.5 . height 4 0.1 0.05 1 1 . age 4 0.1 0.05 1 1 . Coefficients: Intercept weight.1 height.1 age.1 203.13 -1239.24 -1.37 0.13 Degrees of Freedom: 250 Total (i.e. Null); 247 Residual Null Deviance: 17300 Residual Deviance: 6860 AIC: 1550 > > > > cleanEx(); ..nameEx <- "fp" > > ### * fp > > flush(stderr()); flush(stdout()) > > ### Name: fp > ### Title: Fractional Polynomial Transformation > ### Aliases: fp > > > ### ** Examples > > ## Not run: > ##D fp(x, df = 4, select = 0.05, scale = FALSE) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "mfp" > > ### * mfp > > flush(stderr()); flush(stdout()) > > ### Name: mfp > ### Title: Fit a Multiple Fractional Polynomial Model > ### Aliases: mfp > ### Keywords: models > > ### ** Examples > > data(GBSG) > f <- mfp(Surv(rfst, cens) ~ fp(age, df = 4, select = 0.05) + + fp(prm, df = 4, select = 0.05), family = cox, data = GBSG) > print(f) Call: mfp(formula = Surv(rfst, cens) ~ fp(age, df = 4, select = 0.05) + fp(prm, df = 4, select = 0.05), data = GBSG, family = cox) Fractional polynomials: df.initial select alpha df.final power1 power2 prm 4 0.05 0.05 2 0 . age 4 0.05 0.05 4 -2 -0.5 coef exp(coef) se(coef) z p prm.1 -0.215 8.07e-01 0.0298 -7.22 5.4e-13 age.1 4070.015 Inf 833.4929 4.88 1.0e-06 age.2 -49.603 2.87e-22 12.4620 -3.98 6.9e-05 Likelihood ratio test=68.3 on 3 df, p=9.77e-15 n= 686 > survfit(f$fit) # use proposed coxph model fit for survival curve estimation Call: survfit.coxph(object = f$fit) n events median 0.95LCL 0.95UCL 672 299 1814 1589 2034 > > > > cleanEx(); ..nameEx <- "plot.mfp" > > ### * plot.mfp > > flush(stderr()); flush(stdout()) > > ### Name: plot.mfp > ### Title: Plots for mfp objects > ### Aliases: plot.mfp > > > ### ** Examples > > data(GBSG) > f <- mfp(Surv(rfst, cens) ~ fp(age, df = 4, select = 0.05) + + fp(prm, df = 4, select = 0.05), family = cox, data = GBSG) > par(mfrow=c(2,2), mar=c(4,4,1,1), mgp=c(1.5,0.75,0)) > plot(f, var="age") > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > ### *