FitConstrainedGLLVM: Fits a GLLVM to data

View source: R/FitConstrainedGLLVM.R

FitConstrainedGLLVMR Documentation

Fits a GLLVM to data

Description

Fits a GLLVM to data

Usage

FitConstrainedGLLVM(Y, X, formula = NULL, nLVs = 1, Family = "gaussian", ColScorePriorsd = 10, INLAobj = FALSE, ...)

Arguments

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()

Value

A list with fixed, colscores, and roweffs: the posterior summaries for the fixed effects, the column scores and the row effects respectively

Examples

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)

oharar/LatentINLA documentation built on Sept. 13, 2023, 5:18 p.m.