predict.graper {graper} | R Documentation

## Predict response on new data

### Description

Function to predict the response on a new data set using a fitted graper model.

### Usage

    ## S3 method for class 'graper'
    predict(object, newX, type = c("inRange", "response",
      "link"), ...)

### Arguments

`object` | fitted graper model as obtained from `graper`
`newX` | Predictor matrix of size n_test (number of new test samples) x p (number of predictors) (same feature structure as used in `graper`)
`type` | type of prediction returned, either: response:returns the linear predictions for linear regression and class probabilities for logistic regression link:returns the linear predictions inRange:returns linear predictions for linear and class memberships for logistic regression
`...` | other arguments

### Value

A vector with predictions.

### Examples

    # create data
    dat <- makeExampleData()
    # split data into train and test sets of equal size
    ntrain <- dat$n / 2
    # fit the model to the train data
    fit <- graper(dat$X[seq_len(ntrain), ],
                  dat$y[seq_len(ntrain)], dat$annot)
    # make predictions on the test data
    ypred <- predict(fit, dat$X[seq_len(ntrain) + dat$n / 2, ])

    # create data for logistic regression
    dat <- makeExampleData(response="bernoulli")
    # split data into train and test sets of equal size
    ntrain <- dat$n / 2
    # fit the graper model for a logistic model
    fit <- graper(dat$X[seq_len(ntrain), ],
                  dat$y[seq_len(ntrain)],
                  dat$annot, family="binomial")
    # make predictions on the test data
    ypred <- predict(fit, dat$X[seq_len(ntrain) + dat$n / 2, ], type = "inRange")

[Package graper version 1.2.0 Index]