Latent budget analysis (LBA) is a method for the analysis of contingency tables, from where the compositional data is derived. It is used to understand the relationship between the table rows and columns, where the rows denote the categories of the explanatory variable and the columns denote the categories of the response variable.
lba(obj, ...)# S3 method for matrix
lba(obj,
A = NULL,
B = NULL,
K = 1L,
cA = NULL,
cB = NULL,
logitA = NULL,
logitB = NULL,
omsk = NULL,
psitk = NULL,
S = NULL,
T = NULL,
row.weights = NULL,
col.weights = NULL,
tolG = 1e-10,
tolA = 1e-05,
tolB = 1e-05,
itmax.unide = 1e3,
itmax.ide = 1e3,
trace.lba = TRUE,
toltype = "all",
method = c("ls", "mle"),
what = c("inner","outer"), ...)
# S3 method for table
lba(obj,
A = NULL,
B = NULL,
K = 1L,
cA = NULL,
cB = NULL,
logitA = NULL,
logitB = NULL,
omsk = NULL,
psitk = NULL,
S = NULL,
T = NULL,
row.weights = NULL,
col.weights = NULL,
tolG = 1e-10,
tolA = 1e-05,
tolB = 1e-05,
itmax.unide = 1e3,
itmax.ide = 1e3,
trace.lba = TRUE,
toltype = "all",
method = c("ls", "mle"),
what = c("inner","outer"), ...)
# S3 method for formula
lba(formula, data,
A = NULL,
B = NULL,
K = 1L,
cA = NULL,
cB = NULL,
logitA = NULL,
logitB = NULL,
omsk = NULL,
psitk = NULL,
S = NULL,
T = NULL,
row.weights = NULL,
col.weights = NULL,
tolG = 1e-10,
tolA = 1e-05,
tolB = 1e-05,
itmax.unide = 1e3,
itmax.ide = 1e3,
trace.lba = TRUE,
toltype = "all",
method = c("ls", "mle"),
what = c("inner","outer"), ...)
# S3 method for ls
lba(obj,
A ,
B ,
K ,
row.weights ,
col.weights ,
tolA ,
tolB ,
itmax.unide ,
itmax.ide ,
trace.lba ,
what , ...)
# S3 method for mle
lba(obj,
A ,
B ,
K ,
tolG ,
tolA ,
tolB ,
itmax.unide ,
itmax.ide ,
trace.lba ,
toltype ,
what , ...)
# S3 method for ls.fe
lba(obj,
A ,
B ,
K ,
cA ,
cB ,
row.weights ,
col.weights ,
itmax.ide ,
trace.lba , ...)
# S3 method for mle.fe
lba(obj,
A ,
B ,
K ,
cA ,
cB ,
tolG ,
tolA ,
tolB ,
itmax.ide ,
trace.lba ,
toltype , ...)
# S3 method for ls.logit
lba(obj,
A ,
B ,
K ,
cA ,
cB ,
logitA ,
logitB ,
omsk ,
psitk ,
S ,
T ,
row.weights ,
col.weights ,
itmax.ide ,
trace.lba , ...)
# S3 method for mle.logit
lba(obj,
A ,
B ,
K ,
cA ,
cB ,
logitA ,
logitB ,
omsk ,
psitk ,
S ,
T ,
itmax.ide ,
trace.lba , ...)
The method lba.ls
and lba.mle
returns a list of class lba.ls
and lba.mle
respectively with the slots:
The compositional data matrix which is formed by dividing the raw data matrix by their corresponding total, its rows are called observed budgets.
Matrix whose rows are the expected budgets.
Residual matrix P - pij.
(I x K) matrix of the unidentified the mixing parameters.
(J x K) matrix of the unidentified the latent components.
(I x K) matrix of the identified mixing parameters, they may be either the inner extreme values or the outer extreme values.
(J x K) matrix of the identified latent componentes, they may be either the inner extreme values or the outer extreme values.
(J x K) matrix of the rescaled latent components.
Budget proportions.
Value of least squared or likelihood function achieved.
Number of unidentified iterations.
Number of identified iterations.
The method lba.ls.fe
and lba.mle.fe
returns a list of class lba.ls.fe
and lba.mle.fe
respectively with the slots:
The compositional data matrix which is formed by dividing the raw data matrix by their corresponding row total, its rows are called observed budgets.
Matrix whose rows are the expected budgets.
Residual matrix P - pij.
(I x K) matrix of the unidentified the mixing parameters.
(J x K) matrix of the unidentified the latent components.
(J x K) matrix of the rescaled latent components.
Budget proportions.
Value of least squared or likelihood function achieved.
Number of identified iteractions.
The method lba.ls.logit
and lba.mle.logit
returns a list of class lba.ls.logit
and lba.mle.logit
respectively with the slots:
The compositional data matrix which is formed by dividing the raw data matrix by their corresponding total, its rows are called observed budgets.
Matrix whose rows are the expected budgets.
Residual matrix P - pij.
(I x K) matrix of the unidentified the mixing parameters.
(J x K) matrix of the unidentified the latent componentes.
(J x K) matrix of the rescaled latent components.
Budget proportions.
Value of least squared or likelihood function achieved.
Number of identified iterations.
A (SxK) matrix giving estimated values of the multinomial logit parameters of the row covariates.
A (TxK) matrix giving the estimated values for the multinomial logit parameters of the column covariates.
The function is generic, accepting some forms of the principal argument for specifying a two-way frequency table. Currently accepted forms are matrix, data frame (coerced to frequency tables), objects of class "xtabs"
or "table"
and one-sided formulae of the form Col1 + Col2 + ... + Coln ~ Row1 + Row2 + ... + Rown
, where Rown
and Coln
are nth row (the mixing parameters) and column variable (the latent components).
A data frame containing variables in formula
.
The starting value of a (I x K) matrix containing the mixing parameters, if given. The default is NULL
, producing random starting values.
The starting value of a (J x K) matrix containing the latent components, if given. The default is NULL
, producing random starting values.
Integer giving the number of latent budgets chosen by the user. The default is 1
.
The value of a (I x K) matrix containing the constraints on the mixing parameters. Fixed constraints are the values themselves which are numbers in the [0,1] interval. The optional equality constraints are indicated by an integer starting from 2, such that parameters that must be equal have the same integer. The default is NULL
, indicating no constraints.
The value of a (J x K) matrix containing the constraints on the latent components. Fixed constraints are the values themselves which are numbers in the [0,1] interval. The optional equality constraints are indicated by an integer starting from 2, such that parameters that must be equal have the same integer. The default is NULL
, indicating no constraints.
Design (IxS) matrix for row-covariates. The first column contains the one number, indicating a constant covariate. The entries may be continuous or dummy coded values.
Design (JxT) matrix for column-covariates. The entries may be continuous or dummy coded values.
A (SxK) matrix giving the starting values for the multinomial logit parameters of the row covariates. The default is NULL
, producing random starting values.
A (TxK) matrix giving the starting values for the multinomial logit parameters of the column covariates. The default is NULL
, producing random starting values.
Number of row-covariates. The default is NULL
.
Number of column-covariates. The default is NULL
.
A vector with the same number of rows of the matrix of the weighted least squares method. If is NULL
(default), the weights are $$\sqrt{n_{i+}/n_{++}}$$.
A vector with the same number of columns of the matrix of the weighted least squares method. If is NULL
(default), the weights are $$1/\sqrt{n_{+j}/n_{++}}$$.
A tolerance value for judging when convergence has been reached. It is based on the estimated likelihood ratio statistics G2. The default is 1e-10
.
A tolerance value for judging when convergence has been reached. When the one-iteration change in the maximum of the absolute value of the element wise difference of the estimated matrices A is less than tolA. The default is 1e-05
.
A tolerance value for judging when convergence has been reached. When the one-iteration change in the maximum of the absolute value of the element wise difference of the estimated matrices B is less than tolB. The default is 1e-05
.
Maximum number of iterations performed by the mle or ls method, if convergence is not achieved, before identification parameters. The default is 1e3
.
Maximum number of iterations performed by the mle or ls method in the identification process. Is used too when the constrained fixed, equality and logit are required. The default is 1e3
.
Logical, indicating whether the base
function optim
and constrOptim.nl
from package alabama, will trace their results. The default is TRUE
.
String indicating which kind of tolerance to be used. That is, the EM algorithm stops updating and considers the maximum log-likelihood to have been found. Their types are: "all"
when the one-iteration change in the estimated likelihood ratio statistics G2 is less than tolG, and the one-iteration change in the maximum of the absolute value of the element wise difference of the estimated matrices A is less than tolA and the same for estimated matrices B with respect to tolB; "G2"
when the only one-iteration change in the estimated likelihood ratio statistics G2 is less than tolG; "ab"
when only the one-iteration change in the maximum of the absolute value of the element wise difference of the estimated matrices A is less than tolA and the same for estimated matrices B with respect to tolB. toltype
works only for method = "mle"
. The default is "all"
. The ls method uses only "ab"
as tolerance limit.
String indicating which kind of estimating method. They are: "ls"
when least squares, either weighted or ordinary, method is
used; "mle"
when maximum likelihood method is used. The default is "ls"
.
String indicating which kind identified solutions for mixing parameters and latent budgets matrices. They are: the "inner"
extreme solution and the "outer"
extreme solution. The default is "inner"
.
Further arguments (required by generic).
Agresti, Alan. 2002. Categorical Data Analysis, second edition. Hoboken: John Wiley and Sons.
de Leeuw, J., and van der Heijden, P.G.M. 1988. "The analysis of time-budgets with a latent time-budget model". In E. Diday (Ed.), Data Analysis and Informatics V. pp. 159-166. Amsterdam: North-Holland.
de Leeuw, J., van der Heijden, P.G.M., and Verboon, P. 1990. "A latent time budget model". Statistica Neerlandica. 44, 1, 1-21.
Dempster, A.P., Laird, N.M., and Rubin, D.B. 1977. "Maximum likelihood from incomplete data via the EM algorithm". Journal of the Royal Statistical Society, Series. 39, 1-38.
van der Ark, A.L. 1999. Contributions to Latent Budget Analysis, a tool for the analysis of comositional data. Ph.D. Thesis University of Utrecht.
van der Heijden, P.G.M., Mooijaart, A., and de Leeuw, J. 1992. "Constrained latent budget analysis". In P.V. Marsden (Ed.), Sociological Methodology pp. 279-320. Cambridge: Blackwell Publishers.
goodnessfit
, summary.lba.ls
,summary.lba.mle
,plotlba
,plotcorr
data('votB')
# Using LS method (default) without constraint
# K = 2
ex1 <- lba(parties ~ city,
votB,
K = 2)
ex1
# Already tabulated data? Ok!
data('PerfMark')
if (FALSE) {
ex2 <- lba(as.matrix(PerfMark),
K = 2,
what='outer')
ex2
}
# Using LS method (default) with constraint
# Fixed constraint to mixing parameters
cakiF1 <- matrix(c(0.2, NA, NA,
NA , NA,0.2,
NA , NA,0.2,
0.3, NA, NA,
0.2, NA, NA,
NA , NA, NA),
byrow = TRUE,
ncol = 3)
# K = 3
if (FALSE) {
exf1 <- lba(parties ~ city,
votB,
cA = cakiF1,
K = 3)
exf1
}
# Using LS method (default) with LOGIT constrain
data('housing')
# Make cross-table to matrix design.
tbh <- xtabs(value ~ Influence + Housing, housing)
Xis <- model.matrix(~ Housing*Influence,
tbh,
contrasts=list(Housing='contr.sum',
Influence='contr.sum'))
tby <- xtabs(value ~ Satisfaction + Contact, housing)
Yis <- model.matrix(~ Satisfaction*Contact,
tby,
contrasts=list(Satisfaction='contr.sum',
Contact='contr.sum'))[,-1]
S <- 12
T <- 5
tabs <- xtabs(value ~ interaction(Housing,
Influence) + interaction(Satisfaction,
Contact),
housing)
if (FALSE) {
exlogit2 <- lba(tabs,
K = 2,
logitA = Xis,
logitB = Yis,
S = S,
T = T,
trace.lba=FALSE)
exlogit2
}
Run the code above in your browser using DataLab