-
Notifications
You must be signed in to change notification settings - Fork 0
func
Rafat Hussain edited this page Apr 25, 2015
·
16 revisions
void linreg_clrm(double *x,double *y, int N, double* b,
double *var,double *res,double alpha,double *anv,
double* ci_lower, double* ci_upper);
/*
* Classic Linear Regression Model
* y = b[0] + b[1] * x + u
* x,y and res are all of same length - N
* where res is the residual
*
* alpha is used to determine confidence interval limits
* for a given 100*(1-alpha) % confidence interval
*
*
* Alpha takes values between 0 and 1.
*
* For 95% confidence interval, the value of alpha is 0.05
* For 90% confidence interval, the value of alpha is 0.10 etc.
*/
/*
* Parameters ( b is a double vector of length 2)
* b[0] - beta1
* b[1] - beta2
*/
/* Variances ( var is a double vector of length 5)
* var[0] - variance of residuals
* var[1] variance beta1
* var[2] variance beta2
* var[3] covariance beta1,beta2
* var[4] r^2 Goodness of Fit
*/
/*
* ANOVA ( anv is a double vector of length 7)
*
* anv[0] - TSS Total Sum Of Squares
* anv[1] - ESS Explained Sum Of Squares
* anv[2] - RSS Residual Sum Of Squares
* anv[3] - degrees of freedom of ESS
* anv[4] - degrees of freedom of RSS
* anv[5] - F Statistics = (anv[1] / anv[3]) / (anv[2] / anv[4])
* anv[6] - P value associated with anv[5] used to reject/accept
* zero hypothesis
*/
/* ci_lower and ci_upper (Confidence Interval Lower and Upper Limits)
* ( double vectors of length 3)
* ci_lower[0] - CI Lower Limit corresponding to b[0]
* ci_lower[1] - CI Lower Limit corresponding to b[1]
* ci_lower[2] - CI Lower Limit corresponding to var[0] (sigma^2)
* ci_upper[0] - CI Upper Limit corresponding to b[0]
* ci_upper[1] - CI Upper Limit corresponding to b[1]
* ci_upper[2] - CI Upper Limit corresponding to var[0] (sigma^2)
*/
void zerohyp_clrm(int N,double *b, double *var, double *tval, double *pval) {
Zero Hypothesis Test for CLRM
N is the length of the data series. b and var are parameters/variances obtained from linreg_clrm function. tval and pval are double vectors of length 2 each containing Student's T values and the corresponding probability distribution values.
void linreg_multi(int p, double *x, double *y, int N, double* b, double *sigma2,
double *xxti, double *R2, double *res, double alpha, double *anv,
double* ci_lower, double* ci_upper);
/*
* Multiple Regression Model
* y = b[0] + b[1] * x1 + .. + b[p-1]* xp-1 + u
* p is the total number of parameters (p >= 2 for multiple Regression)
* y and res are all of same length - N
* where res is the residual
* x is of length (p-1) * N
* alpha is used to determine confidence interval limits
* for a given 100*(1-alpha) % confidence interval
*
*
* Alpha takes values between 0 and 1.
*
* For 95% confidence interval, the value of alpha is 0.05
* For 90% confidence interval, the value of alpha is 0.10 etc.
*/
/*
* Parameters ( b is a double vector of length 2)
* b[0] - beta1
* b[1] - beta2
*/
/* Variances ( var is a double vector of length 5)
* sigma2 - variance of residuals
* xxti - Variance-Covariance Matrix of size p*p
* R2[0] and R2[1] - R2 is double vector of length 2. r^2 Goodness of Fit and adjust r^2
*/
/*
* ANOVA ( anv is a double vector of length 7)
*
* anv[0] - TSS Total Sum Of Squares
* anv[1] - ESS Explained Sum Of Squares
* anv[2] - RSS Residual Sum Of Squares
* anv[3] - degrees of freedom of ESS
* anv[4] - degrees of freedom of RSS
* anv[5] - F Statistics = (anv[1] / anv[3]) / (anv[2] / anv[4])
* anv[6] - P value associated with anv[5] used to reject/accept
* zero hypothesis
*/
/* ci_lower and ci_upper (Confidence Interval Lower and Upper Limits)
* ( double vectors of length p+1)
* ci_lower[0] to ci_lower[p-1] corresponding to b[0],...,b[p-1]
* ci_lower[p] - CI Lower Limit corresponding to sigma2 (sigma^2)
* ci_upper[0] to ci_upper[p-1] corresponding to b[0],...,b[p-1]
* ci_upper[p] - CI Upper Limit corresponding to sigma2 (sigma^2)
*/
void zerohyp_multi(int N,double *b,int p, double *varcovar, double *tval, double *pval)
Zero Hypothesis Test for Multiple Regression Model
N is the length of the data series and p is the total number of parameters. b and varcovar are parameters/Variance-Covariance Matrices obtained from linreg_multi function. tval and pval are double vectors of length 2 each containing Student's T values and the corresponding probability values.