Skip to contents

Converts inputs and one response column per output into the long format of multi-output models: one row per observed (input, output) pair, with the output index as the last input column.

Usage

gp_stack_outputs(x, y = NULL, outputs = NULL)

Arguments

x

Numeric vector or matrix of inputs, one row per observation.

y

Numeric matrix or data frame with one column per output and one row per row of x; NA marks an output that was not observed there, so outputs may be observed at different inputs (heterotopic data). If NULL, every row of x is stacked for each output in outputs, for prediction.

outputs

Output indices to stack when y is NULL.

Value

A list with x, the stacked input matrix whose last column, output, holds the output index; y, the stacked responses (only when y is given); output, the output index of each row; and row, the row of the original x. Rows are ordered by output, then by row.

Stability

Experimental: this interface may change in a minor release, and every change is listed in NEWS. See gaussianprocesses-package for the policy.

Examples

x <- c(0, 1, 2)
y <- cbind(c(1.0, NA, 0.4), c(0.2, 0.3, NA))
stacked <- gp_stack_outputs(x, y)
stacked$x
#>        output
#> [1,] 0      1
#> [2,] 2      1
#> [3,] 0      2
#> [4,] 1      2
stacked$y
#> [1] 1.0 0.4 0.2 0.3

gp_stack_outputs(c(0.5, 1.5), outputs = 1:2)$x
#>          output
#> [1,] 0.5      1
#> [2,] 1.5      1
#> [3,] 0.5      2
#> [4,] 1.5      2