Skip to content
Rafat Hussain edited this page Apr 22, 2015 · 8 revisions

REG Class and Functions

reg_object obj = reg_init(N,p); // Initialize REG object

// N - Size of Data Vectors (All vectors are assumed to have same length)
// p - Number of Regression Variables (>= 2). In the simple Univariate case( Y ~ b0 + b1 * X + u) , p = 2 
For multiple regressions p > 2

REG Object Parameters

        int N;// Size of Data vectors
	int p;// Total Number of Parameters (>= 2)
	double alpha;// Confidence Interval For Parameters And Residual Variance (1.0 - obj->alpha) * 100
	double sigma;// Residual variance
	double sigma_lower;// Residual variance Lower Limit
	double sigma_upper;// Residual variance Upper Limit
	double r2;// R-Squared
	double r2adj;// Adjusted R-Squared
	double R2[2];// R2[0] = r2, R2[1] = r2adj
	int df;// degree of freedom
	double TSS;// Total Sum Of Squares
	double ESS;// Expected Sum Of Squares
	double RSS;// Residual Sum Of Squares
	int df_ESS;// df due to Regression
	int df_RSS;// df due to Residuals
	double FStat;// F Statistics
	double PVal;// P Values (F)
	bparam beta[1]; // Regression Parameters object beta ( p Parameters) . See below

Regression Parameters beta

	double value;// Parameter Value. ith Parameter value can be accessed by [ (obj->beta+i)->value ]
	double lower;// Parameter Lower Limit [ (obj->beta+i)->lower ]
	double upper;// Parameter Upper Limit [ (obj->beta+i)->upper ]
        double stdErr;// Parameter Standard Error. [ (obj->beta+i)->stdErr ]

Regression Methods (regress and regress_poly)

void regress(reg_object obj, double *x, double *y, double *res, double *varcovar, double alpha);
// Performs Regression Y = b0 + b1 * X1 + b2 * X2 + ... + b(p-1) * X(p-1) + u

// obj - created using reg_init
// x - Independent Variables Vector of size (p-1) * N arranged as x = [x1,x2,....x(p-1)]
// y - Dependent Variable of size N
// res - residual vector of size N
// varcovar - Variance-Covariance Matrix of Size p*p
// alpha - Determines Confidence interval (1-alpha) * 100%

void regress_poly(reg_object obj, double *x, double *y, double *res, double *varcovar, double alpha);
// Performs Regression Y = b0 + b1 * X + b2 * X^2 + ... + b(p-1) * X^(p-1) + u

// obj - created using reg_init
// x - Independent Variables Vector of size N
// y - Dependent Variable of size N
// res - residual vector of size N
// varcovar - Variance-Covariance Matrix of Size p*p
// alpha - Determines Confidence interval (1-alpha) * 100%

Functions associated with REG method


void summary(reg_object obj);// Prints Regression Summary

void anova(reg_object obj);// Prints ANOVA

void confint(reg_object obj);// Prints Confidence Intervals

void zerohyp_val(reg_object obj, double *tval, double *pval);
// Prints Null Hypothesis t-test and associated probabilities values
// Even though the function also returns t values and probabilities value vectors of size p
// each it is recommended that you calculate the values yourself if you are using the code
// only to access these values as screen printing is an expensive operation that can slow 
// down the code. See the function zerohyp_val in the file regression.c and strip away all the
// printf functions

double pointpredict(reg_object obj, double *inp, double *varcovar, double *var);
// Point prediction.
// inp - (p-1) Input Vector
// varcovar - Variance Covariance matrix obtained from regress and regress_poly functions
// var - Variance vector of size 2
// var[0] - Variance of Mean Prediction
// var[1] - Variance Of Individual Prediction
// Output is a double value

Deallocate Object Obj when the computation is finished

 reg_free(obj);

Clone this wiki locally