Merge commit 'origin/stable'
[pspp-builds.git] / src / math / linreg.h
index 18f962c06046b1af232af22b656d231722bcbd65..f9d8c9b3f740abfc161ea7df2ecf20131985f700 100644 (file)
@@ -21,6 +21,7 @@
 #include <gsl/gsl_vector.h>
 #include <gsl/gsl_matrix.h>
 #include <src/math/coefficient.h>
+#include <math/covariance-matrix.h>
 
 enum
 {
@@ -96,9 +97,10 @@ struct pspp_linreg_cache_struct
                                   coefficient here. */
 
   /*
-    Pointer to the dependent variable.
+    Pointers to the variables.
    */
   const struct variable *depvar;
+  const struct variable **indep_vars;
 
   gsl_vector *residuals;
   struct pspp_coeff **coeff;
@@ -175,7 +177,8 @@ typedef struct pspp_linreg_cache_struct pspp_linreg_cache;
   to it. n is the number of cases, p is the number of
   independent variables.
  */
-pspp_linreg_cache *pspp_linreg_cache_alloc (size_t n, size_t p);
+pspp_linreg_cache *pspp_linreg_cache_alloc (const struct variable *, const struct variable **, 
+                                           size_t, size_t);
 
 bool pspp_linreg_cache_free (void *);
 
@@ -197,7 +200,7 @@ pspp_linreg_residual (const struct variable **, const union value **,
 /*
   All variables used in the model.
  */
-int pspp_linreg_get_vars (const void *, struct variable **);
+int pspp_linreg_get_vars (const void *, const struct variable **);
 
 struct pspp_coeff *pspp_linreg_get_coeff (const pspp_linreg_cache
                                                       *,
@@ -214,4 +217,10 @@ void pspp_linreg_set_indep_variable_sd (pspp_linreg_cache *, const struct variab
  */
 double pspp_linreg_get_indep_variable_mean (pspp_linreg_cache *, const struct variable *);
 void pspp_linreg_set_indep_variable_mean (pspp_linreg_cache *, const struct variable *, double);
+
+/*
+  Regression using only the covariance matrix.
+ */
+void pspp_linreg_with_cov (const struct covariance_matrix *, pspp_linreg_cache *);
+double pspp_linreg_mse (const pspp_linreg_cache *);
 #endif