Predict

Predict

The Predict node generates predicted response values from a fitted linear model or GLM using the R predict() function. It can predict using the original training data, manually entered values, or a connected dataset of new observations.

What it does

  • Retrieves a stored model from the upstream Linear Model or GLM node
  • Calls R’s predict() to compute predicted response values
  • Uses type = "response" automatically for GLM (glmmTMB) inputs so predictions are in original response units
  • Supports three prediction modes: training data, manual entry, or a connected dataset
  • Shows the model formula and predictor variable names
  • Optionally stores the predictions as a named dataframe (new, or added as a column to the connected dataframe) for use by downstream nodes such as Calculator

How to use it

  1. Fit a model — add a Linear Model or GLM node, enter a formula, and tick “Output to storr”
  2. Connect the model — drag an edge from the model node to the top model handle
  3. Choose prediction mode:
    • Training data — predict using the original data the model was fitted on
    • Manual values — type new predictor values in CSV format directly
  • Connected dataset — drag an edge from a CSV input node to the top data handle
  1. (Optional) Enter an Output dataframe name (see below)
  2. Click Run — predicted values are computed on the server and displayed

Node handles

This node has two input handles on the top edge and an output handle on the bottom edge (which carries a dataframe only if an output name is entered):

Handle Position Purpose
model Top (35%) Connect output from a Linear Model or GLM node
data Top (65%) (Optional) Connect a dataset of new predictor values

Configuration

Setting Required Description
Model connection Yes A Linear Model or GLM node with “Output to storr” enabled
Predict using Yes “Training data”, “Manual values”, or “Connected dataset”
New data (CSV) Conditional CSV-format text when using manual mode
Data connection Conditional A dataset node when using connected dataset mode
Output dataframe name No If given, predictions are stored in this dataframe in a column named predicted. You are warned if the name already exists and will be overwritten
Comment No Annotation for generated R code

Manual entry format

Enter values in CSV format with column names matching the model’s predictor variables on the first line:

conc,temp
1.5,20
2.0,25
3.0,30

After the first run, the required predictor names are shown above the text area.

Output

Displays a table with one row per observation:

  • observation — row number (1, 2, 3, …)
  • fitted — the predicted response value \(\hat{y}_i\)

For GLM inputs (glmmTMB), fitted values are returned on the response scale.

Output dataframe

By default Predict only displays predictions. Enter an Output dataframe name to keep them: the predictions are stored in a column called predicted, and the node’s output handle (bottom) passes the dataframe to downstream nodes such as Calculator, Summary Statistics or Output CSV.

  • With a connected dataset or manual values, the new dataframe contains those rows plus the predicted column.
  • With training data it contains observation and predicted.
  • To add the column to the connected dataset itself, enter that dataset’s own name. It is modified in place, and the panel warns that the name already exists.

If the number of predictions does not match the number of rows in the dataframe, the run stops with an error.

Generated R code

Training data:

predict(my_data_lm)

With new data:

predict(my_data_lm, newdata = new_data)

Adding predictions to the connected dataframe (output name is the same as the dataset):

new_data$predicted <- predict(my_data_lm, newdata = new_data)

Manual values (the data is built once, then used for the prediction):

predictions_df <- data.frame(conc = 1.5, temp = 20)
predictions_df$predicted <- predict(my_data_lm, newdata = predictions_df)

Creating a new dataframe:

predictions_df <- new_data
predictions_df$predicted <- predict(my_data_lm, newdata = predictions_df)

Tips

  • The upstream Linear Model or GLM node must have “Output to storr” enabled, otherwise the model is not saved and cannot be used for prediction.
  • When using manual entry, run the node once first with “Training data” to see the predictor variable names.
  • When connecting a dataset for new data, ensure it contains columns that match the model’s predictor variables.