File: rcspline.plot.Rd

package info (click to toggle)
hmisc 3.14-5-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,792 kB
  • ctags: 701
  • sloc: asm: 23,440; fortran: 600; ansic: 375; xml: 160; makefile: 1
file content (140 lines) | stat: -rw-r--r-- 4,677 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
\name{rcspline.plot}
\alias{rcspline.plot}
\title{
  Plot Restricted Cubic Spline Function
}
\description{
  Provides plots of the estimated restricted cubic spline function
  relating a single predictor to the response for a logistic or Cox
  model. The \code{rcspline.plot} function does not allow for
  interactions as do \code{\link[rms]{lrm}} and \code{\link[rms]{cph}}, but it can
  provide detailed output for checking spline fits. This function uses
  the \code{\link{rcspline.eval}}, \code{\link[rms]{lrm.fit}}, and Therneau's
  \code{\link{coxph.fit}} functions and plots the estimated spline
  regression and confidence limits, placing summary statistics on the
  graph. If there are no adjustment variables, \code{rcspline.plot} can
  also plot two alternative estimates of the regression function when
  \code{model="logistic"}: proportions or logit proportions on grouped
  data, and a nonparametric estimate. The nonparametric regression
  estimate is based on smoothing the binary responses and taking the
  logit transformation of the smoothed estimates, if desired. The
  smoothing uses \code{\link{supsmu}}.
}
\usage{
rcspline.plot(x,y,model=c("logistic", "cox", "ols"), xrange, event, nk=5,
              knots=NULL, show=c("xbeta","prob"), adj=NULL, xlab, ylab,
              ylim, plim=c(0,1), plotcl=TRUE, showknots=TRUE, add=FALSE,
              subset, lty=1, noprint=FALSE, m, smooth=FALSE, bass=1,
              main="auto", statloc)
}
\arguments{
  \item{x}{
    a numeric predictor
  }
  \item{y}{
    a numeric response. For binary logistic regression, \code{y} should
    be either 0 or 1.
  }
  \item{model}{
    \code{"logistic"} or \code{"cox"}. For \code{"cox"}, uses the
    \code{coxph.fit} function with \code{method="efron"} arguement set.
  }
  \item{xrange}{
    range for evaluating \code{x}, default is \var{f} and
    \eqn{1 - \var{f}} quantiles of \code{x}, where
    \eqn{\var{f} = \frac{10}{\max{(\var{n}, 200)}}}{\var{f} = 10/max(\var{n}, 200)}
  }
  \item{event}{
    event/censoring indicator if \code{model="cox"}. If \code{event} is
    present, \code{model} is assumed to be \code{"cox"}
  }
  \item{nk}{
    number of knots
  }
  \item{knots}{
    knot locations, default based on quantiles of \code{x} (by
    \code{\link{rcspline.eval}}) 
  }
  \item{show}{
    \code{"xbeta"} or \code{"prob"} - what is plotted on \verb{y}-axis
  }
  \item{adj}{
    optional matrix of adjustment variables
  }
  \item{xlab}{
    \verb{x}-axis label, default is the \dQuote{label} attribute of
    \code{x} 
  }
  \item{ylab}{
    \verb{y}-axis label, default is the \dQuote{label} attribute of
    \code{y}
  }
  \item{ylim}{
    \verb{y}-axis limits for logit or log hazard
  }
  \item{plim}{
    \verb{y}-axis limits for probability scale
  }
  \item{plotcl}{
    plot confidence limits
  }
  \item{showknots}{
    show knot locations with arrows
  }
  \item{add}{
    add this plot to an already existing plot
  }
  \item{subset}{
    subset of observations to process, e.g. \code{sex == "male"}
  }
  \item{lty}{
    line type for plotting estimated spline function
  }
  \item{noprint}{
    suppress printing regression coefficients and standard errors
  }
  \item{m}{
    for \code{model="logistic"}, plot grouped estimates with
    triangles. Each group contains \code{m} ordered observations on
    \code{x}.
  }
  \item{smooth}{
    plot nonparametric estimate if \code{model="logistic"} and
    \code{adj} is not specified
  }
  \item{bass}{
    smoothing parameter (see \code{supsmu})
  }
  \item{main}{
    main title, default is \code{"Estimated Spline Transformation"}
  }
  \item{statloc}{
    location of summary statistics. Default positioning by clicking left
    mouse button where upper left corner of statistics should
    appear. Alternative is \code{"ll"} to place below the graph on the
    lower left, or the actual \code{x} and \code{y} coordinates. Use
    \code{"none"} to suppress statistics.
  }
}
\value{
  list with components (\samp{knots}, \samp{x}, \samp{xbeta},
  \samp{lower}, \samp{upper}) which are respectively the knot locations,
  design matrix, linear predictor, and lower and upper confidence limits
}
\author{
  Frank Harrell  \cr
  Department of Biostatistics, Vanderbilt University  \cr
  \email{f.harrell@vanderbilt.edu}
}
\seealso{
  \code{\link[rms]{lrm}}, \code{\link[rms]{cph}}, \code{\link{rcspline.eval}},
  \code{\link[graphics]{plot}}, \code{\link{supsmu}},
  \code{\link[survival:survival-internal]{coxph.fit}},
  \code{\link[rms]{lrm.fit}}
}
\examples{
#rcspline.plot(cad.dur, tvdlm, m=150)
#rcspline.plot(log10(cad.dur+1), tvdlm, m=150)
}
\keyword{regression}
\keyword{models}