sobota, 24 lipca 2010

Obliczanie AVE i CR z pliku out LISRELa

Zaproponowane przez Fornella i Larckera [HairetAl98,FornellLarcker81] rzetelność łączna (composite reliability, CR) oraz przeciętna wariancja wyodrębniona (average variance extracted, AVE) stały się często wykorzystywanymi miarami rzetelności wewnętrznej oraz trafności zbieżnej. CR obliczana jest według następującej formuły [por. także zencaroline.blogspot.com/2007/06/composite-reliability]:

CRη = (∑i ληi )2 / ( (∑i ληi )2 + ∑i var(εi))

gdzie: var(εi) = 1 - (ληi2); ληi to wektor (zestandaryzowanych) ładunków czynnikowych dla zmiennej ukrytej η.

Minimalną akceptowaną wartością CR jest 0,7

Podobny do CR jest wskaźnik przeciętnej wariancji wyodrębnionej (average variance extracted, AVE), służący do oceny trafności zbieżnej (convergent validity). Jest on obliczany według następującej formuły:

AVEη = (∑iηi )2 ) / ( ∑iηi)2 + ∑i var(εi) )

Znaczenie symboli jest identyczne, jak we wzorze określającym rzetelność łączną. Minimalną akceptowaną wartością AVE jest 0,5.

Znając zestandaryzowane wartości ładunków czynnikowych ληi policzenie CR oraz AVE jest proste. Dodanie opcji SC (completely standardized solutions) do polecenia OUTPUT spowoduje wydrukowanie zestandaryzowanych wartości ładunków czynnikowych. Poniższy skrypt obliczy na tej podstawie CR/AVE dla każdej zmiennej ukrytej:


#!/usr/bin/perl
# Computes/prints Composite Reliability (CR) and Average Variance Extracted (AVE)
# from LISREL OUT file. Measures can load on several factors
#
# (c) 2010; t.przechlewski http://pinkaccordions.homelinux.org/staff/tp/
# GPL license
#
# The formulas for CR and AVE are as follows [cf. Hair, Anderson, Tatham and Black, Multivariate Data Analysis, 5th Ed., Pearson Education, p. 637]:
# CR = (\sum standardized loading)^2 / ( (\sum standardized loading)^2 + \sum indicator measurement error ),
# AVE = (\sum (standardized loading)^2 ) / ( \sum (standardized loading)^2 + \sum indicator measurement error )
# where: indicator measurement error = 1 - loading^2
# see also: http://zencaroline.blogspot.com/2007/06/composite-reliability.html
#
# usage: perl print_cr_and_ave lisrel-output-file
#
my $scan = 0; ## flag to figure out where we are
my $initial_latent_var_no = 0;

while (<>) {
chomp;

# We are looking for the line with `Completely Standardized Solution' (CSS), which
# starts the block containing relevant data
if (/Completely Standardized Solution/) { $scan = 1 ;
print STDERR "*** Found *** $_ ***\n"; next ; }

# After CSS line we look the line with LAMBDA-* (there are up to two such lines)
if ( $scan > 0 && /LAMBDA-[XY]/ ) { $scan++;

print STDERR "*** Found *** $_ (initial: $initial_latent_var_no) ***\n";

$_ = <> ; $_ = <> ; $_ = <> ; ## eat exactly next three lines

## ok we are about to scan LAMBDA-X/Y matrix
while (<>) { chomp;

if (/^[ \t]*$/) { # exmpty line ends LAMBDA-X/Y matrix
## before reading next block store the number of latent vars from the 1st block
## first latent var number in the second block = number of vars in the previous block +1
$initial_latent_var_no += $#loadings;

print STDERR "*** Initial var number = $initial_latent_var_no ***\n";
last ; ## OK, all rows in matrix was read...
}

s/- -/xxx/g; # change `- -' to `xxx'
@loadings = split ' ', $_;

# column number = latent var number ; column `0' contains measurement variable name
for ($l=1; $l <= $#loadings; $l++) {
if ($loadings[$l] !~ /xxx/) { ## store in hash
$Loadings{$l + $initial_latent_var_no }{$loadings[0]} = $loadings[$l];
}
}

}
}
}

print STDERR "*** Latent variables = $initial_latent_var_no ***\n";

print "=======================================================\n";

### Compute/print CR i AVE ### ### ### ###

for $l (sort keys %Loadings ) {
$loadings = $sqloadings = $errors = 0;

print STDERR "*** Xi/Eta: $l ***\n";

for $m ( sort keys %{ $Loadings{ $l }} ) {
$load = $Loadings{$l}{$m};

print STDERR "$m ($l) = $load\n";

$loadings += $load ;
$sqloadings += $load * $load ;
$errors += (1 - $load * $load);
}

$cr = ($loadings * $loadings) / ( ($loadings * $loadings) + $errors ) ;
$ave = $sqloadings / ($sqloadings + $errors ) ;

printf "Xi/Eta_%2d -> CR = %6.3f AVE = %6.3f\n", $l, $cr, $ave;

}

print "=======================================================\n";

Skrypt można także pobrać tutaj.

Literatura

FornellLarcker81
Fornell, C. i Larcker, D. F. (1981). Evaluating structural equation models with unobservable variables and measurement error. Journal of Marketing Research, 18(1):39--50.
HairetAl98
Hair, J. F., Black, B., Anderson, R. E., i Tatham, R. L. (1998). Multivariate Data Analysis. Prentice Hall.