How are AIC and BIC calculated in lavaan?

1,465 views
Skip to first unread message

Deuterium

unread,
Apr 19, 2014, 11:20:12 AM4/19/14
to lav...@googlegroups.com
Hello,

I wonder how AIC and BIC are calculated in lavaan. What formula could I use to calculate such values manually and yield same results as that output by lavaan?

Thank you in advance,
Deuterium

yrosseel

unread,
Apr 19, 2014, 1:35:58 PM4/19/14
to lav...@googlegroups.com
On 04/19/2014 05:20 PM, Deuterium wrote:
> Hello,
>
> I wonder how AIC and BIC are calculated in lavaan.

AIC = -2 * logl + 2*npar

where 'logl' is the loglikelihood of the model, and 'npar' is the number
of free parameters.

BIC = -2 * logl + npar*log(N)

where N is the total sample size.

To get the ingredients from a fitted lavaan object ('fit'), so can use:

fitMeasures(fit, "logl") # or logLik(fit)
fitMeasures(fit, "npar")
fitMeasures(fit, "ntotal") # or nobs(fit)

Yves.

Deuterium

unread,
Apr 19, 2014, 3:41:00 PM4/19/14
to lav...@googlegroups.com
Thank you. However, the reason for why I asked is because after I moved to lavaan (from the sem package) I ran some of the models which I had previously ran on sem and noticed the AIC and BIC values resulting for the same exact model are significantly different between the sem package and lavaan. The parameters and standard errors and other tests are generally similar nonetheless.

I primarily thought that the difference might have been due to a different approach to calculating the AIC and BIC values, but after your reply I tried the formulas and they are the same for both packages. So, I checked the log-likelihood of the two runs (sem and lavaan) and they are -90.56904 and -7479.582 respectively - which, accordingly, is the reason behind the different AIC and BIC values.

Why could be a reason behind this significant difference between the log-likelihood of the two runs if the model is the same? What should I do about it?

Thank you,
Deuterium

Jarrett Byrnes

unread,
Apr 19, 2014, 5:19:09 PM4/19/14
to lav...@googlegroups.com
The sem library uses the ChiSquare value such that

AIC = Chisq + 2*npar

as per Tanaka 1993. The delta AIC between models should remain unchanged, only the absolute value.

Refs
Tanaka, J.S. (1993). Multifaceted conceptions of fit in structural equation models. In K.A. Bollen, & J.S. Long (eds.), Testing 
structural equation models. Newbury Park, CA: Sage. 



-- 
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at http://groups.google.com/group/lavaan.
For more options, visit https://groups.google.com/d/optout.

yrosseel

unread,
Apr 19, 2014, 5:22:56 PM4/19/14
to lav...@googlegroups.com
On 04/19/2014 09:41 PM, Deuterium wrote:

> I checked the log-likelihood of the two runs (/sem/ and /lavaan/) and
> they are *-90.56904* and *-7479.582 *respectively - which, accordingly,
> is the reason behind the different AIC and BIC values.

Well, if you run *two *models, what is the difference in AIC/BIC for
those two models as computed by sem and lavaan? I would predict they are
the same. In that case, the two packages just have a different way to
handle the constant part of the multivariate normal distribution. And it
doesn't matter.

Yves.

leveneb...@gmail.com

unread,
Nov 23, 2018, 5:17:54 AM11/23/18
to lavaan
How can I calculate for DWLS estimation? it dont give values

20 Nisan 2014 Pazar 00:22:56 UTC+3 tarihinde yrosseel yazdı:

Terrence Jorgensen

unread,
Nov 23, 2018, 11:05:13 AM11/23/18
to lavaan
How can I calculate for DWLS estimation? it dont give values

Because DWLS is a least-squares estimator, not a likelihood-based estimator.  So there is no likelihood with which to calculate information criteria.

Terrence D. Jorgensen
Assistant Professor, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam

MARIO GARRIDO ESCUDERO

unread,
May 27, 2019, 10:19:34 AM5/27/19
to lavaan
Hi, 
I dont know if this can helps or consude more, Im not an expert on statistics, but I made the same question time ago in other forum and this was the reply

AIC- and BIC- like measures for least-squares methods have been proposed. Note that OLS is a maximum-likelihood estimator (given the assumption of normal errors), so it is in line with Akaike’s (1973, 1974) proposals. Thus we can utilize the sum of squared residuals (SSR) as follows:  

AIC = n*ln(SSR) + 2p, 

For BIC Yamaoka et al. (1978) proposed:

BIC = n*ln(SSR) + p*ln(n),

where n is the sample size, ln the natural log, and p the number of free parameters. 

Yamaoka, K., Nakagawa, T. & Uno, T. (1978). Applications of Akaike's information criterion (AIC) in the evaluation of linear pharmacokinetic equations. Journal of Pharmacokinetics and Pharmacodynamics, 6, 165-175.

Ding, C.S., & Davison, M.L. (2009). Assessing Fit and Dimensionality in Least Squares Metric Multidimensional Scaling Using Akaike’s Information Criterion. Educational and Psychological Measurement, 70(2), 199-214.

Akaike, H. (1973). Information theory as an extension of the maximum likelihood principle. In B. N. Petrov & F. Csaki (Eds.), Second international symposium on information theory (pp. 267-281). Budapest, Hungary: Akademiai Kiado.

Yamaoka et al. (1978) also proposed using SSRw for the WLS regression case. In robust WLS/WLSMV, then, this would be:

AIC = n*ln(Fmin_rwls) + 2p, 
BIC = n*ln(Fmin_rwls) + p*ln(n),

where Fmin_rwls is the minimum value of the fitting function (also a suitably weighted sum of squared discrepancies, but between the observed and model-implied moments, rather than between predicted and observed case-level values as in regression).  Take this all with a large block of salt though-- the behaviour of such statistics has never been studied in the SEM context as far as I know. 


Terrence Jorgensen

unread,
May 31, 2019, 6:52:32 AM5/31/19
to lavaan
AIC- and BIC- like measures for least-squares methods have been proposed. 

Like AICc, these specific proposals were for univariate regression models, not immediately generalizable to multivariate models.

MARIO GARRIDO ESCUDERO

unread,
May 31, 2019, 1:35:24 PM5/31/19
to lavaan
Thanks, Im going to ask
Reply all
Reply to author
Forward
0 new messages