X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Flinreg%2Fpspp_linreg.h;h=a83f7b3d11ec7a8b5d240ec194b838082d0e3da9;hb=f6824ecbc579c68db49144fede419ca0acb0f53b;hp=496bad7b2151db9b430c5709082b871f1621ed0b;hpb=1b6675f7b58799c73b2642378c35acc1bdad2df7;p=pspp diff --git a/lib/linreg/pspp_linreg.h b/lib/linreg/pspp_linreg.h index 496bad7b21..a83f7b3d11 100644 --- a/lib/linreg/pspp_linreg.h +++ b/lib/linreg/pspp_linreg.h @@ -45,7 +45,7 @@ Springer. 1998. ISBN 0-387-98542-5. */ #ifndef PSPP_LINREG_H -#define PSPP_LINREG_H +#define PSPP_LINREG_H 1 #include #include #include @@ -54,6 +54,9 @@ #include #include #include +#include +#include +#define PSPP_LINREG_VAL_NOT_FOUND -1 enum { PSPP_LINREG_SWEEP, @@ -62,18 +65,47 @@ enum /* Cache for the relevant data from the model. There are several - members which the caller may not use, and which could use a lot of + members which the caller might not use, and which could use a lot of storage. Therefore non-essential members of the struct will be allocated only when requested. */ +struct pspp_linreg_coeff +{ + double estimate; /* Estimated coefficient. */ + double std_err; /* Standard error of the estimate. */ + struct varinfo *v_info; /* Information pertaining to the + variable(s) associated with this + coefficient. The calling function + should initialize this value with the + functions in coefficient.c. The + estimation procedure ignores this + member. It is here so the caller can + match parameters with relevant variables + and values. If the coefficient is + associated with an interaction, then + v_info contains information for multiple + variables. + */ + int n_vars; /* Number of variables associated with this coefficient. + Coefficients corresponding to interaction terms will + have more than one variable. + */ +}; struct pspp_linreg_cache_struct { int n_obs; /* Number of observations. */ int n_indeps; /* Number of independent variables. */ - gsl_vector *depvar; - gsl_matrix *indepvar; + int n_coeffs; + + /* + The variable struct is ignored during estimation. + It is here so the calling procedure can + find the variable used in the model. + */ + const struct variable *depvar; + gsl_vector *residuals; - gsl_vector *param_estimates; + struct pspp_linreg_coeff *coeff; int method; /* Method to use to estimate parameters. */ /* Means and standard deviations of the variables. @@ -81,8 +113,8 @@ struct pspp_linreg_cache_struct called, pspp_linreg() will compute their values. Entry i of indep_means is the mean of independent - variable i, whose observations are stored in column i - of indepvar. + variable i, whose observations are stored in the ith + column of the design matrix. */ double depvar_mean; double depvar_std; @@ -158,4 +190,17 @@ void pspp_linreg_cache_free (pspp_linreg_cache * cache); int pspp_linreg (const gsl_vector * Y, const gsl_matrix * X, const pspp_linreg_opts * opts, pspp_linreg_cache * cache); +void pspp_linreg_coeff_init (pspp_linreg_cache *, struct design_matrix *); + +void pspp_linreg_coeff_free (struct pspp_linreg_coeff *); + +void pspp_linreg_coeff_set_estimate (struct pspp_linreg_coeff *, double); + +void pspp_linreg_coeff_set_std_err (struct pspp_linreg_coeff *, double); + +int pspp_linreg_coeff_get_n_vars (struct pspp_linreg_coeff *); + +const struct variable *pspp_linreg_coeff_get_var (struct pspp_linreg_coeff *, int); + +const union value *pspp_linreg_coeff_get_value (struct pspp_linreg_coeff *, const struct variable *); #endif