Calculation STATBEANS®

 

STATBEAN Name: MultipleRegression

 

Purpose: Fits a multiple regression model to describe the relationship between Y and one or more numeric predictor variables by letting Statgraphics products to function as regression analysis software.

DataSource for the multiple regression software: any. 

Regression Analysis Software Read/Write Properties
Name Type Description Possible Values Default Value
includeConstant boolean Whether to include a constant term in the model. true,false true
maximumSteps int Maximum number of steps if stepwise selection. 1+ 1000
pToEnter double P value to enter coefficient into model. 0.000001-0.999999 0.05
pToRemove double P value to remove coefficient into model. 0.000001-0.999999,
>= pToEnter
0.05
selectionMethod String Selection method for independent variables. "All",
"Forward,"
"Backward"
"All"
tablewiseExclusion boolean Whether all rows of the data table containing a missing value in any column should be excluded from the calculations. true,false false
tolerance double Conditioning tolerance for aborting matrix inversion. >0 and <=0.000001 0.0000000001
xVariableNames String[] The names of the column with data values to be used for the independent (X) variables. Any string. ""
yVariableName String The name of the column with data values to be used for the dependent (Y) variable. Any string. "Y"

Other Public Methods
Name Description Arguments Return Value
double getAdjustedRSquared() Returns the adjusted coefficient of determination. None. Adjusted R-squared, or missingValueCode if model cannot be fit.
void getCoefficientPValues(double[numberOfCoefficients]) Returns the P-values for the estimated coefficients. Double output array. None.
void getCoefficients(double[numberOfCoefficients]) Returns the estimated coefficients. Double output array. None.
void getCooksDistance(double c[n]) Returns Cook's distance corresponding to each row in the datasource. Double output array. None.
void getDegreesOfFreedom(int df[3]) Returns the degrees of freedom corresponding to the sums of squares. Double output array. None.
void getDFFITS(double d[n]) Returns the DFFITS statistic corresponding to each row in the datasource. Double output array. None.
double getDurbinWatson() Returns the Durbin-Watson statistic. None. DW, or missingValueCode if model cannot be fit.
void getInModel(boolean[]) Returns true if an X variable is in the final model. Boolean output array. None.
int getNumberOfCoefficients() Returns the number of coefficients in the fitted model. None. Number of coefficients.
void getLeverages(double h[n]) Returns the leverage corresponding to each row in the datasource. Double output array. None.
double getLowerConfidenceLimit(double x[],double conflevel) Returns the lower confidence limit for the mean value of Y. Values of X at which to make prediction, and the percentage confidence. Lower limit.
double getLowerPredictionLimit(double x[],double meansize,double conflevel) Returns the lower prediction limit for a new value of Y. Values of X at which to make prediction,number of observations at X, and the percentage confidence. Lower limit.
void getMahalanobisDistance(double c[n]) Returns the Mahalanobis distance corresponding to each row in the datasource. Double output array. None.
double getMeanAbsoluteError() Returns the residual mean absolute error. None. MAE, or missingValueCode if model cannot be fit.
double getMeanSquaredError() Returns the residual mean squared error. None. MSE, or missingValueCode if model cannot be fit.
double getModelPValue() Returns the P-value for the fitted model. None. P-value.
void getPredictedValues(double p[n]) Returns the predicted value of Y corresponding to each row in the datasource. Double output array. None.
double getPrediction(double x[]) Returns the predicted value of Y. Value of X's at which to make prediction. Predicted value.
double getResidualDegreesOfFreedom() Returns the d.f. for the error term used to estimate the standard errors. None. Residual df, or 0 if model cannot be fit.
void getResiduals(double r[n]) Returns the residual corresponding to each row in the datasource. Double output array. Residual or missingValueCode.
double getResidualStandardError() Returns the estimated standard deviation of the residuals. None. Standard error of the estimate, or missingValueCode if model cannot be fit.
double getRSquared() Returns the coefficient of determination. None. R-squared, or missingValueCode if model cannot be fit.
double getSampleSize() Returns the number of non-missing data values. None. Sample size.
void getStandardErrors(double[numberOfCoefficients]) Returns the coefficient standard errors. Double output array. None.
void getStudentizedResiduals(double s[n]) Returns the studentized deleted residual corresponding to each row in the datasource. Double output array. None.
void getSumsOfSquares(double ss[3]) Returns the following sums of squares: total, model, residual. Double output array. None.
void getTypeISumsOfSquares(double[]) Returns the reduction in the residual sum of squares as each variable is entered into the model. Double output array. None.
double getUpperConfidenceLimit(double x[],double conflevel) Returns the upper confidence limit for the mean value of Y. Values of X at which to make prediction, and the percentage confidence. Upper limit.
double getUpperPredictionLimit(double x[],double meansize,double conflevel) Returns the upper prediction limit for a new value of Y. Values of X at which to make prediction, number of observations at X, and the percentage confidence. Upper limit.
void getVIF(double[]) Returns the variance inflation factors for each X variable in the final model. Double output array. None.
void getXTXInverse(double xtxinv[]) Returns the inverted X-transpose-X matrix. Output array of dimension equal to number of coefficients in model squared. Inverted matrix.

