View source: R/FitConstrainedGLLVM.R
FitConstrainedGLLVM | R Documentation |
Fits a GLLVM to data
FitConstrainedGLLVM(Y, X, formula = NULL, nLVs = 1, Family = "gaussian", ColScorePriorsd = 10, INLAobj = FALSE, ...)
Y |
A data frame or matrix with the response |
X |
A data frame or matrix of covariates |
formula |
for predictors in the ordination |
nLVs |
The number of latent variables required |
Family |
A string indicating the likelihood family. If length 1, it gets repeated with one for each column of the data. |
ColScorePriorsd |
Prior standard deviation for column scores (the betas for INLA insiders), defaults to 10 |
INLAobj |
Should the full INLA object be included in the output object? Defaults to FALSE |
... |
More arguments to be passed to inla() |
A list with fixed, colscores, and roweffs: the posterior summaries for the fixed effects, the column scores and the row effects respectively
set.seed(2021)
NRows <- 200
nLVs <- 1
NCol <- 20
NCovs <- 2
Intercept <- 2
CovBeta <- matrix(c(-0.2, 0.7, 0.7, -0.2), nrow=2)
ColEffs <- matrix(c(1,rnorm(nLVs*(NCol-1), 0, 0.5)), ncol=NCol)
X <- matrix(10+1:(NCovs*NRows), nrow=NRows,
dimnames = list(NULL, paste0("X", 1:NCovs)))
LV.true <- rowSums(apply(X, 2, scale)%*%CovBeta)
E.Y <- Intercept+LV.true%*%ColEffs
TrueFixed <- c(Intercept, CovBeta)
Y.mat <- apply(E.Y, 2, function(e) rpois(length(e), exp(e)))
colnames(Y.mat) <- paste0("Col", 1:ncol(Y.mat))
## Not run:
Try1 <- FitConstrainedGLLVM(Y=Y.mat, X=X, nLVs=1, Family="poisson", INLAobj = FALSE)
Try2 <- FitConstrainedGLLVM(Y=Y.mat, X=X, nLVs=2, Family="poisson",
INLAobj = FALSE, verbose=TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.