static void
-rotate (const gsl_matrix *unrot, const gsl_vector *communalities, enum rotation_type rot_type, gsl_matrix *result)
+rotate (const gsl_matrix *unrot, const gsl_vector *communalities, enum rotation_type rot_type,
+ gsl_matrix *result,
+ gsl_vector *rotated_loadings
+ )
{
int j, k;
int i;
gsl_matrix_free (h_sqrt);
- /* reflect negative sums */
+ /* reflect negative sums and populate the rotated loadings vector*/
for (i = 0 ; i < result->size2; ++i)
{
+ double ssq = 0.0;
double sum = 0.0;
for (j = 0 ; j < result->size1; ++j)
{
+ double s = gsl_matrix_get (result, j, i);
+ ssq += s * s;
sum += gsl_matrix_get (result, j, i);
}
+ gsl_vector_set (rotated_loadings, i, ssq);
+
if ( sum < 0 )
for (j = 0 ; j < result->size1; ++j)
{
*lambda = - *lambda;
}
}
-
- // dump_matrix (result);
}
}
}
+ if ( factor.rotation == ROT_NONE )
+ factor.print &= ~PRINT_ROTATION;
+
if ( ! run_factor (ds, &factor))
goto error;
static void
show_explained_variance (const struct cmd_factor * factor, struct idata *idata,
const gsl_vector *initial_eigenvalues,
- const gsl_vector *extracted_eigenvalues)
+ const gsl_vector *extracted_eigenvalues,
+ const gsl_vector *rotated_loadings)
{
size_t i;
int c = 0;
double e_total = 0.0;
double e_cum = 0.0;
+ double r_cum = 0.0;
+
int nc = heading_columns;
if (factor->print & PRINT_EXTRACTION)
e_total = i_total;
}
-
for (i = 0 ; i < factor->n_vars; ++i)
{
const double i_lambda = gsl_vector_get (initial_eigenvalues, i);
const double e_lambda = gsl_vector_get (extracted_eigenvalues, i);
double e_percent = 100.0 * e_lambda / e_total ;
+ const double r_lambda = gsl_vector_get (rotated_loadings, i);
+ double r_percent = 100.0 * r_lambda / e_total ;
+
c = 0;
tab_text_format (t, c++, i + heading_rows, TAB_LEFT | TAT_TITLE, _("%d"), i + 1);
i_cum += i_percent;
e_cum += e_percent;
+ r_cum += r_percent;
/* Initial Eigenvalues */
if (factor->print & PRINT_INITIAL)
tab_double (t, c++, i + heading_rows, 0, i_cum, NULL);
}
+
if (factor->print & PRINT_EXTRACTION)
{
if (i < idata->n_extractions)
tab_double (t, c++, i + heading_rows, 0, e_cum, NULL);
}
}
+
+ if (factor->print & PRINT_ROTATION)
+ {
+ if (i < idata->n_extractions)
+ {
+ tab_double (t, c++, i + heading_rows, 0, r_lambda, NULL);
+ tab_double (t, c++, i + heading_rows, 0, r_percent, NULL);
+ tab_double (t, c++, i + heading_rows, 0, r_cum, NULL);
+ }
+ }
+
}
tab_submit (t);
}
{
+ gsl_matrix *rotated_factors = NULL;
+ gsl_vector *rotated_loadings = NULL;
+
const gsl_vector *extracted_eigenvalues = NULL;
gsl_vector *initial_communalities = gsl_vector_alloc (factor->n_vars);
gsl_vector *extracted_communalities = gsl_vector_alloc (factor->n_vars);
show_communalities (factor, initial_communalities, extracted_communalities);
- show_explained_variance (factor, idata, idata->eval, extracted_eigenvalues);
+
+ if ( factor->rotation != ROT_NONE)
+ {
+ 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);
+ }
+
+ show_explained_variance (factor, idata, idata->eval, extracted_eigenvalues, rotated_loadings);
factor_matrix_workspace_free (fmw);
if ( factor->rotation != ROT_NONE)
{
- gsl_matrix *rotated_factors = gsl_matrix_calloc (factor_matrix->size1, factor_matrix->size2);
-
- rotate (factor_matrix, extracted_communalities, factor->rotation, rotated_factors);
-
show_factor_matrix (factor, idata,
factor->extraction == EXTRACTION_PC ? _("Rotated Component Matrix") : _("Rotated Factor Matrix"),
rotated_factors);
}
+
gsl_vector_free (initial_communalities);
gsl_vector_free (extracted_communalities);
}