rmsMisc | R Documentation |
These functions are used internally to anova.rms
,
fastbw
, etc., to retrieve various attributes of a design. These
functions allow some fitting functions not in the rms
series
(e.g,, lm
, glm
) to be used with rms.Design
,
fastbw
, and similar functions.
For vcov
, there are several functions. The method for orm
fits is a bit different because the covariance matrix stored in the fit
object only deals with the middle intercept. See the intercepts
argument for more options. There is a method for lrm
that also
allows non-default intercept(s) to be selected (default is first).
The oos.loglik
function for
each type of model implemented computes the -2 log likelihood for
out-of-sample data (i.e., data not necessarily used to fit the model)
evaluated at the parameter estimates from a model fit. Vectors for the
model's linear predictors and response variable must be given.
oos.loglik
is used primarily by bootcov
.
The Getlim
function retrieves distribution summaries
from the fit or from a datadist
object. It handles getting summaries
from both sources to fill in characteristics for variables that were not
defined during the model fit. Getlimi
returns the summary
for an individual model variable.
Mean
is a generic function that creates an R function that
calculates the expected value of the response variable given a fit from
rms
or rmsb
.
The related.predictors
function
returns a list containing variable numbers that are directly or
indirectly related to each predictor. The interactions.containing
function returns indexes of interaction effects containing a given
predictor. The param.order
function returns a vector of logical
indicators for whether parameters are associated with certain types of
effects (nonlinear, interaction, nonlinear interaction).
combineRelatedPredictors
creates of list of inter-connected main
effects and interations for use with predictrms
with
type='ccterms'
(useful for gIndex
).
The Penalty.matrix
function builds a default penalty matrix for
non-intercept term(s) for use in penalized maximum likelihood
estimation. The Penalty.setup
function takes a constant or list
describing penalty factors for each type of term in the model and
generates the proper vector of penalty multipliers for the current model.
logLik.rms
returns the maximized log likelihood for the model,
whereas AIC.rms
returns the AIC. The latter function has an
optional argument for computing AIC on a "chi-square" scale (model
likelihood ratio chi-square minus twice the regression degrees of
freedom. logLik.ols
handles the case for ols
, just by
invoking logLik.lm
in the stats
package.
logLik.Gls
is also defined.
nobs.rms
returns the number of observations used in the fit.
The lrtest
function does likelihood ratio tests for
two nested models, from fits that have stats
components with
"Model L.R."
values. For models such as psm, survreg, ols, lm
which have
scale parameters, it is assumed that scale parameter for the smaller model
is fixed at the estimate from the larger model (see the example).
univarLR
takes a multivariable model fit object from
rms
and re-fits a sequence of models containing one predictor
at a time. It prints a table of likelihood ratio chi^2
statistics
from these fits.
The Newlabels
function is used to override the variable labels in a
fit object. Likewise, Newlevels
can be used to create a new fit object
with levels of categorical predictors changed. These two functions are
especially useful when constructing nomograms.
rmsArgs
handles ... arguments to functions such as
Predict
, summary.rms
, nomogram
so that variables to
vary may be specified without values (after an equals sign).
prModFit
is the workhorse for the print
methods for
highest-level rms
model fitting functions, handling both regular,
html, and LaTeX printing, the latter two resulting in html or LaTeX code
written to the console, automatically ready for knitr
. The work
of printing
summary statistics is done by prStats
, which uses the Hmisc
print.char.matrix
function to print overall model statistics if
options(prType=)
was not set to "latex"
or "html"
.
Otherwise it generates customized LaTeX or html
code. The LaTeX longtable and epic packages must be in effect to use LaTeX.
reListclean
allows one to rename a subset of a named list,
ignoring the previous names and not concatenating them as R does. It
also removes NULL
elements and (by default) elements that are
NA
, as when an
optional named element is fetched that doesn't exist. It has an
argument dec
whose elements are correspondingly removed, then
dec
is appended to the result vector.
formatNP
is a function to format a vector of numerics. If
digits
is specified, formatNP
will make sure that the
formatted representation has digits
positions to the right of the
decimal place. If lang="latex"
it will translate any scientific
notation to LaTeX math form. If lang="html"
will convert to html.
If pvalue=TRUE
, it will replace
formatted values with "< 0.0001" (if digits=4
).
latex.naprint.delete
will, if appropriate, use LaTeX to draw a
dot chart of frequency of variable NA
s related to model fits.
html.naprint.delete
does the same thing in the RStudio R markdown
context, using Hmisc:dotchartp
(which uses plotly
) for
drawing any needed dot chart.
removeFormulaTerms
removes one or more terms from a model
formula, using strictly character manipulation. This handles problems
such as [.terms
removing offset()
if you subset on
anything. The function can also be used to remove the dependent
variable(s) from the formula.
## S3 method for class 'rms'
vcov(object, regcoef.only=TRUE, intercepts='all', ...)
## S3 method for class 'cph'
vcov(object, regcoef.only=TRUE, ...)
## S3 method for class 'Glm'
vcov(object, regcoef.only=TRUE, intercepts='all', ...)
## S3 method for class 'Gls'
vcov(object, intercepts='all', ...)
## S3 method for class 'lrm'
vcov(object, regcoef.only=TRUE, intercepts='all', ...)
## S3 method for class 'ols'
vcov(object, regcoef.only=TRUE, ...)
## S3 method for class 'orm'
vcov(object, regcoef.only=TRUE, intercepts='mid', ...)
## S3 method for class 'psm'
vcov(object, regcoef.only=TRUE, ...)
# Given Design attributes and number of intercepts creates R
# format assign list. atr non.slopes Terms
DesignAssign(atr, non.slopes, Terms)
oos.loglik(fit, ...)
## S3 method for class 'ols'
oos.loglik(fit, lp, y, ...)
## S3 method for class 'lrm'
oos.loglik(fit, lp, y, ...)
## S3 method for class 'cph'
oos.loglik(fit, lp, y, ...)
## S3 method for class 'psm'
oos.loglik(fit, lp, y, ...)
## S3 method for class 'Glm'
oos.loglik(fit, lp, y, ...)
Getlim(at, allow.null=FALSE, need.all=TRUE)
Getlimi(name, Limval, need.all=TRUE)
related.predictors(at, type=c("all","direct"))
interactions.containing(at, pred)
combineRelatedPredictors(at)
param.order(at, term.order)
Penalty.matrix(at, X)
Penalty.setup(at, penalty)
## S3 method for class 'Gls'
logLik(object, ...)
## S3 method for class 'ols'
logLik(object, ...)
## S3 method for class 'rms'
logLik(object, ...)
## S3 method for class 'rms'
AIC(object, ..., k=2, type=c('loglik', 'chisq'))
## S3 method for class 'rms'
nobs(object, ...)
lrtest(fit1, fit2)
## S3 method for class 'lrtest'
print(x, ...)
univarLR(fit)
Newlabels(fit, ...)
Newlevels(fit, ...)
## S3 method for class 'rms'
Newlabels(fit, labels, ...)
## S3 method for class 'rms'
Newlevels(fit, levels, ...)
prModFit(x, title, w, digits=4, coefs=TRUE, footer=NULL,
lines.page=40, long=TRUE, needspace, subtitle=NULL, ...)
prStats(labels, w, lang=c("plain", "latex", "html"))
reListclean(..., dec=NULL, na.rm=TRUE)
formatNP(x, digits=NULL, pvalue=FALSE,
lang=c("plain", "latex", "html"))
## S3 method for class 'naprint.delete'
latex(object, file="", append=TRUE, ...)
## S3 method for class 'naprint.delete'
html(object, ...)
removeFormulaTerms(form, which=NULL, delete.response=FALSE)
fit |
result of a fitting function |
object |
result of a fitting function |
regcoef.only |
For fits such as parametric survival models
which have a final row and column of the covariance matrix for a
non-regression parameter such as a log(scale) parameter, setting
|
intercepts |
set to |
at |
|
pred |
index of a predictor variable (main effect) |
fit1 , fit2 |
fit objects from |
lp |
linear predictor vector for |
y |
values of a new vector of responses passed to |
name |
the name of a variable in the model |
Limval |
an object returned by |
allow.null |
prevents |
need.all |
set to |
type |
For |
term.order |
1 for all parameters, 2 for all parameters associated with either nonlinear or interaction effects, 3 for nonlinear effects (main or interaction), 4 for interaction effects, 5 for nonlinear interaction effects. |
X |
a design matrix, not including columns for intercepts |
penalty |
a vector or list specifying penalty multipliers for types of model terms |
k |
the multiplier of the degrees of freedom to be used in computing AIC. The default is 2. |
x |
a result of |
labels |
a character vector specifying new labels for variables in a fit.
To give new labels for all variables, you can specify |
levels |
a list of named vectors specifying new level labels for categorical
predictors. This will override |
title |
a single character string used to specify an overall title
for the regression fit, which is printed first by |
w |
For |
digits |
number of digits to the right of the decimal point, for formatting numeric values in printed output |
coefs |
specify |
footer |
a character string to appear at the bottom of the regression model output |
file |
name of file to which to write model output |
append |
specify |
lang |
specifies the typesetting language: plain text, LaTeX, or html |
lines.page |
see |
long |
set to |
needspace |
optional character string to insert inside a LaTeX
needspace macro call before the statistics table and before the
coefficient matrix, to avoid bad page splits. This assumes the LaTeX
needspace style is available. Example:
|
subtitle |
optional vector of character strings containing
subtitles that will appear under |
dec |
vector of decimal places used for rounding |
na.rm |
set to |
pvalue |
set to |
form |
a formula object |
which |
a vector of one or more character strings specifying the
names of functions that are called from a formula, e.g.,
|
delete.response |
set to |
atr , non.slopes , Terms |
|
... |
other arguments. For |
vcov
returns a variance-covariance matrix
oos.loglik
returns a scalar -2 log likelihood value.
Getlim
returns a list with components limits
and values
, either
stored in fit
or retrieved from the object created by datadist
and
pointed to in options(datadist=)
.
related.predictors
and combineRelatedPredictors
return a
list of vectors, and interactions.containing
returns a vector. param.order
returns a logical vector corresponding
to non-strata terms in the model.
Penalty.matrix
returns a symmetric matrix with dimension equal to the
number of slopes in the model. For all but categorical predictor main
effect elements, the matrix is diagonal with values equal to the variances
of the columns of X
. For segments corresponding to c-1
dummy variables
for c
-category predictors, puts a c-1
x c-1
sub-matrix in
Penalty.matrix
that is constructed so that a quadratic form with
Penalty.matrix
in the middle computes the sum of squared differences
in parameter values about the mean, including a portion for the reference
cell in which the parameter is by definition zero.
Newlabels
returns a new fit object with the labels adjusted.
reListclean
returns a vector of named (by its arguments) elements.
formatNP
returns a character vector.
removeFormulaTerms
returns a formula object.
rms
, fastbw
, anova.rms
,
summary.lm
, summary.glm
,
datadist
, vif
, bootcov
,
latex
, latexTabular
,
latexSN
,
print.char.matrix
,
## Not run:
f <- psm(S ~ x1 + x2 + sex + race, dist='gau')
g <- psm(S ~ x1 + sex + race, dist='gau',
fixed=list(scale=exp(f$parms)))
lrtest(f, g)
g <- Newlabels(f, c(x2='Label for x2'))
g <- Newlevels(g, list(sex=c('Male','Female'),race=c('B','W')))
nomogram(g)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.