When the values of the outcome variable Y
are either 0 or 1, the function lsm()
calculates the estimation of the log likelihood in the saturated model. This model is characterized by Llinas (2006, ISSN:2389-8976) in section 2.3 through the assumptions 1 and 2. If Y
is dichotomous and the data are grouped in J
populations, it is recommended to use the function lsm()
because it works very well for all K
.
lsm(formula, family = binomial, data = environment(formula), ...)
lsm
returns an object of class "lsm
".
An object of class "lsm
" is a list containing at least the
following components:
Vector of coefficients estimations (intercept and slopes).
Vector of coefficients estimations (intercept and slopes).
Vector of the coefficients’s standard error (intercept and slopes).
Vector with the exponential of the coefficients (intercept and slopes).
Value of the Wald statistic (with chi-squared distribution).
Degree of freedom for the Chi-squared distribution.
P-value calculated with the Chi-squared distribution.
Estimation of the log likelihood in the complete model.
Estimation of the log likelihood in the null model.
Estimation of the log likelihood in the logistic model.
Estimation of the log likelihood in the saturate model.
Number of populations in the saturated model.
Value of the test statistic (Hypothesis: null vs logistic models).
Value of the test statistic (Hypothesis: logistic vs complete models).
Value of the test statistic (Hypothesis: logistic vs saturated models).
Degree of freedom for the test statistic’s distribution (Hypothesis: null vs logistic models).
Degree of freedom for the test statistic’s distribution (Hypothesis: logistic vs saturated models).
Degree of freedom for the test statistic’s distribution (Hypothesis: logistic vs saturated models).
P-value for the hypothesis test: null vs logistic models.
P-value for the hypothesis test: logistic vs complete models.
P-value for the hypothesis test: logistic vs saturated models.
Vector with the log-odds.
Vector with the probabilities that the outcome variable takes the value 1, given the jth
population (estimated with the complete model and without the logistic model).
Vector with the probabilities that the outcome variable takes the value 1, given the jth
population (estimated with the null model and without the logistic model).
Vector with the probabilities that the outcome variable takes the value 1, given the jth
population (estimated with the logistic model).
Vector with the values of the odd in each jth
population.
Vector with the values of the odd ratio for each coefficient of the variables.
Vector with the values of each Zj
(the sum of the observations in the jth
population).
Vector with the nj
(the number of the observations in each jth
population).
Vector with the estimation of each pj
(the probability of success in the jth
population) in the saturated model (without estimate the logistic parameters).
Vector with the variance of the Bernoulli variables in the jth
population.
Vector with the expected values of Zj
in the jth
population.
Vector with the variances of Zj
in the jth
population.
Variance and covariance matrix of Z
, the vector that contains all the Zj
.
Score vector in the saturated model.
Information matrix in the saturated model.
Vector with the values of the standardized variable of Zj
.
Variance and covariance matrix for coefficient estimates.
Correlation matrix for coefficient estimates.
Data frame with estimates in the saturated model. It contains for each population j
: the value of the explanatory variables, nj
, Zj
, pj
and Log-Likelihood Lj_tilde
.
Data frame with estimates in the logistic model. It contains for each population j
: the value of the explanatory variables, nj
, Zj
, pj
, Log-Likelihood Lj
, Logit_pj
and the variance of logit (var.logit
).
It displays the original call that was used to fit the model lsm.
data envarironment.
Additional arguments to be passed to methods.
An expression of the form y ~ model, where y is the outcome variable (binary or dichotomous: its values are 0 or 1).
an optional funtion for example binomial.
an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which lsm()
is called.
further arguments passed to or from other methods.
Dr. rer. nat. Humberto LLinás Solano [aut] (Universidad del Norte, Barranquilla-Colombia); MSc. Omar Fábregas Cera [aut] (Universidad del Norte, Barranquilla-Colombia); MSc. Jorge Villalba Acevedo [cre, aut] (Universidad Tecnológica de Bolívar, Cartagena-Colombia).
Estimation of the log Likelihood of the Saturated Model
An expression of the form y ~ model
is interpreted as a specification that the response y
is modelled by a linear predictor specified symbolically by model
(systematic component). Such a model consists of a series of terms separated by +
operators. The terms themselves consist of variable and factor names separated by :
operators. Such a term is interpreted as the interaction of all the variables and factors appearing in the term. Here, y
is the outcome variable (binary or dichotomous: its values are 0 or 1).
[1] LLinás, H. J. (2006). Precisiones en la teoría de los modelos logísticos. Revista Colombiana de Estadística, 29(2), 239–265. https://revistas.unal.edu.co/index.php/estad/article/view/29310
[2] Hosmer, D.W., Lemeshow, S. and Sturdivant, R.X. (2013). Applied Logistic Regression, 3rd ed., New York: Wiley.
[3] Chambers, J. M. and Hastie, T. J. (1992). Statistical Models in S. Wadsworth & Brooks/Cole.
lsm
#library(lsm)
#1. AGE and Coronary Heart Disease (CHD) Status of 20 subjects:
#AGE <- c(20,23,24,25,25,26,26,28,28,29,30,30,30,30,30,30,30,32,33,33)
#CHD <- c(0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0)
#data <- data.frame (CHD, AGE )
#lsm(CHD ~ AGE , data)
#2.You can use the following notation:
#lsm(y~., data)
#3. Other example:
#y <- c(1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1)
#x1 <- c(2, 2, 2, 5, 5, 5, 5, 8, 8, 11, 11, 11)
#data <- data.frame (y, x1)
#ELAINYS <-lsm(y ~ x1, data)
#summary(ELAINYS)
#4. Other example:
#y <- as.factor(c(1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1))
#x1 <- as.factor(c(2, 2, 2, 5, 5, 5, 5, 8, 8, 11, 11, 11))
#data <- data.frame (y, x1)
#ELAINYS1 <-lsm(y ~ x1, family=binomial, data)
#summary(ELAINYS1)
Run the code above in your browser using DataLab