gpsrc: Gaussian process for survival, regression and classification

Description Usage Arguments Value Examples

View source: R/Gaussian_Process_Survival.R

Description

It works for classification, regression, cox regression and poission regression The first/main purpose is to implement Gaussian process into Cox's model The glmnet is used to solve a general Ridge-regularized regression solver. This may be changed in the future.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
gpsrc(x, ...)

## S3 method for class 'formula'
gpsrc(formula, data = environment(formula), ...)

## Default S3 method:
gpsrc(x, y, scaled = TRUE, kernel = "rbfdot",
  kpar = "automatic", var = 1, family = switch(class(y), Surv = "cox",
  factor = ifelse(nlevels(y) > 2, "multinomial", "binomial"), integer =
  "poisson", "gaussian"), ...)

## S3 method for class 'gpsrc'
predict(object, newdata, type = c("response", "probabilities",
  "link", "risk"))

Arguments

x

Design matrix (NO intercept)

...

Further argument passed to internal functions

formula

Model formula

data

Data

y

Reponse vector of type double, integer, factor or Surv

scaled

Logical value indicating if to standardize x, y

kernel

String or 'kernel' object (see kernlab::gausspr)

kpar

A list of Kernel parameters or 'automatic' if a radial kernel specified

var

Variance of response (from the Gaussian process). Only for regression

family

Options are 'gaussian', 'binomial', 'multinomial', 'poisson', 'cox'

object

'gpsrc' object from gpsrc

newdata

Design matrix of test set

type

Type of output

Value

A 'gprsc' object

Examples

 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
## classification
library(pROC);
library(mlbench);
data(Sonar);
i.tr <- sample(nrow(Sonar), size = 0.6*nrow(Sonar));

gp <- gpsrc(Class ~., data = Sonar[i.tr,], kpar = list(sigma = 0.01))
gp.pred <- predict(gp, Sonar[-i.tr, ], type = 'prob')
cat('AUC:', roc(Sonar$Class[-i.tr], gp.pred[, 2])$auc, '\n');

## regression

data(BostonHousing);
BH <- BostonHousing;
i.tr <- sample(nrow(BH), 200);

gp2 <- gpsrc(medv ~., data = BH[i.tr, ], kpar = list(sigma = 0.1));
gp2.pred <- predict(gp2, BH[-i.tr, ])
cat('RMSE:', sqrt(mean((BH$medv[-i.tr] - gp2.pred)^2)), '\n');

## survival

library(survival);
data(pbc, package = 'randomForestSRC');
pbc <- na.omit(pbc);
i.tr <- sample(nrow(pbc), 100);

gp <- gpsrc(Surv(days, status) ~., data = pbc[i.tr, ],
	kernel = 'laplacedot', kpar = list(sigma = 0.1));
gp.pred <- predict(gp, pbc[-i.tr, ])
cat('C-index:', survConcordance(Surv(days, status) ~ gp.pred, data = pbc[-i.tr, ])$concordance, '\n');

linxihui/sml documentation built on May 21, 2019, 6:39 a.m.