Similar to other predict methods, this function predicts fitted values from a fitted "GLM" object.

# S3 method for GLM
predict(
  model,
  data,
  key,
  features = NULL,
  prediction.type = NULL,
  significance.level = NULL,
  handle.missing = NULL
)

Format

S3 methods

Arguments

model

R6Class object
A "GLM" object for prediction.

data

DataFrame
DataFrame containting the data.

key

character
Name of the ID column.

features

character of list of characters, optional
Name of feature columns for prediction.
If not provided, it defaults to all non-key columns of data.

prediction.type

character, optional
Specifies whether to output predicted values of the response or the link function.
Defaults to 'response'.

significance.level

double, optional
Significance level for confidence intervals and prediction intervals. If specified, overrides the value passed to the GLM constructor.

handle.missing

c("remove", "fill_zero"), optional
How to handle data rows with missing independent variable values.

  • "remove" Remove missing rows.

  • "fill_zero" Replace missing values with 0.

Defaults to "remove".

Value

Dataframe Predicted values, structured as follows. The following two columns are always populated:

  • ID column, with same name and type as data's ID column.

  • PREDICTION, type NVARCHAR(100), representing predicted values.

The following five columns are only populated for IRLS:

  • SE, type DOUBLE. Standard error, or for ordinal regression, the probability that the data point belongs to the predicted category.

  • CI_LOWER, type DOUBLE. Lower bound of the confidence interval.

  • CI_UPPER, type DOUBLE. Upper bound of the confidence interval.

  • PI_LOWER, type DOUBLE. Lower bound of the prediction interval.

  • PI_UPPER, type DOUBLE. Upper bound of the prediction interval.

Examples

DataFrame data2 for prediction:


> data2$Collect()
    ID  X
1   1 -1
2   2  0
3   3  1
4   4  2

Call the function and obtain the result:


> predict(glm, data2, key="ID")$Collect()
    ID          PREDICTION
1   1  0.25543735346197155
2   2    0.744562646538029
3   3   2.1702915689746476
4   4     6.32608352871737

See also