[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pspp-cvs] pspp/src/language/stats regression.q ChangeLog
From: |
Jason H Stover |
Subject: |
[Pspp-cvs] pspp/src/language/stats regression.q ChangeLog |
Date: |
Sat, 17 Mar 2007 03:08:24 +0000 |
CVSROOT: /sources/pspp
Module name: pspp
Changes by: Jason H Stover <jstover> 07/03/17 03:08:24
Modified files:
src/language/stats: regression.q ChangeLog
Log message:
Support moments
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/stats/regression.q?cvsroot=pspp&r1=1.45&r2=1.46
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/stats/ChangeLog?cvsroot=pspp&r1=1.45&r2=1.46
Patches:
Index: regression.q
===================================================================
RCS file: /sources/pspp/pspp/src/language/stats/regression.q,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -b -r1.45 -r1.46
--- regression.q 9 Feb 2007 05:19:08 -0000 1.45
+++ regression.q 17 Mar 2007 03:08:23 -0000 1.46
@@ -45,6 +45,7 @@
#include <math/design-matrix.h>
#include <math/coefficient.h>
#include <math/linreg/linreg.h>
+#include <math/moments.h>
#include <output/table.h>
#include "gettext.h"
@@ -82,6 +83,15 @@
/* (functions) */
static struct cmd_regression cmd;
+/*
+ Moments for each of the variables used.
+ */
+struct moments_var
+{
+ struct moments *m;
+ struct variable *v;
+};
+
/* Linear regression models. */
static pspp_linreg_cache **models = NULL;
@@ -961,10 +971,11 @@
/*
Mark missing cases. Return the number of non-missing cases.
+ Compute the first two moments.
*/
static size_t
mark_missing_cases (const struct casefile *cf, struct variable *v,
- int *is_missing_case, double n_data)
+ int *is_missing_case, double n_data, struct moments_var
*mom)
{
struct casereader *r;
struct ccase c;
@@ -977,6 +988,10 @@
row = casereader_cnum (r) - 1;
val = case_data (&c, v);
+ if (mom != NULL)
+ {
+ moments_pass_one (mom->m, val->f, 1.0);
+ }
cat_value_update (v, val);
if (var_is_value_missing (v, val, MV_ANY))
{
@@ -1049,7 +1064,7 @@
static int
prepare_data (int n_data, int is_missing_case[],
struct variable **indep_vars,
- struct variable *depvar, const struct casefile *cf)
+ struct variable *depvar, const struct casefile *cf, struct
moments_var *mom)
{
int i;
int j;
@@ -1069,13 +1084,13 @@
cat_stored_values_create (v_variables[i]);
}
n_data =
- mark_missing_cases (cf, v_variables[i], is_missing_case, n_data);
+ mark_missing_cases (cf, v_variables[i], is_missing_case, n_data,
mom + i);
}
}
/*
Mark missing cases for the dependent variable.
*/
- n_data = mark_missing_cases (cf, depvar, is_missing_case, n_data);
+ n_data = mark_missing_cases (cf, depvar, is_missing_case, n_data, NULL);
return n_data;
}
@@ -1108,6 +1123,7 @@
struct ccase c;
struct variable **indep_vars;
struct design_matrix *X;
+ struct moments_var *mom;
gsl_vector *Y;
pspp_linreg_opts lopts;
@@ -1135,7 +1151,12 @@
}
is_missing_case = xnmalloc (n_cases, sizeof (*is_missing_case));
-
+ mom = xnmalloc (n_variables, sizeof (*mom));
+ for (i = 0; i < n_variables; i++)
+ {
+ (mom + i)->m = moments_create (MOMENT_VARIANCE);
+ (mom + i)->v = v_variables[i];
+ }
lopts.get_depvar_mean_std = 1;
for (k = 0; k < cmd.n_dependent; k++)
@@ -1151,7 +1172,7 @@
}
n_data = prepare_data (n_cases, is_missing_case, indep_vars,
cmd.v_dependent[k],
- (const struct casefile *) cf);
+ (const struct casefile *) cf, mom);
Y = gsl_vector_alloc (n_data);
X =
@@ -1237,7 +1258,11 @@
free (lopts.get_indep_mean_std);
casereader_destroy (r);
}
-
+ for (i = 0; i < n_variables; i++)
+ {
+ moments_destroy ((mom + i)->m);
+ }
+ free (mom);
free (is_missing_case);
return true;
Index: ChangeLog
===================================================================
RCS file: /sources/pspp/pspp/src/language/stats/ChangeLog,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -b -r1.45 -r1.46
--- ChangeLog 17 Feb 2007 16:16:23 -0000 1.45
+++ ChangeLog 17 Mar 2007 03:08:23 -0000 1.46
@@ -1,3 +1,7 @@
+2007-03-16 Jason Stover <address@hidden>
+
+ * regression.q (run_regression): Added support for moments.
+
Sat Feb 17 08:16:00 2007 Ben Pfaff <address@hidden>
* flip.c (flip_sink_create): Improve error message when temporary
- [Pspp-cvs] pspp/src/language/stats regression.q ChangeLog,
Jason H Stover <=