FactorSCGLR: Function that fits the scglr model with factors

View source: R/FactorSCGLR.R

FactorSCGLRR Documentation

Function that fits the scglr model with factors

Description

Function that fits the scglr model with factors

Usage

FactorSCGLR(
  formula,
  data,
  family,
  H = c(1, 1),
  J = 1,
  size = NULL,
  offset = NULL,
  crit = list(),
  method = methodSR()
)

Arguments

formula

an object of class MultivariateFormula (or one that can be coerced to that class): a symbolic description of the model to be fitted.

data

a data frame to be modeled.

family

a vector of character of the same length as the number of dependent variables: "bernoulli", "binomial", "poisson" or "gaussian" is allowed.

H

a vector of integer representing the number of components per theme.

J

the number of factors

size

describes the number of trials for the binomial dependent variables.

offset

used for the poisson dependent variables.

crit

a list of two elements : maxit and tol, describing respectively the maximum number of iterations and the tolerance convergence criterion for the Expectation Maximization algorithm. Default is set to 50 and 10e-6 respectively.

method

structural relevance criterion.

Value

U

the set of loading vectors

comp

the set of components

eta

the fitted linear predictor

coef

contains regression parameters: intercept, gamma and delta

B

the factors loading

G

the set of factors

sigma2

the residual variances for gaussian responses

offset

the offset used for the poisson dependent variables

Z

the set of working variables

Y

the response matrix

Theme

the list of standardized explanatory themes

A

the supplementary explanatory variables

W

the matrix of GLM weights

family

the distributions

Examples

# load sample data
data <- genus
# get variable names from dataset
n <- names(data)
ny <- n[grep("^gen",n)]
nx1 <- n[grep("^evi",n)]
nx2 <- n[grep("^pluvio",n)]
na <- c("geology", "altitude", "forest", "lon", "lat")
# build multivariate formula
form <- multivariateFormula(Y = ny, X = list(nx1, nx2), A = na)
# define family
fam <- rep("poisson", length(ny))
# run function
H <- c(2,2)
J <- 2
met <- methodSR(l=4, s=0.5)
res <- FactorSCGLR(formula=form, data=data, H=H, J=J,
                   family=fam, method=met, offset = data$surface)


julien-gibaud/FactorsSCGLR documentation built on March 27, 2024, 8:17 a.m.