Output Variables
Name Description
CooksD Cook's distance corresponding to each row in the datasource.
DFFITS The DFFITS statistic corresponding to each row in the datasource.
Leverage The leverage corresponding to each row in the datasource.
MahalanobisD The Mahalanobis distance corresponding to each row in the datasource.
Predicted The predicted value of Y corresponding to each row in the datasource.
Residual The residual corresponding to each row in the datasource.
SResidual The studentized deleted residual corresponding to each row in the datasource.

Other properties are inherited from the general CalculationStatbean class. 
Code Sample 

//create a datasource bean 
FileDataSource fileDataSource1 = new STATBEANS.FileDataSource(); 

//set the file name to be read 
fileDataSource1.setFileName("c:\\statbeans\\samples\\cardata.txt"); 

//create a calculation bean 
MultipleRegression multipleRegression1 = new STATBEANS.MultipleRegression(); 

//set the column names 
multipleRegression1.setYVariableName("mpg"); 
java.lang.String[] tempString = new String[3]; 
tempString[0] = "weight"; 
tempString[1] = "horsepower"; 
tempString[2] = "displace"; 
multipleRegression1.setXVariableNames(tempString); 

//create a table bean 
MultipleRegressionTable multipleRegressionTable1 = new STATBEANS.MultipleRegressionTable(); 

//create plot beans 
MultipleRegressionComponentPlot multipleRegressionPlot1 = new STATBEANS.MultipleRegressionComponentPlot(); 
MultipleRegression2DResponsePlot multipleRegressionPlot2 = new STATBEANS.MultipleRegression2DResponsePlot(); 
MultipleRegressionContourPlot multipleRegressionPlot3 = new STATBEANS.MultipleRegressionContourPlot(); 
MultipleRegressionSurfacePlot multipleRegressionPlot4 = new STATBEANS.MultipleRegressionSurfacePlot(); 

//set the column for the x axis 
multipleRegression1.setXVariableName("weight"); 
//make the calculation bean a listener for changes in the FileDataSource bean 
fileDataSource1.addDataChangeListener(multipleRegression1.listenerForDataChange); 

//make the table and plot beans listeners for changes in the calculation bean 
multipleRegression1.addDataChangeListener(multipleRegressionTable1.listenerForDataChange); 
multipleRegression1.addDataChangeListener(multipleRegressionPlot1.listenerForDataChange); 
multipleRegression1.addDataChangeListener(multipleRegressionPlot2.listenerForDataChange); 
multipleRegression1.addDataChangeListener(multipleRegressionPlot3.listenerForDataChange); 
multipleRegression1.addDataChangeListener(multipleRegressionPlot4.listenerForDataChange); 

//set holdat values 
double hold[]=new double[3]; 
hold[0]=2500; 
hold[1]=90; 
hold[2]=150; 
multipleRegressionPlot2.setHoldAt(hold); 
multipleRegressionPlot3.setHoldAt(hold); 
multipleRegressionPlot4.setHoldAt(hold); 

//instruct the fileDataSource bean to read the file 
fileDataSource1.readData();