rank.predict: Generate predicted ranks for new observations given a new...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/rank.predict.R

Description

This function is called by coxed when method="gam" and new data are specified, and is not intended to be used by itself.

Usage

1
rank.predict(x, v, warn = TRUE)

Arguments

x

A vector of linear predictors for the estimation sample

v

A vector of linear predictors for the new data

warn

If TRUE the function warns the user when linear predictors in the new data are greater than or less than all of the linear predictors in the estimation sample

Details

The purpose of rank.predict is to determine for a single new observation what the rank of that observation's linear predictor would have been had the observation been in the original estimation sample. It calculates the predicted rank by appending the new observation to the vector of linear predictors for the estimation sample and calculating the rank of the observation in the new vector. If the new data contain more than one observation, rank.predict calculates the predicted rank for each observation independently, without taking the other observations in the new data into account.

Any observation with a linear predictor less than the minimum linear predictor in the estimation sample will have a predicted rank of 1; any observation with a linear predictor greater than the maximum linear predictor in the estimation sample will have a predicted rank of length(v). If either condition exists, the function provides a warning.

Value

A numeric vector containing the predicted ranks for the observations in x.

Author(s)

Jonathan Kropko <jkropko@virginia.edu> and Jeffrey J. Harden <jharden2@nd.edu>

See Also

coxed, rank

Examples

1
2
3
4
5
estimationLPs <- rnorm(20)
cbind(estimationLPs, rank(estimationLPs))
newLPs <- rnorm(5)
newLP.rank <- rank.predict(x=newLPs, v=estimationLPs)
cbind(newLPs, newLP.rank)

Example output

Loading required package: rms
Loading required package: Hmisc
Loading required package: lattice
Loading required package: survival
Loading required package: Formula
Loading required package: ggplot2

Attaching package:HmiscThe following objects are masked frompackage:base:

    format.pval, units

Loading required package: SparseM

Attaching package:SparseMThe following object is masked frompackage:base:

    backsolve

Loading required package: mgcv
Loading required package: nlme
This is mgcv 1.8-33. For overview type 'help("mgcv-package")'.
      estimationLPs   
 [1,]     0.3747286 12
 [2,]    -0.9405368  2
 [3,]    -0.3765555  7
 [4,]     0.8505943 16
 [5,]    -0.4069140  6
 [6,]     1.0175884 17
 [7,]    -0.8832403  3
 [8,]    -0.2835588  8
 [9,]     0.1244097 10
[10,]     0.6007141 15
[11,]     0.1649113 11
[12,]     0.0511698  9
[13,]    -1.9084182  1
[14,]    -0.5389643  4
[15,]     1.0822700 18
[16,]     1.1965174 19
[17,]     1.3676164 20
[18,]    -0.5161742  5
[19,]     0.5780777 14
[20,]     0.4609835 13
         newLPs newLP.rank
[1,] -0.7176056          4
[2,]  0.5354689         13
[3,]  2.2162040         20
[4,]  0.6334574         15
[5,]  0.2406560         11

coxed documentation built on Aug. 2, 2020, 9:07 a.m.