Description Usage Arguments Examples
Predict response with a generalized supervised PCA model
1 2 3 |
object |
generalized supervised PCA object |
newdata |
matrix of the same exponential family as covariates in |
type |
the type of fitting required.
|
... |
Additional arguments |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # construct a low rank matrices in the natural parameter space
rows = 100
cols = 10
set.seed(1)
loadings = rnorm(cols)
mat_np = outer(rnorm(rows), rnorm(cols))
mat_np_new = outer(rnorm(rows), loadings)
# generate a count matrices and binary responses
mat = matrix(rpois(rows * cols, c(exp(mat_np))), rows, cols)
mat_new = matrix(rpois(rows * cols, c(exp(mat_np_new))), rows, cols)
response = rbinom(rows, 1, rowSums(mat) / max(rowSums(mat)))
response_new = rbinom(rows, 1, rowSums(mat_new) / max(rowSums(mat_new)))
mod = genSupPCA(mat, response, k = 1, family_x = "poisson", family_y = "binomial",
quiet = FALSE, max_iters_per = 1, discrete_deriv = FALSE)
plot(predict(mod, mat, type = "response"), response_new)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.