- Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <gsl/gsl_vector.h>
#include <gsl/gsl_linalg.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_linalg.h>
#include <gsl/gsl_matrix.h>
-#include <math/covariance.h>
-
-#include <math/correlation.h>
-#include <math/moments.h>
-#include <data/procedure.h>
-#include <language/lexer/variable-parser.h>
-#include <language/lexer/value-parser.h>
-#include <language/command.h>
-#include <language/lexer/lexer.h>
-
-#include <data/casegrouper.h>
-#include <data/casereader.h>
-#include <data/casewriter.h>
-#include <data/dictionary.h>
-#include <data/format.h>
-#include <data/subcase.h>
-
-#include <libpspp/misc.h>
-#include <libpspp/message.h>
-
-#include <output/tab.h>
-
-#include <output/charts/scree.h>
-#include <output/chart-item.h>
+#include "data/casegrouper.h"
+#include "data/casereader.h"
+#include "data/casewriter.h"
+#include "data/dictionary.h"
+#include "data/format.h"
+#include "data/procedure.h"
+#include "data/subcase.h"
+#include "language/command.h"
+#include "language/lexer/lexer.h"
+#include "language/lexer/value-parser.h"
+#include "language/lexer/variable-parser.h"
+#include "libpspp/message.h"
+#include "libpspp/misc.h"
+#include "math/correlation.h"
+#include "math/covariance.h"
+#include "math/moments.h"
+#include "output/chart-item.h"
+#include "output/charts/scree.h"
+#include "output/tab.h"
gsl_vector_free (id->msr);
gsl_vector_free (id->eval);
gsl_matrix_free (id->evec);
gsl_vector_free (id->msr);
gsl_vector_free (id->eval);
gsl_matrix_free (id->evec);
+static double
+initial_sv (const gsl_matrix *fm)
+{
+ int j, k;
+
+ double sv = 0.0;
+ for (j = 0 ; j < fm->size2; ++j)
+ {
+ double l4s = 0;
+ double l2s = 0;
+
+ for (k = j + 1 ; k < fm->size2; ++k)
+ {
+ double lambda = gsl_matrix_get (fm, k, j);
+ double lambda_sq = lambda * lambda;
+ double lambda_4 = lambda_sq * lambda_sq;
+
+ l4s += lambda_4;
+ l2s += lambda_sq;
+ }
+ sv += ( fm->size1 * l4s - (l2s * l2s) ) / (fm->size1 * fm->size1 );
+ }
+ return sv;
+}
+
-rotate (const gsl_matrix *unrot, const gsl_vector *communalities, enum rotation_type rot_type,
+rotate (const struct cmd_factor *cf, const gsl_matrix *unrot,
+ const gsl_vector *communalities,
/* First get a normalised version of UNROT */
gsl_matrix *normalised = gsl_matrix_calloc (unrot->size1, unrot->size2);
/* First get a normalised version of UNROT */
gsl_matrix *normalised = gsl_matrix_calloc (unrot->size1, unrot->size2);
for (p = 0; p < normalised->size1; ++p)
{
double jv = gsl_matrix_get (normalised, p, j);
for (p = 0; p < normalised->size1; ++p)
{
double jv = gsl_matrix_get (normalised, p, j);
- rotation_coeff [rot_type] (&x, &y, a, b, c, d, normalised);
+ rotation_coeff [cf->rotation] (&x, &y, a, b, c, d, normalised);
for (p = 0; p < normalised->size1; ++p)
{
double *lambda0 = gsl_matrix_ptr (normalised, p, j);
double *lambda1 = gsl_matrix_ptr (normalised, p, k);
drot_go (phi, lambda0, lambda1);
}
for (p = 0; p < normalised->size1; ++p)
{
double *lambda0 = gsl_matrix_ptr (normalised, p, j);
double *lambda1 = gsl_matrix_ptr (normalised, p, k);
drot_go (phi, lambda0, lambda1);
}
+
+ /* Calculate the convergence criterium */
+ {
+ double lambda = gsl_matrix_get (normalised, k, j);
+ double lambda_sq = lambda * lambda;
+ double lambda_4 = lambda_sq * lambda_sq;
+
+ l4s += lambda_4;
+ l2s += lambda_sq;
+ }
}
gsl_blas_dgemm (CblasNoTrans, CblasNoTrans, 1.0,
}
gsl_blas_dgemm (CblasNoTrans, CblasNoTrans, 1.0,
if (!parse_variables_const (lexer, dict, &factor.vars, &factor.n_vars,
PV_NO_DUPLICATE | PV_NUMERIC))
if (!parse_variables_const (lexer, dict, &factor.vars, &factor.n_vars,
PV_NO_DUPLICATE | PV_NUMERIC))
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
{
/* VARIMAX and DEFAULT are defaults */
if (lex_match_id (lexer, "VARIMAX") || lex_match_id (lexer, "DEFAULT"))
{
/* VARIMAX and DEFAULT are defaults */
if (lex_match_id (lexer, "VARIMAX") || lex_match_id (lexer, "DEFAULT"))
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
- lex_force_match (lexer, ')');
+ lex_force_match (lexer, T_RPAREN);
+ }
+ }
+ else if (lex_match_id (lexer, "RCONVERGE"))
+ {
+ if ( lex_force_match (lexer, T_LPAREN))
+ {
+ lex_force_num (lexer);
+ factor.rconverge = lex_number (lexer);
+ lex_get (lexer);
+ lex_force_match (lexer, T_RPAREN);
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
- lex_match (lexer, '=');
- while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
- tab_text (t, 0, y, TAT_TITLE, _("Sig. 1-tailed"));
+ tab_text (t, 0, y, TAT_TITLE, _("Sig. (1-tailed)"));
factor->wv, factor->exclude);
for ( ; (c = casereader_read (r) ); case_unref (c))
factor->wv, factor->exclude);
for ( ; (c = casereader_read (r) ); case_unref (c))
var_matrix = covariance_moments (cov, MOMENT_VARIANCE);
mean_matrix = covariance_moments (cov, MOMENT_MEAN);
idata->n = covariance_moments (cov, MOMENT_NONE);
var_matrix = covariance_moments (cov, MOMENT_VARIANCE);
mean_matrix = covariance_moments (cov, MOMENT_MEAN);
idata->n = covariance_moments (cov, MOMENT_NONE);
rotated_factors = gsl_matrix_calloc (factor_matrix->size1, factor_matrix->size2);
rotated_loadings = gsl_vector_calloc (factor_matrix->size2);
rotated_factors = gsl_matrix_calloc (factor_matrix->size1, factor_matrix->size2);
rotated_loadings = gsl_vector_calloc (factor_matrix->size2);
- rotate (factor_matrix, extracted_communalities, factor->rotation, rotated_factors, rotated_loadings);
+ rotate (factor, factor_matrix, extracted_communalities, rotated_factors, rotated_loadings);
}
show_explained_variance (factor, idata, idata->eval, extracted_eigenvalues, rotated_loadings);
}
show_explained_variance (factor, idata, idata->eval, extracted_eigenvalues, rotated_loadings);