Description Usage Arguments Value Author(s) Examples

View source: R/glamlasso_predict.R

Given new covariate data this function computes the linear predictors
based on the estimated model coefficients in an object produced by the function `glamlasso`

. Note that the
data can be supplied in two different formats: i) as a *n' \times p* matrix (*p* is the number of model
coefficients and *n'* is the number of new data points) or ii) as a list of two or three matrices each of
size *n_i' \times p_i, i = 1, 2, 3* (*n_i'* is the number of new marginal data points in the *i*th dimension).

1 2 |

`object` |
An object of Class glamlasso, produced with |

`x` |
a matrix of size |

`X` |
A list containing the data matrices each of size |

`...` |
ignored |

A list of length `nlambda`

containing the linear predictors for each model. If
new covariate data is supplied in one *n' \times p* matrix `x`

each
item is a vector of length *n'*. If the data is supplied as a list of
matrices each of size *n'_{i} \times p_i*, each item is an array of size *n'_1 \times \cdots \times n'_d*, with *d\in \{2,3\}*.

Adam Lund

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ```
## Not run:
n1 <- 65; n2 <- 26; n3 <- 13; p1 <- 13; p2 <- 5; p3 <- 4
X1 <- matrix(rnorm(n1 * p1), n1, p1)
X2 <- matrix(rnorm(n2 * p2), n2, p2)
X3 <- matrix(rnorm(n3 * p3), n3, p3)
Beta <- array(rnorm(p1 * p2 * p3) * rbinom(p1 * p2 * p3, 1, 0.1), c(p1 , p2, p3))
mu <- RH(X3, RH(X2, RH(X1, Beta)))
Y <- array(rnorm(n1 * n2 * n3, mu), dim = c(n1, n2, n3))
fit <- glamlasso(list(X1, X2, X3), Y, family = "gaussian", penalty = "lasso", iwls = "exact")
##new data in matrix form
x <- matrix(rnorm(p1 * p2 * p3), nrow = 1)
predict(fit, x = x)[[100]]
##new data in tensor component form
X1 <- matrix(rnorm(p1), nrow = 1)
X2 <- matrix(rnorm(p2), nrow = 1)
X3 <- matrix(rnorm(p3), nrow = 1)
predict(fit, X = list(X1, X2, X3))[[100]]
## End(Not run)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.