projects
/
pspp-builds.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
afcb117
)
Added variable/parameter matching and error reporting
author
Jason Stover
<jhs@math.gcsu.edu>
Fri, 28 Oct 2005 20:54:06 +0000
(20:54 +0000)
committer
Jason Stover
<jhs@math.gcsu.edu>
Fri, 28 Oct 2005 20:54:06 +0000
(20:54 +0000)
src/regression.q
patch
|
blob
|
history
diff --git
a/src/regression.q
b/src/regression.q
index ca0b65f54cf20f18cb7e821475403c637ba36515..56420c5335e964dd20ee7a3de9a21aa484fd6aa3 100644
(file)
--- a/
src/regression.q
+++ b/
src/regression.q
@@
-24,16
+24,19
@@
#include <gsl/gsl_matrix.h>
#include "alloc.h"
#include "case.h"
#include <gsl/gsl_matrix.h>
#include "alloc.h"
#include "case.h"
+#include "casefile.h"
+#include "cat.h"
+#include "command.h"
#include "dictionary.h"
#include "dictionary.h"
+#include "error.h"
#include "file-handle.h"
#include "file-handle.h"
-#include "
command
.h"
+#include "
gettext
.h"
#include "lexer.h"
#include "lexer.h"
+#include <linreg/pspp_linreg.h>
#include "tab.h"
#include "var.h"
#include "vfm.h"
#include "tab.h"
#include "var.h"
#include "vfm.h"
-#include "casefile.h"
-#include <linreg/pspp_linreg.h>
-#include "cat.h"
+
/* (headers) */
/* (headers) */
@@
-69,6
+72,11
@@
static struct cmd_regression cmd;
*/
size_t *indep_vars;
*/
size_t *indep_vars;
+/*
+ Return value for the procedure.
+ */
+int pspp_reg_rc = CMD_SUCCESS;
+
static void run_regression (const struct casefile *, void *);
/*
STATISTICS subcommand output functions.
static void run_regression (const struct casefile *, void *);
/*
STATISTICS subcommand output functions.
@@
-143,7
+151,8
@@
reg_stats_coeff (pspp_linreg_cache * c)
struct tab_table *t;
assert (c != NULL);
struct tab_table *t;
assert (c != NULL);
- n_rows = 2 + c->param_estimates->size;
+ n_rows = 2;
+
t = tab_create (n_cols, n_rows, 0);
tab_headers (t, 2, 0, 1, 0);
tab_dim (t, tab_natural_dimensions);
t = tab_create (n_cols, n_rows, 0);
tab_headers (t, 2, 0, 1, 0);
tab_dim (t, tab_natural_dimensions);
@@
-462,7
+471,7
@@
cmd_regression (void)
}
multipass_procedure_with_splits (run_regression, &cmd);
}
multipass_procedure_with_splits (run_regression, &cmd);
- return
CMD_SUCCESS
;
+ return
pspp_reg_rc
;
}
/*
}
/*
@@
-492,6
+501,7
@@
run_regression (const struct casefile *cf, void *cmd_ UNUSED)
size_t n_data = 0;
size_t row;
int n_indep;
size_t n_data = 0;
size_t row;
int n_indep;
+ int j = 0;
const union value *val;
struct casereader *r;
struct casereader *r2;
const union value *val;
struct casereader *r;
struct casereader *r2;
@@
-560,7
+570,13
@@
run_regression (const struct casefile *cf, void *cmd_ UNUSED)
*/
if (is_depvar (i))
{
*/
if (is_depvar (i))
{
- assert (v->type == NUMERIC);
+ if (v->type != NUMERIC)
+ {
+ msg (SE, gettext ("Dependent variable must be numeric."));
+ pspp_reg_rc = CMD_FAILURE;
+ return;
+ }
+ lcache->depvar = (const struct var *) v;
gsl_vector_set (Y, row, val->f);
}
else
gsl_vector_set (Y, row, val->f);
}
else
@@
-581,6
+597,18
@@
run_regression (const struct casefile *cf, void *cmd_ UNUSED)
}
}
}
}
}
}
+ /*
+ Now that we know the number of coefficients, allocate space
+ and store pointers to the variables that correspond to the
+ coefficients.
+ */
+ lcache->coeff = xnmalloc (X->m->size2 + 1, sizeof (*lcache->coeff));
+ for (i = 0; i < X->m->size2; i++)
+ {
+ j = i + 1; /* The first coeff is the intercept. */
+ lcache->coeff[j].v =
+ (const struct variable *) design_matrix_col_to_var (X, i);
+ }
/*
Find the least-squares estimates and other statistics.
*/
/*
Find the least-squares estimates and other statistics.
*/
@@
-592,6
+620,7
@@
run_regression (const struct casefile *cf, void *cmd_ UNUSED)
free (lopts.get_indep_mean_std);
free (indep_vars);
casereader_destroy (r);
free (lopts.get_indep_mean_std);
free (indep_vars);
casereader_destroy (r);
+ return;
}
/*
}
/*