LazStats: initial commit.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7345 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-03-30 18:01:44 +00:00
parent 90366be659
commit 2f33dc9f7b
381 changed files with 173808 additions and 0 deletions

View File

@ -0,0 +1,5 @@
1
0
3
2
D:\Prog_Lazarus\wp-git\LazStats

View File

@ -0,0 +1,14 @@
--------------------------------------------------------------------------------
LazStats
--------------------------------------------------------------------------------
Clone of the LazStats statistics application by William Miller
(https://openstat.info/LazStatsMain.htm)
What is different?
------------------
- Updated form layout.
- Units into subfolders for each major menu command in order to avoid the
extremely long file list in the project manager.
- Include data and html folder of the original site. Add data file from the
OpenStat application mentioned in the pdf help files.
- Create chm help from the original pdf help files, tool used: HelpNDoc.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

View File

@ -0,0 +1,64 @@
[LANGUAGE]
DEFAULT=ENGLISH
[ENGLISH]
101=Directions: For entry of data on this form, enter the number of rows, columns and slices in the boxes provided. Press enter after each entry. Then enter the frequencies observed for each cell in the grid. If entering data from a file in the main grid, select the row, column, slice and frequency variables by selecting from the list of variables and clicking the right-arrow for the corresponding variable. Click the compute button to obtain the results.
102=The AxBxR ANOVA involves two between treatment factors and repeated measures factors. Two grid column variables contain the A and B treatment values (codes 1, 2, etc.) and 2 to K grid column variables for the repeated measure observations. All ABC groups are assumed to be of the same size. There is a maximum of 20 repeated measures.
103=This procedure analyzes fixed effects with up to three levels of interaction and one or more covariates. Multiple regression methods are used (See "Multiple Regression in Behavioral Research" by Elazar J. Pedhazur, Harcourt, Brace, College Publishers, 1997, Chapter 16, pages 675-713.) A test is performed for the assumption of homogeneous regression slopes in addition to the ANCOVA. Both adjusted and unadjusted means are reported. Comparisons are made among the adjusted means.
104=Directions: Select a variable to analyze. You may analyxe series from either a column (default) or a "Case" row. You may elect to analyze all values in a column (or row) as desiredClick the buttons for any desired smoothing options. The program will automatically "split" the list of row values (or column values) for that variable into two sub-sets of X and Y scores with each Y score being the value which "lags" behind the X score in the list by k lag values. All possible lags which yield a sample as large as 3 or more are computed and plotted in a "correlogram". You may optionally print the lag,
correlation, means, standard deviations and confidence interval for each correlation. The differences between original and smoothed values (residuals) may be plotted. The smoothed points replace the original values in the analysis if smoothing is elected.
105=The main grid should contain a symetric matrix of similarity or dissimilarity values representing distances among the objects to be clustered. Check the type box io indicate if the measures are similarities (e.g. correlations) or dissimilarities.
106=Directions: It is assumed you have one grid column variable representing the group codes for the (A) between treatment groups effect and 2 to k column variables representing the repeated measures. Group codes should be sequential values of 1, 2, etc. You may elect to plot the means.
107=Directions: You may elect to complete a 1, 2 or 3 way ANOVA by selecting a dependent variable and 1, 2 or 3 factor variables. If you elect post-hoc tests, comparisons are made between factor levels. NOTE: some post-hoc comparisons are made only with equal N's.
108=Directions: First click on the variable name that represents the group codes. Next, click on the variable that reresents the measurement to be plotted. Click the Compute button to obtain the results. You can obtain a single boxplot for all cases if you use a "dummy" group variable containing only the group code 1 for all cases.
109=Directions: First, select the categorical variables of your study. Select them in the order of the desired breakdown. Next, slect the continuous variable for which you want statistics for each cell obtained by by breaking down the categorical variables into their respective categories.
110=Directions: 1. Select the variable containing the bubble identification mumber - an integer in the range of 1 to N objects. 2. Select the variable representing the X axis integer value for the object. This is the repeated measures variable. 3. Select the variable representing the Y axis. This should be a floating point value. 4. Select the variable representing the size of the bubble for each object to be plotted at the X and Y location. NOTE: Each data line reresents one replication (X value) of the object plotted. See the example data in the file labeled BubblePlot.LAZ
111=NOTE: No. of left hand variables must be less than or equal to the number of right hand variables.
112=Directions: Click on the variable that represents the measurement. Click on the Sigma button to change the default value. Click the Compute button to obtain the results.
113=Directions: Two to k variables representing dichotomous (0,1) values are analyzed for N cases. The values of the variables reflect repeated observations on the same subjects or on matched subjects. Click the variables on the left to analyze and enter them by clicking the right arrow button.
114=Directions: Forst select the test scores from the available variables. You will see a default reliability and weight ssigned to each score selected in list boxes to the right. If you click on either a reliability or a weight, an input box will appear in which you can enter a new reliability or weight. Note - you can use the KR#21 reliability program to estimate reliability if you know the maximum score.
115=Directions: A Judge's ratings or observations are recorded as variables (columns) 1 through k. Each line conrresponds to a different judge (person making the rating.) Select the variables from the left list to analyze and click on the right arrow button to enter them. To remove a variable from the list of selected ones, click on the variable name in the selected list and click the left arrow button. Click the Compute button to obtain the results.
116=Directions: Select each categorical variable from the available variables in the leftmost box in the order that you wish to have the breakdown proceed. Click the OK button to start the analysis.
117=Directions: First, click on the variable name that represents the sample lot number. Next, click on the variable that represents the measurement. Click on the Delta size and enter the desired value. Click on the alpha and/or beta probability boxes and enter values to change from the default values. You may also enter target specifications if you first click the check box to use a target specification.
118=Description: Double Declining Value determines accelerated depreciation values for an asset given the initial cost, life expectancy, and value, and depreciation period. EXAMPLE: What is the depreciation value for a computer with a life expectancy of three years if it initially cost $2,000.00 with no expected value at the end of the three years? Initial Cost = 2000.00 Life Expectancy = 3 End Value = 0.0 Depreciation Period = 3 ANSWER: $148.15
119=This procedure provides means, variances, standard deviations, skewness, kurtosis and range values for each variable selected. Select the variables in the left list and enter them for analysiis by clicking the right arrow. If you select the z score option, a new variable will be added to your grid for each variable you select. The new variable will contain the transformation of the original variable into a z score.
120=Each row of the grid below corresponds to one column of the data grid. Complete the information requested in each cell of the row. To add another variable (row in the dictionary), press the down-arrow on your keyboard.
121=Directions: Specify the lag value for the differences desired, e.g. 1 to obtain the difference between point 1 and 2, 2, and 3, etc. Also, indicate the order, i.e. the number of times to repeat the differencing operation. Click OK when ready.
122=This procedure is an adaptation of the program written by Niels G. Waller, Dept. of Psychology, University of California-Davis, Jan. 1998. It's purpose is to identify test items that differ in the response pattern for two groups: a reference group and a focal group. The file of data to be analyzed should consist of a variable containing a code designating the two groups and variables containing subject's item responses coded 0 for incorrect and 1 for correct. No missing data may be included. The results provide the Mantel-Haenszel statistics for identifying those items which are different for the two groups.
123=Directions: The number of intervals may not exceed the number of cses. To change the interval size, click on the current size and replace it with a new size. Press the enter button after entering a new value.
124=Directions: The two way ANOVA on ranks is similar to a mixed design ANOVA with repeated measures (1 to k conditions) on ssubjects in 1 to M groups. The program expects one variable to represent the group code, and 1 to k score variables for each case. The scores for the cases in each group are used to obtain rankings among the k scores within each group. The test is whether or not the rank totals for the conditions are equal within the expected sampling variability.
125=This procedure calculates the Kappa coefficient for objects or subjects classified into two or more categories by a group of judges or procedures. Each object is coded with a sequential integer ranging from 1 to the number of objects. Each judge is also coded with an integer from 1 to the number of judges. Categories are numbered with integers from 1 to the number of categories. These are column variables. It is expected that the total number of cases will be the number of judges times the number of objects.
126=Directions: he GLM procedure permits the user to specify multiple dependent variables and multiple independent variables. Variables for both dependent and independent may be either continuous or categorical variables. The independent variables are classified as fixed effects, random effects, repeated measures or covariates. Interactions among the independent variables may be specified for the model used. To define an interaction in your model, click the start definition button and then click on each independent variable to be included in the interaction. Click the end definition button to end the definition. A maximum of 5 terms is allowed in an interaction.
127=You may obtasin results for a single group or for experimental and control groups. If there is only one group, leave the group variable blank. Data entered on each line of the data grid represent one case within a group. You will typically have two or three columns of data with variable labels like "TIME", "GROUP" and "EVENT". Each variable should be defined as an integer in your variable definitions. Note that the code for experimental and control groups are 1 and 2. The coding for the event or censored is 1 for the event (death) and 2 for the censored (lost, can't observe.) An example file with the name "KaplanMeierTest.LAZ is available for use.
128=This procedure provides both the weighted and unweighted Kappa Coefficients for assessing the consistency of judgements for two raters. It also provides other measures of the independence of the ratings. If nominal categories are used in the ratings, the unweighted statistic is appropriate. If the categories represent ordinal data, the weighted Kappa statistics may be appropriate. The number of rows must equal the number of columns to calculate the Kappa statistics.
129=The main grid should contain data values representing variables meansured on the objects to be clustered (rows.) Enter the desired number of clusters, select the variables to use in clustering and select the options desired.
130=See B. J. Winer's "Statistical Principles in Experimental Design", McGraw-Hill Book Company, New York, 1962, pages 514-577 for the analyses plans provided in this procedure. Note: Factor codes should be formatted as integers, data values as floating point values. All cell sizes should be equal and no missing values are allowed.
131=Complete the specifications for your log-linear analysis of cross-classivation data as indicated below. Complete step 1, step 2 and step 3. Select any options desired. Click the Compute button to obtain the results. Should you need to start over, click the Reset button. When your analysis or analyses are commpleted, click the Return button.
132=Directions: Enter the order of the moving averae. The order is the number of values on each side of a point to be included in the average. When you enter a value, a list of corresponding thetas will appear in the list. Click on each theta of the list for entry of the desired weight (default 1.0). Enter a weight in the theta value box and press the enter key. Repeat for each theta in the list. Click the Apply button when ready. The theta values will be re-proportioned to sum to 1.0 accross all values. Click the OK button to continue.
133=Directions: You may generate sample multivariate data from a population with known intercorrelation among the variables and with known population means and standard deviations. Enter the number of variables and size of the sample to generate. Then enter the correlations among the variables row-wise the program will fill in the lower triangular values.) Next, enter the population means and standard deviations. When ready to generate the data, click the ComputeBtn. The data will be placed in the data grid. You can save this data to a file.
134=Directions: 1. Select the X Variable 2. Select the Y variable 3. Select the group variable (integer) 4. Enter a label for the plot 5. Select an option if desired. 6. Click the Compute button
135=If you use a language that uses the comma (,) separator to separate the whole part from the fractional part of a number (e.g. 123,45) then select the EUROPEAN option. The default is the English convention (a period, e.g. 123.45). You can enter a default directory to locate your data files. Click a button for values that represent a missing value and click a button that indicates how you want to display values in a grid cell (justification.)
136=For partial and semi-partial correlations, select the dependent variable then select the predictor variable(s), and finally the variable(s) to be partialled. Note that simple, higher order and multiple simple and higher order partialling may be completed as a function of the number of predictors and partialled variables included in the analysis.
137=Directions: The p Chart for nonconforming parts assumes you have a variable (column of data) which represents the number of nonconforming parts in a sample lot of size N. You are expected to enter the sample size N in which each of the observations was made. You will also need to enter P, the expected or target proportion of defects in a sample of N parts. To select the measurement variable, click on the name of the variable in the list of variables available. Enter the N and P values in the boxes provided. If you desire a sigma value other than the default, click the desired button. Click the Compute button to obtain the results.
138=Directions: To use the program you should have the following values coded for each subject: (1) a variable (1/2) for the reference or focus group. (2) one or more items which contain an item score (integers representing response categories, e.g. a value from 1 to 5. Follow these steps to complete the analysis: (1) Enter the items in the available variables list into the selected items list. (2) Enter the group variable from the available variables list to the group box. (3) Enter the Lowest Item Score in the corresponding box. (4) Enter the highest Item Score in the corresponding box. (5) Enter the Reference Group Code in its box. (6) Enter the Focal Group Code in its box. (7) Enter the number of levels of total scores to analyze in the corresponding box. (8) For each level, enter the minimum and maximum scores. Click the scroll bar to go to the next level. You may need to click the down end of the scroll bar to correct errors or change minimum and maximum values for a level.
139=Directions: In polynomial regression smoothing, the value of a point y at a given time t is estimated by the sum of regression weights times t raised to a power of 1, 2, etc. up to the order specified. Enter the order and click the OK button.
140=Directions: Cases should consist of k dichotomous item scores (0 and 1 scores.) You can use the Classical Test program to score your test and save the item scores to the grid if necessary.
141=Directions: First, click on the variable name that represents the sample lot number. Next, click on the variable that represents the measurement. Click on the sigma button to change the default and click on any of the optional check boxes and enter specifications desired. Click the Compute button to obtain the results. Up to 200 groups may be analyzed. Note! Equal group sizes of 2 to 25 required for ranges analysis. Control limits are plus and minus 3 sigma.
142=R = 1 - (s2 / S2) x (1 - r) where R is the estimated reliability of a test obtained on a new group with variance S2 when a reliability of r was obtained for the same test on a group with variance s2. It is assumed the difference in variance is due soley to the difference in true score variance of the two groups. See Theory of Mental Tests by H. Guliksen, 1950.
143=Directions: Your data grid should consist of a table of N rows and M+1 column variables. Each row should have a string type label variable and M columns of integer frequency data. 1. Enter the variable for the row labels (strings) 2. Enter the variables representing the columns of frequency integers 3. Select the Options desired 4. If only one variable is to be considered the reference variable, click the button labeled "Use Only the reference variable selected and click on one of the column variables just selected to represent the reference distribution. 5. If each column variable is to be considered as a reference variable, click on the other button labeled "Let each variable be a reference variable" 6. Change the alpha level for significance if desired. 7. Check the Bonferroni contrasts if desired. 8. Click the Compute button to obtain the results.
144=This procedure calculates the Pearson Product-Moment correlation coefficients for two or more variables. If one or more of the variables selected have been filtered out or contain a missing value, the case containing that variable will not be included in the analysis (list-wise deletion.) You may elect to obtain not only the correlations but also the raw cross-products, the variance-covariance matrix and the means, variances and standard deviations of the variables. Click on the variable in the list to the left and enter it for analysis by clicking the right arrow box. Repeat this for each variable to be included or click the ALL button to include all variables.
145=Directions: First click on the variable name that represents the sample lot number. Next, click on the variable that represents the measurement. Click the Compute Button to obtain the results. NOTE! Equal group (lot) sizes of 2 to 25 required for Sigma analysis. Control limits are plus and minus 3 sigma. Up to 200 lots may be analyzed.
146=Description: Straight Line Depreciation calculates the depreciation allowance for an asset over one period in it's life. The function divides the cost minus the salvage value by the number of years of useful life of the asset. Cost is the inital amount paid for the asset. Salvage is the value left at the end of the asset's life. EXAMPLE: What is the depreciation value on might expect for a computer purchased for $2,000.00 and expected to have a useful life of three years with no residual value? ANSWER: Approximately $666.67
147=R = Kr / (1 + (K - 1) r where R is the estimated reliability of a test when increased by a factor of K. K is the number of items in the lengthened test divided by the number of items in the original test. r is the reliability of the original test.
148=Directions: Click on the variables from the left list of available variables. Click the right-pointing arrow to enter your selection(s). You can remove a selected variable by clicking on it and click the left-pointing arrow button. Click the Compute button to do the analysis. NOTE: Some leaves may represent fragments smaller than the leaf depth.
149=Description: Sum of Years Digits Depreciation calculates depreciation amounts for an asset using an accelerated depreciation method. This allows for higher depreciation in the early years of an asset's life. Cost is the initial cost of the asset. Salvage is the value of the asset at the end of it's life expectancy. Life is the length of the asset's life expectancy. Period is the period that you wish to calculate the depreciation. EXAMPLE: What is the depreciation for period 1, 2 or 3 that one can claim for a computer purchased at a price of $2,000.00 and expected to have a useful life of 3 years with no salvage value? ANSWER: $1,000.00 the first year, $666.67 the second period and $333.33 the last year.
150=New variables may be created that are transformations of an existing variable or a combination of two variables or a variable and a constant. For example, you may want to create a new variable that is the natural log of an existing variable. As another example, you may want to create a variable that is the product of two other variables. To create the new variable, enter a name for the new variable in the edit box provided for the new variable name. Next, select the transformation in the list of functions available. The selected transformation will be shown in a box below the list of functions. Next, click on the name of the variable for the first arguement of the function to be performed and use the corresponding right arrow button to enter it. If a second variable is required (V2) click on the name of the variable and enter it with the corresponding arrow for V2. If a constant is required, click on the constant edit box and enter the value. Click on the Compute button.
151=Directions: For Dependent samples, click on the three variables representing X, Y and Z (in that order.) The test will compare the r(x,y) with the r(x,z). For Independent samples, click on the X and Y variables to be correlated and then the variable representing the group coding variable. The correlations obtained in each of two groups will be compared.
152=Directions: For independent groups you should have a variable indicating group membership using 1 and 2 for the group codes and a variable with 0 or 1 values which represent observed or not observed in the group. For dependent proportions you should have two variables code with 0 or 1 in each case.
153=Select the Dependent Variable and enter it in its box. Select the predictors (including the ones dependent on the instrumental variables) and enter them in the explanatory list. Copy the predictors dependent on the instrumental variables to the Instrumental Variables list. Add the instrumental variables to the same list. Select options desired and click the Compute button. NOTE: The number of variables in the Instrumental list should be equal to or greater than the Explanatory list.
154=Directions: Data may be entered on this form or from a file loaded in the grid. First, enter the number of rows and columns pressing the return key after each entry. If entering Grid data, click on the variables corresponding to row, column and frequency data. If entering on this form, enter the frequencies in the cells corresponding to the row and column of your data.
155=Directions: Click on the variable that represents the count of defects. Enter the number inspected in each subgroup (lot.) Note - all groups are of equal size. Click on a Sigma button to change to a different value. You may enter a specific value if you choose the X sigma option. Click the Compute button to see the results.
156=Directions: First click on one of the variables representing matched pairs of observations from the list of available variables. Click the right-pointing button to enter your choice for variable 1. Repeat for the second variable. Click the Compute button to obtain the results.
157=Directions: The repeated measures ANOVA requires you to select two or more variables (columns) which represent repeated observations on the same subjects (rows.) Homogeneity of variance and covariance are assumed and may be tested as an option. In addition, the ANOVA provides the basis for estimates of reliability as developed by Hoyt (Intraclass reliability) with the adjusted estimate equivalent to the Cronbach Alpha estimate. Finally, you may elect to plot the means obtained for the repeated measures.
158=Weighted Least Squares Regression lets you save the residuals and squared residuals for an OLS weighted analysis. You may also complete a regression of these residuals on the independent variables and save the residuals and squared residuals from those analyses. The square root of the reciprocal of the absolute squared residuals from this last analysis may be used as weights to reduce the heteroscedasticity in your data. If this option is chosen, an OLS regression of the weighted variables is conducted. This may be done through the origin.
159=Directions: Firs, click in the variable name that represents the sample lot numbers. Next, click on the variable that represents the measurement. Click on the sigma button to change the default and click on any of the optional check boxes and enter specifications desired. Click the Compute button to obtain the results.
160=Correspondence analysis is a method for examining the relationship between two sets of categorical variables much as in a Chi-Squared analysis of a two-way contingency table. In fact, a typical chi-squared analysis is completed as part of this procedure. In addition, visualization of the relationships among the columns or rows of the analysis is performed in a manner similar to factor analysis. The data analyzed in the visualization is the table of relative proportions, that is, the original frequency values divided by the sum of all frequencies. The relative proportions of the row sums and the column sums are termed the �masses� of the rows or columns. The method used to analyze the relative proportions involves what is now called the �Generalized Singular Value Decomposition� or more simply the generalized SVD. This method obtains roots and vectors of a rectangular matrix by decomposing that matrix into three portions: a matrix of left singular column vectors (A) that has n rows and q columns (n � q), a square diagonal matrix with q rows and columns of singular values (D), and a transposed matrix (B�) that is m x q in size of right generalized singular vectors (m = q-1). Completing this analysis involves several steps. The first is to obtain the (regular) SVD analysis of a matrix Q defined as Dr-1/2PDc -1/2 where Dr and Dc are diagonal matrices of row and column relative proportions and P is the matrix of relative proportions. The SVD of Q gives Q = U D V� where D is the desired diagonal matrix of eigenvalues and U�U = V�V = I. It should be noted that the first of the q roots is trivial and to be ignored. At this point we obtain A = Dr1/2U and B = Dc 1/2 V. The results of this SVD analysis is available on the output. Now P = ADB�. The row coordinates F and column coordinates G are then computed according to the table: Analysis Choice Button Selected Row Coordinates Column Coordinates Row Profile Row F = Dr-1AD G = Dc-1B Column Profile Column F = Dr-1A G = Dc-1BD Both Profiles Both F = Dr-1AD G = Dc-1BD If Row profiles are computed, the row coordinates are weighted centroids of the column coordinates and the inertias D2 refer only to the row points. If the column profiles are computed, the column coordinates are weighted eentroids of the row coordinates and the inertias D2 refer only to the column points. If both profiles are selected, neither row or column coordinates are weighted centroids of the other but the inertias D2 refer to both sets of points. The q-1 inertias are plotted in a manner similar to a scree plot of roots in a factor analysis. The total inertia is, in fact, the chi-squared statistic divided by the total of all cell frequencies. You may elect to plot the coordinates for any two pairs of coordinates. This will provide a graphical representation of the separation of the row or column categories similar to a plot of variables in a discriminant function analysis or factors in a factor analysis. A way of looking at correspondence analysis is to consider it as a method for decomposing the overall inertia by identifying a small number of dimensions in which the deviations from the expected values can be represented. This is similar to factor analysis where the total variance is decomposed so as to arrive at a lower dimensional representation of variables.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,34 @@
program LazStats;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms,
Globals, LicenseUnit, OptionsUnit, MainDM, MainUnit;
{$R LazStats.res}
begin
RequireDerivedFormResource := True;
Application.Title:='';
Application.Scaled:=True;
Application.Initialize;
LoadOptions;
if not LoggedOn then
begin
if AcceptLicenseForm then
LoggedOn := true
else
Application.Terminate;
end;
Application.CreateForm(TMainDataModule, MainDataModule);
Application.CreateForm(TOS3MainFrm, OS3MainFrm);
Application.Run;
end.

Binary file not shown.

View File

@ -0,0 +1,439 @@
object ABCNestedForm: TABCNestedForm
Left = 529
Height = 640
Top = 153
Width = 479
AutoSize = True
Caption = 'ABCNestedForm'
ClientHeight = 640
ClientWidth = 479
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = ResetBtnClick
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 266
Height = 25
Top = 607
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 2
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 328
Height = 25
Top = 607
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 3
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 412
Height = 25
Top = 607
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 4
end
object OptionsBox: TRadioGroup
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1
Left = 8
Height = 72
Top = 519
Width = 463
Anchors = [akLeft, akRight, akBottom]
AutoFill = True
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Right = 8
Caption = 'OptionsBox'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 16
ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2
ClientHeight = 52
ClientWidth = 459
Columns = 2
Items.Strings = (
'Plot means using 2D Horizontal Bars'
'Plot means using 3D Horizontal Bars'
'Plot means using 2D Vertical Bars'
'Plot means using 3D Vertical Bars'
)
TabOrder = 1
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 591
Width = 479
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object Memo1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 8
Height = 180
Top = 8
Width = 463
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Directions: This analysis assumes that levels of Factor B are Nested within levels of Factor A. It is assumed that all factors are fixed level factors.'#13#10#13#10'The variables for the group coding should be defined as integers. The dependent variable should be defined as a floating point variable. The number of cases for each ABC group should be equal and the number of B treatments in in each A level should be equal. The number of C treatment levels should be the same for each AB combination.'#13#10#13#10'Click the variable for each factor variable and the corresponding arrow to enter it in the edit box for that variable. Select the type of plot desired for the means (if any.) Click the Compute button to continue.'
ParentColor = False
WordWrap = True
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Memo1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = OptionsBox
Left = 8
Height = 307
Top = 204
Width = 463
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 16
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
BevelOuter = bvNone
ClientHeight = 307
ClientWidth = 463
TabOrder = 0
object Label2: TLabel
AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = FactorAEdit
Left = 253
Height = 15
Top = 25
Width = 88
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 2
Caption = 'Factor A Variable'
ParentColor = False
end
object Label3: TLabel
AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = FactorBEdit
Left = 253
Height = 15
Top = 101
Width = 115
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 2
Caption = 'Factor B (Nested in A)'
ParentColor = False
end
object Label4: TLabel
AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = DepEdit
Left = 253
Height = 15
Top = 253
Width = 102
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 2
Caption = 'Dependent Variable'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = AInBtn
AnchorSideBottom.Control = Panel1
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 290
Top = 17
Width = 209
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Right = 8
ItemHeight = 0
MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object AInBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
Left = 217
Height = 28
Top = 17
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = AInBtnClick
Spacing = 0
TabOrder = 1
end
object AOutBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = AInBtn
AnchorSideTop.Side = asrBottom
Left = 217
Height = 28
Top = 49
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = AOutBtnClick
Spacing = 0
TabOrder = 2
end
object BInBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = AOutBtn
AnchorSideTop.Side = asrBottom
Left = 217
Height = 28
Top = 93
Width = 28
BorderSpacing.Top = 16
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = BInBtnClick
Spacing = 0
TabOrder = 4
end
object BOutBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = BInBtn
AnchorSideTop.Side = asrBottom
Left = 217
Height = 28
Top = 125
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = BOutBtnClick
Spacing = 0
TabOrder = 5
end
object DepInBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = COutBtn
AnchorSideTop.Side = asrBottom
Left = 217
Height = 28
Top = 245
Width = 28
BorderSpacing.Top = 16
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = DepInBtnClick
Spacing = 0
TabOrder = 10
end
object DepOutBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = DepInBtn
AnchorSideTop.Side = asrBottom
Left = 217
Height = 28
Top = 277
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = DepOutBtnClick
Spacing = 0
TabOrder = 11
end
object FactorAEdit: TEdit
AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = AOutBtn
AnchorSideBottom.Side = asrBottom
Left = 253
Height = 23
Top = 42
Width = 210
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 3
Text = 'FactorAEdit'
end
object FactorBEdit: TEdit
AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = BOutBtn
AnchorSideBottom.Side = asrBottom
Left = 253
Height = 23
Top = 118
Width = 210
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 6
Text = 'FactorBEdit'
end
object DepEdit: TEdit
AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = DepOutBtn
AnchorSideBottom.Side = asrBottom
Left = 253
Height = 23
Top = 270
Width = 210
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 12
Text = 'DepEdit'
end
object CInBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = BOutBtn
AnchorSideTop.Side = asrBottom
Left = 217
Height = 28
Top = 169
Width = 28
BorderSpacing.Top = 16
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = CInBtnClick
Spacing = 0
TabOrder = 7
end
object COutBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = CInBtn
AnchorSideTop.Side = asrBottom
Left = 217
Height = 28
Top = 201
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = COutBtnClick
Spacing = 0
TabOrder = 8
end
object FactorCEdit: TEdit
AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = COutBtn
AnchorSideBottom.Side = asrBottom
Left = 253
Height = 23
Top = 194
Width = 210
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 9
Text = 'FactorCEdit'
end
object Label5: TLabel
AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = FactorCEdit
Left = 253
Height = 15
Top = 177
Width = 88
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 2
Caption = 'Factor C Variable'
ParentColor = False
end
object Label1: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
Left = 0
Height = 15
Top = 0
Width = 100
Caption = 'Available Variables:'
ParentColor = False
end
end
end

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,380 @@
object ABRAnovaFrm: TABRAnovaFrm
Left = 577
Height = 405
Top = 337
Width = 481
AutoSize = True
Caption = 'AxBxR ANOVA (two between and repeated measures)'
ClientHeight = 405
ClientWidth = 481
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object GroupBox1: TGroupBox
AnchorSideLeft.Control = Owner
AnchorSideBottom.Control = Bevel1
Left = 8
Height = 51
Top = 305
Width = 324
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 8
Caption = 'Options:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 24
ChildSizing.VerticalSpacing = 2
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2
ClientHeight = 31
ClientWidth = 320
TabOrder = 1
object PlotChk: TCheckBox
Left = 12
Height = 19
Top = 6
Width = 79
Caption = 'Plot Means'
TabOrder = 0
end
object TestChk: TCheckBox
Left = 115
Height = 19
Top = 6
Width = 193
Caption = 'Test Homogeneity of Covariance'
TabOrder = 1
end
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 268
Height = 25
Top = 372
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 3
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 330
Height = 25
Top = 372
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 4
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 414
Height = 25
Top = 372
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 5
end
object HelpBtn: TButton
Tag = 102
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 209
Height = 25
Top = 372
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 2
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 356
Width = 481
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = GroupBox1
Left = 8
Height = 289
Top = 8
Width = 465
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
BevelOuter = bvNone
ClientHeight = 289
ClientWidth = 465
TabOrder = 0
object Label1: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
Left = 0
Height = 15
Top = 0
Width = 100
Caption = 'Available Variables:'
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = ACodes
Left = 254
Height = 15
Top = 25
Width = 88
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 2
Caption = 'Factor A Variable'
ParentColor = False
end
object Label3: TLabel
AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = BCodes
Left = 254
Height = 15
Top = 109
Width = 87
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 2
Caption = 'Factor B Variable'
ParentColor = False
end
object Label4: TLabel
AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CInBtn
Left = 254
Height = 15
Top = 185
Width = 102
BorderSpacing.Left = 8
Caption = 'Repeated Measures'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = AInBtn
AnchorSideBottom.Control = Panel1
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 272
Top = 17
Width = 210
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Right = 8
ItemHeight = 0
MultiSelect = True
OnSelectionChange = CListSelectionChange
TabOrder = 0
end
object AInBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
Left = 218
Height = 28
Top = 17
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = AInBtnClick
Spacing = 0
TabOrder = 1
end
object AOutBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = AInBtn
AnchorSideTop.Side = asrBottom
Left = 218
Height = 28
Top = 49
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = AOutBtnClick
Spacing = 0
TabOrder = 2
end
object BInBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = AOutBtn
AnchorSideTop.Side = asrBottom
Left = 218
Height = 28
Top = 101
Width = 28
BorderSpacing.Top = 24
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = BInBtnClick
Spacing = 0
TabOrder = 4
end
object BOutBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = BInBtn
AnchorSideTop.Side = asrBottom
Left = 218
Height = 28
Top = 133
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = BOutBtnClick
Spacing = 0
TabOrder = 5
end
object CInBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = BOutBtn
AnchorSideTop.Side = asrBottom
Left = 218
Height = 28
Top = 185
Width = 28
BorderSpacing.Top = 24
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = CInBtnClick
Spacing = 0
TabOrder = 7
end
object COutBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = CInBtn
AnchorSideTop.Side = asrBottom
Left = 218
Height = 28
Top = 217
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = COutBtnClick
Spacing = 0
TabOrder = 8
end
object ACodes: TEdit
AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = AOutBtn
AnchorSideBottom.Side = asrBottom
Left = 254
Height = 23
Top = 42
Width = 211
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
OnChange = ACodesChange
ReadOnly = True
TabOrder = 3
Text = 'ACodes'
end
object BCodes: TEdit
AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = BOutBtn
AnchorSideBottom.Side = asrBottom
Left = 254
Height = 23
Top = 126
Width = 211
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
OnChange = ACodesChange
ReadOnly = True
TabOrder = 6
Text = 'BCodes'
end
object CList: TListBox
AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label4
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Panel1
AnchorSideBottom.Side = asrBottom
Left = 254
Height = 85
Top = 202
Width = 211
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
ItemHeight = 0
MultiSelect = True
OnSelectionChange = CListSelectionChange
TabOrder = 9
end
end
end

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,633 @@
object ANCOVAfrm: TANCOVAfrm
Left = 505
Height = 525
Top = 250
Width = 486
Caption = 'Analysis of Covariance Using Multiple Regression Methods'
ClientHeight = 525
ClientWidth = 486
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object GroupBox1: TGroupBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel3
Left = 8
Height = 72
Top = 404
Width = 470
Anchors = [akLeft, akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 12
BorderSpacing.Right = 8
Caption = 'Output Options:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 16
ChildSizing.VerticalSpacing = 2
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 3
ClientHeight = 52
ClientWidth = 466
TabOrder = 1
object DescriptiveStats: TCheckBox
Left = 12
Height = 19
Top = 6
Width = 127
Caption = 'Descriptive Statistics'
TabOrder = 0
end
object CorrelationMats: TCheckBox
AnchorSideTop.Side = asrBottom
Left = 155
Height = 19
Top = 6
Width = 169
Caption = 'Correlation Matrices'
TabOrder = 1
end
object PrintInverseMat: TCheckBox
AnchorSideTop.Side = asrBottom
Left = 340
Height = 19
Top = 6
Width = 119
Caption = 'Inverse of Matrices'
TabOrder = 2
end
object PlotMeans: TCheckBox
AnchorSideTop.Side = asrBottom
Left = 12
Height = 19
Top = 27
Width = 127
Caption = 'Plot Factor Means'
TabOrder = 3
end
object MultCompChk: TCheckBox
AnchorSideTop.Side = asrBottom
Left = 155
Height = 19
Top = 27
Width = 169
Caption = 'Show Multiple Comparisons'
TabOrder = 4
end
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = GroupBox1
Left = 8
Height = 384
Top = 8
Width = 470
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BevelOuter = bvNone
ClientHeight = 384
ClientWidth = 470
TabOrder = 0
object Label1: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
Left = 0
Height = 15
Top = 0
Width = 100
Caption = 'Available Variables:'
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = DepVar
AnchorSideBottom.Control = DepVar
Left = 288
Height = 15
Top = 25
Width = 102
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Dependent Variable'
ParentColor = False
end
object Label3: TLabel
AnchorSideLeft.Control = FixedList
AnchorSideTop.Control = DepOut
AnchorSideTop.Side = asrBottom
Left = 288
Height = 15
Top = 101
Width = 69
BorderSpacing.Top = 24
Caption = 'Fixed Factors'
ParentColor = False
end
object Label4: TLabel
AnchorSideLeft.Control = CovList
AnchorSideTop.Control = FixedList
AnchorSideTop.Side = asrBottom
Left = 288
Height = 15
Top = 253
Width = 55
BorderSpacing.Top = 24
Caption = 'Covariates'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = DepIn
AnchorSideBottom.Control = Panel1
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 367
Top = 17
Width = 244
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Right = 8
ItemHeight = 0
MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object DepIn: TBitBtn
AnchorSideLeft.Control = Bevel1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = VarList
Left = 252
Height = 28
Top = 17
Width = 28
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00216324B81D5E2006FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF002A702F38256929F7216324D9FFFFFF00FFFFFF00FFFFFF00FFFFFF0061BE
6DFF5DB868FF58B162FF53A95CFF4DA156FF47994FFF419149FF3B8842FF3580
3BFF3F8845FF59A15EFF448B49FF216324CFFFFFFF00FFFFFF00FFFFFF0065C3
71FFA0D7A9FF9CD5A5FF98D3A1FF94D09DFF90CE98FF8BCB93FF87C98EFF82C6
89FF7EC384FF7AC180FF76BE7CFF458C4AFF216324C4FFFFFF00FFFFFF0068C7
74FFA5DAAEFFA2D8ABFF9ED6A7FF9AD4A3FF96D29FFF93CF9AFF8ECC95FF89CA
90FF85C78BFF81C587FF7DC282FF4A9150FF256929C9FFFFFF00FFFFFF0068C7
74FF68C774FF65C371FF61BE6DFF5DB868FF58B162FF53A95CFF4DA156FF4799
4FFF419149FF5AA362FF559D5CFF2F7835D1FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00419149F73B8842DBFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0047994FBB41914906FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = DepInClick
Spacing = 0
TabOrder = 1
end
object DepOut: TBitBtn
AnchorSideLeft.Control = Bevel1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = DepIn
AnchorSideTop.Side = asrBottom
Left = 252
Height = 28
Top = 49
Width = 28
BorderSpacing.Top = 4
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF004DA1560647994FB8FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0053A95CD94DA156F747994F38FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF005DB868CF71BE7BFF7AC183FF5BAA64FF47994FFF419149FF3B8842FF3580
3BFF2F7835FF2A702FFF256929FF216324FF1D5E20FFFFFFFF00FFFFFF0065C3
71C47BC886FF9CD5A5FF98D3A1FF94D09DFF90CE98FF8BCB93FF87C98EFF82C6
89FF7EC384FF7AC180FF76BE7CFF72BD78FF216324FFFFFFFF00FFFFFF0068C7
74C97FCC8AFFA2D8ABFF9ED6A7FF9AD4A3FF96D29FFF93CF9AFF8ECC95FF89CA
90FF85C78BFF81C587FF7DC282FF78C07EFF256929FFFFFFFF00FFFFFF00FFFF
FF0068C774D180CD8BFF7CC987FF5DB868FF58B162FF53A95CFF4DA156FF4799
4FFF419149FF3B8842FF35803BFF2F7835FF2A702FFFFFFFFF00FFFFFF00FFFF
FF00FFFFFF0068C774DB65C371F7FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0068C7740668C774BBFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = DepOutClick
Spacing = 0
TabOrder = 2
end
object FixedIn: TBitBtn
AnchorSideLeft.Control = Bevel1
AnchorSideLeft.Side = asrBottom
Left = 252
Height = 28
Top = 144
Width = 28
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00216324B81D5E2006FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF002A702F38256929F7216324D9FFFFFF00FFFFFF00FFFFFF00FFFFFF0061BE
6DFF5DB868FF58B162FF53A95CFF4DA156FF47994FFF419149FF3B8842FF3580
3BFF3F8845FF59A15EFF448B49FF216324CFFFFFFF00FFFFFF00FFFFFF0065C3
71FFA0D7A9FF9CD5A5FF98D3A1FF94D09DFF90CE98FF8BCB93FF87C98EFF82C6
89FF7EC384FF7AC180FF76BE7CFF458C4AFF216324C4FFFFFF00FFFFFF0068C7
74FFA5DAAEFFA2D8ABFF9ED6A7FF9AD4A3FF96D29FFF93CF9AFF8ECC95FF89CA
90FF85C78BFF81C587FF7DC282FF4A9150FF256929C9FFFFFF00FFFFFF0068C7
74FF68C774FF65C371FF61BE6DFF5DB868FF58B162FF53A95CFF4DA156FF4799
4FFF419149FF5AA362FF559D5CFF2F7835D1FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00419149F73B8842DBFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0047994FBB41914906FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = FixedInClick
Spacing = 0
TabOrder = 4
end
object FixedOut: TBitBtn
AnchorSideLeft.Control = Bevel1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Bevel2
AnchorSideTop.Side = asrBottom
Left = 252
Height = 28
Top = 175
Width = 28
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF004DA1560647994FB8FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0053A95CD94DA156F747994F38FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF005DB868CF71BE7BFF7AC183FF5BAA64FF47994FFF419149FF3B8842FF3580
3BFF2F7835FF2A702FFF256929FF216324FF1D5E20FFFFFFFF00FFFFFF0065C3
71C47BC886FF9CD5A5FF98D3A1FF94D09DFF90CE98FF8BCB93FF87C98EFF82C6
89FF7EC384FF7AC180FF76BE7CFF72BD78FF216324FFFFFFFF00FFFFFF0068C7
74C97FCC8AFFA2D8ABFF9ED6A7FF9AD4A3FF96D29FFF93CF9AFF8ECC95FF89CA
90FF85C78BFF81C587FF7DC282FF78C07EFF256929FFFFFFFF00FFFFFF00FFFF
FF0068C774D180CD8BFF7CC987FF5DB868FF58B162FF53A95CFF4DA156FF4799
4FFF419149FF3B8842FF35803BFF2F7835FF2A702FFFFFFFFF00FFFFFF00FFFF
FF00FFFFFF0068C774DB65C371F7FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0068C7740668C774BBFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = FixedOutClick
Spacing = 0
TabOrder = 5
end
object CovIn: TBitBtn
AnchorSideLeft.Control = Bevel1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CovList
Left = 252
Height = 28
Top = 270
Width = 28
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00216324B81D5E2006FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF002A702F38256929F7216324D9FFFFFF00FFFFFF00FFFFFF00FFFFFF0061BE
6DFF5DB868FF58B162FF53A95CFF4DA156FF47994FFF419149FF3B8842FF3580
3BFF3F8845FF59A15EFF448B49FF216324CFFFFFFF00FFFFFF00FFFFFF0065C3
71FFA0D7A9FF9CD5A5FF98D3A1FF94D09DFF90CE98FF8BCB93FF87C98EFF82C6
89FF7EC384FF7AC180FF76BE7CFF458C4AFF216324C4FFFFFF00FFFFFF0068C7
74FFA5DAAEFFA2D8ABFF9ED6A7FF9AD4A3FF96D29FFF93CF9AFF8ECC95FF89CA
90FF85C78BFF81C587FF7DC282FF4A9150FF256929C9FFFFFF00FFFFFF0068C7
74FF68C774FF65C371FF61BE6DFF5DB868FF58B162FF53A95CFF4DA156FF4799
4FFF419149FF5AA362FF559D5CFF2F7835D1FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00419149F73B8842DBFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0047994FBB41914906FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = CovInClick
Spacing = 0
TabOrder = 7
end
object CovOut: TBitBtn
AnchorSideLeft.Control = Bevel1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CovIn
AnchorSideTop.Side = asrBottom
Left = 252
Height = 28
Top = 302
Width = 28
BorderSpacing.Top = 4
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF004DA1560647994FB8FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0053A95CD94DA156F747994F38FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF005DB868CF71BE7BFF7AC183FF5BAA64FF47994FFF419149FF3B8842FF3580
3BFF2F7835FF2A702FFF256929FF216324FF1D5E20FFFFFFFF00FFFFFF0065C3
71C47BC886FF9CD5A5FF98D3A1FF94D09DFF90CE98FF8BCB93FF87C98EFF82C6
89FF7EC384FF7AC180FF76BE7CFF72BD78FF216324FFFFFFFF00FFFFFF0068C7
74C97FCC8AFFA2D8ABFF9ED6A7FF9AD4A3FF96D29FFF93CF9AFF8ECC95FF89CA
90FF85C78BFF81C587FF7DC282FF78C07EFF256929FFFFFFFF00FFFFFF00FFFF
FF0068C774D180CD8BFF7CC987FF5DB868FF58B162FF53A95CFF4DA156FF4799
4FFF419149FF3B8842FF35803BFF2F7835FF2A702FFFFFFFFF00FFFFFF00FFFF
FF00FFFFFF0068C774DB65C371F7FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0068C7740668C774BBFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = CovOutClick
Spacing = 0
TabOrder = 8
end
object DepVar: TEdit
AnchorSideLeft.Control = DepIn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = DepOut
AnchorSideBottom.Side = asrBottom
Left = 288
Height = 23
Top = 42
Width = 182
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 3
Text = 'DepVar'
end
object CovList: TListBox
AnchorSideLeft.Control = CovIn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label4
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Panel1
AnchorSideBottom.Side = asrBottom
Left = 288
Height = 114
Top = 270
Width = 182
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
ItemHeight = 0
MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 9
end
object FixedList: TListBox
AnchorSideLeft.Control = FixedIn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label3
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 288
Height = 111
Top = 118
Width = 182
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
ItemHeight = 0
MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 6
end
object Bevel2: TBevel
AnchorSideLeft.Control = VarList
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = FixedList
AnchorSideTop.Side = asrCenter
Left = 252
Height = 4
Top = 171
Width = 24
Shape = bsSpacer
end
object Bevel1: TBevel
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
Left = 218
Height = 18
Top = 2
Width = 34
Shape = bsSpacer
end
end
object Panel2: TPanel
Left = 8
Height = 25
Top = 492
Width = 470
Align = alBottom
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
BevelOuter = bvNone
ClientHeight = 25
ClientWidth = 470
TabOrder = 2
object ResetBtn: TButton
AnchorSideTop.Control = Panel2
AnchorSideRight.Control = ComputeBtn
Left = 269
Height = 25
Top = 0
Width = 54
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Right = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 1
end
object ComputeBtn: TButton
AnchorSideTop.Control = Panel2
AnchorSideRight.Control = CloseBtn
Left = 331
Height = 25
Top = 0
Width = 76
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Right = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 2
end
object CloseBtn: TButton
AnchorSideTop.Control = Panel2
AnchorSideRight.Control = Panel2
AnchorSideRight.Side = asrBottom
Left = 415
Height = 25
Top = 0
Width = 55
Anchors = [akTop, akRight]
AutoSize = True
Caption = 'Close'
ModalResult = 11
TabOrder = 3
end
object HelpBtn: TButton
Tag = 103
AnchorSideTop.Control = Panel2
AnchorSideRight.Control = ResetBtn
Left = 210
Height = 25
Top = 0
Width = 51
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Right = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 0
end
end
object Bevel3: TBevel
Left = 0
Height = 8
Top = 476
Width = 486
Align = alBottom
Shape = bsBottomLine
end
end

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,313 @@
object AxSAnovaFrm: TAxSAnovaFrm
Left = 629
Height = 360
Top = 278
Width = 471
AutoSize = True
Caption = 'Treatments by Subjects ANOVA (AxS)'
ClientHeight = 360
ClientWidth = 471
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object GroupBox1: TGroupBox
AnchorSideLeft.Control = Owner
AnchorSideBottom.Control = Bevel1
Left = 8
Height = 51
Top = 260
Width = 282
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 12
Caption = 'Option'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 16
ChildSizing.VerticalSpacing = 2
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2
ClientHeight = 31
ClientWidth = 278
TabOrder = 1
object PlotChk: TCheckBox
Left = 12
Height = 19
Top = 6
Width = 102
Caption = 'Plot Cell Means'
TabOrder = 0
end
object PosthocChk: TCheckBox
Left = 130
Height = 19
Top = 6
Width = 136
BorderSpacing.Left = 8
Caption = 'Posthoc Comparisons'
TabOrder = 1
end
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 258
Height = 25
Top = 327
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 3
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 320
Height = 25
Top = 327
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 4
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 404
Height = 25
Top = 327
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 5
end
object HelpBtn: TButton
Tag = 106
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 199
Height = 25
Top = 327
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 2
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 311
Width = 471
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = GroupBox1
Left = 8
Height = 240
Top = 8
Width = 455
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BevelOuter = bvNone
ClientHeight = 240
ClientWidth = 455
TabOrder = 0
object Label1: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
Left = 0
Height = 15
Top = 0
Width = 100
Caption = 'Available Variables:'
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = DepInBtn
AnchorSideLeft.Side = asrBottom
Left = 249
Height = 15
Top = 25
Width = 77
BorderSpacing.Left = 8
Caption = 'Group Variable'
ParentColor = False
end
object Label3: TLabel
AnchorSideLeft.Control = DepInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = RepInBtn
Left = 249
Height = 15
Top = 106
Width = 102
BorderSpacing.Left = 8
BorderSpacing.Top = 5
Caption = 'Repeated Measures'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = DepInBtn
AnchorSideBottom.Control = Panel1
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 223
Top = 17
Width = 205
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Right = 8
Constraints.MinHeight = 220
ItemHeight = 0
MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object DepInBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
Left = 213
Height = 28
Top = 17
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = DepInBtnClick
Spacing = 0
TabOrder = 1
end
object DepOutBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = DepInBtn
AnchorSideTop.Side = asrBottom
Left = 213
Height = 28
Top = 49
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = DepOutBtnClick
Spacing = 0
TabOrder = 2
end
object RepInBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = DepOutBtn
AnchorSideTop.Side = asrBottom
Left = 213
Height = 28
Top = 101
Width = 28
BorderSpacing.Top = 24
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = RepInBtnClick
Spacing = 0
TabOrder = 4
end
object RepOutBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = RepInBtn
AnchorSideTop.Side = asrBottom
Left = 213
Height = 28
Top = 133
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = RepOutBtnClick
Spacing = 0
TabOrder = 5
end
object GrpVar: TEdit
AnchorSideLeft.Control = DepInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 249
Height = 23
Top = 40
Width = 206
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
OnChange = GrpVarChange
ReadOnly = True
TabOrder = 3
Text = 'GrpVar'
end
object RepList: TListBox
AnchorSideLeft.Control = DepInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label3
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Panel1
AnchorSideBottom.Side = asrBottom
Left = 249
Height = 117
Top = 123
Width = 206
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
ItemHeight = 0
MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 6
end
end
end

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,750 @@
object BlksAnovaFrm: TBlksAnovaFrm
Left = 853
Height = 454
Top = 256
Width = 742
AutoSize = True
Caption = 'One, Two or Three Way Analysis of Variance'
ClientHeight = 454
ClientWidth = 742
Constraints.MinHeight = 450
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Label1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 8
Height = 15
Top = 8
Width = 49
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Variables:'
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = Fact1Grp
AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = Fact1Grp
Left = 441
Height = 15
Top = 76
Width = 68
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 8
Caption = 'Variable Type'
ParentColor = False
end
object Label3: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = OverallAlpha
AnchorSideTop.Side = asrCenter
Left = 8
Height = 15
Top = 386
Width = 147
BorderSpacing.Left = 8
Caption = 'Alpha Level for Overall Tests'
ParentColor = False
end
object Label4: TLabel
AnchorSideLeft.Control = OverallAlpha
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = PostAlpha
AnchorSideTop.Side = asrCenter
Left = 232
Height = 15
Top = 386
Width = 163
BorderSpacing.Left = 24
Caption = 'Alpha Level for Post-Hoc Tests:'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel4
AnchorSideBottom.Control = OverallAlpha
Left = 8
Height = 349
Top = 25
Width = 201
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
ItemHeight = 0
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object Fact1Grp: TRadioGroup
AnchorSideRight.Control = GroupBox1
AnchorSideBottom.Control = Panel2
AnchorSideBottom.Side = asrBottom
Left = 411
Height = 70
Top = 99
Width = 128
Anchors = [akRight, akBottom]
AutoFill = True
AutoSize = True
BorderSpacing.Right = 8
Caption = 'Factor 1'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 50
ClientWidth = 124
Items.Strings = (
'Fixed Levels'
'Random Levels'
)
TabOrder = 3
end
object Fact2Grp: TRadioGroup
AnchorSideLeft.Control = Fact1Grp
AnchorSideRight.Control = Fact1Grp
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Panel3
AnchorSideBottom.Side = asrBottom
Left = 411
Height = 70
Top = 183
Width = 128
Anchors = [akLeft, akRight, akBottom]
AutoFill = True
AutoSize = True
Caption = 'Factor 2'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 50
ClientWidth = 124
Items.Strings = (
'Fixed Levels'
'Random Levels'
)
TabOrder = 5
end
object Fact3Grp: TRadioGroup
AnchorSideLeft.Control = Fact1Grp
AnchorSideRight.Control = Fact1Grp
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Panel4
AnchorSideBottom.Side = asrBottom
Left = 411
Height = 70
Top = 267
Width = 128
Anchors = [akLeft, akRight, akBottom]
AutoFill = True
AutoSize = True
Caption = 'Factor 3'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 50
ClientWidth = 124
Items.Strings = (
'Fixed Levels'
'Random Levels'
)
TabOrder = 7
end
object GroupBox1: TGroupBox
AnchorSideLeft.Control = GroupBox2
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 547
Height = 177
Top = 21
Width = 187
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Right = 8
Caption = 'Post-Hoc Comparisons:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ClientHeight = 157
ClientWidth = 183
TabOrder = 8
object Scheffe: TCheckBox
Left = 12
Height = 19
Top = 6
Width = 138
Caption = 'Scheffe'
TabOrder = 0
end
object TukeyHSD: TCheckBox
Left = 12
Height = 19
Top = 27
Width = 138
Caption = 'Tukey HSD (= n''s)'
TabOrder = 1
end
object TukeyB: TCheckBox
Left = 12
Height = 19
Top = 48
Width = 138
Caption = 'Tukey B (= n''s)'
TabOrder = 2
end
object TukeyKramer: TCheckBox
Left = 12
Height = 19
Top = 69
Width = 138
Caption = 'Tukey-Kramer'
TabOrder = 3
end
object NewmanKeuls: TCheckBox
Left = 12
Height = 19
Top = 90
Width = 138
Caption = 'Newman-Keuls (= n''s)'
TabOrder = 4
end
object Bonferoni: TCheckBox
Left = 12
Height = 19
Top = 111
Width = 138
Caption = 'Bonferroni'
TabOrder = 5
end
object OrthoContrasts: TCheckBox
Left = 12
Height = 19
Top = 132
Width = 138
Caption = 'Orthogonal Contrasts'
TabOrder = 6
end
end
object GroupBox2: TGroupBox
AnchorSideTop.Control = GroupBox1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 547
Height = 152
Top = 214
Width = 187
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 16
BorderSpacing.Right = 8
Caption = 'Options'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ClientHeight = 132
ClientWidth = 183
TabOrder = 9
object PlotMeans: TCheckBox
Left = 12
Height = 19
Top = 6
Width = 159
Caption = 'Plot Means Using 3D bars'
TabOrder = 0
end
object Plot2DLines: TCheckBox
Left = 12
Height = 19
Top = 27
Width = 159
Caption = 'Plot Means Using 2D Lines'
TabOrder = 1
end
object Plot3DLines: TCheckBox
Left = 12
Height = 19
Top = 48
Width = 159
Caption = 'Plot Means Using 3D Lines'
TabOrder = 2
end
object Label5: TLabel
Left = 12
Height = 15
Top = 69
Width = 159
Caption = 'Corrections for unequal Var.'
ParentColor = False
end
object BrownForsythe: TCheckBox
Left = 12
Height = 19
Top = 86
Width = 159
Caption = 'Brown-Forsythe for 1-way'
TabOrder = 3
end
object Welch: TCheckBox
Left = 12
Height = 19
Top = 107
Width = 159
Caption = 'Welch for 1-way'
TabOrder = 4
end
end
object OverallAlpha: TEdit
AnchorSideLeft.Control = Label3
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = Bevel1
Left = 163
Height = 23
Top = 382
Width = 45
Alignment = taRightJustify
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
TabOrder = 10
Text = 'OverallAlpha'
end
object PostAlpha: TEdit
AnchorSideLeft.Control = Label4
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = OverallAlpha
AnchorSideTop.Side = asrCenter
Left = 403
Height = 23
Top = 382
Width = 51
Alignment = taRightJustify
BorderSpacing.Left = 8
TabOrder = 11
Text = 'PostAlpha'
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 521
Height = 25
Top = 421
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 13
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 587
Height = 25
Top = 421
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 14
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 675
Height = 25
Top = 421
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 15
end
object HelpBtn: TButton
Tag = 107
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 458
Height = 25
Top = 421
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 12
end
object Panel1: TPanel
AnchorSideTop.Control = VarList
AnchorSideRight.Control = Panel3
AnchorSideRight.Side = asrBottom
Left = 217
Height = 60
Top = 25
Width = 186
Anchors = [akTop, akRight]
AutoSize = True
BevelOuter = bvNone
ClientHeight = 60
ClientWidth = 186
TabOrder = 1
object DepIn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
Left = 0
Height = 28
Top = 0
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = DepInClick
Spacing = 0
TabOrder = 0
end
object DepOut: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = DepIn
AnchorSideTop.Side = asrBottom
Left = 0
Height = 28
Top = 32
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = DepOutClick
Spacing = 0
TabOrder = 1
end
object StaticText1: TStaticText
AnchorSideLeft.Control = DepOut
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = DepVar
Left = 36
Height = 16
Top = 7
Width = 103
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Bottom = 2
Caption = 'Dependent Variable'
TabOrder = 2
end
object DepVar: TEdit
AnchorSideLeft.Control = DepOut
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = DepOut
AnchorSideBottom.Side = asrBottom
Left = 36
Height = 23
Top = 25
Width = 150
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
Constraints.MinWidth = 150
OnChange = VarChange
ReadOnly = True
TabOrder = 3
Text = 'DepVar'
end
end
object Panel2: TPanel
AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Fact1Grp
Left = 217
Height = 60
Top = 109
Width = 186
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 24
BorderSpacing.Right = 8
BevelOuter = bvNone
ClientHeight = 60
ClientWidth = 186
TabOrder = 2
object Fact1In: TBitBtn
AnchorSideLeft.Control = Panel2
AnchorSideTop.Control = Panel2
Left = 0
Height = 28
Top = 0
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = Fact1InClick
Spacing = 0
TabOrder = 0
end
object Fact1Out: TBitBtn
AnchorSideLeft.Control = Panel2
AnchorSideTop.Control = Fact1In
AnchorSideTop.Side = asrBottom
Left = 0
Height = 28
Top = 32
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = Fact1OutClick
Spacing = 0
TabOrder = 1
end
object StaticText2: TStaticText
AnchorSideLeft.Control = Factor1
AnchorSideBottom.Control = Factor1
Left = 36
Height = 16
Top = 7
Width = 87
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Bottom = 2
Caption = 'Factor 1 Variable'
TabOrder = 2
end
object Factor1: TEdit
AnchorSideLeft.Control = Fact1Out
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel2
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Fact1Out
AnchorSideBottom.Side = asrBottom
Left = 36
Height = 23
Top = 25
Width = 150
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
Constraints.MinWidth = 150
OnChange = VarChange
ReadOnly = True
TabOrder = 3
Text = 'Edit1'
end
end
object Panel3: TPanel
AnchorSideTop.Control = Panel2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Fact2Grp
Left = 217
Height = 60
Top = 193
Width = 186
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 24
BorderSpacing.Right = 8
BevelOuter = bvNone
ClientHeight = 60
ClientWidth = 186
TabOrder = 4
object Fact2In: TBitBtn
AnchorSideLeft.Control = Panel3
AnchorSideTop.Control = Panel3
Left = 0
Height = 28
Top = 0
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = Fact2InClick
Spacing = 0
TabOrder = 0
end
object Fact2Out: TBitBtn
AnchorSideLeft.Control = Panel3
AnchorSideTop.Control = Fact2In
AnchorSideTop.Side = asrBottom
Left = 0
Height = 28
Top = 32
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = Fact2OutClick
Spacing = 0
TabOrder = 1
end
object StaticText3: TStaticText
AnchorSideLeft.Control = Fact2In
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = Factor2
Left = 36
Height = 16
Top = 7
Width = 87
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Bottom = 2
Caption = 'Factor 2 Variable'
TabOrder = 2
end
object Factor2: TEdit
AnchorSideLeft.Control = Fact2In
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel3
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Fact2Out
AnchorSideBottom.Side = asrBottom
Left = 36
Height = 23
Top = 25
Width = 150
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
Constraints.MinWidth = 150
OnChange = VarChange
ReadOnly = True
TabOrder = 3
Text = 'Edit1'
end
end
object Panel4: TPanel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel3
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Fact3Grp
Left = 217
Height = 60
Top = 277
Width = 186
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 24
BorderSpacing.Right = 8
BevelOuter = bvNone
ClientHeight = 60
ClientWidth = 186
TabOrder = 6
object Fact3In: TBitBtn
AnchorSideLeft.Control = Panel4
AnchorSideTop.Control = Panel4
Left = 0
Height = 28
Top = 0
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = Fact3InClick
Spacing = 0
TabOrder = 0
end
object Fact3Out: TBitBtn
AnchorSideLeft.Control = Panel4
AnchorSideTop.Control = Fact3In
AnchorSideTop.Side = asrBottom
Left = 0
Height = 28
Top = 32
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = Fact3OutClick
Spacing = 0
TabOrder = 1
end
object StaticText4: TStaticText
AnchorSideLeft.Control = Fact3In
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = Factor3
Left = 36
Height = 16
Top = 7
Width = 72
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Bottom = 2
Caption = 'Factor 3 Clark'
TabOrder = 2
end
object Factor3: TEdit
AnchorSideLeft.Control = Fact3In
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel4
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Fact3Out
AnchorSideBottom.Side = asrBottom
Left = 36
Height = 23
Top = 25
Width = 150
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
OnChange = VarChange
ReadOnly = True
TabOrder = 3
Text = 'Edit1'
end
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 405
Width = 742
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
end

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,370 @@
object BNestedAForm: TBNestedAForm
Left = 768
Height = 498
Top = 238
Width = 488
AutoSize = True
Caption = 'Factor B Nested in Factor A Analysis of Variance'
ClientHeight = 498
ClientWidth = 488
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = ResetBtnClick
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Label1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Memo1
AnchorSideTop.Side = asrBottom
Left = 8
Height = 15
Top = 114
Width = 100
BorderSpacing.Left = 8
BorderSpacing.Top = 16
Caption = 'Available Variables:'
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = ACodes
Left = 266
Height = 15
Top = 138
Width = 88
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 2
Caption = 'Factor A Variable'
ParentColor = False
end
object Label3: TLabel
AnchorSideLeft.Control = BInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = BCodes
Left = 266
Height = 15
Top = 222
Width = 115
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 2
Caption = 'Factor B (Nested in A)'
ParentColor = False
end
object Label4: TLabel
AnchorSideLeft.Control = DepInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = DepEdit
Left = 266
Height = 15
Top = 317
Width = 102
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 2
Caption = 'Dependent Variable'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = AInBtn
AnchorSideBottom.Control = OptionsBox
Left = 9
Height = 239
Top = 130
Width = 213
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 9
BorderSpacing.Top = 1
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
ItemHeight = 0
MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object AInBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
Left = 230
Height = 28
Top = 130
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = AInBtnClick
Spacing = 0
TabOrder = 1
end
object AOutBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = AInBtn
AnchorSideTop.Side = asrBottom
Left = 230
Height = 28
Top = 162
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = AOutBtnClick
Spacing = 0
TabOrder = 2
end
object BInBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = AOutBtn
AnchorSideTop.Side = asrBottom
Left = 230
Height = 28
Top = 214
Width = 28
BorderSpacing.Top = 24
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = BInBtnClick
Spacing = 0
TabOrder = 4
end
object BOutBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = BInBtn
AnchorSideTop.Side = asrBottom
Left = 230
Height = 28
Top = 246
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = BOutBtnClick
Spacing = 0
TabOrder = 5
end
object DepInBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = RandomBChk
AnchorSideTop.Side = asrBottom
Left = 230
Height = 28
Top = 309
Width = 28
BorderSpacing.Top = 8
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = DepInBtnClick
Spacing = 0
TabOrder = 8
end
object DepOutBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = DepInBtn
AnchorSideTop.Side = asrBottom
Left = 230
Height = 28
Top = 341
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = DepOutBtnClick
Spacing = 0
TabOrder = 9
end
object ACodes: TEdit
AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = AOutBtn
AnchorSideBottom.Side = asrBottom
Left = 266
Height = 23
Top = 155
Width = 214
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 3
Text = 'ACodes'
end
object BCodes: TEdit
AnchorSideLeft.Control = BInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = BOutBtn
AnchorSideBottom.Side = asrBottom
Left = 266
Height = 23
Top = 239
Width = 214
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 6
Text = 'BCodes'
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 275
Height = 25
Top = 465
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 12
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 337
Height = 25
Top = 465
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 13
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 421
Height = 25
Top = 465
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 14
end
object DepEdit: TEdit
AnchorSideLeft.Control = DepInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = DepOutBtn
AnchorSideBottom.Side = asrBottom
Left = 266
Height = 23
Top = 334
Width = 214
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 10
Text = 'DepEdit'
end
object OptionsBox: TRadioGroup
AnchorSideLeft.Control = Owner
AnchorSideBottom.Control = Bevel1
Left = 8
Height = 72
Top = 377
Width = 466
Anchors = [akLeft, akBottom]
AutoFill = True
AutoSize = True
BorderSpacing.Left = 8
Caption = 'OptionsBox'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 16
ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2
ClientHeight = 52
ClientWidth = 462
Columns = 2
Items.Strings = (
'Plot means using 2D Horizontal Bars'
'Plot means using 3D Horizontal Bars'
'Plot means using 2D Vertical Bars'
'Plot means using 3D Vertical Bars'
)
TabOrder = 11
end
object RandomBChk: TCheckBox
AnchorSideLeft.Control = BCodes
AnchorSideTop.Control = BOutBtn
AnchorSideTop.Side = asrBottom
Left = 266
Height = 19
Top = 282
Width = 136
BorderSpacing.Top = 8
Caption = 'B is random, not fixed'
TabOrder = 7
end
object Memo1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 8
Height = 90
Top = 8
Width = 472
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Directions: This analysis assumes that levels of Factor B are Nested within levels of Factor A. Unless otherwise specified, it is assumed that Factors A and B are fixed level factors. If Factor B is a random variable, check the provided box to indicate this.'#13#10#13#10'The number of cases for each B group should be equal and the number of B treatements in each A level should be equal.'
ParentColor = False
WordWrap = True
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 449
Width = 488
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
end

View File

@ -0,0 +1,601 @@
unit BNestAUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons, ExtCtrls,
MainUnit, OutputUnit, FunctionsLib, GraphLib, Globals;
type
{ TBNestedAForm }
TBNestedAForm = class(TForm)
ACodes: TEdit;
AInBtn: TBitBtn;
AOutBtn: TBitBtn;
BCodes: TEdit;
Bevel1: TBevel;
BInBtn: TBitBtn;
BOutBtn: TBitBtn;
Memo1: TLabel;
RandomBChk: TCheckBox;
DepInBtn: TBitBtn;
ComputeBtn: TButton;
DepOutBtn: TBitBtn;
DepEdit: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
OptionsBox: TRadioGroup;
ResetBtn: TButton;
CloseBtn: TButton;
VarList: TListBox;
procedure AInBtnClick(Sender: TObject);
procedure AOutBtnClick(Sender: TObject);
procedure BInBtnClick(Sender: TObject);
procedure BOutBtnClick(Sender: TObject);
procedure ComputeBtnClick(Sender: TObject);
procedure DepInBtnClick(Sender: TObject);
procedure DepOutBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean);
private
{ private declarations }
FAutoSized: Boolean;
SS, SumSqr, CellMeans, CellSDs : DblDyneMat;
CellCount : IntDyneMat;
ASS, BSS, ASumSqr, BSumSqr, AMeans, BMeans, ASDs : DblDyneVec;
ACount, BCount : IntDyneVec;
MinA, MinB, MaxA, MaxB, NoALevels, NoBLevels, ACol, BCol, YCol : integer;
DepVar, FactorA, FactorB : string;
SSTot, SumSqrTot, TotMean, MSTot, SSA, MSA, SSB, MSB, SSW, MSW : double;
TotN, dfA, dfBwA, dfwcell, dftotal : integer;
function GetVars: Boolean;
procedure GetMemory;
procedure GetSums;
procedure ShowMeans(AReport: TStrings);
procedure GetResults;
procedure ShowResults(AReport: TStrings);
procedure ReleaseMemory;
procedure TwoWayPlot;
procedure UpdateBtnStates;
public
{ public declarations }
end;
var
BNestedAForm: TBNestedAForm;
implementation
uses
Math;
{ TBNestedAForm }
procedure TBNestedAForm.ResetBtnClick(Sender: TObject);
var
i: integer;
begin
VarList.Items.Clear;
ACodes.Text := '';
BCodes.Text := '';
DepEdit.Text := '';
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
end;
procedure TBNestedAForm.AInBtnClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (ACodes.Text = '') then
begin
ACodes.Text := VarList.Items[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TBNestedAForm.AOutBtnClick(Sender: TObject);
begin
if ACodes.Text <> '' then
begin
VarList.Items.Add(ACodes.Text);
ACodes.Text := '';
end;
UpdateBtnStates;
end;
procedure TBNestedAForm.BInBtnClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (BCodes.Text = '') then
begin
BCodes.Text := VarList.Items[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TBNestedAForm.BOutBtnClick(Sender: TObject);
begin
if BCodes.Text <> '' then
begin
VarList.Items.Add(BCodes.Text);
BCodes.Text := '';
end;
UpdateBtnStates;
end;
procedure TBNestedAForm.ComputeBtnClick(Sender: TObject);
var
lReport: TStrings;
begin
lReport := TStringList.Create;
try
if GetVars then
begin
GetMemory;
GetSums;
ShowMeans(lReport);
GetResults;
ShowResults(lReport);
DisplayReport(lReport);
TwoWayPlot;
ReleaseMemory;
end;
finally
lReport.Free;
end;
end;
procedure TBNestedAForm.DepInBtnClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (DepEdit.Text = '') then
begin
DepEdit.Text := VarList.Items[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TBNestedAForm.DepOutBtnClick(Sender: TObject);
begin
if DepEdit.Text <> '' then
begin
VarList.Items.Add(DepEdit.Text);
DepEdit.Text := '';
end;
UpdateBtnStates;
end;
procedure TBNestedAForm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
VarList.Constraints.MinHeight := DepOutBtn.Top + DepOutBtn.Height - VarList.Top;
Constraints.MinHeight := Height;
Constraints.MinWidth := Width;
FAutoSized := true;
end;
procedure TBNestedAForm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
if GraphFrm = nil then
Application.CreateForm(TGraphFrm, GraphFrm);
end;
function TBNestedAForm.GetVars: Boolean;
var
i, group : integer;
strvalue, cellstring : string;
begin
Result := false;
DepVar := DepEdit.Text;
FactorA := ACodes.Text;
FactorB := BCodes.Text;
ACol := 0;
BCol := 0;
YCol := 0;
MinA := 1000;
MaxA := -1000;
MinB := 1000;
MaxB := -1000;
for i := 1 to NoVariables do
begin
strvalue := Trim(OS3MainFrm.DataGrid.Cells[i,0]);
if FactorA = strvalue then ACol := i;
if FactorB = strvalue then BCol := i;
if DepVar = strvalue then YCol := i;
end;
if (ACol = 0) or (BCol = 0) or (YCol = 0) then
begin
MessageDlg('Select a variable for each entry box.', mtError, [mbOK], 0);
exit;
end;
// get number of levels for Factors
for i := 1 to NoCases do
begin
cellstring := Trim(OS3MainFrm.DataGrid.Cells[ACol,i]);
group := round(StrToFloat(cellstring));
if (group > MaxA) then MaxA := group;
if (group < MinA) then MinA := group;
cellstring := Trim(OS3MainFrm.DataGrid.Cells[BCol,i]);
group := round(StrToFLoat(cellstring));
if (group > MaxB) then MaxB := group;
if (group < MinB) then MinB := group;
end;
NoALevels := MaxA - MinA + 1;
NoBLevels := MaxB - MinB + 1;
Result := true;
end;
procedure TBNestedAForm.GetMemory;
begin
SetLength(SS,NoBLevels,NoALevels);
SetLength(SumSqr,NoBLevels,NoALevels);
SetLength(CellCount,NoBLevels,NoALevels);
SetLength(CellMeans,NoBLevels,NoALevels);
SetLength(CellSDs,NoBLevels,NoALevels);
SetLength(ASS,NoALevels);
SetLength(BSS,NoBLevels);
SetLength(ASumSqr,NoALevels);
SetLength(BSumSqr,NoBLevels);
SetLength(AMeans,NoALevels);
SetLength(BMeans,NoBLevels);
SetLength(ACount,NoALevels);
SetLength(BCount,NoBLevels);
SetLength(ASDs,NoALevels);
end;
procedure TBNestedAForm.GetSums;
VAR
Aindex, Bindex, i, j : integer;
YValue : double;
strvalue : string;
begin
// initialize memory
for i := 0 to NoBLevels-1 do
begin
for j := 0 to NoALevels-1 do
begin
SS[i,j] := 0.0;
SumSqr[i,j] := 0.0;
CellCount[i,j] := 0;
end;
end;
for i := 0 to NoALevels-1 do
begin
ACount[i] := 0;
AMeans[i] := 0.0;
ASS[i] := 0.0;
ASumSqr[i] := 0.0;
end;
for j := 0 to NoBLevels-1 do
begin
BCount[i] := 0;
BMeans[i] := 0.0;
BSS[i] := 0.0;
BSumSqr[i] := 0.0;
end;
// Accumulate sums and sums of squared values
for i := 1 to NoCases do
begin
strvalue := Trim(OS3MainFrm.DataGrid.Cells[ACol,i]);
Aindex := round(StrToFloat(strvalue));
strvalue := Trim(OS3MainFrm.DataGrid.Cells[BCol,i]);
Bindex := round(StrToFloat(strvalue));
strvalue := Trim(OS3MainFrm.DataGrid.Cells[YCol,i]);
YValue := StrToFloat(strvalue);
Aindex := Aindex - MinA;
Bindex := Bindex - MinB;
SS[Bindex,Aindex] := SS[Bindex,Aindex] + YValue * YValue;
SumSqr[Bindex,Aindex] := SumSqr[Bindex,Aindex] + YValue;
CellCount[Bindex,Aindex] := CellCount[Bindex,Aindex] + 1;
ACount[Aindex] := ACount[Aindex] + 1;
BCount[Bindex] := BCount[Bindex] + 1;
ASS[Aindex] := ASS[Aindex] + YValue * YValue;
BSS[Bindex] := BSS[Bindex] + YValue * YValue;
ASumSqr[Aindex] := ASumSqr[Aindex] + YValue;
BSumSqr[Bindex] := BSumSqr[Bindex] + YValue;
SSTot := SSTot + YValue * YValue;
SumSqrTot := SumSqrTot + YValue;
TotN := TotN + 1;
end;
//get cell means and marginal means, SDs plus square of sums
for i := 0 to NoBlevels-1 do
begin
for j := 0 to NoALevels-1 do
begin
if CellCount[i,j] > 0 then
begin
CellMeans[i,j] := SumSqr[i,j] / CellCount[i,j];
SumSqr[i,j] := SumSqr[i,j] * SumSqr[i,j];
CellSDs[i,j] := SS[i,j] - (SumSqr[i,j] / CellCount[i,j]);
CellSDs[i,j] := CellSDs[i,j] / (CellCount[i,j] - 1);
CellSDs[i,j] := Sqrt(CellSDs[i,j]);
end;
end;
end;
for i := 0 to NoBLevels-1 do
begin
BMeans[i] := BSumSqr[i] / BCount[i];
BSumSqr[i] := BSumSqr[i] * BSumSqr[i];
end;
for i := 0 to NoALevels-1 do
begin
AMeans[i] := ASumSqr[i] / ACount[i];
ASumSqr[i] := ASumSqr[i] * ASumSqr[i];
ASDs[i] := ASS[i] - (ASumSqr[i] / ACount[i]);
ASDs[i] := ASDs[i] / (ACount[i] - 1);
ASDs[i] := Sqrt(ASDs[i]);
end;
TotMean := SumSqrTot / TotN;
SumSqrTot := SumSqrTot * SumSqrTot;
end;
procedure TBNestedAForm.ShowMeans(AReport: TStrings);
var
i, j: integer;
begin
AReport.Add('NESTED ANOVA by Bill Miller');
AReport.Add('');
AReport.Add('File Analyzed: %s', [OS3MainFrm.FileNameEdit.Text]);
AReport.Add('');
AReport.Add('CELL MEANS');
AReport.Add('A LEVEL BLEVEL MEAN STD.DEV.');
for i := 0 to NoALevels-1 do
for j := 0 to NoBLevels-1 do
if CellCount[j,i] > 0 then
AReport.Add('%5d %5d %10.3f %10.3f', [i+MinA, j+MinB, CellMeans[j,i], CellSDs[j,i]]);
AReport.Add('');
AReport.Add('A MARGIN MEANS');
AReport.Add('A LEVEL MEAN STD.DEV.');
for i := 0 to NoALevels-1 do
AReport.Add('%5d %10.3f %10.3f', [i+MinA, AMeans[i], ASDs[i]]);
AReport.Add('');
AReport.Add('GRAND MEAN: %0.3f', [TotMean]);
AReport.Add('');
AReport.Add('');
end;
procedure TBNestedAForm.GetResults;
VAR
temp, constant : double;
NoBLevelsInA, BLevCount, i, j, celln : integer;
begin
celln := 0;
for i := 0 to NoALevels-1 do
begin
for j := 0 to NoBLevels-1 do
begin
if CellCount[j,i] > celln then celln := CellCount[j,i];
end;
end;
// assume all cells have same n size
// get no. of levels in A
BLevCount := 0;
for i := 0 to NoALevels-1 do
begin
NoBLevelsInA := 0;
for j := 0 to NoBLevels-1 do
begin
if CellCount[j,i] > 0 then NoBLevelsInA := NoBLevelsInA + 1;
end;
if NoBLevelsInA > BLevCount then BLevCount := NoBLevelsInA;
end;
dfA := NoALevels - 1;
dfBwA := NoALevels * (BLevCount - 1);
dfwcell := NoALevels * BLevCount * (celln - 1);
dftotal := TotN - 1;
constant := SumSqrTot / TotN;
SSTot := SSTot - constant;
MSTot := SSTot / dftotal;
SSA := 0.0;
for i := 0 to NoALevels-1 do SSA := SSA + (ASumSqr[i] / ACount[i]);
temp := SSA;
SSA := SSA - constant;
MSA := SSA / dfA;
SSB := 0.0;
for i := 0 to NoALevels - 1 do
begin
for j := 0 to NoBLevels-1 do
begin
if CellCount[j,i] > 0 then SSB := SSB + (SumSqr[j,i] / CellCount[j,i]);
end;
end;
SSB := SSB - temp;
MSB := SSB / dfBwA;
SSW := SSTot - SSA - SSB;
MSW := SSW / dfwcell;
(*
OutputFrm.RichEdit.Clear;
strvalue := format('SSA = %10.3f MSA = %10.3f SSB = %10.3f MSB = %10.3f',
[SSA,MSA,SSB,MSB]);
OutputFrm.RichEdit.Lines.Add(strvalue);
strvalue := format('SSW = %10.3f MSW = %10.3f',[SSW,MSW]);
OutputFrm.RichEdit.Lines.Add(strvalue);
OutputFrm.ShowModal;
*)
end;
procedure TBNestedAForm.ShowResults(AReport: TStrings);
var
F, PF: double;
begin
AReport.Add('ANOVA TABLE');
AReport.Add('SOURCE D.F. SS MS F PROB.');
if RandomBChk.Checked then
begin
F := MSA / MSB;
PF := probf(F, dfA, dfBwA);
end else
begin
F := MSA / MSW;
PF := probf(F, dfA, dfwcell);
end;
AReport.Add('A %4d %10.3f%10.3f%10.3f%10.3f', [dfA, SSA, MSA, F, PF]);
F := MSB / MSW;
PF := probf(F,dfBwA,dfwcell);
AReport.Add('B(W) %4d %10.3f%10.3f%10.3f%10.3f', [dfBwA, SSB, MSB, F, PF]);
AReport.Add('w.cells %4d %10.3f%10.3f', [dfwcell, SSW, MSW]);
AReport.Add('Total %4d %10.3f', [dftotal, SSTot]);
end;
procedure TBNestedAForm.ReleaseMemory;
begin
ASDs := nil;
BCount := nil;
ACount := nil;
BMeans := nil;
AMeans := nil;
BSumSqr := nil;
ASumSqr := nil;
BSS := nil;
ASS := nil;
CellSDs := nil;
CellMeans := nil;
CellCount := nil;
SumSqr := nil;
SS := nil;
end;
procedure TBNestedAForm.TwoWayPlot;
VAR
plottype, i: integer;
maxmean: double;
title: string;
XValue : DblDyneVec;
begin
case OptionsBox.ItemIndex of
0: plotType := 9;
1: plotType := 10;
2: plotType := 1;
3: plotType := 2;
else raise Exception.Create('Plot type not supported.');
end;
GraphFrm.SetLabels[1] := 'FACTOR A';
maxmean := -1000.0;
SetLength(XValue,NoALevels+NoBLevels);
SetLength(GraphFrm.Xpoints,1,NoALevels);
SetLength(GraphFrm.Ypoints,1,NoALevels);
for i := 1 to NoALevels do
begin
GraphFrm.Ypoints[0,i-1] := AMeans[i-1];
if AMeans[i-1] > maxmean then maxmean := AMeans[i-1];
XValue[i-1] := MinA + i -1;
GraphFrm.Xpoints[0,i-1] := XValue[i-1];
end;
GraphFrm.nosets := 1;
GraphFrm.nbars := NoALevels;
GraphFrm.Heading := FactorA;
GraphFrm.XTitle := FactorA + ' Group Codes';
GraphFrm.YTitle := 'Mean';
GraphFrm.barwideprop := 0.5;
GraphFrm.AutoScaled := false;
GraphFrm.miny := 0.0;
GraphFrm.maxy := maxmean;
GraphFrm.GraphType := plottype;
GraphFrm.BackColor := clCream;
GraphFrm.WallColor := clDkGray;
GraphFrm.FloorColor := clLtGray;
GraphFrm.ShowBackWall := true;
GraphFrm.ShowModal;
GraphFrm.Xpoints := nil;
GraphFrm.Ypoints := nil;
// Factor B next
maxmean := 0.0;
GraphFrm.SetLabels[1] := 'FACTOR B';
SetLength(GraphFrm.Xpoints,1,NoBLevels);
SetLength(GraphFrm.Ypoints,1,NoBLevels);
for i := 1 to NoBLevels do
begin
GraphFrm.Ypoints[0,i-1] := BMeans[i-1];
if BMeans[i-1] > maxmean then maxmean := BMeans[i-1];
XValue[i-1] := MinB + i - 1;
GraphFrm.Xpoints[0,i-1] := XValue[i-1];
end;
GraphFrm.nosets := 1;
GraphFrm.nbars := NoBLevels;
GraphFrm.Heading := 'FACTOR B';
GraphFrm.XTitle := FactorB + ' Group Codes';
GraphFrm.YTitle := 'Mean';
GraphFrm.barwideprop := 0.5;
GraphFrm.AutoScaled := false;
GraphFrm.miny := 0.0;
GraphFrm.maxy := maxmean;
GraphFrm.GraphType := plottype;
GraphFrm.BackColor := clCream;
GraphFrm.WallColor := clDkGray;
GraphFrm.FloorColor := clLtGray;
GraphFrm.ShowBackWall := true;
GraphFrm.ShowModal;
GraphFrm.Xpoints := nil;
GraphFrm.Ypoints := nil;
XValue := nil;
end;
procedure TBNestedAForm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
procedure TBNestedAForm.UpdateBtnStates;
var
i: Integer;
lSelected: Boolean;
begin
lSelected := false;
for i := 0 to VarList.Items.Count-1 do
if VarList.Selected[i] then
begin
lSelected := true;
break;
end;
AInBtn.Enabled := lSelected and (ACodes.Text = '');
BInBtn.Enabled := lSelected and (BCodes.Text = '');
DepInBtn.Enabled := lSelected and (DepEdit.Text = '');
AOutBtn.Enabled := (ACodes.Text <> '');
BOutBtn.Enabled := (BCodes.Text <> '');
DepOutBtn.Enabled := (DepEdit.Text <> '');
end;
initialization
{$I bnestaunit.lrs}
end.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,574 @@
object LatinSpecsFrm: TLatinSpecsFrm
Left = 887
Height = 519
Top = 260
Width = 420
AutoSize = True
Caption = 'Latin Squares Analysis Specification Form'
ClientHeight = 519
ClientWidth = 420
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Label1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 8
Height = 15
Top = 8
Width = 67
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'File Variables'
ParentColor = False
end
object Label8: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = nPerCellEdit
AnchorSideTop.Side = asrCenter
Left = 8
Height = 15
Top = 491
Width = 66
BorderSpacing.Left = 8
Caption = 'No. per cell: '
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel7
AnchorSideBottom.Control = Bevel1
Left = 8
Height = 445
Top = 25
Width = 232
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
Constraints.MinWidth = 150
ItemHeight = 0
TabOrder = 0
end
object ResetBtn: TButton
AnchorSideRight.Control = CancelBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 226
Height = 25
Top = 486
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 3
end
object CancelBtn: TButton
AnchorSideRight.Control = OKBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 292
Height = 25
Top = 486
Width = 62
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Cancel'
ModalResult = 2
TabOrder = 4
end
object OKBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 366
Height = 25
Top = 486
Width = 42
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'OK'
ModalResult = 1
OnClick = OKBtnClick
TabOrder = 5
end
object nPerCellEdit: TEdit
AnchorSideLeft.Control = Label8
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = OKBtn
AnchorSideTop.Side = asrCenter
AnchorSideRight.Side = asrBottom
Left = 82
Height = 23
Top = 487
Width = 48
Alignment = taRightJustify
BorderSpacing.Left = 8
TabOrder = 2
Text = 'nPerCellEdit'
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = OKBtn
Left = 0
Height = 8
Top = 470
Width = 420
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object Panel7: TPanel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = VarList
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1
Left = 248
Height = 440
Top = 25
Width = 164
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Right = 8
BevelOuter = bvNone
ChildSizing.VerticalSpacing = 16
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsHomogenousChildResize
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 440
ClientWidth = 164
TabOrder = 1
object PanelA: TPanel
AnchorSideRight.Side = asrBottom
Left = 0
Height = 60
Top = 0
Width = 164
AutoSize = True
BevelOuter = bvNone
ClientHeight = 60
ClientWidth = 164
TabOrder = 0
object ACodeLabel: TLabel
AnchorSideLeft.Control = ACodeEdit
AnchorSideBottom.Control = ACodeEdit
Left = 37
Height = 15
Top = 8
Width = 119
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Factor A Code Variable'
ParentColor = False
end
object AInBtn: TBitBtn
AnchorSideLeft.Control = PanelA
AnchorSideTop.Control = PanelA
Left = 0
Height = 28
Top = 0
Width = 29
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = AInBtnClick
Spacing = 0
TabOrder = 0
end
object AOutBtn: TBitBtn
AnchorSideLeft.Control = PanelA
AnchorSideTop.Control = AInBtn
AnchorSideTop.Side = asrBottom
Left = 0
Height = 28
Top = 32
Width = 29
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = AOutBtnClick
Spacing = 0
TabOrder = 1
end
object ACodeEdit: TEdit
AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = PanelA
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = AOutBtn
AnchorSideBottom.Side = asrBottom
Left = 37
Height = 23
Top = 25
Width = 127
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
TabOrder = 2
Text = 'ACodeEdit'
end
end
object PanelB: TPanel
Left = 0
Height = 60
Top = 76
Width = 164
AutoSize = True
BevelOuter = bvNone
ClientHeight = 60
ClientWidth = 164
TabOrder = 1
object BCodeLabel: TLabel
AnchorSideLeft.Control = BCodeEdit
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = BCodeEdit
Left = 37
Height = 15
Top = 8
Width = 118
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Factor B Code Variable'
ParentColor = False
end
object BInBtn: TBitBtn
AnchorSideLeft.Control = PanelB
AnchorSideTop.Control = PanelB
Left = 0
Height = 28
Top = 0
Width = 29
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = BInBtnClick
Spacing = 0
TabOrder = 0
end
object BOutBtn: TBitBtn
AnchorSideLeft.Control = PanelB
AnchorSideTop.Control = BInBtn
AnchorSideTop.Side = asrBottom
Left = 0
Height = 28
Top = 32
Width = 29
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = BOutBtnClick
Spacing = 0
TabOrder = 1
end
object BCodeEdit: TEdit
AnchorSideLeft.Control = BInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = PanelB
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = BOutBtn
AnchorSideBottom.Side = asrBottom
Left = 37
Height = 23
Top = 25
Width = 127
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
TabOrder = 2
Text = 'Edit1'
end
end
object PanelC: TPanel
Left = 0
Height = 60
Top = 152
Width = 164
AutoSize = True
BevelOuter = bvNone
ClientHeight = 60
ClientWidth = 164
TabOrder = 2
object CCodeLabel: TLabel
AnchorSideLeft.Control = CCodeEdit
AnchorSideBottom.Control = CCodeEdit
Left = 37
Height = 15
Top = 8
Width = 119
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Factor C Code Variable'
ParentColor = False
end
object CInBtn: TBitBtn
AnchorSideLeft.Control = PanelC
AnchorSideTop.Control = PanelC
Left = 0
Height = 28
Top = 0
Width = 29
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = CInBtnClick
Spacing = 0
TabOrder = 0
end
object COutBtn: TBitBtn
AnchorSideLeft.Control = PanelC
AnchorSideTop.Control = CInBtn
AnchorSideTop.Side = asrBottom
Left = 0
Height = 28
Top = 32
Width = 29
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = COutBtnClick
Spacing = 0
TabOrder = 1
end
object CCodeEdit: TEdit
AnchorSideLeft.Control = CInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = PanelC
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = COutBtn
AnchorSideBottom.Side = asrBottom
Left = 37
Height = 23
Top = 25
Width = 127
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
TabOrder = 2
Text = 'Edit1'
end
end
object PanelD: TPanel
Left = 0
Height = 60
Top = 228
Width = 164
AutoSize = True
BevelOuter = bvNone
ClientHeight = 60
ClientWidth = 164
TabOrder = 3
object DCodeLabel: TLabel
AnchorSideLeft.Control = DCodeEdit
AnchorSideBottom.Control = DCodeEdit
Left = 45
Height = 15
Top = 8
Width = 119
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 2
Caption = 'Factor D Code Variable'
ParentColor = False
end
object DInBtn: TBitBtn
AnchorSideLeft.Control = PanelD
AnchorSideTop.Control = PanelD
Left = 0
Height = 28
Top = 0
Width = 29
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = DInBtnClick
Spacing = 0
TabOrder = 0
end
object DOutBtn: TBitBtn
AnchorSideLeft.Control = PanelD
AnchorSideTop.Control = DInBtn
AnchorSideTop.Side = asrBottom
Left = 0
Height = 28
Top = 32
Width = 29
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = DOutBtnClick
Spacing = 0
TabOrder = 1
end
object DCodeEdit: TEdit
AnchorSideLeft.Control = DInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = PanelD
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = DOutBtn
AnchorSideBottom.Side = asrBottom
Left = 37
Height = 23
Top = 25
Width = 127
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
TabOrder = 2
Text = 'Edit1'
end
end
object PanelGrp: TPanel
Left = 0
Height = 60
Top = 304
Width = 164
AutoSize = True
BevelOuter = bvNone
ClientHeight = 60
ClientWidth = 164
TabOrder = 4
object GrpCodeLabel: TLabel
AnchorSideLeft.Control = GrpCodeEdit
AnchorSideBottom.Control = GrpCodeEdit
Left = 37
Height = 15
Top = 8
Width = 108
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Group Code Variable'
ParentColor = False
end
object GrpInBtn: TBitBtn
AnchorSideLeft.Control = PanelGrp
AnchorSideTop.Control = PanelGrp
Left = 0
Height = 28
Top = 0
Width = 29
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = GrpInBtnClick
Spacing = 0
TabOrder = 0
end
object GrpOutBtn: TBitBtn
AnchorSideLeft.Control = PanelGrp
AnchorSideTop.Control = GrpInBtn
AnchorSideTop.Side = asrBottom
Left = 0
Height = 28
Top = 32
Width = 29
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = GrpOutBtnClick
Spacing = 0
TabOrder = 1
end
object GrpCodeEdit: TEdit
AnchorSideLeft.Control = GrpInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = PanelGrp
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = GrpOutBtn
AnchorSideBottom.Side = asrBottom
Left = 37
Height = 23
Top = 25
Width = 127
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
TabOrder = 2
Text = 'Edit1'
end
end
object PanelDep: TPanel
Left = 0
Height = 60
Top = 380
Width = 164
AutoSize = True
BevelOuter = bvNone
ClientHeight = 60
ClientWidth = 164
TabOrder = 5
object DepVarLabel: TLabel
AnchorSideLeft.Control = DepVarEdit
AnchorSideBottom.Control = DepVarEdit
Left = 37
Height = 15
Top = 8
Width = 102
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Dependent Variable'
ParentColor = False
end
object DataInBtn: TBitBtn
AnchorSideLeft.Control = PanelDep
AnchorSideTop.Control = PanelDep
Left = 0
Height = 28
Top = 0
Width = 29
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = DataInBtnClick
Spacing = 0
TabOrder = 0
end
object DataOutBtn: TBitBtn
AnchorSideLeft.Control = PanelDep
AnchorSideTop.Control = DataInBtn
AnchorSideTop.Side = asrBottom
Left = 0
Height = 28
Top = 32
Width = 29
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = DataOutBtnClick
Spacing = 0
TabOrder = 1
end
object DepVarEdit: TEdit
AnchorSideLeft.Control = DataInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = PanelDep
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = DataOutBtn
AnchorSideBottom.Side = asrBottom
Left = 37
Height = 23
Top = 25
Width = 127
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
TabOrder = 2
Text = 'Edit1'
end
end
end
end

View File

@ -0,0 +1,273 @@
unit LatinSpecsUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, Buttons,
MainUnit, Globals;
type
{ TLatinSpecsFrm }
TLatinSpecsFrm = class(TForm)
AInBtn: TBitBtn;
nPerCellEdit: TEdit;
GrpOutBtn: TBitBtn;
DataInBtn: TBitBtn;
DataOutBtn: TBitBtn;
AOutBtn: TBitBtn;
BInBtn: TBitBtn;
BOutBtn: TBitBtn;
CInBtn: TBitBtn;
COutBtn: TBitBtn;
DInBtn: TBitBtn;
DOutBtn: TBitBtn;
GrpInBtn: TBitBtn;
Label8: TLabel;
PanelA: TPanel;
PanelB: TPanel;
PanelC: TPanel;
PanelD: TPanel;
PanelGrp: TPanel;
PanelDep: TPanel;
Panel7: TPanel;
ResetBtn: TButton;
CancelBtn: TButton;
OKBtn: TButton;
ACodeEdit: TEdit;
BCodeEdit: TEdit;
CCodeEdit: TEdit;
DCodeEdit: TEdit;
GrpCodeEdit: TEdit;
DepVarEdit: TEdit;
Label1: TLabel;
ACodeLabel: TLabel;
BCodeLabel: TLabel;
CCodeLabel: TLabel;
DCodeLabel: TLabel;
GrpCodeLabel: TLabel;
DepVarLabel: TLabel;
VarList: TListBox;
Bevel1: TBevel;
procedure AInBtnClick(Sender: TObject);
procedure AOutBtnClick(Sender: TObject);
procedure BInBtnClick(Sender: TObject);
procedure BOutBtnClick(Sender: TObject);
procedure CInBtnClick(Sender: TObject);
procedure COutBtnClick(Sender: TObject);
procedure DataInBtnClick(Sender: TObject);
procedure DataOutBtnClick(Sender: TObject);
procedure DInBtnClick(Sender: TObject);
procedure DOutBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure GrpInBtnClick(Sender: TObject);
procedure GrpOutBtnClick(Sender: TObject);
procedure OKBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
private
{ private declarations }
FAutoSized: Boolean;
function Validate(out AMsg: String; out AControl: TWinControl): Boolean;
public
{ public declarations }
end;
var
LatinSpecsFrm: TLatinSpecsFrm;
implementation
uses
Math,
LatinSqrsUnit;
{ TLatinSpecsFrm }
procedure TLatinSpecsFrm.ResetBtnClick(Sender: TObject);
VAR i : integer;
begin
VarList.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
end;
procedure TLatinSpecsFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([ResetBtn.Width, CancelBtn.Width, OKBtn.Width]);
ResetBtn.Constraints.MinWidth := w;
CancelBtn.Constraints.MinWidth := w;
OKBtn.Constraints.MinWidth := w;
VarList.Constraints.MinHeight := Panel7.Height;
Constraints.MinWidth := nPerCellEdit.Left + nPerCellEdit.Width + Width - ResetBtn.Left + ResetBtn.BorderSpacing.Left;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TLatinSpecsFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
end;
procedure TLatinSpecsFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(Self);
end;
procedure TLatinSpecsFrm.GrpInBtnClick(Sender: TObject);
VAR index : integer;
begin
index := VarList.ItemIndex;
GrpCodeEdit.Text := VarList.Items.Strings[index];
VarList.Items.Delete(index);
GrpInBtn.Enabled := false;
GrpOutBtn.Enabled := true;
end;
procedure TLatinSpecsFrm.GrpOutBtnClick(Sender: TObject);
begin
VarList.Items.Add(GrpCodeEdit.Text);
GrpCodeEdit.Text := '';
GrpInBtn.Enabled := true;
GrpOutBtn.Enabled := false;
end;
procedure TLatinSpecsFrm.AInBtnClick(Sender: TObject);
VAR index : integer;
begin
index := VarList.ItemIndex;
ACodeEdit.Text := VarList.Items.Strings[index];
VarList.Items.Delete(index);
AinBtn.Enabled := false;
AOutBtn.Enabled := true;
end;
procedure TLatinSpecsFrm.AOutBtnClick(Sender: TObject);
begin
VarList.Items.Add(ACodeEdit.Text);
ACodeEdit.Text := '';
AinBtn.Enabled := true;
AOutBtn.Enabled := false;
end;
procedure TLatinSpecsFrm.BInBtnClick(Sender: TObject);
VAR index : integer;
begin
index := VarList.ItemIndex;
BCodeEdit.Text := VarList.Items.Strings[index];
VarList.Items.Delete(index);
BinBtn.Enabled := false;
BOutBtn.Enabled := true;
end;
procedure TLatinSpecsFrm.BOutBtnClick(Sender: TObject);
begin
VarList.Items.Add(BCodeEdit.Text);
BCodeEdit.Text := '';
BinBtn.Enabled := true;
BOutBtn.Enabled := false;
end;
procedure TLatinSpecsFrm.CInBtnClick(Sender: TObject);
VAR index : integer;
begin
index := VarList.ItemIndex;
CCodeEdit.Text := VarList.Items.Strings[index];
VarList.Items.Delete(index);
CinBtn.Enabled := false;
COutBtn.Enabled := true;
end;
procedure TLatinSpecsFrm.COutBtnClick(Sender: TObject);
begin
VarList.Items.Add(CCodeEdit.Text);
CCodeEdit.Text := '';
CinBtn.Enabled := true;
COutBtn.Enabled := false;
end;
procedure TLatinSpecsFrm.DataInBtnClick(Sender: TObject);
VAR index : integer;
begin
index := VarList.ItemIndex;
DepVarEdit.Text := VarList.Items.Strings[index];
VarList.Items.Delete(index);
DataInBtn.Enabled := false;
DataOutBtn.Enabled := true;
end;
procedure TLatinSpecsFrm.DataOutBtnClick(Sender: TObject);
begin
VarList.Items.Add(DepVarEdit.Text);
DepVarEdit.Text := '';
DataInBtn.Enabled := true;
DataOutBtn.Enabled := false;
end;
procedure TLatinSpecsFrm.DInBtnClick(Sender: TObject);
VAR index : integer;
begin
index := VarList.ItemIndex;
DCodeEdit.Text := VarList.Items.Strings[index];
VarList.Items.Delete(index);
DinBtn.Enabled := false;
DOutBtn.Enabled := true;
end;
procedure TLatinSpecsFrm.DOutBtnClick(Sender: TObject);
begin
VarList.Items.Add(DCodeEdit.Text);
DCodeEdit.Text := '';
DinBtn.Enabled := true;
DOutBtn.Enabled := false;
end;
procedure TLatinSpecsFrm.OKBtnClick(Sender: TObject);
var
C: TWinControl;
msg: String;
begin
if not Validate(msg, C) then begin
C.SetFocus;
MessageDlg(msg, mtError, [mbOK], 0);
ModalResult := mrNone;
end;
end;
function TLatinSpecsFrm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
var
n: Integer;
begin
Result := false;
if (nPerCellEdit.Text = '') then begin
AMsg := 'Please specify the number of cases per cell.';
AControl := nPercellEdit;
exit;
end;
if not TryStrToInt(nPercellEdit.Text, n) or (n <= 0) then begin
AMsg := 'Please specify a valid number for the cases per cell.';
AControl := nPercellEdit;
exit;
end;
Result := true;
end;
initialization
{$I latinspecsunit.lrs}
end.

View File

@ -0,0 +1,109 @@
object LatinSqrsFrm: TLatinSqrsFrm
Left = 199
Height = 248
Top = 108
Width = 523
ActiveControl = Plan
AutoSize = True
BorderStyle = bsDialog
Caption = 'Latin and Greco-Latin Squares Analyses'
ClientHeight = 248
ClientWidth = 523
OnActivate = FormActivate
OnCreate = FormCreate
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object CancelBtn: TButton
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Plan
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = OKBtn
Left = 399
Height = 25
Top = 214
Width = 62
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Cancel'
ModalResult = 2
TabOrder = 2
end
object OKBtn: TButton
AnchorSideTop.Control = Plan
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 473
Height = 25
Top = 214
Width = 42
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'OK'
ModalResult = 1
OnClick = OKBtnClick
TabOrder = 3
end
object Plan: TRadioGroup
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 8
Height = 198
Top = 8
Width = 515
AutoFill = True
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Winer''s Plans:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 178
ClientWidth = 511
Items.Strings = (
'Plan 1. Three Factors (A,B,C) with no interactions.'
'Plan 2. Four Factors (A,B,C,D) with partial interactions.'
'Plan 3. Like Plan 2 but different assumptions (Partial confounding of interaction ABC.)'
'The Greco-Latin with no interactions assumed.'
'Plan 5. Repeated measures Latin Square (random assignment of groups to rows.)'
'Plan 6. Fractional replication of a three factor factorial experiment in incomplete blocks.'
'Plan 7. Plan 5 with superimposing of an orthogonal Latin square.'
'Plan 9. AxBxC (same square used for all levels of Factor C.)'
)
OnClick = PlanClick
TabOrder = 0
end
object HelpBtn: TButton
Tag = 130
AnchorSideTop.Control = Plan
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = CancelBtn
Left = 340
Height = 25
Top = 214
Width = 51
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 1
end
end

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,583 @@
object OneCaseAnovaForm: TOneCaseAnovaForm
Left = 694
Height = 458
Top = 246
Width = 567
AutoSize = True
Caption = 'OneCaseAnovaForm'
ClientHeight = 458
ClientWidth = 567
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object GroupBox1: TGroupBox
AnchorSideLeft.Control = PlotOptionsBox
AnchorSideTop.Control = PlotOptionsBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = PlotOptionsBox
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = OverAllAlpha
Left = 364
Height = 135
Top = 146
Width = 195
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 16
BorderSpacing.Bottom = 8
Caption = 'Post-Hoc Comparisons:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsHomogenousChildResize
ChildSizing.ShrinkVertical = crsHomogenousChildResize
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 115
ClientWidth = 191
TabOrder = 2
object ScheffeChk: TCheckBox
Left = 12
Height = 19
Top = 6
Width = 167
Caption = 'ScheffeChk'
TabOrder = 0
end
object TukeyHSDChk: TCheckBox
Left = 12
Height = 19
Top = 27
Width = 167
Caption = 'Tukey HSD (= n''s)'
TabOrder = 1
end
object TukeyBChk: TCheckBox
Left = 12
Height = 19
Top = 48
Width = 167
Caption = 'Tukey B (= n''s)'
TabOrder = 2
end
object TukeyKramerChk: TCheckBox
Left = 12
Height = 19
Top = 69
Width = 167
Caption = 'Tukey-Kramer'
TabOrder = 3
end
object NewmanKeulsChk: TCheckBox
Left = 12
Height = 19
Top = 90
Width = 167
Caption = 'Newman-Keuls (= n''s)'
TabOrder = 4
end
end
object Label3: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = OverAllAlpha
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = OverAllAlpha
Left = 8
Height = 15
Top = 390
Width = 147
BorderSpacing.Left = 8
BorderSpacing.Right = 8
Caption = 'Alpha Level for Overall Tests'
ParentColor = False
end
object OverAllAlpha: TEdit
AnchorSideLeft.Control = Label3
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = PostAlpha
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1
Left = 163
Height = 23
Top = 386
Width = 51
Alignment = taRightJustify
Anchors = [akLeft, akBottom]
TabOrder = 4
Text = 'OverAllAlpha'
end
object Label4: TLabel
AnchorSideLeft.Control = OverAllAlpha
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = PostAlpha
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = PostAlpha
Left = 238
Height = 15
Top = 390
Width = 163
BorderSpacing.Left = 24
BorderSpacing.Right = 8
Caption = 'Alpha Level for Post-Hoc Tests:'
ParentColor = False
end
object PostAlpha: TEdit
AnchorSideLeft.Control = Label4
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Side = asrCenter
AnchorSideBottom.Control = Bevel1
Left = 409
Height = 23
Top = 386
Width = 51
Alignment = taRightJustify
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
TabOrder = 5
Text = 'PostAlpha'
end
object HelpBtn: TButton
Tag = 107
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 295
Height = 25
Top = 425
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 6
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 354
Height = 25
Top = 425
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 7
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 416
Height = 25
Top = 425
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 8
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 500
Height = 25
Top = 425
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 9
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 409
Width = 567
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object InteractBtn: TCheckBox
AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = GroupBox1
AnchorSideTop.Side = asrBottom
Left = 380
Height = 19
Top = 297
Width = 103
BorderSpacing.Left = 16
BorderSpacing.Top = 16
BorderSpacing.Bottom = 8
Caption = 'Get Interactions'
TabOrder = 3
end
object PlotOptionsBox: TRadioGroup
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 364
Height = 114
Top = 16
Width = 195
Anchors = [akTop, akRight]
AutoFill = True
AutoSize = True
BorderSpacing.Left = 16
BorderSpacing.Top = 16
BorderSpacing.Right = 8
Caption = 'Plot Options'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 94
ClientWidth = 191
ItemIndex = 0
Items.Strings = (
'no plot'
'Plot with Vertical 3D Bars'
'Plot with Vertical 2D Bars'
'Plot with Horizontal 2D Bars'
)
TabOrder = 1
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = PlotOptionsBox
AnchorSideBottom.Control = OverAllAlpha
Left = 8
Height = 370
Top = 8
Width = 340
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Bottom = 8
BevelOuter = bvNone
ClientHeight = 370
ClientWidth = 340
TabOrder = 0
object Label1: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
Left = 0
Height = 15
Top = 0
Width = 49
Caption = 'Variables:'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = DepIn
AnchorSideBottom.Control = Panel1
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 353
Top = 17
Width = 187
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Right = 8
ItemHeight = 0
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object DepIn: TBitBtn
AnchorSideLeft.Control = Bevel2
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = VarList
Left = 195
Height = 28
Top = 17
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = DepInClick
Spacing = 0
TabOrder = 1
end
object StaticText1: TStaticText
AnchorSideLeft.Control = DepIn
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = DepVar
Left = 231
Height = 16
Top = 24
Width = 103
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Bottom = 2
Caption = 'Dependent Variable'
TabOrder = 3
end
object DepOut: TBitBtn
AnchorSideLeft.Control = DepIn
AnchorSideTop.Control = DepIn
AnchorSideTop.Side = asrBottom
Left = 195
Height = 28
Top = 49
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = DepOutClick
Spacing = 0
TabOrder = 2
end
object Fact1In: TBitBtn
AnchorSideLeft.Control = DepIn
AnchorSideTop.Control = DepOut
AnchorSideTop.Side = asrBottom
Left = 195
Height = 28
Top = 101
Width = 28
BorderSpacing.Top = 24
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = Fact1InClick
Spacing = 0
TabOrder = 5
end
object Fact1Out: TBitBtn
AnchorSideLeft.Control = DepIn
AnchorSideTop.Control = Fact1In
AnchorSideTop.Side = asrBottom
Left = 195
Height = 28
Top = 133
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = Fact1OutClick
Spacing = 0
TabOrder = 6
end
object Fact2In: TBitBtn
AnchorSideLeft.Control = DepIn
AnchorSideTop.Control = Fact1Out
AnchorSideTop.Side = asrBottom
Left = 195
Height = 28
Top = 185
Width = 28
BorderSpacing.Top = 24
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = Fact2InClick
Spacing = 0
TabOrder = 9
end
object Fact2Out: TBitBtn
AnchorSideLeft.Control = DepIn
AnchorSideTop.Control = Fact2In
AnchorSideTop.Side = asrBottom
Left = 195
Height = 28
Top = 217
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = Fact2OutClick
Spacing = 0
TabOrder = 10
end
object StaticText2: TStaticText
AnchorSideLeft.Control = DepIn
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = Factor1
Left = 231
Height = 16
Top = 108
Width = 87
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Bottom = 2
Caption = 'Factor 1 Variable'
TabOrder = 7
end
object Factor1: TEdit
AnchorSideLeft.Control = DepIn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Fact1Out
AnchorSideBottom.Side = asrBottom
Left = 231
Height = 23
Top = 126
Width = 109
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 8
Text = 'Edit1'
end
object StaticText3: TStaticText
AnchorSideLeft.Control = DepIn
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = Factor2
Left = 231
Height = 16
Top = 192
Width = 87
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Bottom = 2
Caption = 'Factor 2 Variable'
TabOrder = 11
end
object Factor2: TEdit
AnchorSideLeft.Control = DepIn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Fact2Out
AnchorSideBottom.Side = asrBottom
Left = 231
Height = 23
Top = 210
Width = 109
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 12
Text = 'Edit1'
end
object Fact3In: TBitBtn
AnchorSideLeft.Control = DepIn
AnchorSideTop.Control = Fact2Out
AnchorSideTop.Side = asrBottom
Left = 195
Height = 28
Top = 269
Width = 28
BorderSpacing.Top = 24
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = Fact3InClick
Spacing = 0
TabOrder = 13
end
object Fact3Out: TBitBtn
AnchorSideLeft.Control = DepIn
AnchorSideTop.Control = Fact3In
AnchorSideTop.Side = asrBottom
Left = 195
Height = 28
Top = 301
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = Fact3OutClick
Spacing = 0
TabOrder = 14
end
object StaticText4: TStaticText
AnchorSideLeft.Control = DepIn
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = Factor3
Left = 231
Height = 16
Top = 276
Width = 72
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Bottom = 2
Caption = 'Factor 3 Clark'
TabOrder = 15
end
object Factor3: TEdit
AnchorSideLeft.Control = DepIn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Fact3Out
AnchorSideBottom.Side = asrBottom
Left = 231
Height = 23
Top = 294
Width = 109
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 16
Text = 'Edit1'
end
object DepVar: TEdit
AnchorSideLeft.Control = DepIn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = DepOut
AnchorSideBottom.Side = asrBottom
Left = 231
Height = 23
Top = 42
Width = 109
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 4
Text = 'DepVar'
end
object Bevel2: TBevel
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Panel1
Left = 145
Height = 17
Top = 0
Width = 50
Shape = bsSpacer
end
end
end

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,686 @@
object TtestFrm: TTtestFrm
Left = 629
Height = 505
Top = 216
Width = 544
AutoSize = True
Caption = 'Comparison of Two Sample Means'
ClientHeight = 505
ClientWidth = 544
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Label1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = CloseBtn
AnchorSideTop.Side = asrCenter
Left = 8
Height = 15
Top = 477
Width = 149
BorderSpacing.Left = 8
Caption = 'Percent Confidence Interval:'
ParentColor = False
end
object RadioGroup1: TRadioGroup
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 8
Height = 72
Top = 8
Width = 195
AutoFill = True
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Data Entry By:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 52
ClientWidth = 191
Items.Strings = (
'Values Entered on this Form'
'Values in the data grid file'
)
OnClick = RadioGroup1Click
TabOrder = 0
end
object RadioGroup2: TRadioGroup
AnchorSideLeft.Control = RadioGroup1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Owner
Left = 219
Height = 72
Top = 8
Width = 152
AutoFill = True
AutoSize = True
BorderSpacing.Left = 16
BorderSpacing.Top = 8
Caption = 'Test Assumptions:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 52
ClientWidth = 148
Items.Strings = (
'Independent Scores'
'Correlated Scores'
)
OnClick = RadioGroup2Click
TabOrder = 1
end
object CInterval: TEdit
AnchorSideLeft.Control = Label1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ResetBtn
AnchorSideTop.Side = asrCenter
Left = 165
Height = 23
Top = 473
Width = 46
Alignment = taRightJustify
BorderSpacing.Left = 8
TabOrder = 4
Text = '95.0'
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 331
Height = 25
Top = 472
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 5
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 393
Height = 25
Top = 472
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 6
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 477
Height = 25
Top = 472
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 7
end
object RadioGroup3: TRadioGroup
AnchorSideLeft.Control = RadioGroup2
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Owner
Left = 387
Height = 72
Top = 8
Width = 140
AutoFill = True
AutoSize = True
BorderSpacing.Left = 16
BorderSpacing.Top = 8
Caption = 'Test Probability'
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 52
ClientWidth = 136
ItemIndex = 0
Items.Strings = (
'Two-tailed (default)'
'One-tailed'
)
TabOrder = 2
end
object Notebook1: TNotebook
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Bevel3
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel2
Left = 8
Height = 360
Top = 96
Width = 528
PageIndex = 1
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
TabOrder = 3
object Page1: TPage
object Panel2: TPanel
AnchorSideLeft.Control = Page1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Page1
Left = 48
Height = 117
Top = 16
Width = 433
AutoSize = True
BorderSpacing.Top = 16
BevelOuter = bvNone
ClientHeight = 117
ClientWidth = 433
TabOrder = 0
object Mean1Label: TLabel
AnchorSideTop.Control = Mean1
AnchorSideTop.Side = asrCenter
Left = 8
Height = 15
Top = 4
Width = 39
BorderSpacing.Left = 8
Caption = 'Mean 1'
ParentColor = False
end
object Mean2Label: TLabel
AnchorSideTop.Control = Mean2
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Mean1Label
AnchorSideRight.Side = asrBottom
Left = 8
Height = 15
Top = 51
Width = 39
Anchors = [akTop, akRight]
BorderSpacing.Left = 8
Caption = 'Mean 2'
ParentColor = False
end
object SD1Label: TLabel
AnchorSideLeft.Control = Mean1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = SD1
AnchorSideTop.Side = asrCenter
Left = 145
Height = 15
Top = 4
Width = 55
BorderSpacing.Left = 24
Caption = 'Std. Dev. 1'
ParentColor = False
end
object SD2Label: TLabel
AnchorSideTop.Control = SD2
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = SD2
Left = 145
Height = 15
Top = 51
Width = 55
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Std. Dev. 2'
ParentColor = False
end
object SampSize1Label: TLabel
AnchorSideLeft.Control = SD1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = N1
AnchorSideTop.Side = asrCenter
Left = 292
Height = 15
Top = 4
Width = 71
BorderSpacing.Left = 24
Caption = 'Sample Size 1'
ParentColor = False
end
object SampSize2Label: TLabel
AnchorSideTop.Control = N2
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = N2
Left = 292
Height = 15
Top = 51
Width = 71
Anchors = [akTop]
BorderSpacing.Right = 8
Caption = 'Sample Size 2'
ParentColor = False
end
object CorBetweenLabel: TLabel
AnchorSideTop.Control = Cor12
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Cor12
Left = 60
Height = 15
Top = 98
Width = 147
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Correlation Between Scores:'
ParentColor = False
end
object Mean1: TEdit
AnchorSideLeft.Control = Mean1Label
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel2
Left = 55
Height = 23
Top = 0
Width = 66
Alignment = taRightJustify
BorderSpacing.Left = 8
TabOrder = 0
Text = 'Mean1'
end
object Mean2: TEdit
AnchorSideLeft.Control = Mean1
AnchorSideTop.Control = Mean1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Mean1
AnchorSideRight.Side = asrBottom
Left = 55
Height = 23
Top = 47
Width = 66
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 24
TabOrder = 3
Text = 'Mean2'
end
object SD1: TEdit
AnchorSideLeft.Control = SD1Label
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel2
Left = 208
Height = 23
Top = 0
Width = 60
Alignment = taRightJustify
BorderSpacing.Left = 8
TabOrder = 1
Text = 'SD1'
end
object SD2: TEdit
AnchorSideLeft.Control = SD1
AnchorSideTop.Control = SD1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = SD1
AnchorSideRight.Side = asrBottom
Left = 208
Height = 23
Top = 47
Width = 60
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 24
TabOrder = 4
Text = 'SD2'
end
object N1: TEdit
AnchorSideLeft.Control = SampSize1Label
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel2
Left = 371
Height = 23
Top = 0
Width = 62
Alignment = taRightJustify
BorderSpacing.Left = 8
TabOrder = 2
Text = 'N1'
end
object N2: TEdit
AnchorSideLeft.Control = N1
AnchorSideTop.Control = N1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = N1
AnchorSideRight.Side = asrBottom
Left = 371
Height = 23
Top = 47
Width = 62
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 24
TabOrder = 5
Text = 'N2'
end
object Cor12: TEdit
AnchorSideLeft.Control = SD1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = SD2
AnchorSideTop.Side = asrBottom
Left = 215
Height = 23
Top = 94
Width = 47
Alignment = taRightJustify
BorderSpacing.Top = 24
TabOrder = 6
Text = 'Cor12'
end
end
end
object Page2: TPage
object Memo1: TLabel
AnchorSideLeft.Control = Page2
AnchorSideTop.Control = Page2
AnchorSideRight.Control = Page2
AnchorSideRight.Side = asrBottom
Left = 0
Height = 75
Top = 0
Width = 528
Anchors = [akTop, akLeft, akRight]
Caption = 'Directions: '#13#10'For independent groups data, first click the variable to be analyzed then click the variable containing group codes. '#13#10'For dependent variables it is assumed the data for each pair of values are in a case. '#13#10'Enter the names of those two variables.'
ParentColor = False
WordWrap = True
end
object SelVarLabel: TLabel
AnchorSideLeft.Control = Page2
AnchorSideTop.Control = Memo1
AnchorSideTop.Side = asrBottom
Left = 0
Height = 15
Top = 91
Width = 83
BorderSpacing.Top = 16
Caption = 'Select Variables:'
ParentColor = False
end
object ListBox1: TListBox
AnchorSideLeft.Control = Page2
AnchorSideTop.Control = SelVarLabel
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Bevel1
AnchorSideBottom.Control = Page2
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 252
Top = 108
Width = 256
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
ItemHeight = 0
OnClick = ListBox1Click
TabOrder = 0
end
object Bevel1: TBevel
AnchorSideLeft.Control = Page2
AnchorSideLeft.Side = asrCenter
Left = 256
Height = 91
Top = 92
Width = 16
Shape = bsSpacer
end
object FirstVarLabel: TLabel
AnchorSideLeft.Control = Bevel1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Var1
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Var1
Left = 284
Height = 15
Top = 112
Width = 62
Alignment = taRightJustify
BorderSpacing.Left = 12
BorderSpacing.Right = 8
Caption = '1st Variable:'
ParentColor = False
end
object SecdVarLabel: TLabel
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Var2
Left = 279
Height = 15
Top = 143
Width = 67
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = '2nd Variable:'
ParentColor = False
end
object GrpLabel: TLabel
AnchorSideTop.Control = Grp
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Grp
Left = 279
Height = 15
Top = 143
Width = 67
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Group Code:'
ParentColor = False
end
object Bevel5: TBevel
Left = 273
Height = 11
Top = 92
Width = 87
Shape = bsSpacer
end
object Var1: TEdit
AnchorSideLeft.Control = FirstVarLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ListBox1
AnchorSideRight.Control = Page2
AnchorSideRight.Side = asrBottom
Left = 354
Height = 23
Top = 108
Width = 174
Anchors = [akTop, akLeft, akRight]
TabOrder = 1
Text = 'Var1'
end
object Var2: TEdit
AnchorSideLeft.Control = Var1
AnchorSideTop.Control = Var1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Var1
AnchorSideRight.Side = asrBottom
Left = 354
Height = 23
Top = 139
Width = 174
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
TabOrder = 2
Text = 'Var2'
end
object Grp: TEdit
AnchorSideLeft.Control = Var1
AnchorSideTop.Control = Var1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Var2
AnchorSideRight.Side = asrBottom
Left = 354
Height = 23
Top = 139
Width = 174
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
TabOrder = 3
Text = 'Grp'
end
object GroupBox1: TGroupBox
AnchorSideLeft.Control = Grp
AnchorSideTop.Control = Grp
AnchorSideTop.Side = asrBottom
Left = 354
Height = 90
Top = 170
Width = 164
AutoSize = True
BorderSpacing.Top = 8
ClientHeight = 70
ClientWidth = 160
TabOrder = 5
object Grp1Code: TEdit
AnchorSideTop.Control = GroupBox1
AnchorSideRight.Control = GroupBox1
AnchorSideRight.Side = asrBottom
Left = 100
Height = 23
Top = 8
Width = 52
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Enabled = False
TabOrder = 0
Text = 'Grp1Code'
end
object Grp2Code: TEdit
AnchorSideTop.Control = Grp1Code
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = GroupBox1
AnchorSideRight.Side = asrBottom
Left = 100
Height = 23
Top = 39
Width = 52
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Enabled = False
TabOrder = 1
Text = 'Grp2Code'
end
object GrpCodeLabel1: TLabel
AnchorSideTop.Control = Grp1Code
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Grp1Code
Left = 16
Height = 15
Top = 12
Width = 76
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Left = 16
BorderSpacing.Right = 8
Caption = 'Group 1 Code:'
Enabled = False
ParentColor = False
end
object GrpCodeLabel2: TLabel
AnchorSideTop.Control = Grp2Code
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Grp2Code
Left = 16
Height = 15
Top = 43
Width = 76
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Group 2 Code:'
Enabled = False
ParentColor = False
end
end
object GroupCodeBtn: TCheckBox
AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = GroupBox1
Left = 362
Height = 19
Top = 170
Width = 130
BorderSpacing.Left = 8
Caption = 'Specify Group Codes'
OnChange = GroupCodeBtnChange
TabOrder = 4
end
end
end
object Bevel2: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 456
Width = 544
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object Bevel3: TBevel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = RadioGroup1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 8
Top = 80
Width = 544
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Bottom = 8
Shape = bsBottomLine
end
object Bevel4: TBevel
Left = 5
Height = 11
Top = 382
Width = 15
Shape = bsSpacer
end
end

View File

@ -0,0 +1,624 @@
unit TTestUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
ExtCtrls, StdCtrls,
MainUnit, Globals, FunctionsLib, OutputUnit, DataProcs;
type
{ TTtestFrm }
TTtestFrm = class(TForm)
Bevel1: TBevel;
Bevel2: TBevel;
Bevel3: TBevel;
Bevel4: TBevel;
Bevel5: TBevel;
GroupBox1: TGroupBox;
GroupCodeBtn: TCheckBox;
Grp1Code: TEdit;
Grp2Code: TEdit;
GrpCodeLabel1: TLabel;
GrpCodeLabel2: TLabel;
Memo1: TLabel;
Notebook1: TNotebook;
Page1: TPage;
Page2: TPage;
RadioGroup3: TRadioGroup;
ResetBtn: TButton;
ComputeBtn: TButton;
CloseBtn: TButton;
CorBetweenLabel: TLabel;
Cor12: TEdit;
CInterval: TEdit;
Grp: TEdit;
Label1: TLabel;
Var2: TEdit;
Var1: TEdit;
FirstVarLabel: TLabel;
GrpLabel: TLabel;
SecdVarLabel: TLabel;
ListBox1: TListBox;
SelVarLabel: TLabel;
N2: TEdit;
N1: TEdit;
SampSize2Label: TLabel;
SampSize1Label: TLabel;
SD2: TEdit;
SD1: TEdit;
SD2Label: TLabel;
SD1Label: TLabel;
Mean2: TEdit;
Mean1: TEdit;
Mean2Label: TLabel;
Mean1Label: TLabel;
Panel2: TPanel;
RadioGroup1: TRadioGroup;
RadioGroup2: TRadioGroup;
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure GroupCodeBtnChange(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
procedure RadioGroup1Click(Sender: TObject);
procedure RadioGroup2Click(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
private
{ private declarations }
FAutoSized: Boolean;
independent: boolean;
griddata: boolean;
function Validate(out AMsg: String; out AControl: TWinControl): Boolean;
public
{ public declarations }
end;
var
TtestFrm: TTtestFrm;
implementation
uses
Math;
{ TTtestFrm }
procedure TTtestFrm.ResetBtnClick(Sender: TObject);
var
i: integer;
begin
CInterval.Text := FormatFloat('0.0', DEFAULT_CONFIDENCE_LEVEL_PERCENT);
RadioGroup1.ItemIndex := 0;
RadioGroup2.ItemIndex := 0;
Notebook1.PageIndex := RadioGroup1.ItemIndex;
ListBox1.Clear;
Var1.Text := '';
Var2.Text := '';
Mean1.Text := '';
Mean2.Text := '';
SD1.Text := '';
SD2.Text := '';
N1.Text := '';
N2.Text := '';
Cor12.Text := '';
independent := true;
griddata := false;
GroupCodeBtn.Checked := false;
Grp.Text := '';
for i := 1 to NoVariables do
ListBox1.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
Grp.Text := '';
Grp1Code.Text := '';
Grp2Code.Text := '';
end;
procedure TTtestFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
Constraints.MinWidth := CInterval.Left + CInterval.Width + (Width - ResetBtn.Left) + ResetBtn.BorderSpacing.Left;
Bevel5.Width := SecdVarLabel.Canvas.TextWidth(SecdVarlabel.Caption);
//ListBox1.Constraints.MinHeight := Grp2Code.Top + Grp2Code.Height - Listbox1.Top - Var2.Height - Var2.BorderSpacing.Top;
//Constraints.MinHeight := ListBox1.Top + ListBox1.Constraints.MinHeight + Bevel2.Height + CloseBtn.Height + CloseBtn.BorderSpacing.Top*2;
FAutoSized := true;
end;
procedure TTtestFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
end;
procedure TTtestFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TTtestFrm.GroupCodeBtnChange(Sender: TObject);
begin
Grp1Code.Enabled := GroupCodeBtn.Checked;
Grp2Code.Enabled := GroupCodeBtn.Checked;
GrpCodeLabel1.Enabled := GroupCodeBtn.Checked;
GrpCodeLabel2.Enabled := GroupCodeBtn.Checked;
end;
procedure TTtestFrm.ComputeBtnClick(Sender: TObject);
var
M1, M2, Dif, stddev1, stddev2, r12, stderr1, stderr2: double;
tequal, tunequal, cov12, lowci, hici, F, Fp, df1, df2: double;
tprobability, value1, value2: double;
variance1, variance2, pooled, sedif, df, ConfInt, tconfint: double;
i, v1, v2, ncases1, ncases2, NoSelected: integer;
group, min, max: integer;
ColNoSelected: IntDyneVec;
label1Str, label2Str: string;
msg: String;
C: TWinControl;
lReport: TStrings;
begin
if not Validate(msg, C) then
begin
C.SetFocus;
MessageDlg(msg, mtError, [mbOK], 0);
ModalResult := mrNone;
exit;
end;
SetLength(ColNoSelected,NoVariables);
ncases1 := 0;
ncases2 := 0;
variance1 := 0.0;
variance2 := 0.0;
M1 := 0.0;
M2 := 0.0;
Dif := 0.0;
r12 := 0.0;
v1 := 0;
v2 := 0;
stddev1 := 0.0;
stddev2 := 0.0;
ConfInt := (100.0 - StrToFloat(CInterval.Text)) / 2.0 ;
ConfInt := (100.0 - ConfInt) / 100.0; // one tail
if independent then
Var2.Text := Grp.Text;
// data read from grid
if griddata then
begin
for i := 1 to NoVariables do
begin
if Var1.Text = OS3MainFrm.DataGrid.Cells[i,0] then
begin
v1 := i;
ColNoSelected[0] := i;
label1Str := Var1.Text;
end;
if Var2.Text = OS3MainFrm.DataGrid.Cells[i,0] then
begin
v2 := i;
ColNoSelected[1] := i;
label2Str := Var2.Text;
end;
end; // next variable
ncases1 := 0;
ncases2 := 0;
NoSelected := 2;
M1 := 0.0;
M2 := 0.0;
variance1 := 0.0;
variance2 := 0.0;
r12 := 0.0;
if not independent then // correlated data
begin
for i := 1 to NoCases do
begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
ncases1 := ncases1 + 1;
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i]));
value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i]));
M1 := M1 + value1;
M2 := M2 + value2;
variance1 := variance1 + value1 * value1;
variance2 := variance2 + value2 * value2;
r12 := r12 + value1 * value2;
end;
ncases2 := ncases1;
variance1 := variance1 - (M1 * M1 / ncases1);
variance1 := variance1 / (ncases1 - 1);
stddev1 := sqrt(variance1);
variance2 := variance2 - (M2 * M2 / ncases2);
variance2 := variance2 / (ncases2 - 1);
stddev2 := sqrt(variance2);
r12 := r12 - (M1 * M2 / ncases1);
r12 := r12 / (ncases1 - 1);
cov12 := r12;
r12 := r12 / (stddev1 * stddev2);
M1 := M1 / ncases1;
M2 := M2 / ncases2;
Dif := M1 - M2;
end; //if not independent
if independent then
begin
if GroupCodeBtn.Checked then
begin
min := StrToInt(Grp1Code.Text);
max := StrToInt(Grp2Code.Text);
{
response := InputBox('Group 1','Enter the code for group 1','1');
min := StrToInt(response);
response := InputBox('Group 2','Enter the code for group 2','2');
max := StrToInt(response);
}
end else
begin
min := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,1])));
max := min;
end;
for i := 2 to NoCases do
begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
group := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i])));
if GroupCodeBtn.Checked = false then
begin
if group < min then min := group;
if group > max then max := group;
end;
end;
for i := 1 to NoCases do
begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i]));
value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i]));
group := round(value2);
if group = min then
begin
M1 := M1 + value1;
variance1 := variance1 + (value1 * value1);
ncases1 := ncases1 + 1;
end else if group = max then
begin
M2 := M2 + value1;
variance2 := variance2 + (value1 * value1);
ncases2 := Ncases2 + 1;
end;
end; // next case
variance1 := variance1 - ((M1 * M1) / ncases1);
variance1 := variance1 / (ncases1 - 1);
stddev1 := sqrt(variance1);
variance2 := variance2 - ((M2 * M2) / ncases2);
variance2 := variance2 / (ncases2 - 1);
stddev2 := sqrt(variance2);
M1 := M1 / ncases1;
M2 := M2 / ncases2;
Dif := M1 - M2;
Label1Str := format('Group %d',[min]);
Label2Str := format('Group %d',[max]);
end; // if independent data
end; // if reading grid data
if not griddata then // data read from form
begin
M1 := StrToFloat(Mean1.Text);
M2 := StrToFloat(Mean2.Text);
stddev1 := StrToFloat(SD1.Text);
stddev2 := StrToFloat(SD2.Text);
ncases1 := round(StrToFloat(N1.Text));
ncases2 := round(StrToFloat(N2.Text));
variance1 := stddev1 * stddev1;
variance2 := stddev2 * stddev2;
Label1Str := 'Group 1';
Label2Str := 'Group 2';
Dif := M1 - M2;
if not independent then
begin
r12 := StrToFloat(Cor12.Text);
cov12 := r12 * stddev1 * stddev2;
end;
end;
// Initialize output form
lReport := TStringList.Create;
try
lReport.Add('COMPARISON OF TWO MEANS');
lReport.Add('');
// Calculate pooled and independent t and z values and test statistic
if independent then
begin
stderr1 := sqrt(variance1 / ncases1);
Stderr2 := sqrt(variance2 / ncases2);
lReport.Add('Variable Mean Variance Std.Dev. S.E.Mean N');
lReport.Add('%-10s%8.2f %8.2f %8.2f %8.2f %d', [Label1Str, M1, variance1, stddev1, stderr1, ncases1]);
lReport.Add('%-10s%8.2f %8.2f %8.2f %8.2f %d', [Label2Str, M2, variance2, stddev2, stderr2, ncases2]);
lReport.Add('');
pooled := ((ncases1-1) * variance1) + ((ncases2-1) * variance2);
pooled := pooled / (ncases1 + ncases2 - 2);
pooled := pooled * ( 1.0 / ncases1 + 1.0 / ncases2);
sedif := sqrt(pooled);
tequal := dif / sedif;
df := ncases1 + ncases2 - 2;
tprobability := probt(tequal,df);
if RadioGroup3.ItemIndex = 1 then tprobability := 0.5 * tprobability;
lReport.Add('Assuming equal variances, t = %.3f with probability = %.4f and %.0f degrees of freedom', [
tequal, tprobability, df
]);
lReport.Add('Difference = %.2f and Standard Error of difference = %.2f', [dif, sedif]);
tconfint := inverset(ConfInt,df);
lowci := dif - tconfint * sedif;
hici := dif + tconfint * sedif;
lReport.Add('Confidence interval = (%.2f ... %.2f)', [lowci, hici]);
// now for unequal variances
sedif := sqrt((variance1 / ncases1) + (variance2 / ncases2));
tunequal := dif / sedif;
df := sqr((variance1 / ncases1) + (variance2 / ncases2));
df := df / (sqr(variance1 / ncases1) / (ncases1 - 1) + sqr(variance2 / ncases2) / (ncases2 - 1) );
tprobability := probt(tequal,df);
if RadioGroup3.ItemIndex = 1 then tprobability := 0.5 * tprobability;
lReport.Add('Assuming unequal variances, t = %.3f with probability = %.4f and %.0f degrees of freedom', [
tunequal, tprobability, df
]);
lReport.Add('Difference = %.2f and Standard Error of difference = %.2f', [dif, sedif]);
tconfint := inverset(ConfInt,df);
lowci := dif - tconfint * sedif;
hici := dif + tconfint * sedif;
lReport.Add('Confidence interval = (%.2f ... %.2f)', [lowci, hici]);
df1 := ncases1 - 1;
df2 := ncases2 - 1;
if variance1 > variance2 then
begin
F := variance1 / variance2;
Fp := probf(F,df1,df2);
end else
begin
F := variance2 / variance1;
Fp := probf(F,df2,df1);
end;
lReport.Add('F test for equal variances = %.3f, Probability = %.4f', [F, fp]);
end
else
// dependent t test
begin
stderr1 := sqrt(variance1 / ncases1);
Stderr2 := sqrt(variance2 / ncases2);
lReport.Add('Variable Mean Variance Std.Dev. S.E.Mean N');
lReport.Add('%-10s%8.2f %8.2f %8.2f %8.2f %d', [Label1Str, M1, variance1, stddev1, stderr1, ncases1]);
lReport.Add('%-10s%8.2f %8.2f %8.2f %8.2f %d', [Label2Str,M2, variance2, stddev2, stderr2, ncases2]);
lReport.Add('');
sedif := variance1 + variance2 - (2.0 * cov12);
sedif := sqrt(sedif / ncases1);
tequal := Dif / sedif;
df := ncases1 - 1;
tprobability := probt(tequal,df);
lReport.Add('Assuming dependent samples, t = %.3f with probability = %.4f and %.0f degrees of freedom', [
tequal, tprobability, df
]);
lReport.Add('Correlation between %s and %s = %.3f', [Label1Str, Label2Str, r12]);
lReport.Add('Difference = %.2f and Standard Error of difference = %.2f', [dif, sedif]);
tconfint := inverset(ConfInt,df);
lowci := dif - tconfint * sedif;
hici := dif + tconfint * sedif;
lReport.Add('Confidence interval = (%.2f ... %.2f)', [lowci, hici]);
tequal := variance1 - variance2;
tequal := tequal / sqrt( (4 * variance1 * variance2)/(ncases1 - 2) * (1.0 - sqr(r12)) );
df := ncases1 - 2;
tprobability := probt(tequal,df);
lReport.Add('t for test of equal variances = %.3f with probability = %.4f', [tequal, tprobability]);
end;
DisplayReport(lReport);
finally
lReport.Free;
ColNoSelected := nil;
end;
end;
procedure TTtestFrm.ListBox1Click(Sender: TObject);
VAR index : integer;
begin
index := ListBox1.ItemIndex;
if not independent then
begin
if Var1.Text <> '' then Var2.Text := ListBox1.Items.Strings[index]
else Var1.Text := ListBox1.Items.Strings[index];
end;
if independent then
begin
if Var1.Text <> '' then Grp.Text := ListBox1.Items.Strings[index]
else Var1.Text := ListBox1.Items.Strings[index];
end;
end;
procedure TTtestFrm.RadioGroup1Click(Sender: TObject);
VAR
index : integer;
begin
index := RadioGroup1.ItemIndex;
Notebook1.PageIndex := index;
if index = 0 then
begin
// Panel2.Visible := true;
// Panel1.Visible := false;
griddata := false;
end
else
begin
// Panel1.Visible := true;
// Panel2.Visible := false;
griddata := true;
if RadioGroup2.ItemIndex = 1 then
begin
SecdVarLabel.Visible := true;
Var2.Visible := true;
Grp.Visible := false;
GrpLabel.Visible := false;
end
else
begin
SecdVarLabel.Visible := false;
Var2.Visible := false;
Grp.Visible := true;
GrpLabel.Visible := true;
end;
end;
end;
procedure TTtestFrm.RadioGroup2Click(Sender: TObject);
var
index: integer;
begin
index := RadioGroup2.ItemIndex;
independent := (index = 0);
Grp.Visible := independent;
GrpLabel.Visible := independent;
GroupCodeBtn.Visible := independent;
GroupBox1.Visible := independent;
SecdVarLabel.Visible := not independent;
Var2.Visible := not independent;
{
if index = 0 then
begin
independent := true;
CorBetweenLabel.Visible := false;
Cor12.Visible := false;
Grp.Visible := true;
GrpLabel.Visible := true;
GroupCodeBtn.Visible := true;
Groupbxo1.Visible := true;
SecdVarLabel.Visible := false;
Var2.Visible := false;
end
else
begin
independent := false;
CorBetweenLabel.Visible := true;
Cor12.Visible := true;
GrpLabel.Visible := false;
Grp.Visible := false;
GroupCodeBtn.Visible := false;
SecdVarLabel.Visible := true;
Var2.Visible := true;
end;
}
end;
function TTtestFrm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
var
n: Integer;
x: Double;
begin
Result := false;
AControl := nil;
AMsg := '';
if Notebook1.PageIndex = 0 then
begin
if (Mean1.Text = '') or not TryStrToFloat(Mean1.Text, x) then
begin
AControl := Mean1;
AMsg := 'Invalid input for the mean of sample 1';
exit;
end;
if (SD1.Text = '') or not TryStrToFloat(SD1.Text, x) or (x <= 0) then
begin
AControl := SD1;
AMsg := 'Invald input for the standard deviation of sample 1';
exit;
end;
if (N1.Text = '') or not TryStrToInt(N1.Text, n) or (n <= 0) then
begin
AControl := N1;
AMsg := 'Invald input for the size of sample 1';
exit;
end;
if (Mean2.Text = '') or not TryStrToFloat(Mean2.Text, x) then
begin
AControl := Mean2;
AMsg := 'Invalid input for the mean of sample 2';
exit;
end;
if (SD2.Text = '') or not TryStrToFloat(SD2.Text, x) or (x <= 0) then
begin
AControl := SD2;
AMsg := 'Invald input for the standard deviation of sample 2';
exit;
end;
if (N2.Text = '') or not TryStrToInt(N2.Text, n) or (n <= 0) then
begin
AControl := N2;
AMsg := 'Invald input for the size of sample 2';
exit;
end;
end else
if Notebook1.PageIndex = 1 then
begin
if (Var1.Text = '') then
begin
AControl := Var1;
AMsg := 'Variable 1 not specified.';
exit;
end;
if Var2.Visible and (Var2.Text = '') then
begin
AControl := Var2;
AMsg := 'Variable 2 not specified.';
exit;
end;
if Grp.Visible and (Grp.Text = '') then
begin
AControl := Grp;
AMsg := 'Group variable not specified.';
exit;
end;
if Grp1Code.Visible and ((Grp1Code.Text = '') or not TryStrToInt(Grp1Code.Text, n))then
begin
AControl := Grp1Code;
AMsg := 'Code for group 1 missing.';
exit;
end;
if Grp2Code.Visible and ((Grp2Code.Text = '') or not TryStrToInt(Grp2Code.Text, n))then
begin
AControl := Grp2Code;
AMsg := 'Code for group 2 missing.';
exit;
end;
end;
Result := true;
end;
initialization
{$I ttestunit.lrs}
end.

View File

@ -0,0 +1,634 @@
object TwoCorrsFrm: TTwoCorrsFrm
Left = 559
Height = 391
Top = 286
Width = 462
Caption = 'Comparison of Two Correlations'
ClientHeight = 391
ClientWidth = 462
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Label14: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = CInterval
AnchorSideTop.Side = asrCenter
Left = 8
Height = 15
Top = 323
Width = 149
BorderSpacing.Left = 8
Caption = 'Percent Confidence Interval:'
ParentColor = False
end
object RadioGroup1: TRadioGroup
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 8
Height = 72
Top = 8
Width = 225
AutoFill = True
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Data Entered From:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 52
ClientWidth = 221
Items.Strings = (
'Values entered on this form.'
'Values in the data grid from a file.'
)
OnClick = RadioGroup1Click
TabOrder = 0
end
object RadioGroup2: TRadioGroup
AnchorSideLeft.Control = RadioGroup1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Owner
Left = 257
Height = 72
Top = 8
Width = 185
AutoFill = True
AutoSize = True
BorderSpacing.Left = 24
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Test Assumptions:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 52
ClientWidth = 181
Items.Strings = (
'Independent Correlations.'
'Dependent Correlations.'
)
OnClick = RadioGroup2Click
TabOrder = 1
end
object CInterval: TEdit
AnchorSideLeft.Control = Label14
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = Bevel2
Left = 165
Height = 23
Top = 319
Width = 36
Alignment = taRightJustify
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
TabOrder = 3
Text = 'CInterval'
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 243
Height = 25
Top = 358
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 5
end
object ComputeBtn: TButton
AnchorSideRight.Control = ReturnBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 305
Height = 25
Top = 358
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 6
end
object ReturnBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 389
Height = 25
Top = 358
Width = 61
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Return'
ModalResult = 1
TabOrder = 7
end
object HelpBtn: TButton
Tag = 151
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 184
Height = 25
Top = 358
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 4
end
object Notebook1: TNotebook
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = RadioGroup1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CInterval
Left = 8
Height = 223
Top = 88
Width = 454
PageIndex = 0
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Bottom = 8
TabOrder = 2
object Page1: TPage
object PanelPage1: TPanel
AnchorSideLeft.Control = Page1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Page1
Left = 143
Height = 132
Top = 0
Width = 168
AutoSize = True
BorderSpacing.Bottom = 24
BevelOuter = bvNone
ClientHeight = 132
ClientWidth = 168
TabOrder = 0
object firstcorlabel: TLabel
AnchorSideLeft.Control = PanelPage1
AnchorSideTop.Control = rxy1
AnchorSideTop.Side = asrCenter
Left = 0
Height = 15
Top = 20
Width = 87
Caption = 'First Correlation:'
ParentColor = False
end
object size1label: TLabel
AnchorSideLeft.Control = PanelPage1
AnchorSideTop.Control = Size1
AnchorSideTop.Side = asrCenter
Left = 0
Height = 15
Top = 51
Width = 74
Caption = 'Sample Size 1:'
ParentColor = False
end
object SecdCorLabel: TLabel
AnchorSideLeft.Control = PanelPage1
AnchorSideTop.Control = rxy2
AnchorSideTop.Side = asrCenter
Left = 0
Height = 15
Top = 82
Width = 104
Caption = 'Second Correlation:'
ParentColor = False
end
object Size2Label: TLabel
AnchorSideLeft.Control = PanelPage1
AnchorSideTop.Control = Size2
Left = 0
Height = 15
Top = 109
Width = 74
Caption = 'Sample Size 2:'
ParentColor = False
end
object rxy1: TEdit
AnchorSideLeft.Control = SecdCorLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = PanelPage1
Left = 112
Height = 23
Top = 16
Width = 56
Alignment = taRightJustify
BorderSpacing.Left = 8
BorderSpacing.Top = 16
TabOrder = 0
Text = 'rxy1'
end
object Size1: TEdit
AnchorSideLeft.Control = SecdCorLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = rxy1
AnchorSideTop.Side = asrBottom
Left = 112
Height = 23
Top = 47
Width = 56
Alignment = taRightJustify
BorderSpacing.Left = 8
BorderSpacing.Top = 8
TabOrder = 1
Text = 'Edit1'
end
object rxy2: TEdit
AnchorSideLeft.Control = SecdCorLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Size1
AnchorSideTop.Side = asrBottom
Left = 112
Height = 23
Top = 78
Width = 56
Alignment = taRightJustify
BorderSpacing.Left = 8
BorderSpacing.Top = 8
TabOrder = 2
Text = 'Edit1'
end
object Size2: TEdit
AnchorSideLeft.Control = SecdCorLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = rxy2
AnchorSideTop.Side = asrBottom
Left = 112
Height = 23
Top = 109
Width = 56
Alignment = taRightJustify
BorderSpacing.Left = 8
BorderSpacing.Top = 8
TabOrder = 3
Text = 'Edit1'
end
end
end
object Page2: TPage
object PanelPage2: TPanel
AnchorSideLeft.Control = Page2
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Page2
Left = 144
Height = 156
Top = 0
Width = 167
AutoSize = True
BevelOuter = bvNone
ClientHeight = 156
ClientWidth = 167
TabOrder = 0
object corxylabel: TLabel
AnchorSideLeft.Control = PanelPage2
AnchorSideTop.Control = rxy
AnchorSideTop.Side = asrCenter
Left = 0
Height = 15
Top = 20
Width = 89
Caption = 'Correlation r(x,y)'
ParentColor = False
end
object corxzlabel: TLabel
AnchorSideLeft.Control = PanelPage2
AnchorSideTop.Control = rxz
AnchorSideTop.Side = asrCenter
Left = 0
Height = 15
Top = 51
Width = 88
Caption = 'Correlation r(x,z)'
ParentColor = False
end
object coryzlabel: TLabel
AnchorSideLeft.Control = PanelPage2
AnchorSideTop.Control = ryz
AnchorSideTop.Side = asrCenter
Left = 0
Height = 15
Top = 82
Width = 88
Caption = 'Correlation r(y,z)'
ParentColor = False
end
object sampsizelabel: TLabel
AnchorSideLeft.Control = PanelPage2
AnchorSideTop.Control = SampSize
AnchorSideTop.Side = asrCenter
Left = 0
Height = 15
Top = 113
Width = 65
Caption = 'Sample Size:'
ParentColor = False
end
object rxy: TEdit
AnchorSideLeft.Control = corxylabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = PanelPage2
Left = 105
Height = 23
Top = 16
Width = 62
Alignment = taRightJustify
BorderSpacing.Left = 16
BorderSpacing.Top = 16
TabOrder = 0
Text = 'rxy'
end
object SampSize: TEdit
AnchorSideLeft.Control = rxy
AnchorSideTop.Control = ryz
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = rxy
AnchorSideRight.Side = asrBottom
Left = 105
Height = 23
Top = 109
Width = 62
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
BorderSpacing.Bottom = 24
TabOrder = 3
Text = 'Edit1'
end
object rxz: TEdit
AnchorSideLeft.Control = rxy
AnchorSideTop.Control = rxy
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = rxy
AnchorSideRight.Side = asrBottom
Left = 105
Height = 23
Top = 47
Width = 62
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
TabOrder = 1
Text = 'Edit1'
end
object ryz: TEdit
AnchorSideLeft.Control = rxy
AnchorSideTop.Control = rxz
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = rxy
AnchorSideRight.Side = asrBottom
Left = 105
Height = 23
Top = 78
Width = 62
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
TabOrder = 2
Text = 'Edit1'
end
end
end
object Page3: TPage
object PanelPage3: TPanel
Left = 0
Height = 223
Top = 0
Width = 446
Align = alClient
BorderSpacing.Right = 8
BevelOuter = bvNone
ClientHeight = 223
ClientWidth = 446
TabOrder = 0
object SelVarLabel: TLabel
AnchorSideLeft.Control = PanelPage3
AnchorSideTop.Control = PanelPage3
Left = 0
Height = 15
Top = 0
Width = 83
Caption = 'Select Variables:'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = PanelPage3
AnchorSideTop.Control = SelVarLabel
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideBottom.Control = PanelPage3
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 206
Top = 17
Width = 246
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
ItemHeight = 0
OnClick = VarListClick
TabOrder = 0
end
object Bevel1: TBevel
AnchorSideLeft.Control = PanelPage3
AnchorSideLeft.Side = asrCenter
Left = 200
Height = 13
Top = 2
Width = 46
Shape = bsSpacer
end
object Panel1: TPanel
AnchorSideLeft.Control = Bevel1
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = PanelPage3
AnchorSideRight.Side = asrBottom
Left = 246
Height = 116
Top = 32
Width = 162
AutoSize = True
BevelOuter = bvNone
ClientHeight = 116
ClientWidth = 162
TabOrder = 1
object xlabel: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Xvar
AnchorSideTop.Side = asrCenter
Left = 48
Height = 15
Top = 4
Width = 18
Alignment = taRightJustify
BorderSpacing.Left = 48
Caption = 'X ='
ParentColor = False
end
object Xvar: TEdit
AnchorSideLeft.Control = xlabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel1
Left = 74
Height = 23
Top = 0
Width = 88
BorderSpacing.Left = 8
ReadOnly = True
TabOrder = 0
Text = 'Xvar'
end
object ylabel: TLabel
AnchorSideTop.Control = Yvar
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = xlabel
AnchorSideRight.Side = asrBottom
Left = 48
Height = 15
Top = 35
Width = 18
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Left = 8
Caption = 'Y ='
ParentColor = False
end
object Yvar: TEdit
AnchorSideLeft.Control = Xvar
AnchorSideTop.Control = Xvar
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Xvar
AnchorSideRight.Side = asrBottom
Left = 74
Height = 23
Top = 31
Width = 88
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
ReadOnly = True
TabOrder = 1
Text = 'Edit1'
end
object zlabel: TLabel
AnchorSideTop.Control = Zvar
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = xlabel
AnchorSideRight.Side = asrBottom
Left = 48
Height = 15
Top = 66
Width = 18
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Left = 8
Caption = 'Z ='
ParentColor = False
end
object Zvar: TEdit
AnchorSideLeft.Control = Xvar
AnchorSideTop.Control = Yvar
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Xvar
AnchorSideRight.Side = asrBottom
Left = 74
Height = 23
Top = 62
Width = 88
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
ReadOnly = True
TabOrder = 2
Text = 'Edit1'
end
object GroupLabel: TLabel
AnchorSideTop.Control = GroupVar
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = xlabel
AnchorSideRight.Side = asrBottom
Left = 22
Height = 15
Top = 97
Width = 44
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Left = 8
Caption = 'Group ='
ParentColor = False
end
object GroupVar: TEdit
AnchorSideLeft.Control = Xvar
AnchorSideTop.Control = Zvar
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Xvar
AnchorSideRight.Side = asrBottom
Left = 74
Height = 23
Top = 93
Width = 88
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
ReadOnly = True
TabOrder = 3
Text = 'Edit1'
end
end
end
end
end
object Bevel2: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ReturnBtn
Left = 0
Height = 8
Top = 342
Width = 462
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
end

View File

@ -0,0 +1,679 @@
unit TwoCorrsUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
ExtCtrls, StdCtrls,
MainUnit, Globals, FunctionsLib, OutputUnit, DataProcs, ContextHelpUnit;
type
{ TTwoCorrsFrm }
TTwoCorrsFrm = class(TForm)
Bevel1: TBevel;
Bevel2: TBevel;
HelpBtn: TButton;
Notebook1: TNotebook;
Page1: TPage;
Page2: TPage;
Page3: TPage;
Panel1: TPanel;
PanelPage1: TPanel;
ResetBtn: TButton;
ComputeBtn: TButton;
ReturnBtn: TButton;
CInterval: TEdit;
Label14: TLabel;
Xvar: TEdit;
Yvar: TEdit;
Zvar: TEdit;
GroupVar: TEdit;
xlabel: TLabel;
ylabel: TLabel;
zlabel: TLabel;
GroupLabel: TLabel;
SelVarLabel: TLabel;
VarList: TListBox;
PanelPage3: TPanel;
rxy1: TEdit;
Size1: TEdit;
rxy2: TEdit;
Size2: TEdit;
firstcorlabel: TLabel;
size1label: TLabel;
SecdCorLabel: TLabel;
Size2Label: TLabel;
rxy: TEdit;
rxz: TEdit;
ryz: TEdit;
SampSize: TEdit;
corxylabel: TLabel;
corxzlabel: TLabel;
coryzlabel: TLabel;
sampsizelabel: TLabel;
PanelPage2: TPanel;
RadioGroup1: TRadioGroup;
RadioGroup2: TRadioGroup;
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
procedure RadioGroup1Click(Sender: TObject);
procedure RadioGroup2Click(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure VarListClick(Sender: TObject);
private
{ private declarations }
FAutoSized: Boolean;
independent: boolean;
griddata: boolean;
function Validate(out AMsg: String; out AControl: TWinControl): Boolean;
public
{ public declarations }
end;
var
TwoCorrsFrm: TTwoCorrsFrm;
implementation
uses
Math;
{ TTwoCorrsFrm }
procedure TTwoCorrsFrm.ResetBtnClick(Sender: TObject);
var
i: integer;
begin
CInterval.Text := FormatFloat('0.0', DEFAULT_CONFIDENCE_LEVEL_PERCENT);
RadioGroup1.ItemIndex := 0;
RadioGroup2.ItemIndex := 0;
Notebook1.PageIndex := 0;
VarList.Clear;
Xvar.Text := '';
Yvar.Text := '';
Zvar.Text := '';
rxy.Text := '';
rxz.Text := '';
ryz.Text := '';
SampSize.Text := '';
rxy1.Text := '';
rxy2.Text := '';
Size1.Text := '';
Size2.Text := '';
zlabel.Visible := false;
Zvar.Visible := false;
GroupLabel.Visible := true;
GroupVar.Text := '';
GroupVar.Visible := true;
independent := true;
griddata := false;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
end;
procedure TTwoCorrsFrm.VarListClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if Xvar.Text = '' then
begin
Xvar.Text := VarList.Items.Strings[index];
exit;
end;
if Yvar.Text = '' then
begin
Yvar.Text := VarList.Items.Strings[index];
exit;
end;
if not independent then
begin
if Zvar.Text = '' then
begin
Zvar.Text := VarList.Items.Strings[index];
exit;
end;
end;
if independent then
begin
if GroupVar.Text = '' then
begin
GroupVar.Text := VarList.Items.Strings[index];
exit;
end;
end;
end;
procedure TTwoCorrsFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, ReturnBtn.Width]);
HelpBtn.Constraints.MinWidth := w;
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
ReturnBtn.Constraints.MinWidth := w;
Width := Max(
RadioGroup2.Left + RadioGroup2.Width + RadioGroup2.BorderSpacing.Right,
Width - HelpBtn.Left + HelpBtn.BorderSpacing.Left
);
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TTwoCorrsFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
end;
procedure TTwoCorrsFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TTwoCorrsFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).tag);
end;
procedure TTwoCorrsFrm.ComputeBtnClick(Sender: TObject);
var
Corxy, Corxz, Coryz, Cor1, Cor2, alpha, tvalue, df1, df2: double;
CorDif, zOne, zTwo, zDif, StdErr, zValue, zprobability: double;
UCL, LCL, ztest, ConfLevel, tprobability, ttest: double;
mean1, mean2, mean3, variance1, variance2, variance3: double;
stddev1, stddev2, stddev3, value1, value2, value3: double;
meanx1, meanx2, meany1, meany2, varx1, varx2, vary1, vary2: double;
sdx1, sdx2, sdy1, sdy2: double;
SSize1, SSize2, SSize, v1, v2, v3, grp, ncases, NoSelected: integer;
min, max, grpval, ncases1, ncases2, i: integer;
cellstring: string;
ColNoSelected: IntDyneVec;
msg: String;
C: TWinControl;
lReport: TStrings;
begin
if not Validate(msg, C) then
begin
C.SetFocus;
MessageDlg(msg, mtError, [mbOK], 0);
ModalResult := mrNone;
exit;
end;
SetLength(ColNoSelected,NoVariables);
Corxy := 0.0;
Corxz := 0.0;
Coryz := 0.0;
Cor1 := 0.0;
Cor2 := 0.0;
mean1 := 0.0;
mean2 := 0.0;
mean3 := 0.0;
variance1 := 0.0;
variance2 := 0.0;
variance3 := 0.0;
meanx1 := 0.0;
meanx2 := 0.0;
meany1 := 0.0;
ConfLevel := StrToFloat(CInterval.Text) / 100.0;
// *** USE DATA ON THE FORM ***
if not griddata then
begin
// read data from form and obtain results
if independent then
begin
Cor1 := StrToFloat(rxy1.Text);
Cor2 := StrToFloat(rxy2.Text);
SSize1 := StrToInt(Size1.Text);
SSize2 := StrToInt(Size2.Text);
CorDif := Cor1 - Cor2;
zOne := 0.5 * ln((1.0 + Cor1) / (1.0 - Cor1));
zTwo := 0.5 * ln((1.0 + Cor2) / (1.0 - Cor2));
zDif := zOne - zTwo;
StdErr := sqrt((1.0 / (SSize1 - 3.0)) + (1.0 / (SSize2 -3.0)));
zValue := zDif / StdErr;
alpha := (1.0 - ConfLevel) / 2.0;
zTest := inversez(1.0 - alpha);
zprobability := 1.0 - probz(zValue);
UCL := zDif + StdErr * zTest;
LCL := zDif - StdErr * zTest;
UCL := (exp(2.0 * UCL) - 1.0) / (exp(2.0 * UCL) + 1.0);
LCL := (exp(2.0 * LCL) - 1.0) / (exp(2.0 * LCL) + 1.0);
end;
// obtain data from form and obtain results
if not independent then
begin
Corxy := StrToFloat(rxy.Text);
Corxz := StrToFloat(rxz.Text);
Coryz := StrToFloat(ryz.Text);
SSize := StrToInt(SampSize.Text);
CorDif := Corxy - Corxz;
alpha := (1.0 - ConfLevel) / 2.0;
tvalue := CorDif * sqrt((SSize - 3.0) * (1.0 + Coryz)) / sqrt(2.0 * (1.0 - Corxy*Corxy - Corxz*Corxz - Coryz*Coryz + 2.0*Corxy*Corxz*Coryz));
df1 := 1.0;
df2 := SSize - 3.0;
tprobability := probt(tvalue,df2);
ttest := inverset(1.0 - alpha, df2);
end;
end;
if griddata then
begin
v1 := 1;
v2 := 1;
grp := 1;
// read grid data for independent r's
if independent then
begin
for i := 1 to NoVariables do
begin
cellstring := OS3MainFrm.DataGrid.Cells[i,0];
if cellstring = Xvar.Text then v1 := i;
if cellstring = Yvar.Text then v2 := i;
if cellstring = GroupVar.Text then grp := i;
end;
ColNoSelected[0] := v1;
ColNoSelected[1] := v2;
ColNoSelected[2] := grp;
NoSelected := 3;
meanx1 := 0.0;
meany1 := 0.0;
varx1 := 0.0;
vary1 := 0.0;
meanx2 := 0.0;
meany2 := 0.0;
varx2 := 0.0;
vary2 := 0.0;
Cor1 := 0.0;
Cor2 := 0.0;
ncases1 := 0;
ncases2 := 0;
min := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[grp,1])));
max := min;
for i := 2 to NoCases do
begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
grpval := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[grp,i])));
if grpval > max then max := grpval;
if grpval < min then min := grpval;
end;
for i := 1 to NoCases do
begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
grpval := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[grp,i])));
if grpval = min then
begin
ncases1 := ncases1 + 1;
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i]));
meanx1 := meanx1 + value1;
varx1 := varx1 + (value1 * value1);
value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i]));
meany1 := meany1 + value2;
vary1 := vary1 + value2 * value2;
Cor1 := Cor1 + value1 * value2;
end;
if grpval = max then
begin
ncases2 := ncases2 + 1;
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i]));
meanx2 := meanx2 + value1;
varx2 := varx2 + (value1 * value1);
value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i]));
meany2 := meany2 + value2;
vary2 := vary2 + value2 * value2;
Cor2 := Cor2 + value1 * value2;
end;
end; // next case
varx1 := varx1 - meanx1 * meanx1 / ncases1;
varx1 := varx1 / (ncases1 - 1.0);
varx2 := varx2 - meanx2 * meanx2 / ncases2;
varx2 := varx2 / (ncases2 - 1.0);
vary1 := vary1 - meany1 * meany1 / ncases1;
vary1 := vary1 / (ncases1 - 1.0);
vary2 := vary2 - meany2 * meany2 / ncases2;
vary2 := vary2 / (ncases2 - 1.0);
Cor1 := Cor1 - meanx1 * meany1 / ncases1;
Cor1 := Cor1 / (ncases1 - 1.0);
Cor2 := Cor2 - meanx2 * meany2 / ncases2;
Cor2 := Cor2 / (ncases2 - 1.0);
sdx1 := sqrt(varx1);
sdx2 := sqrt(varx2);
sdy1 := sqrt(vary1);
sdy2 := sqrt(vary2);
Cor1 := Cor1 / (sdx1 * sdy1);
Cor2 := Cor2 / (sdx2 * sdy2);
meanx1 := meanx1 / ncases1;
meany1 := meany1 / ncases1;
meanx2 := meanx2 / ncases2;
meany2 := meany2 / ncases2;
SSize1 := ncases1;
SSize2 := ncases2;
CorDif := Cor1 - Cor2;
zOne := 0.5 * ln((1.0 + Cor1) / (1.0 - Cor1));
zTwo := 0.5 * ln((1.0 + Cor2) / (1.0 - Cor2));
zDif := zOne - zTwo;
StdErr := sqrt((1.0 / (SSize1 - 3.0)) + (1.0 / (SSize2 -3.0)));
zValue := zDif / StdErr;
alpha := (1.0 - ConfLevel) / 2.0;
zTest := inversez(1.0 - alpha);
zprobability := 1.0 - probz(zValue);
UCL := zDif + StdErr * zTest;
LCL := zDif - StdErr * zTest;
UCL := (exp(2.0 * UCL) - 1.0) / (exp(2.0 * UCL) + 1.0);
LCL := (exp(2.0 * LCL) - 1.0) / (exp(2.0 * LCL) + 1.0);
end;
// read grid data for dependent r's
if not independent then
begin
mean1 := 0.0;
mean2 := 0.0;
mean3 := 0.0;
variance1 := 0.0;
variance2 := 0.0;
variance3 := 0.0;
Corxy := 0.0;
Corxz := 0.0;
Coryz := 0.0;
ncases := 0;
for i := 1 to NoVariables do
begin
cellstring := OS3MainFrm.DataGrid.Cells[i,0];
if cellstring = Xvar.Text then v1 := i;
if cellstring = Yvar.Text then v2 := i;
if cellstring = ZVar.Text then v3 := i;
end;
ColNoSelected[0] := v1;
ColNoSelected[1] := v2;
ColNoSelected[2] := v3;
NoSelected := 3;
for i := 1 to NoCases do
begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
ncases := ncases + 1;
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i]));
value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i]));
value3 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v3,i]));
mean1 := mean1 + value1;
mean2 := mean2 + value2;
mean3 := mean3 + value3;
variance1 := variance1 + value1 * value1;
variance2 := variance2 + value2 * value2;
variance3 := variance3 + value3 * value3;
Corxy := Corxy + value1 * value2;
Corxz := Corxz + value1 * value3;
Coryz := Coryz + value2 * value3;
end;
variance1 := variance1 - mean1 * mean1 / ncases;
variance1 := variance1 / (ncases - 1.0);
stddev1 := sqrt(variance1);
variance2 := variance2 - mean2 * mean2 / ncases;
variance2 := variance2 / (ncases - 1.0);
stddev2 := sqrt(variance2);
variance3 := variance3 - mean3 * mean3 / ncases;
variance3 := variance3 / (ncases - 1.0);
stddev3 := sqrt(variance3);
Corxy := Corxy - mean1 * mean2 / ncases;
Corxy := Corxy / (ncases - 1.0);
Corxy := Corxy / (stddev1 * stddev2);
Corxz := Corxz - mean1 * mean3 / ncases;
Corxz := Corxz / (ncases - 1.0);
Corxz := Corxz / (stddev1 * stddev3);
Coryz := Coryz - mean2 * mean3 / ncases;
Coryz := Coryz / (ncases - 1.0);
Coryz := Coryz / (stddev2 * stddev3);
mean1 := mean1 / ncases;
mean2 := mean2 / ncases;
mean3 := mean3 / ncases;
SSize := ncases;
CorDif := Corxy - Corxz;
alpha := (1.0 - ConfLevel) / 2.0;
tvalue := CorDif * sqrt((SSize - 3.0) * (1.0 + Coryz)) /
sqrt(2.0 * (1.0 - Corxy * Corxy - Corxz * Corxz - Coryz * Coryz + 2.0 * Corxy * Corxz * Coryz));
df1 := 1.0;
df2 := SSize - 3.0;
tprobability := probt(tvalue,df2);
ttest := inverset(1.0 - alpha, df2);
end;
end;
// Initialize output form
lReport := TStringList.Create;
try
lReport.Add('COMPARISON OF TWO CORRELATIONS');
lReport.Add('');
if independent then
begin
lReport.Add('Correlation one: %6.3f', [Cor1]);
lReport.Add('Sample size one: %6d', [SSize1]);
lReport.Add('Correlation two: %6.3f', [Cor2]);
lReport.Add('Sample size two: %6d', [SSize2]);
lReport.Add('Difference between correlations: %6.3f', [CorDif]);
lReport.Add('Confidence level selected: %6s', [CInterval.Text]);
lReport.Add('z for Correlation One: %6.3f', [zOne]);
lReport.Add('z for Correlation Two: %6.3f', [zTwo]);
lReport.Add('z difference: %6.3f', [zDif]);
lReport.Add('Standard error of difference: %6.3f', [StdErr]);
lReport.Add('z test statistic: %6.3f', [zValue]);
lReport.Add('Probability > |z|: %6.3f', [zprobability]);
lReport.Add('z Required for significance: %6.3f', [zTest]);
lReport.Add('Note: above is a two-tailed test.');
lReport.Add('Confidence Limits = (%.3f ... %.3f)', [LCL, UCL]);
lReport.Add('');
if griddata then
begin
lReport.Add('Mean X for group 1: %9.3f', [meanx1]);
lReport.Add('Mean X for group 2: %9.3f', [meanx2]);
lReport.Add('Std.Dev. X for group 1: %9.3f', [sdx1]);
lReport.Add('Std.Dev. X for group 2: %9.3f', [sdx2]);
lReport.Add('Mean y for group 1; %9.3f', [meany1]);
lReport.Add('Mean Y for group 2: %9.3f', [meany2]);
lReport.Add('Std.Dev. Y for group 1: %9.3f', [sdy1]);
lReport.Add('Std.Dev. Y for group 2: %9.3f', [sdy2]);
end;
end;
if not independent then
begin
lReport.Add('Correlation x with y: %6.3f', [Corxy]);
lReport.Add('Correlation x with z: %6.3f', [Corxz]);
lReport.Add('Correlation y with z: %6.3f', [Coryz]);
lReport.Add('Sample size: %6d', [SSize]);
lReport.Add('Confidence Level Selected: %6s', [CInterval.Text]);
lReport.Add('Difference r(x,y) - r(x,z): %6.3f', [CorDif]);
lReport.Add('t test statistic: %6.3f', [tvalue]);
lReport.Add('Probability > |t|: %6.3f', [tprobability]);
lReport.Add('t value for significance: %6.3f', [ttest]);
lReport.Add('');
if griddata then
begin
lReport.Add('Variable Mean Variance Std.Dev.');
lReport.Add(' X %9.3f %9.3f %9.3f', [mean1, variance1, stddev1]);
lReport.Add(' Y %9.3f %9.3f %9.3f', [mean2, variance2, stddev2]);
lReport.Add(' Z %9.3f %9.3f %9.3f', [mean3, variance3, stddev3]);
end;
end;
DisplayReport(lReport);
finally
lReport.Free;
ColNoSelected := nil;
end;
end;
procedure TTwoCorrsFrm.RadioGroup1Click(Sender: TObject);
var
index: integer;
begin
index := RadioGroup1.ItemIndex;
if index = 0 then
begin
griddata := false;
if independent then
Notebook1.PageIndex := 0
else
Notebook1.PageIndex := 1;
end else
begin
griddata := true;
Notebook1.PageIndex := 2;
end;
end;
procedure TTwoCorrsFrm.RadioGroup2Click(Sender: TObject);
var
index1, index2: integer;
begin
index1 := RadioGroup1.ItemIndex;
index2 := RadioGroup2.ItemIndex;
// form input with independent corrs
if ((index2 = 0) and (index1 = 0)) then
begin
independent := true;
Notebook1.PageIndex := 0;
end;
// grid data for independent corrs
if ((index2 = 0) and (index1 = 1)) then
begin
Notebook1.PageIndex := 2;
zlabel.Visible := false;
zvar.Visible := false;
grouplabel.Visible := true;
groupvar.Visible := true;
end;
// form data for dependent corrs
if ((index2 = 1) and (index1 = 0)) then
begin
Notebook1.PageIndex := 1;
end;
// grid data for dependent corrs
if ((index2 = 1) and (index1 = 1)) then
begin
Notebook1.PageIndex := 2;
independent := false;
zlabel.Visible := true;
Zvar.Visible := true;
GroupLabel.Visible := false;
GroupVar.Visible := false;
end;
end;
function TTwoCorrsFrm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
var
n: Integer;
x: Double;
begin
Result := false;
AControl := nil;
AMsg := '';
if Notebook1.PageIndex = 0 then
begin
if (rxy1.Text = '') or not TryStrToFloat(rxy1.Text, x) then
begin
AControl := rxy1;
AMsg := 'Invalid input for first correlation';
exit;
end;
if (Size1.Text = '') or not TryStrToInt(Size1.Text, n) or (n <= 0) then
begin
AControl := Size1;
AMsg := 'Invald input for size of sample 1';
exit;
end;
if (rxy2.Text = '') or not TryStrToFloat(rxy2.Text, x) then
begin
AControl := rxy2;
AMsg := 'Invalid input for second correlation';
exit;
end;
if (Size2.Text = '') or not TryStrToInt(Size2.Text, n) or (n <= 0) then
begin
AControl := Size2;
AMsg := 'Invalud input for size of sample 2';
exit;
end;
end else
if Notebook1.PageIndex = 1 then
begin
if (rxy.Text = '') or not TryStrToFloat(rxy.Text, x) then
AControl := rxy
else
if (rxz.Text = '') or not TryStrToFloat(rxz.Text, x) then
AControl := rxz
else
if (ryz.Text = '') or not TryStrToFloat(ryz.Text, x) then
AControl := ryz
else
if (SampSize.Text = '') or not TryStrToInt(SampSize.Text, n) or (n < 0) then
AControl := SampSize;
if AControl <> nil then
begin
AMsg := 'Invalid input.';
exit;
end;
end else
if Notebook1.PageIndex = 2 then
begin
if XVar.Text = '' then
begin
AControl := XVar;
AMsg := 'X variable not specified.';
exit;
end;
if YVar.Text = '' then
begin
AControl := YVar;
AMsg := 'Y variable not specified.';
exit;
end;
case RadioGroup2.ItemIndex of
0: if (GroupVar.Text = '') then
begin
AControl := GroupVar;
AMsg := 'Group variable not specified';
exit;
end;
1: if (ZVar.Text = '') then begin
AControl := ZVar;
AMsg := 'Z variable not specified.';
exit;
end;
end;
end;
Result := true;
end;
initialization
{$I twocorrsunit.lrs}
end.

View File

@ -0,0 +1,585 @@
object TwoPropFrm: TTwoPropFrm
Left = 603
Height = 427
Top = 225
Width = 455
Caption = 'Test of Equality for two Proportions'
ClientHeight = 427
ClientWidth = 455
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
LCLVersion = '2.1.0.0'
object ConfLabel: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = CInterval
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = CInterval
Left = 8
Height = 15
Top = 359
Width = 149
BorderSpacing.Left = 8
BorderSpacing.Right = 8
Caption = 'Percent Confidence Interval:'
ParentColor = False
end
object CInterval: TEdit
AnchorSideLeft.Control = ConfLabel
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel4
Left = 165
Height = 23
Top = 355
Width = 41
Alignment = taRightJustify
Anchors = [akLeft, akBottom]
BorderSpacing.Right = 8
TabOrder = 1
Text = '95.0'
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 242
Height = 25
Top = 394
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 3
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 304
Height = 25
Top = 394
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 4
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 388
Height = 25
Top = 394
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 5
end
object HelpBtn: TButton
Tag = 152
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 183
Height = 25
Top = 394
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 2
end
object Notebook1: TNotebook
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CInterval
Left = 8
Height = 259
Top = 88
Width = 439
PageIndex = 1
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
TabOrder = 0
object Page1: TPage
AnchorSideTop.Side = asrBottom
object Label11: TLabel
AnchorSideLeft.Control = Page1
AnchorSideTop.Control = Page1
Left = 0
Height = 15
Top = 0
Width = 83
Caption = 'Select Variables:'
ParentColor = False
end
object FirstVarLabel: TLabel
AnchorSideLeft.Control = Bevel1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = VarList
Left = 223
Height = 15
Top = 17
Width = 66
Caption = 'First Variable'
ParentColor = False
end
object SecdVarLabel: TLabel
AnchorSideLeft.Control = Bevel1
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = Var2
Left = 223
Height = 15
Top = 110
Width = 83
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Second Variable'
ParentColor = False
end
object GrpLabel: TLabel
AnchorSideLeft.Control = Bevel1
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = Grp
Left = 223
Height = 15
Top = 219
Width = 64
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Group Code'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Page1
AnchorSideTop.Control = Label11
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Bevel1
AnchorSideBottom.Control = Page1
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 242
Top = 17
Width = 215
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
Constraints.MinHeight = 220
ItemHeight = 0
OnClick = VarListClick
TabOrder = 0
end
object Var1: TEdit
AnchorSideLeft.Control = Bevel1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = FirstVarLabel
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Page1
AnchorSideRight.Side = asrBottom
Left = 223
Height = 23
Top = 34
Width = 216
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 2
ReadOnly = True
TabOrder = 1
Text = 'Var1'
end
object Var2: TEdit
AnchorSideLeft.Control = Bevel1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = VarList
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Page1
AnchorSideRight.Side = asrBottom
Left = 223
Height = 23
Top = 127
Width = 216
Anchors = [akTop, akLeft, akRight]
ReadOnly = True
TabOrder = 2
Text = 'Var2'
end
object Grp: TEdit
AnchorSideLeft.Control = Bevel1
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Page1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = VarList
AnchorSideBottom.Side = asrBottom
Left = 223
Height = 23
Top = 236
Width = 216
Anchors = [akLeft, akRight, akBottom]
ReadOnly = True
TabOrder = 3
Text = 'Grp'
end
object Bevel1: TBevel
AnchorSideLeft.Control = Page1
AnchorSideLeft.Side = asrCenter
Left = 215
Height = 49
Top = 53
Width = 8
Shape = bsSpacer
end
end
object Page2: TPage
object Panel4: TPanel
AnchorSideTop.Control = Page2
Left = 24
Height = 62
Top = 16
Width = 344
AutoSize = True
BorderSpacing.Top = 16
BevelOuter = bvNone
ChildSizing.HorizontalSpacing = 8
ChildSizing.VerticalSpacing = 12
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 5
ClientHeight = 62
ClientWidth = 344
TabOrder = 0
object Samp1Label: TLabel
AnchorSideTop.Side = asrCenter
Left = 0
Height = 23
Top = 4
Width = 77
Caption = 'Sample 1 Freq.'
ParentColor = False
end
object IndFreq1: TEdit
Left = 85
Height = 23
Top = 4
Width = 80
Alignment = taRightJustify
TabOrder = 0
Text = 'IndFreq1'
end
object Bevel2: TBevel
Left = 173
Height = 10
Top = 4
Width = 10
Constraints.MaxHeight = 10
Constraints.MaxWidth = 10
Shape = bsSpacer
end
object Samp1SizeLabel: TLabel
AnchorSideTop.Side = asrCenter
Left = 191
Height = 23
Top = 4
Width = 65
BorderSpacing.Top = 4
Caption = 'Sample Size:'
ParentColor = False
end
object IndSize1: TEdit
Left = 264
Height = 23
Top = 4
Width = 80
Alignment = taRightJustify
TabOrder = 1
Text = 'IndSize1'
end
object Samp2Label: TLabel
Left = 0
Height = 23
Top = 39
Width = 77
Caption = 'Sample 2 Freq.'
ParentColor = False
end
object IndFreq2: TEdit
Left = 85
Height = 23
Top = 39
Width = 80
Alignment = taRightJustify
TabOrder = 2
Text = 'IndFreq2'
end
object Bevel3: TBevel
Left = 173
Height = 10
Top = 39
Width = 10
Constraints.MaxHeight = 10
Constraints.MaxWidth = 10
Shape = bsSpacer
end
object Samp2SizeLabel: TLabel
Left = 191
Height = 23
Top = 39
Width = 65
Caption = 'Sample Size:'
ParentColor = False
end
object IndSize2: TEdit
Left = 264
Height = 23
Top = 39
Width = 80
Alignment = taRightJustify
TabOrder = 3
Text = 'IndSize2'
end
end
end
object Page3: TPage
object DepSamp2Label: TLabel
AnchorSideLeft.Control = Page3
Left = 8
Height = 15
Top = 72
Width = 45
BorderSpacing.Left = 8
Caption = 'Sample2'
ParentColor = False
end
object DepSamp1Label: TLabel
AnchorSideTop.Control = Page3
Left = 168
Height = 15
Top = 0
Width = 45
Caption = 'Sample1'
ParentColor = False
end
object Panel3: TPanel
AnchorSideTop.Control = DepSamp1Label
AnchorSideTop.Side = asrBottom
Left = 72
Height = 85
Top = 23
Width = 201
BorderSpacing.Top = 8
BevelOuter = bvNone
ChildSizing.HorizontalSpacing = 16
ChildSizing.VerticalSpacing = 12
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 3
ClientHeight = 85
ClientWidth = 201
TabOrder = 0
object LabelCorner: TLabel
Left = 0
Height = 15
Top = 0
Width = 9
Caption = ' '
ParentColor = False
end
object Samp10Label: TLabel
Left = 25
Height = 15
Top = 0
Width = 80
Alignment = taCenter
Caption = '0'
ParentColor = False
end
object Samp11Label: TLabel
Left = 121
Height = 15
Top = 0
Width = 80
Alignment = taCenter
Caption = '1'
ParentColor = False
end
object Samp20Label: TLabel
Left = 0
Height = 23
Top = 27
Width = 9
Caption = '0'
Layout = tlCenter
ParentColor = False
end
object DepFreq00: TEdit
Left = 25
Height = 23
Top = 27
Width = 80
Alignment = taRightJustify
TabOrder = 0
Text = 'DepFreq00'
end
object DepFreq10: TEdit
Left = 121
Height = 23
Top = 27
Width = 80
Alignment = taRightJustify
TabOrder = 1
Text = 'DepFreq10'
end
object Samp21Label: TLabel
Left = 0
Height = 23
Top = 62
Width = 9
Caption = '1'
Layout = tlCenter
ParentColor = False
end
object DepFreq01: TEdit
Left = 25
Height = 23
Top = 62
Width = 80
Alignment = taRightJustify
TabOrder = 2
Text = 'DepFreq01'
end
object DepFreq11: TEdit
Left = 121
Height = 23
Top = 62
Width = 80
Alignment = taRightJustify
TabOrder = 3
Text = 'DepFreq11'
end
end
end
end
object Bevel4: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 378
Width = 455
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 80
Top = 0
Width = 455
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BevelOuter = bvNone
ClientHeight = 80
ClientWidth = 455
TabOrder = 6
object RadioGroup1: TRadioGroup
AnchorSideTop.Control = Panel1
AnchorSideRight.Control = Bevel5
Left = 16
Height = 72
Top = 8
Width = 203
Anchors = [akTop, akRight]
AutoFill = True
AutoSize = True
BorderSpacing.Top = 8
Caption = 'Data Entry By:'
ChildSizing.LeftRightSpacing = 16
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 52
ClientWidth = 199
Items.Strings = (
'Values Entered on this Form'
'Values in the Data Grid'
)
OnClick = RadioGroup1Click
TabOrder = 0
end
object RadioGroup2: TRadioGroup
AnchorSideLeft.Control = Bevel5
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel1
Left = 235
Height = 72
Top = 8
Width = 188
AutoFill = True
AutoSize = True
BorderSpacing.Top = 8
Caption = 'Test Assumptions:'
ChildSizing.LeftRightSpacing = 16
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 52
ClientWidth = 184
Items.Strings = (
'Independent Proportions'
'Dependent Proportions'
)
OnClick = RadioGroup2Click
TabOrder = 1
end
object Bevel5: TBevel
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Panel1
Left = 219
Height = 41
Top = 0
Width = 16
Shape = bsSpacer
end
end
end

View File

@ -0,0 +1,541 @@
unit TwoPropUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls,
Graphics, Dialogs, ExtCtrls, StdCtrls, ComCtrls, MainUnit, Globals,
FunctionsLib, OutPutUnit, DataProcs, contexthelpunit;
type
{ TTwoPropFrm }
TTwoPropFrm = class(TForm)
Bevel1: TBevel;
Bevel2: TBevel;
Bevel3: TBevel;
Bevel4: TBevel;
Bevel5: TBevel;
HelpBtn: TButton;
LabelCorner: TLabel;
Notebook1: TNotebook;
Page1: TPage;
Page2: TPage;
Page3: TPage;
Panel1: TPanel;
Panel3: TPanel;
Panel4: TPanel;
ResetBtn: TButton;
ComputeBtn: TButton;
CloseBtn: TButton;
DepFreq00: TEdit;
DepFreq10: TEdit;
DepFreq01: TEdit;
DepFreq11: TEdit;
CInterval: TEdit;
Grp: TEdit;
GrpLabel: TLabel;
ConfLabel: TLabel;
Var2: TEdit;
SecdVarLabel: TLabel;
Var1: TEdit;
IndSize2: TEdit;
IndSize1: TEdit;
IndFreq2: TEdit;
IndFreq1: TEdit;
Samp1Label: TLabel;
Samp21Label: TLabel;
Label11: TLabel;
FirstVarLabel: TLabel;
Samp2Label: TLabel;
Samp1SizeLabel: TLabel;
Samp2SizeLabel: TLabel;
DepSamp2Label: TLabel;
DepSamp1Label: TLabel;
Samp10Label: TLabel;
Samp11Label: TLabel;
Samp20Label: TLabel;
VarList: TListBox;
RadioGroup1: TRadioGroup;
RadioGroup2: TRadioGroup;
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
procedure RadioGroup1Click(Sender: TObject);
procedure RadioGroup2Click(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure VarListClick(Sender: TObject);
private
{ private declarations }
FAutoSized: Boolean;
independent: boolean;
griddata: boolean;
function Validate(out AMsg: String; out AControl: TWinControl): Boolean;
public
{ public declarations }
end;
var
TwoPropFrm: TTwoPropFrm;
implementation
uses
Math;
{ TTwoPropFrm }
procedure TTwoPropFrm.ResetBtnClick(Sender: TObject);
var
i: integer;
begin
CInterval.Text := FormatFloat('0.0', DEFAULT_CONFIDENCE_LEVEL_PERCENT);
RadioGroup1.ItemIndex := 0;
RadioGroup2.ItemIndex := 0;
VarList.Clear;
Var1.Text := '';
Var2.Text := '';
independent := true;
griddata := false;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
GrpLabel.Visible := true;
Grp.Visible := true;
Grp.Text := '';
Var2.Visible := false;
SecdVarLabel.Visible := false;
DepFreq00.Text := '';
DepFreq01.Text := '';
DepFreq10.Text := '';
DepFreq11.Text := '';
IndFreq1.Text := '';
IndFreq2.Text := '';
IndSize1.Text := '';
IndSize2.Text := '';
Notebook1.PageIndex := 1;
end;
procedure TTwoPropFrm.VarListClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if not independent then
begin
if Var1.Text <> '' then
Var2.Text := VarList.Items[index]
else
Var1.Text := VarList.Items[index];
end;
if independent then
begin
if Var1.Text <> '' then
Grp.Text := VarList.Items[index]
else
Var1.Text := VarList.Items[index];
end;
end;
procedure TTwoPropFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TTwoPropFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).tag);
end;
procedure TTwoPropFrm.ComputeBtnClick(Sender: TObject);
var
ConfInt, Prop1, Prop2, zstatistic, zprobability: double;
PropDif, stderr, UCL, LCL, value1, value2, ztest: double;
P, Q: double;
i, v1, v2, NoSelected, f1, f2, f3, f4, ncases1, ncases2: integer;
min, max, group, AB, AC, CD, BD: integer;
ColNoSelected: IntDyneVec;
msg: String;
C: TWinControl;
lReport: TStrings;
begin
if not Validate(msg, C) then
begin
C.SetFocus;
MessageDlg(msg, mtError, [mbOK], 0);
ModalResult := mrNone;
exit;
end;
// Initialize output form
stderr := 0.0;
PropDif := 0.0;
v2 := 0;
ztest := 0.0;
Prop1 := 0.0;
Prop2 := 0.0;
NoSelected := 0;
v1 := 0;
zstatistic := 0.0;
zprobability := 0.0;
UCL := 0.0;
LCL := 0.0;
SetLength(ColNoSelected,NoVariables);
ConfInt := (100.0 - StrToFloat(CInterval.Text)) / 2.0 ;
ConfInt := (100.0 - ConfInt) / 100.0; // one tail
ncases1 := 0;
ncases2 := 0;
f1 := 0;
f2 := 0;
f3 := 0;
f4 := 0;
if independent then
Var2.Text := Grp.Text;
if griddata then // data read from grid
begin
for i := 1 to NoVariables do
begin
if Var1.Text = OS3MainFrm.DataGrid.Cells[i,0] then
begin
v1 := i;
ColNoSelected[0] := i;
end;
if Var2.Text = OS3MainFrm.DataGrid.Cells[i,0] then
begin
v2 := i;
ColNoSelected[1] := i;
end;
end; // next variable
if not independent then // correlated data
begin
for i := 1 to NoCases do
begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
ncases1 := ncases1 + 1;
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i]));
value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i]));
f1 := f1 + round(value1);
f2 := f2 + round(value2);
end; // next case
f3 := ncases1 - f1;
f4 := ncases1 - f2;
AB := f1 + f2;
AC := f1 + f3;
CD := f3 + f4;
BD := f2 + f4;
Prop1 := BD / ncases1;
Prop2 := AB / ncases1;
stderr := sqrt((f1 / ncases1 + f4 / ncases1) / ncases1);
PropDif := Prop1 - Prop2;
zstatistic := PropDif / stderr;
ztest := inversez(ConfInt);
zprobability := 1.0 - probz(abs(zstatistic));
UCL := PropDif + stderr * ztest;
LCL := PropDif - stderr * ztest;
end; // if not independent
if independent then
begin
min := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,1])));
max := min;
for i := 2 to NoCases do
begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
group := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i])));
if group < min then min := group;
if group > max then max := group;
end;
for i := 1 to NoCases do
begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i]));
group := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i])));
if group = min then
begin
f1 := f1 + round(value1);
ncases1 := ncases1 + 1;
end else
begin
f2 := f2 + round(value1);
ncases2 := ncases2 + 1;
end;
end; // next case
Prop1 := f1 / ncases1;
Prop2 := f2 / ncases2;
PropDif := Prop1 - Prop2;
P := (f1 + f2) / (ncases1 + ncases2);
Q := 1.0 - P;
stderr := sqrt(P * Q * ((1.0 / ncases1) + (1.0 / ncases2)));
zstatistic := (Prop1 - Prop2) / stderr;
zprobability := 1.0 - probz(abs(zstatistic));
ztest := inversez(ConfInt);
UCL := PropDif + ztest * stderr;
LCL := PropDif - ztest * stderr;
end; // end if independent
end; // if reading grid data
if not griddata then // data read from form
begin
if not independent then // correlated data
begin
f1 := round(StrToFloat(DepFreq00.Text));
f2 := round(StrToFloat(DepFreq10.Text));
f3 := round(StrToFloat(DepFreq01.Text));
f4 := round(StrToFloat(DepFreq11.Text));
ncases1 := f1 + f2 + f3 + f4;
AB := f1 + f2;
AC := f1 + f3;
CD := f3 + f4;
BD := f2 + f4;
Prop1 := BD / ncases1;
Prop2 := AB / ncases1;
stderr := sqrt((f1 / ncases1 + f4 / ncases1) / ncases1);
PropDif := Prop1 - Prop2;
zstatistic := PropDif / stderr;
ztest := inversez(ConfInt);
zprobability := 1.0 - probz(abs(zstatistic));
UCL := PropDif + stderr * ztest;
LCL := PropDif - stderr * ztest;
end; // if not independent
if independent then // independent data
begin
f1 := StrToInt(IndFreq1.Text);
f2 := StrToInt(IndFreq2.Text);
ncases1 := StrToInt(IndSize1.Text);
ncases2 := StrToInt(IndSize2.Text);
Prop1 := f1 / ncases1;
Prop2 := f2 / ncases2;
PropDif := Prop1 - Prop2;
P := (f1 + f2) / (ncases1 + ncases2);
Q := 1.0 - P;
stderr := sqrt(P * Q * ((1.0 / ncases1) + (1.0 / ncases2)));
zstatistic := (Prop1 - Prop2) / stderr;
zprobability := 1.0 - probz(abs(zstatistic));
ztest := inversez(ConfInt);
UCL := PropDif + ztest * stderr;
LCL := PropDif - ztest * stderr;
end;
end;
// Print the results
lReport := TStringList.Create;
try
lReport.Add('COMPARISON OF TWO PROPORTIONS');
lReport.Add('');
if not independent then
begin
lReport.Add('Test for Difference Between Two Dependent Proportions');
lReport.Add('');
lReport.Add('Entered Values');
lReport.Add('');
lReport.Add('Sample 1');
lReport.Add(' 0 1 sum');
lReport.Add(' -----------------------');
lReport.Add(' 0 |%5d %5d %5d |', [f1, f2, AB]);
lReport.Add(' 2 --------|-------|------');
lReport.Add(' 1 |%5d %5d %5d |', [f3, f4, CD]);
lReport.Add(' --------|-------|------');
lReport.Add(' sum | %5d %5d %5d |', [AC, BD, ncases1]);
lReport.Add('');
lReport.Add('Confidence Level selected: %s', [CInterval.Text]);
lReport.Add('Proportion 1 = %.3f and Proportion 2 = %.3f with %d cases', [Prop1, Prop2, ncases1]);
lReport.Add('Difference in proportions: %9.3f', [PropDif]);
lReport.Add('Standard Error of Difference: %9.3f', [stderr]);
lReport.Add('z test statistic: %9.3f with probability = %.4f', [zstatistic, zprobability]);
lReport.Add('z value for confidence interval: %9.3f', [ztest]);
lReport.Add('Confidence Interval: (%.3f, %.3f)', [LCL, UCL]);
end;
if independent then
begin
lReport.Add('Test for Difference Between Two Independent Proportions');
lReport.Add('');
lReport.Add('Entered Values');
lReport.Add('');
lReport.Add('Sample 1: Frequency = %5d for %5d cases.', [f1, ncases1]);
lReport.Add('Sample 2: Frequency = %5d for %5d cases.', [f2, ncases2]);
lReport.Add('');
lReport.Add('Proportion 1: %9.3f', [Prop1]);
lReport.Add('Proportion 2: %9.3f', [Prop2]);
lReport.Add('Difference: %9.3f', [PropDif]);
lReport.Add('Standard Error of Difference: %9.3f', [stderr]);
lReport.Add('Confidence Level selected: %9s', [CInterval.Text]);
lReport.Add('z test statistic: %9.3f with probability = %.4f', [zstatistic, zprobability]);
lReport.Add('z value for confidence interval: %9.3f', [ztest]);
lReport.Add('Confidence Interval: (%.3f, %.3f)', [LCL, UCL]);
end;
DisplayReport(lReport);
finally
lReport.Free;
ColNoSelected := nil;
end;
end;
procedure TTwoPropFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
RadioGroup2.Constraints.MinWidth := RadioGroup1.Width;
w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
HelpBtn.Constraints.MinWidth := w;
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
Width := Max(
RadioGroup2.Left + RadioGroup2.Width + RadioGroup2.BorderSpacing.Right,
Width - HelpBtn.Left + HelpBtn.BorderSpacing.Left
);
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TTwoPropFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
end;
procedure TTwoPropFrm.RadioGroup1Click(Sender: TObject);
begin
griddata := RadioGroup1.ItemIndex = 1;
RadioGroup2Click(nil);
end;
procedure TTwoPropFrm.RadioGroup2Click(Sender: TObject);
begin
case RadioGroup2.ItemIndex of
0: begin
independent := true;
if griddata then begin
Notebook1.PageIndex := 0;
Var2.Visible := false;
Grp.Visible := true;
SecdVarLabel.Visible := Var2.Visible;
GrpLabel.Visible := Grp.Visible;
end else
Notebook1.PageIndex := 1;
end;
1: begin
independent := false;
if griddata then begin
Notebook1.PageIndex := 0;
Var2.Visible := true;
Grp.Visible := false;
SecdVarLabel.Visible := Var2.Visible;
GrpLabel.Visible := Grp.Visible;
end else
Notebook1.PageIndex := 2;
end;
end;
end;
function TTwoPropFrm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
var
n: Integer;
begin
Result := false;
AControl := nil;
AMsg := '';
if Notebook1.PageIndex = 0 then
begin
if Var1.Text = '' then
begin
AControl := Var1;
AMsg := 'First variable not specified.';
exit;
end;
case RadioGroup2.ItemIndex of
0: if (Grp.Text = '') then
begin
AControl := Grp;
AMsg := 'Group code not specified';
exit;
end;
1: if (Var2.Text = '') then begin
AControl := Var2;
AMsg := 'Second variable not specified.';
exit;
end;
end;
end else
if Notebook1.PageIndex = 1 then
begin
if (IndFreq1.Text = '') or not TryStrToInt(IndFreq1.Text, n) or (n < 0) then
begin
AControl := IndFreq1;
AMsg := 'Invalid input for Sample 1 frequency';
exit;
end;
if (IndFreq2.Text = '') or not TryStrToInt(IndFreq2.Text, n) or (n < 0) then
begin
AControl := IndFreq2;
AMsg := 'Invalid input for Sample 2 frequency';
exit;
end;
if (IndSize1.Text = '') or not TryStrToInt(IndSize1.Text, n) or (n <= 0) then
begin
AControl := IndSize1;
AMsg := 'Invald input for size of sample 1';
exit;
end;
if (IndSize2.Text = '') or not TryStrToInt(IndSize2.Text, n) or (n <= 0) then
begin
AControl := IndSize2;
AMsg := 'Invalud input for size of sample 2';
exit;
end;
end else
if Notebook1.PageIndex = 2 then
begin
if (DepFreq00.Text = '') or not TryStrToInt(DepFreq00.Text, n) or (n < 0) then
AControl := DepFreq00
else
if (DepFreq01.Text = '') or not TryStrToInt(DepFreq01.Text, n) or (n < 0) then
AControl := DepFreq01
else
if (DepFreq10.Text = '') or not TryStrToInt(DepFreq10.Text, n) or (n < 0) then
AControl := DepFreq10
else
if (DepFreq11.Text = '') or not TryStrToInt(DepFreq11.Text, n) or (n < 0) then
AControl := DepFreq11;
if AControl <> nil then
begin
AMsg := 'Invalid input.';
exit;
end;
end;
Result := true;
end;
initialization
{$I twopropunit.lrs}
end.

View File

@ -0,0 +1,242 @@
object WithinANOVAFrm: TWithinANOVAFrm
Left = 544
Height = 362
Top = 330
Width = 458
AutoSize = True
Caption = 'Within Subjects ANOVA and Hoyt Reliability Estimates'
ClientHeight = 362
ClientWidth = 458
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Label1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 8
Height = 15
Top = 8
Width = 97
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Available Variables'
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = SelList
AnchorSideTop.Control = Owner
Left = 251
Height = 15
Top = 8
Width = 96
BorderSpacing.Top = 8
Caption = 'Selected Variables:'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = InBtn
AnchorSideBottom.Control = GroupBox1
Left = 8
Height = 229
Top = 25
Width = 199
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Constraints.MinHeight = 220
ItemHeight = 0
MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object InBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
Left = 215
Height = 28
Top = 25
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = InBtnClick
Spacing = 0
TabOrder = 1
end
object OutBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = InBtn
AnchorSideTop.Side = asrBottom
Left = 215
Height = 28
Top = 57
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = OutBtnClick
Spacing = 0
TabOrder = 2
end
object SelList: TListBox
AnchorSideLeft.Control = InBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = GroupBox1
Left = 251
Height = 229
Top = 25
Width = 199
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
ItemHeight = 0
MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 3
end
object GroupBox1: TGroupBox
AnchorSideLeft.Control = Owner
AnchorSideBottom.Control = Bevel1
Left = 8
Height = 51
Top = 262
Width = 384
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Right = 8
Caption = 'Options:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 20
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 3
ClientHeight = 31
ClientWidth = 380
TabOrder = 4
object RelChk: TCheckBox
Left = 12
Height = 19
Top = 6
Width = 124
Caption = 'Reliability Estimates'
TabOrder = 0
end
object AssumpChk: TCheckBox
Left = 156
Height = 19
Top = 6
Width = 113
Caption = 'Test Assumptions'
TabOrder = 1
end
object PlotChk: TCheckBox
Left = 289
Height = 19
Top = 6
Width = 79
Caption = 'Plot Means'
TabOrder = 2
end
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 245
Height = 25
Top = 329
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 6
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 307
Height = 25
Top = 329
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 7
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 391
Height = 25
Top = 329
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 8
end
object HelpBtn: TButton
Tag = 157
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 186
Height = 25
Top = 329
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 5
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 313
Width = 458
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
end

View File

@ -0,0 +1,521 @@
// Use file "itemdata2.laz" for testing
unit WithinANOVAUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons, ExtCtrls, Math,
MainUnit, FunctionsLib, OutputUnit, MatrixLib, Globals, DataProcs,
GraphLib, ContextHelpUnit;
type
{ TWithinANOVAFrm }
TWithinANOVAFrm = class(TForm)
AssumpChk: TCheckBox;
Bevel1: TBevel;
HelpBtn: TButton;
ResetBtn: TButton;
ComputeBtn: TButton;
CloseBtn: TButton;
PlotChk: TCheckBox;
RelChk: TCheckBox;
GroupBox1: TGroupBox;
InBtn: TBitBtn;
Label2: TLabel;
SelList: TListBox;
OutBtn: TBitBtn;
Label1: TLabel;
VarList: TListBox;
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
procedure InBtnClick(Sender: TObject);
procedure OutBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean);
private
{ private declarations }
FAutoSized: Boolean;
procedure UpdateBtnStates;
public
{ public declarations }
end;
var
WithinANOVAFrm: TWithinANOVAFrm;
implementation
{ TWithinANOVAFrm }
procedure TWithinANOVAFrm.ResetBtnClick(Sender: TObject);
VAR
i: integer;
begin
VarList.Clear;
SelList.Clear;
PlotChk.Checked := false;
RelChk.Checked := false;
AssumpChk.Checked := false;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
UpdateBtnStates;
end;
procedure TWithinANOVAFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
HelpBtn.Constraints.MinWidth := w;
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := True;
end;
procedure TWithinANOVAFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
if GraphFrm = nil then
Application.CreateForm(TGraphFrm, GraphFrm);
end;
procedure TWithinANOVAFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TWithinANOVAFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).tag);
end;
procedure TWithinANOVAFrm.ComputeBtnClick(Sender: TObject);
var
i, j, k, f3: integer;
LabelStr: string;
NoSelected, count, row: integer;
SSrows, SScols, SSwrows, SSerr, SStot: double;
MSrows, MScols, MSwrows, MSerr, MStot: double;
dfrows, dfcols, dfwrows, dferr, dftot: double;
f1, f2, probf1, GrandMean, Term1, Term2, Term3, Term4: double;
r1, r2, r3, r4, X, avgvar, avgcov: double;
determ1, determ2, M2, C2, chi2, prob: double;
errorfound: boolean;
Selected: IntDyneVec;
ColLabels: StrDyneVec;
ColMeans, ColVar, RowMeans, RowVar, ColStdDev: DblDyneVec;
varcovmat, vcmat, workmat: DblDyneMat;
title: string;
lReport: TStrings;
begin
if SelList.Items.Count = 0 then
begin
MessageDlg('No variables selected.', mtError, [mbOK], 0);
exit;
end;
if SelList.Items.Count = 1 then
begin
MessageDlg('At least two variables must be selected.', mtError, [mbOK], 0);
exit;
end;
errorfound := false;
NoSelected := SelList.Items.Count;
Caption := IntToStr(NoSelected);
SetLength(Selected,NoSelected);
SetLength(ColLabels,NoSelected);
SetLength(ColMeans,NoSelected);
SetLength(ColVar,NoSelected);
SetLength(RowMeans,NoCases);
SetLength(RowVar,NoCases);
for i := 0 to NoSelected - 1 do
begin
LabelStr := SelList.Items[i];
for j := 1 to NoVariables do
if LabelStr = OS3MainFrm.DataGrid.Cells[j, 0] then
begin
Selected[i] := j;
ColLabels[i] := labelStr;
break;
end;
end;
// Initialize values
SScols := 0.0;
SSrows := 0.0;
SStot := 0.0;
dfwrows := 0.0;
dftot := 0.0;
GrandMean := 0.0;
count := 0;
for i := 0 to NoSelected-1 do
begin
ColMeans[i] := 0.0;
ColVar[i] := 0.0;
end;
for j := 0 to NoCases-1 do
begin
RowMeans[j] := 0.0;
RowVar[j] := 0.0;
end;
// Read data and compute sums while reading
row := 0;
for i := 1 to NoCases do
begin
if not GoodRecord(i,NoSelected,Selected) then continue;
count := count + 1;
for j := 1 to NoSelected do
begin
k := Selected[j-1];
X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[k,i]));
RowMeans[row] := RowMeans[row] + X;
RowVar[row] := RowVar[row] + (X * X);
ColMeans[j-1] := ColMeans[j-1] + X;
ColVar[j-1] := ColVar[j-1] + (X * X);
GrandMean := GrandMean + X;
SStot := SStot + (X * X);
end;
row := row + 1;
end;
// Calculate ANOVA results
Term1 := (GrandMean * GrandMean) / (count * NoSelected);
Term2 := SStot;
for i := 1 to count do SSrows := SSrows + (RowMeans[i-1] * RowMeans[i-1]);
Term4 := SSrows / NoSelected;
for i := 1 to NoSelected do SScols := SScols + (ColMeans[i-1] * ColMeans[i-1]);
Term3 := SScols / count;
SSrows := Term4 - Term1;
SScols := Term3 - Term1;
SSwrows := Term2 - Term4;
SSerr := Term2 - Term3 - Term4 + Term1;
SStot := Term2 - Term1;
dfrows := count - 1;
dfcols := NoSelected - 1;
dfwrows := count * (NoSelected - 1);
dferr := (count - 1) * (NoSelected - 1);
dftot := (count * NoSelected) - 1;
MSrows := SSrows / dfrows;
MScols := SScols / dfcols;
MSwrows := SSwrows / dfwrows;
MSerr := SSerr / dferr;
MStot := SStot / dftot; // variance of all scores
GrandMean := GrandMean / (count * NoSelected);
for i := 0 to count-1 do
begin
RowVar[i] := RowVar[i] - (RowMeans[i] * RowMeans[i] / NoSelected);
RowVar[i] := RowVar[i] / (NoSelected - 1);
RowMeans[i] := RowMeans[i] / NoSelected;
end;
for i := 0 to NoSelected-1 do
begin
ColVar[i] := ColVar[i] - (ColMeans[i] * ColMeans[i] / count);
ColVar[i] := ColVar[i] / (count - 1);
ColMeans[i] := ColMeans[i] / count;
end;
f1 := MScols / MSerr; // treatment F statistic
probf1 := probf(f1,dfcols,dferr);
// Do reliability terms if requested
if RelChk.Checked then
begin
r1 := 1.0 - (MSwrows / MSrows); // unadjusted reliability of test
r2 := (MSrows - MSwrows) / (MSrows + (NoSelected - 1) * MSwrows);
// r2 is unadjusted reliability of a single item
r3 := (MSrows - MSerr) / MSrows; // Cronbach alpha for test
r4 := (MSrows - MSerr) / (MSrows + (NoSelected - 1) * MSerr);
// r4 is adjusted reliability of a single item
end;
// do homogeneity of variance and covariance checks if requested
lReport := TStringList.Create;
try
// print results
lReport.Add('Treatments by Subjects (AxS) ANOVA Results.');
lReport.Add('');
lReport.Add('Data File = ' + OS3MainFrm.FileNameEdit.Text);
lReport.Add('');
lReport.Add('');
lReport.Add('-----------------------------------------------------------');
lReport.Add('SOURCE DF SS MS F Prob. > F');
lReport.Add('-----------------------------------------------------------');
lReport.Add('SUBJECTS %4.0f%10.3f%10.3f', [dfrows, SSrows, MSrows]);
lReport.Add('WITHIN SUBJECTS%4.0f%10.3f%10.3f', [dfwrows, SSwrows, MSwrows]);
lReport.Add(' TREATMENTS %4.0f%10.3f%10.3f%10.3f%10.3f', [dfcols, SScols, MScols, f1, probf1]);
lReport.Add(' RESIDUAL %4.0f%10.3f%10.3f', [dferr, SSerr, MSerr]);
lReport.Add('-----------------------------------------------------------');
lReport.Add('TOTAL %4.0f%10.3f%10.3f', [dftot, SStot, MStot]);
lReport.Add('-----------------------------------------------------------');
lReport.Add('');
lReport.Add('');
lReport.Add('TREATMENT (COLUMN) MEANS AND STANDARD DEVIATIONS');
lReport.Add('VARIABLE MEAN STD.DEV.');
for i := 1 to NoSelected do
lReport.Add('%-8s%10.3f%10.3f', [ColLabels[i-1], ColMeans[i-1], sqrt(ColVar[i-1])]);
lReport.Add('');
lReport.Add('Mean of all scores = %.3f with standard deviation = %.3f', [GrandMean, sqrt(MStot)]);
lReport.Add('');
lReport.Add('');
// Do reliability estimates if requested
if RelChk.Checked then
begin
lReport.Add('RELIABILITY ESTIMATES');
lReport.Add('');
lReport.Add('TYPE OF ESTIMATE VALUE');
lReport.Add('Unadjusted total reliability %7.3f', [r1]);
lReport.Add('Unadjusted item reliability %7.3f', [r2]);
lReport.Add('Adjusted total (Cronbach) %7.3f', [r3]);
lReport.Add('Adjusted item reliability %7.3f', [r4]);
lReport.Add('');
lReport.Add('');
end;
// Test assumptions of variance - covariance homogeneity if requested
if AssumpChk.Checked then
begin
SetLength(varcovmat,NoSelected+1,NoSelected+1);
SetLength(vcmat,NoSelected+1,NoSelected+1);
SetLength(workmat,NoSelected+1,NoSelected+1);
SetLength(ColStdDev,NoSelected);
errorfound := false;
count := NoCases;
lReport.Add('BOX TEST FOR HOMOGENEITY OF VARIANCE-COVARIANCE MATRIX');
lReport.Add('');
GridCovar(NoSelected, Selected, varcovmat, ColMeans, ColVar, ColStdDev, errorfound, count);
title := 'SAMPLE COVARIANCE MATRIX';
MatPrint(varcovmat, NoSelected, NoSelected, title, ColLabels, ColLabels, NoCases, lReport);
if errorfound then
MessageDlg('Zero variance found for a variable.', mtError, [mbOK], 0);
// get average of variances into workmat diagonal and average of
// covariances into workmat off-diagonals (See Winer, pg 371)
avgvar := 0.0;
avgcov := 0.0;
for i := 0 to NoSelected-1 do
vcmat[i,i] := varcovmat[i,i];
for i := 0 to NoSelected-2 do
begin
for j := i+1 to NoSelected-1 do
begin
vcmat[i,j] := varcovmat[i,j];
vcmat[j,i] := vcmat[i,j];
end;
end;
for i := 0 to NoSelected-1 do
avgvar := avgvar + varcovmat[i,i];
for i := 0 to NoSelected-2 do
for j := i+1 to NoSelected-1 do
avgcov := avgcov + varcovmat[i,j];
avgvar := avgvar / NoSelected;
avgcov := avgcov / (NoSelected * NoSelected - 1) / 2.0;
for i := 0 to NoSelected-1 do
workmat[i,i] := avgvar;
for i := 0 to NoSelected-2 do
begin
for j := i+1 to NoSelected-1 do
begin
workmat[i,j] := avgcov;
workmat[j,i] := workmat[i,j];
end;
end;
// get determinants of varcov and workmat
determ1 := 0.0;
determ2 := 0.0;
M2 := 0.0;
C2 := 0.0;
chi2 := 0.0;
f2 := 0;
prob := 0.0;
Determ(vcmat,NoSelected,NoSelected,determ1,errorfound);
if determ1 < 0.0 then determ1 := 0.0;
Determ(workmat,NoSelected,NoSelected,determ2,errorfound);
if determ2 < 0.0 then determ2 := 0.0;
count := NoCases;
GridCovar(NoSelected,Selected,varcovmat,ColMeans,ColVar,ColStdDev,errorfound,count);
errorfound := false;
if ((determ1 > 0.0) and (determ2 > 0.0)) then
M2 := -(NoCases*NoSelected - 1) * ln(determ1 / determ2)
else
begin
M2 := 0.0;
errorfound := true;
MessageDlg('A determinant <= zero was found.', mtError, [mbOK], 0);
end;
if not errorfound then
begin
C2 := NoSelected * (NoSelected+1) * (NoSelected + 1) * (2 * NoSelected - 3);
C2 := C2 / (6 * (count - 1)*(NoSelected - 1) * (NoSelected * NoSelected + NoSelected - 4));
chi2 := (1.0 - C2) * M2;
f3 := (NoSelected * NoSelected + NoSelected - 4) div 2;
if ((chi2 > 0.01) and (chi2 < 1000.0)) then
prob := chisquaredprob(chi2,f3)
else
begin
if chi2 <= 0.0 then prob := 1.0;
if chi2 >= 1000.0 then prob := 0.0;
end;
end;
title := 'ASSUMED POP. COVARIANCE MATRIX';
for i := 0 to NoSelected-1 do
for j := 0 to NoSelected-1 do
varcovmat[i,j] := workmat[i,j];
MatPrint(varcovmat, NoSelected, NoSelected, title, ColLabels, ColLabels, NoCases, lReport);
lReport.Add('Determinant of variance-covariance matrix = %10.3g', [determ1]);
lReport.Add('Determinant of homogeneity matrix = %10.3g', [determ2]);
if not errorfound then
begin
lReport.Add('ChiSquare = %10.3f with %3d degrees of freedom', [chi2,f3]);
lReport.Add('Probability of larger chisquare = %6.3g', [1.0-prob]);
end;
end;
DisplayReport(lReport);
finally
lReport.Free;
ColStdDev := nil;
workmat := nil;
vcmat := nil;
varcovmat := nil;
end;
{ Now, plot values if indicated in options list }
if PlotChk.Checked then
begin
SetLength(GraphFrm.Xpoints,1,NoSelected);
SetLength(GraphFrm.Ypoints,1,NoSelected);
// use rowvar to hold variable no.
for i := 1 to NoSelected do
begin
rowvar[i-1] := Selected[i-1];
GraphFrm.Xpoints[0,i-1] := Selected[i-1];
GraphFrm.Ypoints[0,i-1] := ColMeans[i-1];
end;
GraphFrm.nosets := 1;
GraphFrm.nbars := NoSelected;
GraphFrm.Heading := 'WITHIN SUBJECTS ANOVA';
GraphFrm.XTitle := 'Repeated Measure Var. No.';
GraphFrm.YTitle := 'Mean';
GraphFrm.barwideprop := 0.5;
GraphFrm.AutoScaled := true;
GraphFrm.GraphType := 2; // 3d Vertical Bar Chart
GraphFrm.BackColor := clYellow;
GraphFrm.WallColor := clBlack;
GraphFrm.FloorColor := clLtGray;
GraphFrm.ShowBackWall := true;
GraphFrm.ShowModal;
end;
// Clean-up
RowVar := nil;
RowMeans := nil;
ColVar := nil;
ColMeans := nil;
ColLabels := nil;
GraphFrm.Xpoints := nil;
GraphFrm.Ypoints := nil;
Selected := nil;
end;
procedure TWithinANOVAFrm.InBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while i < VarList.Items.Count do
begin
if VarList.Selected[i] then
begin
SelList.Items.Add(VarList.Items[i]);
VarList.Items.Delete(i);
i := 0;
end else
inc(i);
end;
UpdateBtnStates;
end;
procedure TWithinANOVAFrm.OutBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while i < SelList.Items.Count do
begin
if SelList.Selected[i] then
begin
VarList.Items.Add(SelList.Items[i]);
SelList.Items.Delete(i);
i := 0;
end else
inc(i);
end;
VarList.ItemIndex := -1;
SelList.ItemIndex := -1;
UpdateBtnStates;
end;
procedure TWithinANOVAFrm.UpdateBtnStates;
var
i: Integer;
lEnabled: Boolean;
begin
lEnabled := false;
for i:=0 to VarList.Items.Count-1 do
if VarList.Selected[i] then
begin
lEnabled := true;
break;
end;
InBtn.Enabled := lEnabled;
lEnabled := false;
for i:=0 to SelList.Items.Count-1 do
if SelList.Selected[i] then
begin
lEnabled := true;
break;
end;
OutBtn.Enabled := lEnabled;
end;
procedure TWithinANOVAFrm.VarListSelectionChange(Sender: TObject;
User: boolean);
begin
UpdateBtnStates;
end;
initialization
{$I withinanovaunit.lrs}
end.

View File

@ -0,0 +1,708 @@
object AutoCorrFrm: TAutoCorrFrm
Left = 456
Height = 459
Top = 163
Width = 684
AutoSize = True
Caption = 'Autocorrelation'
ClientHeight = 459
ClientWidth = 684
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object GroupBox1: TGroupBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 8
Height = 68
Top = 8
Width = 137
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'The series is code in:'
ClientHeight = 48
ClientWidth = 133
TabOrder = 0
object ColBtn: TRadioButton
AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = GroupBox1
Left = 16
Height = 19
Top = 0
Width = 99
BorderSpacing.Left = 16
Caption = 'A Grid Column'
OnClick = ColBtnClick
TabOrder = 0
end
object RowBtn: TRadioButton
AnchorSideLeft.Control = ColBtn
AnchorSideTop.Control = ColBtn
AnchorSideTop.Side = asrBottom
Left = 16
Height = 19
Top = 21
Width = 109
BorderSpacing.Top = 2
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'A row of the grid'
OnClick = RowBtnClick
TabOrder = 1
end
end
object GroupBox2: TGroupBox
AnchorSideLeft.Control = GroupBox1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Owner
Left = 169
Height = 68
Top = 8
Width = 275
AutoSize = True
BorderSpacing.Left = 24
BorderSpacing.Top = 8
Caption = 'Include Cases:'
ClientHeight = 48
ClientWidth = 271
TabOrder = 1
object Label1: TLabel
AnchorSideLeft.Control = FromCaseEdit
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = OnlyCasesBtn
AnchorSideTop.Side = asrCenter
Left = 189
Height = 15
Top = 23
Width = 12
BorderSpacing.Left = 4
Caption = 'To'
ParentColor = False
end
object AllCasesBtn: TRadioButton
AnchorSideLeft.Control = GroupBox2
AnchorSideTop.Control = GroupBox2
Left = 12
Height = 19
Top = 0
Width = 67
BorderSpacing.Left = 12
Caption = 'All Cases'
TabOrder = 0
end
object OnlyCasesBtn: TRadioButton
AnchorSideLeft.Control = GroupBox2
AnchorSideTop.Control = AllCasesBtn
AnchorSideTop.Side = asrBottom
Left = 12
Height = 19
Top = 21
Width = 112
BorderSpacing.Left = 12
BorderSpacing.Top = 2
BorderSpacing.Bottom = 8
Caption = 'Only Cases From:'
TabOrder = 1
end
object FromCaseEdit: TEdit
AnchorSideLeft.Control = OnlyCasesBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = OnlyCasesBtn
AnchorSideTop.Side = asrCenter
Left = 128
Height = 23
Top = 19
Width = 57
Alignment = taRightJustify
BorderSpacing.Left = 4
TabOrder = 2
Text = 'FromCaseEdit'
end
object ToCaseEdit: TEdit
AnchorSideLeft.Control = Label1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = OnlyCasesBtn
AnchorSideTop.Side = asrCenter
Left = 205
Height = 23
Top = 19
Width = 58
Alignment = taRightJustify
BorderSpacing.Left = 4
BorderSpacing.Right = 8
TabOrder = 3
Text = 'ToCaseEdit'
end
end
object ResetBtn: TButton
AnchorSideRight.Control = CancelBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 387
Height = 25
Top = 426
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 5
end
object CancelBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 453
Height = 25
Top = 426
Width = 62
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Cancel'
ModalResult = 2
TabOrder = 6
end
object ComputeBtn: TButton
AnchorSideRight.Control = ReturnBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 527
Height = 25
Top = 426
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Compute'
ModalResult = 1
OnClick = ComputeBtnClick
TabOrder = 7
end
object ReturnBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 615
Height = 25
Top = 426
Width = 61
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Return'
ModalResult = 1
OnClick = ReturnBtnClick
TabOrder = 8
end
object HelpBtn: TButton
Tag = 104
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 324
Height = 25
Top = 426
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 4
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ReturnBtn
Left = 0
Height = 8
Top = 410
Width = 684
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = GroupBox2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel2
AnchorSideBottom.Control = Bevel1
Left = 8
Height = 326
Top = 84
Width = 447
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BevelOuter = bvNone
ClientHeight = 326
ClientWidth = 447
TabOrder = 2
object Label3: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
Left = 0
Height = 15
Top = 0
Width = 100
Caption = 'Available Variables:'
ParentColor = False
end
object Label4: TLabel
AnchorSideLeft.Control = DepVarEdit
AnchorSideBottom.Control = DepVarEdit
Left = 301
Height = 15
Top = 25
Width = 88
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Selected Variable'
ParentColor = False
end
object Label5: TLabel
AnchorSideTop.Control = AlphaEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = AlphaEdit
Left = 311
Height = 15
Top = 93
Width = 67
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Alpha Level: '
ParentColor = False
end
object Label6: TLabel
AnchorSideTop.Control = MaxLagEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = MaxLagEdit
Left = 295
Height = 15
Top = 120
Width = 83
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Maximum Lag: '
ParentColor = False
end
object GroupBox3: TGroupBox
AnchorSideLeft.Control = InBtn
AnchorSideTop.Control = MaxLagEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 265
Height = 51
Top = 163
Width = 182
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 24
Caption = 'Projection Option:'
ClientHeight = 31
ClientWidth = 178
TabOrder = 6
object Label2: TLabel
AnchorSideLeft.Control = ProjPtsEdit
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ProjPtsEdit
AnchorSideTop.Side = asrCenter
Left = 135
Height = 15
Top = 6
Width = 33
BorderSpacing.Left = 8
BorderSpacing.Right = 16
BorderSpacing.Bottom = 8
Caption = 'Points'
ParentColor = False
end
object ProjectChk: TCheckBox
AnchorSideLeft.Control = GroupBox3
AnchorSideTop.Control = ProjPtsEdit
AnchorSideTop.Side = asrCenter
Left = 12
Height = 19
Top = 4
Width = 57
BorderSpacing.Left = 12
Caption = 'Project'
TabOrder = 0
end
object ProjPtsEdit: TEdit
AnchorSideLeft.Control = ProjectChk
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = GroupBox3
Left = 85
Height = 23
Top = 2
Width = 42
Alignment = taRightJustify
BorderSpacing.Left = 16
BorderSpacing.Top = 2
BorderSpacing.Bottom = 6
TabOrder = 1
end
end
object VarList: TListBox
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Label3
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = InBtn
AnchorSideBottom.Control = Panel1
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 309
Top = 17
Width = 257
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Right = 8
Constraints.MinHeight = 220
ItemHeight = 0
TabOrder = 0
end
object InBtn: TBitBtn
AnchorSideLeft.Control = Bevel2
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = VarList
Left = 265
Height = 28
Top = 17
Width = 28
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00216324B81D5E2006FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF002A702F38256929F7216324D9FFFFFF00FFFFFF00FFFFFF00FFFFFF0061BE
6DFF5DB868FF58B162FF53A95CFF4DA156FF47994FFF419149FF3B8842FF3580
3BFF3F8845FF59A15EFF448B49FF216324CFFFFFFF00FFFFFF00FFFFFF0065C3
71FFA0D7A9FF9CD5A5FF98D3A1FF94D09DFF90CE98FF8BCB93FF87C98EFF82C6
89FF7EC384FF7AC180FF76BE7CFF458C4AFF216324C4FFFFFF00FFFFFF0068C7
74FFA5DAAEFFA2D8ABFF9ED6A7FF9AD4A3FF96D29FFF93CF9AFF8ECC95FF89CA
90FF85C78BFF81C587FF7DC282FF4A9150FF256929C9FFFFFF00FFFFFF0068C7
74FF68C774FF65C371FF61BE6DFF5DB868FF58B162FF53A95CFF4DA156FF4799
4FFF419149FF5AA362FF559D5CFF2F7835D1FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00419149F73B8842DBFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0047994FBB41914906FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = InBtnClick
Spacing = 0
TabOrder = 1
end
object OutBtn: TBitBtn
AnchorSideLeft.Control = InBtn
AnchorSideTop.Control = InBtn
AnchorSideTop.Side = asrBottom
Left = 265
Height = 28
Top = 49
Width = 28
BorderSpacing.Top = 4
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF004DA1560647994FB8FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0053A95CD94DA156F747994F38FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF005DB868CF71BE7BFF7AC183FF5BAA64FF47994FFF419149FF3B8842FF3580
3BFF2F7835FF2A702FFF256929FF216324FF1D5E20FFFFFFFF00FFFFFF0065C3
71C47BC886FF9CD5A5FF98D3A1FF94D09DFF90CE98FF8BCB93FF87C98EFF82C6
89FF7EC384FF7AC180FF76BE7CFF72BD78FF216324FFFFFFFF00FFFFFF0068C7
74C97FCC8AFFA2D8ABFF9ED6A7FF9AD4A3FF96D29FFF93CF9AFF8ECC95FF89CA
90FF85C78BFF81C587FF7DC282FF78C07EFF256929FFFFFFFF00FFFFFF00FFFF
FF0068C774D180CD8BFF7CC987FF5DB868FF58B162FF53A95CFF4DA156FF4799
4FFF419149FF3B8842FF35803BFF2F7835FF2A702FFFFFFFFF00FFFFFF00FFFF
FF00FFFFFF0068C774DB65C371F7FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0068C7740668C774BBFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = OutBtnClick
Spacing = 0
TabOrder = 2
end
object DepVarEdit: TEdit
AnchorSideLeft.Control = InBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = OutBtn
AnchorSideBottom.Side = asrBottom
Left = 301
Height = 23
Top = 42
Width = 146
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
TabOrder = 3
Text = 'DepVarEdit'
end
object AlphaEdit: TEdit
AnchorSideTop.Control = DepVarEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 386
Height = 23
Top = 89
Width = 61
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Top = 24
TabOrder = 4
Text = 'AlphaEdit'
end
object MaxLagEdit: TEdit
AnchorSideTop.Control = AlphaEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 386
Height = 23
Top = 116
Width = 61
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Top = 4
TabOrder = 5
Text = 'MaxLagEdit'
end
object Bevel2: TBevel
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Panel1
Left = 182
Height = 12
Top = 0
Width = 83
Shape = bsSpacer
end
end
object Panel2: TPanel
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 463
Height = 357
Top = 6
Width = 213
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Right = 8
BevelOuter = bvNone
ClientHeight = 357
ClientWidth = 213
TabOrder = 3
object GroupBox4: TGroupBox
AnchorSideLeft.Control = Panel2
AnchorSideTop.Control = GroupBox5
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 0
Height = 177
Top = 180
Width = 213
AutoSize = True
BorderSpacing.Top = 16
Caption = 'Data Smoothing:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ClientHeight = 157
ClientWidth = 209
TabOrder = 1
object MeanChk: TCheckBox
Left = 12
Height = 19
Top = 6
Width = 185
Caption = 'Center on Mean'
TabOrder = 0
end
object DifferenceChk: TCheckBox
Left = 12
Height = 19
Top = 27
Width = 185
Caption = 'Difference Smoothing'
TabOrder = 1
end
object MoveAvgChk: TCheckBox
Left = 12
Height = 19
Top = 48
Width = 185
Caption = 'Moving Average Smooth'
TabOrder = 2
end
object ExpSmoothChk: TCheckBox
Left = 12
Height = 19
Top = 69
Width = 185
Caption = 'Exponentially Smooth'
TabOrder = 3
end
object FourierSmoothChk: TCheckBox
Left = 12
Height = 19
Top = 90
Width = 185
Caption = 'Fourier Filter Smooth'
TabOrder = 4
end
object PolyChk: TCheckBox
Left = 12
Height = 19
Top = 111
Width = 185
Caption = 'Polynomial Regression Smooth'
TabOrder = 5
end
object MRegSmoothChk: TCheckBox
Left = 12
Height = 19
Top = 132
Width = 185
Caption = 'Multiple Regression Smooth'
TabOrder = 6
end
end
object GroupBox5: TGroupBox
AnchorSideLeft.Control = Panel2
AnchorSideTop.Control = Panel2
AnchorSideRight.Control = GroupBox4
AnchorSideRight.Side = asrBottom
Left = 0
Height = 156
Top = 8
Width = 213
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 8
Caption = 'Analysis / Output Options'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ClientHeight = 136
ClientWidth = 209
TabOrder = 0
object PlotChk: TCheckBox
Left = 12
Height = 19
Top = 6
Width = 142
Caption = 'Correlogram'
TabOrder = 0
end
object StatsChk: TCheckBox
Left = 12
Height = 19
Top = 27
Width = 142
Caption = 'Statistics'
TabOrder = 1
end
object RMatChk: TCheckBox
Left = 12
Height = 19
Top = 48
Width = 142
Caption = 'Print correlation Mat.'
TabOrder = 2
end
object PartialsChk: TCheckBox
Left = 12
Height = 19
Top = 69
Width = 142
Caption = 'Partial autocorrelations'
TabOrder = 3
end
object YuleWalkerChk: TCheckBox
Left = 12
Height = 19
Top = 90
Width = 142
Caption = 'Yule-Walker Coef.s'
TabOrder = 4
end
object ResidChk: TCheckBox
Left = 12
Height = 19
Top = 111
Width = 142
Caption = 'Residual Plot'
TabOrder = 5
end
end
end
end

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,67 @@
object AutoPlotFrm: TAutoPlotFrm
Left = 480
Height = 517
Top = 170
Width = 743
Caption = 'Autocorrelation and partial autocorrelation'
ClientHeight = 517
ClientWidth = 743
OnActivate = FormActivate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Image1: TImage
Left = 0
Height = 476
Top = 0
Width = 743
Align = alClient
end
object Panel1: TPanel
Left = 0
Height = 41
Top = 476
Width = 743
Align = alBottom
AutoSize = True
BevelOuter = bvNone
ClientHeight = 41
ClientWidth = 743
TabOrder = 0
object PrintBtn: TButton
AnchorSideTop.Control = Panel1
AnchorSideRight.Control = ReturnBtn
Left = 607
Height = 25
Top = 8
Width = 51
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Print'
OnClick = PrintBtnClick
TabOrder = 0
end
object ReturnBtn: TButton
AnchorSideTop.Control = Panel1
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 670
Height = 25
Top = 8
Width = 61
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Return'
ModalResult = 1
TabOrder = 1
end
end
end

View File

@ -0,0 +1,231 @@
unit AutoPlotUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
ExtCtrls, StdCtrls, Printers,
Globals;
type
{ TAutoPlotFrm }
TAutoPlotFrm = class(TForm)
Image1: TImage;
PrintBtn: TButton;
ReturnBtn: TButton;
Panel1: TPanel;
procedure FormActivate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure PrintBtnClick(Sender: TObject);
procedure AutoPlot(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
correlations, partcors : DblDyneVec;
uplimit, lowlimit : double;
npoints : integer;
DepVarEdit : string;
PlotPartCors : boolean; // true to plot partial correlations
PlotLimits : boolean; // true to show upper and lower limits
end;
var
AutoPlotFrm: TAutoPlotFrm;
implementation
uses
Math;
{ TAutoPlotFrm }
procedure TAutoPlotFrm.FormShow(Sender: TObject);
begin
Image1.Canvas.Brush.Color := clWhite;
Image1.Canvas.FillRect(0, 0, Image1.Width, Image1.Height);
// AutoPlotFrm.Image1.Canvas.Clear;
AutoPlot(self);
end;
procedure TAutoPlotFrm.PrintBtnClick(Sender: TObject);
var r : Trect;
begin
with Printer do
begin
Printer.Orientation := poPortrait;
r := Rect(20,20,printer.pagewidth-20,printer.pageheight div 2 + 20);
BeginDoc;
Canvas.StretchDraw(r,Image1.Picture.BitMap);
EndDoc;
end;
end;
procedure TAutoPlotFrm.AutoPlot(Sender: TObject);
var
topmarg, botmarg, leftmarg, rightmarg, verthi, horizlong : integer;
i, X, Y, middle, yincrement, xincrement, labelheight : integer;
labelstring : string;
labelstr : string;
corstep, yprop, scaley : double;
begin
height := Image1.Canvas.Height;
width := Image1.Canvas.Width;
middle := height div 2;
topmarg := height div 10;
verthi := height - (2 * topmarg);
botmarg := topmarg + verthi;
leftmarg := width div 10;
horizlong := width - 2 * leftmarg;
rightmarg := leftmarg + horizlong;
yincrement := verthi div 20;
xincrement := horizlong div npoints;
// AutoPlotFrm.Show;
Image1.Canvas.Pen.Color := clBlack;
// print title at top, centered
labelstring := 'Autocorrelations analysis for :';
labelstring := labelstring + DepVarEdit;
X := (leftmarg + horizlong div 2) - (Image1.Canvas.TextWidth(labelstring) div 2);
Y := 1;
Image1.Canvas.TextOut(X,Y,labelstring);
// draw middle (zero correlation) axis
Y := middle;
Image1.Canvas.MoveTo(leftmarg,Y);
X := rightmarg;
Image1.Canvas.LineTo(X,Y);
// draw right axis
X := leftmarg;
Y := botmarg;
Image1.Canvas.MoveTo(X,Y);
Y := topmarg;
Image1.Canvas.LineTo(X,Y);
// correlation scale to left of vertical axis
corstep := 1.0;
for i := 0 to 20 do
begin
Y := topmarg + (i * yincrement);
labelstr := format('%4.2f -',[corstep]);
labelstring := labelstr;
X := leftmarg - Image1.Canvas.TextWidth(labelstring);
Image1.Canvas.TextOut(X,Y,labelstring);
corstep := corstep - 0.1;
end;
// Make legend axis on bottom
X := leftmarg;
Y := botmarg;
Image1.Canvas.MoveTo(X,Y);
X := rightmarg;
Image1.Canvas.LineTo(X,Y);
for i := 0 to npoints do
begin
X := leftmarg + (xincrement * i);
labelstring := '|';
Image1.Canvas.TextOut(X,Y,labelstring);
labelstring := IntToStr(i);
Y := Y + 5;
if (i mod 2) = 1 then Image1.Canvas.TextOut(X,Y,labelstring);
Y := botmarg;
end;
labelstring := 'LAG VALUE';
X := (leftmarg + horizlong div 2) - (Image1.Canvas.TextWidth(labelstring) div 2);
Y := botmarg + Image1.Canvas.TextHeight(labelstring);
Image1.Canvas.TextOut(X,Y,labelstring);
// Plot lines from correlation to correlation
Image1.Canvas.Pen.Color := clRed;
for i := 0 to npoints - 1 do
begin
yprop := (1.0 - correlations[i]) / 2.0;
scaley := yprop * verthi;
X := leftmarg + round(xincrement * i);
Y := topmarg + round(scaley);
if (i = 0)then Image1.Canvas.MoveTo(X,Y)
else Canvas.LineTo(X,Y);
Image1.Canvas.Ellipse(X-3,Y-3,X+3,Y+3);
end;
// Plot partial correlations
if PlotPartCors then
begin
Image1.Canvas.Pen.Color := clBlue;
for i := 0 to npoints - 1 do
begin
yprop := (1.0 - partcors[i]) / 2.0;
scaley := yprop * verthi;
X := leftmarg + round(xincrement * i);
Y := topmarg + round(scaley);
if (i = 0) then Image1.Canvas.MoveTo(X,Y)
else Image1.Canvas.LineTo(X,Y);
Image1.Canvas.Ellipse(X-3,Y-3,X+3,Y+3);
end;
end;
// Plot lines for upper and lower 95% confidence levels
if PlotLimits then
begin
Image1.Canvas.Pen.Color := clGreen;
yprop := (1.0 - uplimit) / 2.0;
scaley := yprop * verthi;
Y := topmarg + round(scaley);
Image1.Canvas.MoveTo(leftmarg,Y);
X := rightmarg;
Image1.Canvas.LineTo(X,Y);
yprop := (1.0 - lowlimit) / 2.0;
scaley := yprop * verthi;
Y := topmarg + round(scaley);
Image1.Canvas.MoveTo(leftmarg,Y);
X := rightmarg;
Image1.Canvas.LineTo(X,Y);
end;
// Show legend at right
X := rightmarg;
labelstring := 'Correlations';
labelheight := Image1.Canvas.TextHeight(labelstring);
Y := 5 * labelheight;
Image1.Canvas.Font.Color := clRed;
Image1.Canvas.TextOut(X,Y,labelstring);
if PlotPartCors then
begin
labelstring := 'Partials';
Y := 6 * labelheight;
Image1.Canvas.Font.Color := clBlue;
Image1.Canvas.TextOut(X,Y,labelstring);
end;
if PlotLimits then
begin
Y := 7 * labelheight;
labelstring := '95% C.I.';
Image1.Canvas.Font.Color := clGreen;
Image1.Canvas.TextOut(X,Y,labelstring);
end;
end;
procedure TAutoPlotFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
w := MaxValue([PrintBtn.Width, ReturnBtn.Width]);
PrintBtn.Constraints.MinWidth := w;
ReturnBtn.Constraints.MinWidth := w;
end;
initialization
{$I autoplotunit.lrs}
end.

View File

@ -0,0 +1,484 @@
object CannonFrm: TCannonFrm
Left = 261
Height = 379
Top = 157
Width = 401
AutoSize = True
Caption = 'Canonical Correlation Analysis'
ClientHeight = 379
ClientWidth = 401
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object GroupBox1: TGroupBox
AnchorSideLeft.Control = Owner
AnchorSideBottom.Control = Bevel1
Left = 8
Height = 72
Top = 258
Width = 225
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 8
Caption = 'Options'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 16
ChildSizing.VerticalSpacing = 2
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2
ClientHeight = 52
ClientWidth = 221
TabOrder = 1
object CorsChk: TCheckBox
Left = 12
Height = 19
Top = 6
Width = 87
Caption = 'Correlations'
TabOrder = 0
end
object InvChk: TCheckBox
Left = 115
Height = 19
Top = 6
Width = 94
Caption = 'Matrix Inverse'
TabOrder = 1
end
object EigenChk: TCheckBox
Left = 12
Height = 19
Top = 27
Width = 87
Caption = 'Eigenvectors'
TabOrder = 2
end
object RedundChk: TCheckBox
Left = 115
Height = 19
Top = 27
Width = 94
Caption = 'Redundancies'
TabOrder = 3
end
end
object ResetBtn: TButton
AnchorSideRight.Control = CancelBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 104
Height = 25
Top = 346
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 3
end
object CancelBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 170
Height = 25
Top = 346
Width = 62
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Cancel'
ModalResult = 2
TabOrder = 4
end
object ComputeBtn: TButton
AnchorSideRight.Control = ReturnBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 244
Height = 25
Top = 346
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 5
end
object ReturnBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 332
Height = 25
Top = 346
Width = 61
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Return'
ModalResult = 1
TabOrder = 6
end
object HelpBtn: TButton
Tag = 111
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 41
Height = 25
Top = 346
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 2
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ReturnBtn
Left = 0
Height = 8
Top = 330
Width = 401
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = GroupBox1
Left = 0
Height = 258
Top = 0
Width = 401
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = True
BevelOuter = bvNone
ClientHeight = 258
ClientWidth = 401
TabOrder = 0
object Label1: TLabel
AnchorSideTop.Control = Panel1
Left = 8
Height = 15
Top = 8
Width = 100
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Available Variables:'
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = LeftList
Left = 222
Height = 15
Top = 8
Width = 103
BorderSpacing.Top = 8
Caption = 'Left-Hand Variables'
ParentColor = False
end
object Label3: TLabel
AnchorSideLeft.Control = RightList
AnchorSideTop.Control = VarList
AnchorSideTop.Side = asrCenter
Left = 222
Height = 15
Top = 130
Width = 111
Caption = 'Right-Hand Variables'
ParentColor = False
end
object VarList: TListBox
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = LeftIn
AnchorSideBottom.Control = Panel1
AnchorSideBottom.Side = asrBottom
Left = 8
Height = 225
Top = 25
Width = 170
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Constraints.MinHeight = 220
ItemHeight = 0
MultiSelect = True
TabOrder = 0
end
object LeftIn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
Left = 186
Height = 28
Top = 25
Width = 28
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00216324B81D5E2006FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF002A702F38256929F7216324D9FFFFFF00FFFFFF00FFFFFF00FFFFFF0061BE
6DFF5DB868FF58B162FF53A95CFF4DA156FF47994FFF419149FF3B8842FF3580
3BFF3F8845FF59A15EFF448B49FF216324CFFFFFFF00FFFFFF00FFFFFF0065C3
71FFA0D7A9FF9CD5A5FF98D3A1FF94D09DFF90CE98FF8BCB93FF87C98EFF82C6
89FF7EC384FF7AC180FF76BE7CFF458C4AFF216324C4FFFFFF00FFFFFF0068C7
74FFA5DAAEFFA2D8ABFF9ED6A7FF9AD4A3FF96D29FFF93CF9AFF8ECC95FF89CA
90FF85C78BFF81C587FF7DC282FF4A9150FF256929C9FFFFFF00FFFFFF0068C7
74FF68C774FF65C371FF61BE6DFF5DB868FF58B162FF53A95CFF4DA156FF4799
4FFF419149FF5AA362FF559D5CFF2F7835D1FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00419149F73B8842DBFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0047994FBB41914906FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = LeftInClick
Spacing = 0
TabOrder = 1
end
object LeftOut: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = LeftIn
AnchorSideTop.Side = asrBottom
Left = 186
Height = 28
Top = 57
Width = 28
BorderSpacing.Top = 4
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF004DA1560647994FB8FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0053A95CD94DA156F747994F38FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF005DB868CF71BE7BFF7AC183FF5BAA64FF47994FFF419149FF3B8842FF3580
3BFF2F7835FF2A702FFF256929FF216324FF1D5E20FFFFFFFF00FFFFFF0065C3
71C47BC886FF9CD5A5FF98D3A1FF94D09DFF90CE98FF8BCB93FF87C98EFF82C6
89FF7EC384FF7AC180FF76BE7CFF72BD78FF216324FFFFFFFF00FFFFFF0068C7
74C97FCC8AFFA2D8ABFF9ED6A7FF9AD4A3FF96D29FFF93CF9AFF8ECC95FF89CA
90FF85C78BFF81C587FF7DC282FF78C07EFF256929FFFFFFFF00FFFFFF00FFFF
FF0068C774D180CD8BFF7CC987FF5DB868FF58B162FF53A95CFF4DA156FF4799
4FFF419149FF3B8842FF35803BFF2F7835FF2A702FFFFFFFFF00FFFFFF00FFFF
FF00FFFFFF0068C774DB65C371F7FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0068C7740668C774BBFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = LeftOutClick
Spacing = 0
TabOrder = 2
end
object RightIn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = RightOut
Left = 186
Height = 28
Top = 190
Width = 28
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 4
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00216324B81D5E2006FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF002A702F38256929F7216324D9FFFFFF00FFFFFF00FFFFFF00FFFFFF0061BE
6DFF5DB868FF58B162FF53A95CFF4DA156FF47994FFF419149FF3B8842FF3580
3BFF3F8845FF59A15EFF448B49FF216324CFFFFFFF00FFFFFF00FFFFFF0065C3
71FFA0D7A9FF9CD5A5FF98D3A1FF94D09DFF90CE98FF8BCB93FF87C98EFF82C6
89FF7EC384FF7AC180FF76BE7CFF458C4AFF216324C4FFFFFF00FFFFFF0068C7
74FFA5DAAEFFA2D8ABFF9ED6A7FF9AD4A3FF96D29FFF93CF9AFF8ECC95FF89CA
90FF85C78BFF81C587FF7DC282FF4A9150FF256929C9FFFFFF00FFFFFF0068C7
74FF68C774FF65C371FF61BE6DFF5DB868FF58B162FF53A95CFF4DA156FF4799
4FFF419149FF5AA362FF559D5CFF2F7835D1FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00419149F73B8842DBFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0047994FBB41914906FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = RightInClick
Spacing = 0
TabOrder = 4
end
object RightOut: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = VarList
AnchorSideBottom.Side = asrBottom
Left = 186
Height = 28
Top = 222
Width = 28
Anchors = [akLeft, akBottom]
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF004DA1560647994FB8FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0053A95CD94DA156F747994F38FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF005DB868CF71BE7BFF7AC183FF5BAA64FF47994FFF419149FF3B8842FF3580
3BFF2F7835FF2A702FFF256929FF216324FF1D5E20FFFFFFFF00FFFFFF0065C3
71C47BC886FF9CD5A5FF98D3A1FF94D09DFF90CE98FF8BCB93FF87C98EFF82C6
89FF7EC384FF7AC180FF76BE7CFF72BD78FF216324FFFFFFFF00FFFFFF0068C7
74C97FCC8AFFA2D8ABFF9ED6A7FF9AD4A3FF96D29FFF93CF9AFF8ECC95FF89CA
90FF85C78BFF81C587FF7DC282FF78C07EFF256929FFFFFFFF00FFFFFF00FFFF
FF0068C774D180CD8BFF7CC987FF5DB868FF58B162FF53A95CFF4DA156FF4799
4FFF419149FF3B8842FF35803BFF2F7835FF2A702FFFFFFFFF00FFFFFF00FFFF
FF00FFFFFF0068C774DB65C371F7FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0068C7740668C774BBFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = RightOutClick
Spacing = 0
TabOrder = 5
end
object LeftList: TListBox
AnchorSideLeft.Control = LeftIn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Label3
Left = 222
Height = 89
Top = 25
Width = 171
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
BorderSpacing.Bottom = 16
ItemHeight = 0
TabOrder = 3
end
object RightList: TListBox
AnchorSideLeft.Control = LeftList
AnchorSideTop.Control = Label3
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = LeftList
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = VarList
AnchorSideBottom.Side = asrBottom
Left = 222
Height = 103
Top = 147
Width = 171
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
ItemHeight = 0
TabOrder = 6
end
end
end

View File

@ -0,0 +1,621 @@
unit CanonUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons, ExtCtrls,
MainUnit, OutputUnit, FunctionsLib, GraphLib, Globals, MatrixLib,
ContextHelpUnit;
type
{ TCannonFrm }
TCannonFrm = class(TForm)
Bevel1: TBevel;
HelpBtn: TButton;
Panel1: TPanel;
ResetBtn: TButton;
CancelBtn: TButton;
ComputeBtn: TButton;
ReturnBtn: TButton;
CorsChk: TCheckBox;
InvChk: TCheckBox;
EigenChk: TCheckBox;
RedundChk: TCheckBox;
GroupBox1: TGroupBox;
LeftIn: TBitBtn;
LeftOut: TBitBtn;
RightIn: TBitBtn;
RightOut: TBitBtn;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
LeftList: TListBox;
RightList: TListBox;
VarList: TListBox;
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
procedure LeftInClick(Sender: TObject);
procedure LeftOutClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure RightInClick(Sender: TObject);
procedure RightOutClick(Sender: TObject);
private
{ private declarations }
FAutoSized: Boolean;
public
{ public declarations }
end;
var
CannonFrm: TCannonFrm;
implementation
uses
Math;
{ TCannonFrm }
procedure TCannonFrm.ResetBtnClick(Sender: TObject);
VAR i : integer;
begin
VarList.Clear;
LeftList.Clear;
RightList.Clear;
LeftOut.Enabled := false;
LeftIn.Enabled := true;
RightOut.Enabled := false;
RightIn.Enabled := true;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
end;
procedure TCannonFrm.RightInClick(Sender: TObject);
VAR i, index : integer;
begin
index := VarList.Items.Count;
i := 0;
while i < index do
begin
if (VarList.Selected[i]) then
begin
RightList.Items.Add(VarList.Items.Strings[i]);
VarList.Items.Delete(i);
index := index - 1;
i := 0;
end
else i := i + 1;
end;
RightOut.Enabled := true;
end;
procedure TCannonFrm.RightOutClick(Sender: TObject);
VAR index : integer;
begin
index := RightList.ItemIndex;
if index < 0 then
begin
RightOut.Enabled := false;
exit;
end;
VarList.Items.Add(RightList.Items.Strings[index]);
RightList.Items.Delete(index);
end;
procedure TCannonFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([HelpBtn.Width, ResetBtn.Width, CancelBtn.Width, ComputeBtn.Width, ReturnBtn.Width]);
HelpBtn.Constraints.MinWidth := w;
ResetBtn.Constraints.MinWidth := w;
CancelBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
ReturnBtn.Constraints.MinWidth := w;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TCannonFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
if OutputFrm = nil then Application.CreateForm(TOutputFrm, OutputFrm);
end;
procedure TCannonFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TCannonFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).tag);
end;
procedure TCannonFrm.ComputeBtnClick(Sender: TObject);
label cleanup;
var
i, j, k, count, a_size, b_size, no_factors, novars, IER: integer;
outline, cellstring, gridstring: string;
s, m, n, df1, df2, q, w, pcnt_extracted, trace : double;
minroot, critical_prob, Lambda, Pillia : double;
chisqr, HLTrace, chiprob, ftestprob, Roys, f, Hroot : double;
raa, rbb, rab, rba, bigmat, prod, first_prod, second_prod : DblDyneMat;
char_equation, raainv, rbbinv, eigenvectors, norm_a, norm_b : DblDyneMat;
raw_a, raw_b, a_cors, b_cors, eigentrans, theta, tempmat : DblDyneMat;
mean, variance, stddev, roots, root_chi, chi_prob, pv_a, pv_b : DblDyneVec;
rd_a, rd_b, pcnt_trace : DblDyneVec;
root_df, a_vars, b_vars : IntDyneVec;
selected : IntDyneVec;
RowLabels, ColLabels : StrDyneVec;
CanLabels : StrDyneVec;
NCases : integer;
title : string;
errorcode : boolean = false;
begin
k := 0;
no_factors := 0;
pcnt_extracted := 0.0;
trace := 0.0;
minroot := 0.0;
critical_prob := 0.0;
Pillia := 0.0;
chisqr := 0.0;
HLTrace := 0.0;
chiprob := 0.0;
// Get size of the Left and Right matrices (predictors and dependents)
a_size := LeftList.Items.Count;
b_size := RightList.Items.Count;
novars := a_size + b_size;
// allocate memory for matrices and vectors
SetLength(raa,a_size,a_size);
SetLength(rbb,b_size,b_size);
SetLength(rab,a_size,b_size);
SetLength(rba,b_size,a_size);
SetLength(bigmat,novars+1,novars+1);
SetLength(prod,novars,novars);
SetLength(first_prod,novars,novars);
SetLength(second_prod,novars,novars);
SetLength(char_equation,novars,novars);
SetLength(raainv,a_size,a_size);
SetLength(rbbinv,b_size,b_size);
SetLength(eigenvectors,novars,novars);
SetLength(norm_a,novars,novars);
SetLength(norm_b,novars,novars);
SetLength(raw_a,novars,novars);
SetLength(raw_b,novars,novars);
SetLength(a_cors,novars,novars);
SetLength(b_cors,novars,novars);
SetLength(eigentrans,novars,novars);
SetLength(theta,novars,novars);
SetLength(tempmat,novars,novars);
SetLength(mean,novars);
SetLength(variance,novars);
SetLength(stddev,novars);
SetLength(roots,novars);
SetLength(root_chi,novars);
SetLength(chi_prob,novars);
SetLength(pv_a,novars);
SetLength(pv_b,novars);
SetLength(rd_a,novars);
SetLength(rd_b,novars);
SetLength(pcnt_trace,novars);
SetLength(root_df,novars);
SetLength(a_vars,a_size);
SetLength(b_vars,b_size);
SetLength(CanLabels,novars);
SetLength(RowLabels,novars);
SetLength(ColLabels,novars);
SetLength(Selected,novars);
//------------ WORK STARTS HERE! -------------------------------------
// Build labels for canonical functions 1 to novars
for i := 1 to b_size do
CanLabels[i-1]:='Var. ' + IntToStr(i);
// identify variables selected for left and right variables
for i := 0 to a_size - 1 do // identify left variables
begin
cellstring := LeftList.Items.Strings[i];
for j := 1 to NoVariables do
begin
gridstring := OS3MainFrm.DataGrid.Cells[j,0];
if (cellstring = gridstring) then
begin
a_vars[i] := j;
RowLabels[i] := gridstring;
end;
end;
end;
for i := 0 to b_size - 1 do // identify left variables
begin
cellstring := RightList.Items.Strings[i];
for j := 1 to NoVariables do
begin
gridstring := OS3MainFrm.DataGrid.Cells[j,0];
if (cellstring = gridstring) then
begin
b_vars[i] := j;
ColLabels[i] := gridstring;
end;
end;
end;
// build list of all variables selected
for i := 1 to a_size do selected[i-1] := a_vars[i-1];
for i := 1 to b_size do selected[i-1 + a_size] := b_vars[i-1];
OutputFrm.RichEdit.Clear;
OutputFrm.RichEdit.Lines.Add('CANONICAL CORRELATION ANALYSIS');
OutputFrm.RichEdit.Lines.Add('');
// Get means, standard deviations, etc. for total matrix
Correlations(novars,selected,bigmat,mean,variance,stddev,errorcode,Ncases);
count := Ncases;
if (IER = 1)then
begin
ShowMessage('Zero variance found for a variable-terminating');
goto cleanup;
end;
//partition matrix into quadrants
for i := 1 to a_size do
for j := 1 to a_size do raa[i-1,j-1]:= bigmat[i-1,j-1];
for i := a_size + 1 to novars do
for j := a_size + 1 to novars do
rbb[i-1-a_size,j-1-a_size] := bigmat[i-1,j-1];
for i := 1 to a_size do
for j := a_size + 1 to novars do
rab[i-1,j-1-a_size] := bigmat[i-1,j-1];
for i := a_size + 1 to novars do
for j := 1 to a_size do
rba[i-1-a_size,j-1] := bigmat[i-1,j-1];
if CorsChk.Checked then
begin
title := 'Left Correlation Matrix';
MAT_PRINT(raa,a_size,a_size,title,RowLabels,RowLabels,NCases);
title := 'Right Correlation Matrix';
MAT_PRINT(rbb,b_size,b_size,title,ColLabels,ColLabels,NCases);
title := 'Left-Right Correlation Matrix';
MAT_PRINT(rab,a_size,b_size,title,RowLabels,ColLabels,NCases);
OutputFrm.ShowModal;
OutputFrm.RichEdit.Clear;
end;
// get inverses of left and right hand matrices raa and rbb
for i := 1 to a_size do
for j := 1 to a_size do
raainv[i-1,j-1] := raa[i-1,j-1];
SVDinverse(raainv,a_size);
if InvChk.Checked then
begin
title := 'Inverse of Left Matrix';
MAT_PRINT(raainv,a_size,a_size,title,RowLabels,RowLabels,NCases);
end;
for i := 1 to b_size do
for j := 1 to b_size do
rbbinv[i-1,j-1] := rbb[i-1,j-1];
SVDinverse(rbbinv,b_size);
if InvChk.Checked then
begin
title := 'Inverse of Right Matrix';
MAT_PRINT(rbbinv,b_size,b_size,title,ColLabels,ColLabels,NCases);
end;
// get products of raainv x rab and the rbbinv x rba matrix
MatAxB(first_prod,rbbinv,rba,b_size,b_size,b_size,a_size,errorcode);
MatAxB(second_prod,raainv,rab,a_size,a_size,a_size,b_size,errorcode);
title := 'Right Inverse x Right-Left Matrix';
MAT_PRINT(first_prod,b_size,a_size,title,ColLabels,RowLabels,NCases);
title := 'Left Inverse x Left-Right Matrix';
MAT_PRINT(second_prod,a_size,b_size,title,RowLabels,ColLabels,NCases);
//get characteristic equations matrix (product of last two product matrices
//The product should yeild rows and cols representing the smaller of the two sets
MatAxB(char_equation,first_prod,second_prod,b_size,a_size, a_size,b_size,errorcode);
title := 'Canonical Function';
MAT_PRINT(char_equation,b_size,b_size,title,CanLabels,CanLabels,NCases);
OutputFrm.ShowModal;
OutputFrm.RichEdit.Clear;
// now get roots and vectors of the characteristic equation using
// NonSymRoots routine
minroot := 0.0;
for i := 1 to b_size do
begin
roots[i-1] := 0.0;
pcnt_trace[i-1] := 0.0;
for j := 1 to b_size do eigenvectors[i-1,j-1] := 0.0;
end;
trace := 0.0;
no_factors := b_size;
nonsymroots(char_equation, b_size, no_factors, minroot, eigenvectors, roots,
pcnt_trace, trace, pcnt_extracted);
outline := format('Trace of the matrix:=%10.4f',[trace]);
OutputFrm.RichEdit.Lines.Add(outline);
outline := format('Percent of trace extracted: %10.4f',[pcnt_extracted]);
OutputFrm.RichEdit.Lines.Add(outline);
// Normalize smaller set weights and coumpute larger set weights
MATTRN(eigentrans,eigenvectors,b_size,b_size);
MatAxB(tempmat,eigentrans,rbb,b_size,b_size,b_size,b_size,errorcode);
MatAxB(theta,tempmat,eigenvectors,b_size,b_size,b_size,b_size,errorcode);
for j := 1 to b_size do
begin
q := 1.0 / sqrt(theta[j-1,j-1]);
for i := 1 to b_size do
begin
norm_b[i-1,j-1] := eigenvectors[i-1,j-1] * q;
raw_b[i-1,j-1] := norm_b[i-1,j-1] / stddev[a_size+i-1];
end;
end;
MatAxB(norm_a,second_prod,norm_b,a_size,b_size,b_size,b_size,errorcode);
for j := 1 to b_size do
begin
for i := 1 to a_size do
begin
norm_a[i-1,j-1] := norm_a[i-1,j-1] * (1.0 / sqrt(roots[j-1]));
raw_a[i-1,j-1] := norm_a[i-1,j-1] / stddev[i-1];
end;
end;
// Compute the correlations between variables and canonical variables
MatAxB(a_cors,raa,norm_a,a_size,a_size,a_size,b_size,errorcode);
for j := 1 to b_size do
begin
q := 0.0;
for i := 1 to a_size do q := q + norm_a[i-1,j-1] * a_cors[i-1,j-1];
q := 1.0 / sqrt(q);
for i := 1 to a_size do a_cors[i-1,j-1] := a_cors[i-1,j-1] * q;
end;
MatAxB(b_cors,rbb,norm_b,b_size,b_size,b_size,b_size,errorcode);
for j := 1 to b_size do
begin
q := 0.0;
for i := 1 to b_size do q := q + norm_b[i-1,j-1] * b_cors[i-1,j-1];
q := 1.0 / sqrt(q);
for i := 1 to b_size do b_cors[i-1,j-1] := b_cors[i-1,j-1] * q;
end;
// Compute the Proportions of Variance (PVs) and Redundancy Coefficients
for j := 1 to b_size do
begin
pv_a[j-1] := 0.0;
for i := 1 to a_size do pv_a[j-1] := pv_a[j-1] + (a_cors[i-1,j-1] * a_cors[i-1,j-1]);
pv_a[j-1] := pv_a[j-1] / a_size;
rd_a[j-1] := pv_a[j-1] * roots[j-1];
end;
for j := 1 to b_size do
begin
pv_b[j-1] := 0.0;
for i := 1 to b_size do pv_b[j-1] := pv_b[j-1] + (b_cors[i-1,j-1] * b_cors[i-1,j-1]);
pv_b[j-1] := pv_b[j-1] / b_size;
rd_b[j-1] := pv_b[j-1] * roots[j-1];
end;
// Compute tests of the roots
q := a_size + b_size + 1;
q := -(count - 1.0 - (q / 2.0));
k := 0;
for i := 1 to b_size do
begin
w := 1.0;
for j := i to b_size do w := w * (1.0 - roots[j-1]);
root_chi[i-1] := q * ln(w);
root_df[i-1] := (a_size - i + 1) * (b_size - i + 1);
chi_prob[i-1] := 1.0 - chisquaredprob(root_chi[i-1],root_df[i-1]);
if (chi_prob[i-1] < critical_prob) then k := k + 1;
end;
Roys := roots[0] / (1.0 - roots[0]);
Lambda := 1.0;
for i := 1 to b_size do
begin
Hroot := roots[i-1] / (1.0 - roots[i-1]);
Lambda := Lambda * (1.0 / (1.0 + Hroot));
Pillia := Pillia + (Hroot / (1.0 + Hroot));
HLTrace := HLTrace + Hroot;
end;
// Print remaining results
OutputFrm.RichEdit.Lines.Add('');
OutputFrm.RichEdit.Lines.Add('');
outline := ' Canonical R Root % Trace Chi-Sqr D.F. Prob.';
OutputFrm.RichEdit.Lines.Add(outline);
for i := 1 to b_size do
begin
outline := format('%2d %10.6f %8.3f %7.3f %8.3f %2d %8.3f',
[i, sqrt(roots[i-1]), roots[i-1], pcnt_trace[i-1], root_chi[i-1], root_df[i-1], chi_prob[i-1]]);
OutputFrm.RichEdit.Lines.Add(outline);
end;
chisqr := -ln(Lambda) * (count - 1.0 - 0.5 * (a_size + b_size - 1.0));
chiprob := 1.0 - chisquaredprob(chisqr,a_size * b_size);
OutputFrm.RichEdit.Lines.Add('');
OutputFrm.RichEdit.Lines.Add('Overall Tests of Significance:');
OutputFrm.RichEdit.Lines.Add(' Statistic Approx. Stat. Value D.F. Prob.>Value');
outline := format('Wilk''s Lambda Chi-Squared %10.4f %3d %6.4f',
[chisqr,a_size * b_size,chiprob]);
OutputFrm.RichEdit.Lines.Add(outline);
s := b_size;
m := 0.5 * (a_size - b_size - 1);
n := 0.5 * (count - b_size - a_size - 2);
f := (HLTrace * 2.0 * (s * n + 1)) / (s * s * (2.0 * m + s + 1.0));
df1 := s * (2.0 * m + s + 1.0);
df2 := 2.0 * ( s * n + 1.0);
ftestprob := probf(f,df1,df2);
outline := format('Hotelling-Lawley Trace F-Test %10.4f %2.0f %2.0f %6.4f',
[f, df1,df2, ftestprob]);
OutputFrm.RichEdit.Lines.Add(outline);
df2 := s * (2.0 * n + s + 1.0);
f := (Pillia / (s - Pillia)) * ( (2.0 * n + s +1.0) / (2.0 * m + s + 1.0) );
ftestprob := probf(f,df1,df2);
outline := format('Pillai Trace F-Test %10.4f %2.0f %2.0f %6.4f',
[f, df1,df2, ftestprob]);
OutputFrm.RichEdit.Lines.Add(outline);
Roys := Roys * (count - 1 - a_size + b_size)/ a_size ;
df1 := a_size;
df2 := count - 1 - a_size + b_size;
ftestprob := probf(Roys,df1,df2);
outline := format('Roys Largest Root F-Test %10.4f %2.0f %2.0f %6.4f',
[Roys, df1, df2, ftestprob]);
OutputFrm.RichEdit.Lines.Add(outline);
OutputFrm.ShowModal;
OutputFrm.RichEdit.Clear;
if EigenChk.Checked then
begin
title := 'Eigenvectors';
MAT_PRINT(eigenvectors,b_size,b_size,title,CanLabels,CanLabels,NCases);
OutputFrm.ShowModal();
OutputFrm.RichEdit.Clear;
end;
title := 'Standardized Right Side Weights';
MAT_PRINT(norm_a,a_size,b_size,title,RowLabels,CanLabels,NCases);
title := 'Standardized Left Side Weights';
MAT_PRINT(norm_b,b_size,b_size,title,ColLabels,CanLabels,NCases);
OutputFrm.ShowModal;
OutputFrm.RichEdit.Clear;
title := 'Raw Right Side Weights';
MAT_PRINT(raw_a,a_size,b_size,title,RowLabels,CanLabels,NCases);
title := 'Raw Left Side Weights';
MAT_PRINT(raw_b,b_size,b_size,title,ColLabels,CanLabels,NCases);
OutputFrm.ShowModal;
OutputFrm.RichEdit.Clear;
title := 'Right Side Correlations with Function';
MAT_PRINT(a_cors,a_size,b_size,title,RowLabels,CanLabels,NCases);
title := 'Left Side Correlations with Function';
MAT_PRINT(b_cors,b_size,b_size,title,ColLabels,CanLabels,NCases);
OutputFrm.ShowModal;
OutputFrm.RichEdit.Clear;
if RedundChk.Checked then
begin
outline := 'Redundancy Analysis for Right Side Variables';
OutputFrm.RichEdit.Lines.Add(outline);
OutputFrm.RichEdit.Lines.Add('');
outline := ' Variance Prop. Redundancy';
OutputFrm.RichEdit.Lines.Add(outline);
for i := 1 to b_size do
begin
outline := format('%10d %10.5f %10.5f',[i,pv_a[i-1],rd_a[i-1]]);
OutputFrm.RichEdit.Lines.Add(outline);
end;
OutputFrm.RichEdit.Lines.Add('');
outline := 'Redundancy Analysis for Left Side Variables';
OutputFrm.RichEdit.Lines.Add(outline);
outline := ' Variance Prop. Redundancy';
OutputFrm.RichEdit.Lines.Add(outline);
for i := 1 to b_size do
begin
outline := format('%10d %10.5f %10.5f',[i,pv_b[i-1],rd_b[i-1]]);
OutputFrm.RichEdit.Lines.Add(outline);
end;
OutputFrm.ShowModal;
OutputFrm.RichEdit.Clear;
end;
//------------- Now, clean up memory mess ----------------------------
cleanup:
Selected := nil;
ColLabels := nil;
RowLabels := nil;
CanLabels := nil;
b_vars := nil;
a_vars := nil;
root_df := nil;
pcnt_trace := nil;
rd_b := nil;
rd_a := nil;
pv_b := nil;
pv_a := nil;
chi_prob := nil;
root_chi := nil;
roots := nil;
stddev := nil;
variance := nil;
mean := nil;
tempmat := nil;
theta := nil;
eigentrans := nil;
b_cors := nil;
a_cors := nil;
raw_b := nil;
raw_a := nil;
norm_b := nil;
norm_a := nil;
eigenvectors := nil;
rbbinv := nil;
raainv := nil;
char_equation := nil;
second_prod := nil;
first_prod := nil;
prod := nil;
rba := nil;
rab := nil;
rbb := nil;
raa := nil;
end;
procedure TCannonFrm.LeftInClick(Sender: TObject);
VAR i, index : integer;
begin
index := VarList.Items.Count;
i := 0;
while i < index do
begin
if (VarList.Selected[i]) then
begin
LeftList.Items.Add(VarList.Items.Strings[i]);
VarList.Items.Delete(i);
index := index - 1;
i := 0;
end
else i := i + 1;
end;
LeftOut.Enabled := true;
end;
procedure TCannonFrm.LeftOutClick(Sender: TObject);
VAR index : integer;
begin
index := LeftList.ItemIndex;
if index < 0 then
begin
LeftOut.Enabled := false;
exit;
end;
VarList.Items.Add(LeftList.Items.Strings[index]);
LeftList.Items.Delete(index);
end;
initialization
{$I canonunit.lrs}
end.

View File

@ -0,0 +1,153 @@
object DifferenceFrm: TDifferenceFrm
Left = 611
Height = 115
Top = 292
Width = 318
AutoSize = True
BorderStyle = bsDialog
Caption = 'Differencing Specification'
ClientHeight = 115
ClientWidth = 318
OnActivate = FormActivate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object CancelBtn: TButton
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
Left = 128
Height = 25
Top = 78
Width = 62
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Cancel'
ModalResult = 2
TabOrder = 2
end
object OKBtn: TButton
AnchorSideLeft.Control = CancelBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
Left = 202
Height = 25
Top = 78
Width = 42
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 16
BorderSpacing.Bottom = 8
Caption = 'OK'
ModalResult = 1
TabOrder = 3
end
object HelpBtn: TButton
Tag = 121
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = CancelBtn
Left = 65
Height = 25
Top = 78
Width = 51
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Left = 16
BorderSpacing.Top = 8
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 1
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Owner
Left = 68
Height = 50
Top = 8
Width = 183
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BevelOuter = bvNone
ClientHeight = 50
ClientWidth = 183
TabOrder = 0
object Label1: TLabel
AnchorSideTop.Control = LagEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = LagEdit
Left = 13
Height = 15
Top = 4
Width = 108
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Difference for lag of:'
ParentColor = False
end
object Label2: TLabel
AnchorSideTop.Control = OrderEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = OrderEdit
Left = 0
Height = 15
Top = 31
Width = 121
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'No. of times to repeat: '
ParentColor = False
end
object LagEdit: TEdit
AnchorSideTop.Control = Panel1
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 129
Height = 23
Top = 0
Width = 54
Alignment = taRightJustify
Anchors = [akTop, akRight]
TabOrder = 0
Text = '1'
end
object OrderEdit: TEdit
AnchorSideTop.Control = LagEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 129
Height = 23
Top = 27
Width = 54
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Top = 4
TabOrder = 1
Text = '1'
end
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 8
Top = 62
Width = 318
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 4
Shape = bsBottomLine
end
end

View File

@ -0,0 +1,71 @@
unit DifferenceUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, contexthelpunit;
type
{ TDifferenceFrm }
TDifferenceFrm = class(TForm)
Bevel1: TBevel;
CancelBtn: TButton;
HelpBtn: TButton;
OKBtn: TButton;
LagEdit: TEdit;
OrderEdit: TEdit;
Label1: TLabel;
Label2: TLabel;
Panel1: TPanel;
procedure FormActivate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
DifferenceFrm: TDifferenceFrm;
implementation
uses
Math;
{ TDifferenceFrm }
procedure TDifferenceFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
w := MaxValue([HelpBtn.Width, CancelBtn.Width, OKBtn.Width]);
HelpBtn.Constraints.MinWidth := w;
CancelBtn.Constraints.MinWidth := w;
OKBtn.Constraints.MinWidth := w;
end;
procedure TDifferenceFrm.FormShow(Sender: TObject);
begin
LagEdit.Text := '1';
OrderEdit.Text := '1';
end;
procedure TDifferenceFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).tag);
end;
initialization
{$I differenceunit.lrs}
end.

View File

@ -0,0 +1,137 @@
object ExpSmoothFrm: TExpSmoothFrm
Left = 659
Height = 131
Top = 369
Width = 352
AutoSize = True
BorderStyle = bsDialog
Caption = 'Exponential Smoothing Form'
ClientHeight = 131
ClientWidth = 352
OnActivate = FormActivate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Label1: TLabel
AnchorSideTop.Control = AlphaEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = AlphaEdit
Left = 101
Height = 15
Top = 12
Width = 45
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Alpha = '
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = AlphaScroll
AnchorSideTop.Side = asrBottom
Left = 8
Height = 15
Top = 66
Width = 15
BorderSpacing.Left = 8
BorderSpacing.Top = 4
Caption = '0.0'
ParentColor = False
end
object Label3: TLabel
AnchorSideTop.Control = AlphaScroll
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 329
Height = 15
Top = 66
Width = 15
Anchors = [akTop, akRight]
BorderSpacing.Top = 4
BorderSpacing.Right = 8
Caption = '1.0'
ParentColor = False
end
object AlphaEdit: TEdit
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Owner
Left = 154
Height = 23
Top = 8
Width = 44
Alignment = taRightJustify
BorderSpacing.Top = 8
TabOrder = 0
Text = '0.99'
end
object AlphaScroll: TScrollBar
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = AlphaEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 8
Height = 23
Top = 39
Width = 336
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Max = 1
PageSize = 0
Position = 1
TabOrder = 1
OnChange = AlphaScrollChange
end
object CancelBtn: TButton
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = OKBtn
Left = 228
Height = 25
Top = 97
Width = 62
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Cancel'
ModalResult = 2
TabOrder = 2
end
object OKBtn: TButton
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 302
Height = 25
Top = 97
Width = 42
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'OK'
ModalResult = 1
TabOrder = 3
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label3
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 8
Top = 81
Width = 352
Anchors = [akTop, akLeft, akRight]
Shape = bsBottomLine
end
end

View File

@ -0,0 +1,68 @@
unit ExpSmoothUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls;
type
{ TExpSmoothFrm }
TExpSmoothFrm = class(TForm)
AlphaEdit: TEdit;
Bevel1: TBevel;
CancelBtn: TButton;
OKBtn: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
AlphaScroll: TScrollBar;
procedure AlphaScrollChange(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
alpha : double;
end;
var
ExpSmoothFrm: TExpSmoothFrm;
implementation
uses
Math;
{ TExpSmoothFrm }
procedure TExpSmoothFrm.FormActivate(Sender: TObject);
begin
OKBtn.Constraints.MinWidth := MaxValue([OKBtn.Width, CancelBtn.Width]);
CancelBtn.Constraints.MinWidth := OKBtn.Constraints.MinWidth;
end;
procedure TExpSmoothFrm.FormShow(Sender: TObject);
begin
AlphaEdit.Text := '0.99';
AlphaScroll.Position := 99;
alpha := 0.99;
end;
procedure TExpSmoothFrm.AlphaScrollChange(Sender: TObject);
begin
AlphaEdit.Text := FloatToStr(AlphaScroll.Position / 100.0);
alpha := AlphaScroll.Position / 100.0;
end;
initialization
{$I expsmoothunit.lrs}
end.

View File

@ -0,0 +1,122 @@
object FFTFrm: TFFTFrm
Left = 648
Height = 127
Top = 346
Width = 305
BorderStyle = bsDialog
Caption = 'Fourier Transform Form'
ClientHeight = 127
ClientWidth = 305
OnActivate = FormActivate
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object CancelBtn: TButton
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = OKBtn
Left = 177
Height = 25
Top = 93
Width = 62
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Cancel'
ModalResult = 2
TabOrder = 1
end
object OKBtn: TButton
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 251
Height = 25
Top = 93
Width = 42
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'OK'
ModalResult = 1
TabOrder = 2
end
object Memo1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 8
Height = 30
Top = 8
Width = 289
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Enter the number of data points to include in the Fourier smoothing.'
ParentColor = False
WordWrap = True
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Memo1
AnchorSideTop.Side = asrBottom
Left = 66
Height = 23
Top = 50
Width = 172
AutoSize = True
BorderSpacing.Left = 64
BorderSpacing.Top = 12
BorderSpacing.Right = 64
BorderSpacing.Bottom = 4
BevelOuter = bvNone
ClientHeight = 23
ClientWidth = 172
TabOrder = 0
object Label1: TLabel
AnchorSideTop.Control = NptsEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = NptsEdit
Left = 0
Height = 15
Top = 4
Width = 100
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Number of points: '
ParentColor = False
end
object NptsEdit: TEdit
AnchorSideTop.Control = Panel1
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 108
Height = 23
Top = 0
Width = 64
Alignment = taRightJustify
Anchors = [akTop, akRight]
TabOrder = 0
end
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 8
Top = 77
Width = 305
Anchors = [akTop, akLeft, akRight]
Shape = bsBottomLine
end
end

View File

@ -0,0 +1,53 @@
unit FFTUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls;
type
{ TFFTFrm }
TFFTFrm = class(TForm)
Bevel1: TBevel;
CancelBtn: TButton;
Memo1: TLabel;
OKBtn: TButton;
NptsEdit: TEdit;
Label1: TLabel;
Panel1: TPanel;
procedure FormActivate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
FFTFrm: TFFTFrm;
implementation
uses
Math;
{ TFFTFrm }
procedure TFFTFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
w := MaxValue([CancelBtn.Width, OKBtn.Width]);
CancelBtn.Constraints.MinWidth := w;
OKBtn.Constraints.MinWidth := w;
end;
initialization
{$I fftunit.lrs}
end.

View File

@ -0,0 +1,154 @@
object MoveAvgFrm: TMoveAvgFrm
Left = 434
Height = 307
Top = 163
Width = 372
Caption = 'Moving Average Specification Form'
ClientHeight = 307
ClientWidth = 372
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Label1: TLabel
AnchorSideTop.Control = OrderEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = OrderEdit
Left = 38
Height = 15
Top = 17
Width = 36
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Order: '
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = ThetaEdit
AnchorSideTop.Side = asrCenter
Left = 8
Height = 15
Top = 52
Width = 66
BorderSpacing.Left = 8
Caption = 'Theta Value: '
ParentColor = False
end
object OrderEdit: TEdit
AnchorSideLeft.Control = ThetaEdit
AnchorSideRight.Control = ThetaList
AnchorSideRight.Side = asrBottom
Left = 82
Height = 23
Top = 13
Width = 118
Alignment = taRightJustify
OnKeyPress = OrderEditKeyPress
TabOrder = 0
Text = 'OrderEdit'
end
object ThetaEdit: TEdit
AnchorSideLeft.Control = Label2
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = ThetaList
AnchorSideRight.Side = asrBottom
Left = 82
Height = 23
Top = 48
Width = 118
Alignment = taRightJustify
BorderSpacing.Left = 8
OnKeyPress = ThetaEditKeyPress
TabOrder = 1
Text = 'ThetaEdit'
end
object ThetaList: TListBox
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Panel1
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 8
Height = 219
Top = 80
Width = 286
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
ItemHeight = 0
OnClick = ThetaListClick
TabOrder = 2
end
object Panel1: TPanel
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 302
Height = 157
Top = 142
Width = 62
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
BevelOuter = bvNone
ChildSizing.VerticalSpacing = 8
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ClientHeight = 157
ClientWidth = 62
TabOrder = 3
object HelpBtn: TButton
Tag = 132
Left = 0
Height = 25
Top = 0
Width = 62
AutoSize = True
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 0
end
object ResetBtn: TButton
Left = 0
Height = 25
Top = 33
Width = 62
AutoSize = True
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 1
end
object CancelBtn: TButton
Left = 0
Height = 25
Top = 66
Width = 62
AutoSize = True
Caption = 'Cancel'
ModalResult = 2
TabOrder = 2
end
object ApplyBtn: TButton
Left = 0
Height = 25
Top = 99
Width = 62
AutoSize = True
Caption = 'Apply'
OnClick = ApplyBtnClick
TabOrder = 3
end
object OKBtn: TButton
Left = 0
Height = 25
Top = 132
Width = 62
AutoSize = True
Caption = 'OK'
ModalResult = 1
TabOrder = 4
end
end
end

View File

@ -0,0 +1,133 @@
unit MoveAvgUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls,
ContextHelpUnit;
type
{ TMoveAvgFrm }
TMoveAvgFrm = class(TForm)
HelpBtn: TButton;
Panel1: TPanel;
ResetBtn: TButton;
CancelBtn: TButton;
ApplyBtn: TButton;
OKBtn: TButton;
ThetaList: TListBox;
ThetaEdit: TEdit;
Label2: TLabel;
OrderEdit: TEdit;
Label1: TLabel;
procedure ApplyBtnClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
procedure OrderEditKeyPress(Sender: TObject; var Key: char);
procedure ResetBtnClick(Sender: TObject);
procedure ThetaEditKeyPress(Sender: TObject; var Key: char);
procedure ThetaListClick(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
W : array[0..20] of double;
order : integer;
currentindex : integer;
end;
var
MoveAvgFrm: TMoveAvgFrm;
implementation
{ TMoveAvgFrm }
procedure TMoveAvgFrm.ResetBtnClick(Sender: TObject);
VAR i : integer;
begin
OrderEdit.Text := '';
ThetaEdit.Text := '';
ThetaList.Clear;
currentindex := 0;
for i := 0 to 20 do W[i] := 1.0;
end;
procedure TMoveAvgFrm.ThetaEditKeyPress(Sender: TObject; var Key: char);
var cellstring : string;
begin
if currentindex < 1 then exit;
if ord(Key) <> 13 then exit;
cellstring := 'Theta(' + IntToStr(currentindex + 1) + ') = ';
cellstring := cellstring + ThetaEdit.Text;
W[currentindex + 1] := StrToFloat(ThetaEdit.Text);
end;
procedure TMoveAvgFrm.ThetaListClick(Sender: TObject);
VAR index : integer;
begin
index := ThetaList.ItemIndex;
if index < 0 then exit;
currentindex := index;
ThetaEdit.Text := '1.0';
ThetaEdit.SetFocus;
end;
procedure TMoveAvgFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TMoveAvgFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).tag);
end;
procedure TMoveAvgFrm.ApplyBtnClick(Sender: TObject);
var
sum : double;
i : integer;
cellstring : string;
begin
ThetaList.Clear;
sum := W[0];
for i := 1 to order do sum := sum + (2.0 * W[i]);
for i := 0 to order do
begin
W[i] := W[i] / sum;
cellstring := 'Theta(' + IntToStr(i+1) + ') = ';
cellstring := cellstring + FloatToStr(W[i]);
ThetaList.Items.Add(cellstring);
end;
end;
procedure TMoveAvgFrm.OrderEditKeyPress(Sender: TObject; var Key: char);
VAR cellstring : string;
i : integer;
begin
if ord(Key) <> 13 then exit;
ThetaList.Clear;
order := StrToInt(OrderEdit.Text);
for i := 1 to order do
begin
cellstring := 'Theta(' + IntToStr(i) + ')';
ThetaList.Items.Add(cellstring);
end;
end;
initialization
{$I moveavgunit.lrs}
end.

View File

@ -0,0 +1,559 @@
object PartialsFrm: TPartialsFrm
Left = 637
Height = 460
Top = 307
Width = 412
AutoSize = True
Caption = 'Partial Correlation'
ClientHeight = 460
ClientWidth = 412
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Label1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 8
Height = 15
Top = 8
Width = 100
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Available Variables:'
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = DepVar
AnchorSideTop.Control = DepInBtn
AnchorSideBottom.Control = DepVar
Left = 228
Height = 15
Top = 25
Width = 152
Caption = 'Selected Dependent Variable:'
ParentColor = False
end
object Label3: TLabel
AnchorSideLeft.Control = PredList
Left = 229
Height = 15
Top = 120
Width = 144
Caption = 'Selected Predictor Variables'
ParentColor = False
end
object Label4: TLabel
AnchorSideLeft.Control = PartList
AnchorSideTop.Control = PartInBtn
AnchorSideTop.Side = asrBottom
Left = 8
Height = 15
Top = 289
Width = 121
BorderSpacing.Top = 8
Caption = 'Variables Partialed Out:'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = DepInBtn
Left = 8
Height = 220
Top = 25
Width = 176
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
Constraints.MinHeight = 220
Constraints.MinWidth = 175
ItemHeight = 0
MultiSelect = True
TabOrder = 0
end
object DepInBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
Left = 192
Height = 28
Top = 25
Width = 28
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00216324B81D5E2006FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF002A702F38256929F7216324D9FFFFFF00FFFFFF00FFFFFF00FFFFFF0061BE
6DFF5DB868FF58B162FF53A95CFF4DA156FF47994FFF419149FF3B8842FF3580
3BFF3F8845FF59A15EFF448B49FF216324CFFFFFFF00FFFFFF00FFFFFF0065C3
71FFA0D7A9FF9CD5A5FF98D3A1FF94D09DFF90CE98FF8BCB93FF87C98EFF82C6
89FF7EC384FF7AC180FF76BE7CFF458C4AFF216324C4FFFFFF00FFFFFF0068C7
74FFA5DAAEFFA2D8ABFF9ED6A7FF9AD4A3FF96D29FFF93CF9AFF8ECC95FF89CA
90FF85C78BFF81C587FF7DC282FF4A9150FF256929C9FFFFFF00FFFFFF0068C7
74FF68C774FF65C371FF61BE6DFF5DB868FF58B162FF53A95CFF4DA156FF4799
4FFF419149FF5AA362FF559D5CFF2F7835D1FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00419149F73B8842DBFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0047994FBB41914906FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = DepInBtnClick
Spacing = 0
TabOrder = 1
end
object DepOutBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = DepInBtn
AnchorSideTop.Side = asrBottom
Left = 192
Height = 28
Top = 57
Width = 28
BorderSpacing.Top = 4
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF004DA1560647994FB8FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0053A95CD94DA156F747994F38FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF005DB868CF71BE7BFF7AC183FF5BAA64FF47994FFF419149FF3B8842FF3580
3BFF2F7835FF2A702FFF256929FF216324FF1D5E20FFFFFFFF00FFFFFF0065C3
71C47BC886FF9CD5A5FF98D3A1FF94D09DFF90CE98FF8BCB93FF87C98EFF82C6
89FF7EC384FF7AC180FF76BE7CFF72BD78FF216324FFFFFFFF00FFFFFF0068C7
74C97FCC8AFFA2D8ABFF9ED6A7FF9AD4A3FF96D29FFF93CF9AFF8ECC95FF89CA
90FF85C78BFF81C587FF7DC282FF78C07EFF256929FFFFFFFF00FFFFFF00FFFF
FF0068C774D180CD8BFF7CC987FF5DB868FF58B162FF53A95CFF4DA156FF4799
4FFF419149FF3B8842FF35803BFF2F7835FF2A702FFFFFFFFF00FFFFFF00FFFF
FF00FFFFFF0068C774DB65C371F7FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0068C7740668C774BBFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = DepOutBtnClick
Spacing = 0
TabOrder = 2
end
object PredInBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = PredOutBtn
Left = 192
Height = 28
Top = 185
Width = 28
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 4
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00216324B81D5E2006FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF002A702F38256929F7216324D9FFFFFF00FFFFFF00FFFFFF00FFFFFF0061BE
6DFF5DB868FF58B162FF53A95CFF4DA156FF47994FFF419149FF3B8842FF3580
3BFF3F8845FF59A15EFF448B49FF216324CFFFFFFF00FFFFFF00FFFFFF0065C3
71FFA0D7A9FF9CD5A5FF98D3A1FF94D09DFF90CE98FF8BCB93FF87C98EFF82C6
89FF7EC384FF7AC180FF76BE7CFF458C4AFF216324C4FFFFFF00FFFFFF0068C7
74FFA5DAAEFFA2D8ABFF9ED6A7FF9AD4A3FF96D29FFF93CF9AFF8ECC95FF89CA
90FF85C78BFF81C587FF7DC282FF4A9150FF256929C9FFFFFF00FFFFFF0068C7
74FF68C774FF65C371FF61BE6DFF5DB868FF58B162FF53A95CFF4DA156FF4799
4FFF419149FF5AA362FF559D5CFF2F7835D1FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00419149F73B8842DBFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0047994FBB41914906FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = PredInBtnClick
Spacing = 0
TabOrder = 4
end
object PredOutBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = VarList
AnchorSideBottom.Side = asrBottom
Left = 192
Height = 28
Top = 217
Width = 28
Anchors = [akLeft, akBottom]
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF004DA1560647994FB8FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0053A95CD94DA156F747994F38FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF005DB868CF71BE7BFF7AC183FF5BAA64FF47994FFF419149FF3B8842FF3580
3BFF2F7835FF2A702FFF256929FF216324FF1D5E20FFFFFFFF00FFFFFF0065C3
71C47BC886FF9CD5A5FF98D3A1FF94D09DFF90CE98FF8BCB93FF87C98EFF82C6
89FF7EC384FF7AC180FF76BE7CFF72BD78FF216324FFFFFFFF00FFFFFF0068C7
74C97FCC8AFFA2D8ABFF9ED6A7FF9AD4A3FF96D29FFF93CF9AFF8ECC95FF89CA
90FF85C78BFF81C587FF7DC282FF78C07EFF256929FFFFFFFF00FFFFFF00FFFF
FF0068C774D180CD8BFF7CC987FF5DB868FF58B162FF53A95CFF4DA156FF4799
4FFF419149FF3B8842FF35803BFF2F7835FF2A702FFFFFFFFF00FFFFFF00FFFF
FF00FFFFFF0068C774DB65C371F7FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0068C7740668C774BBFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = PredOutBtnClick
Spacing = 0
TabOrder = 5
end
object PartInBtn: TBitBtn
AnchorSideTop.Control = VarList
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Bevel1
Left = 64
Height = 28
Top = 253
Width = 28
Anchors = [akTop, akRight]
BorderSpacing.Top = 8
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00256929C4216425C9FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF002D7533CF488F4DFF458C4AFF2265
26D1FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF003C8A430638833ED9519957FF79C07EFF76BF7CFF468D
4BFF236627DB20622306FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF0042924AB83D8C45F765AD6CFF7DC282FF7AC180FF4B92
50FF276D2CF7246828BBFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF0043944B384E9A55FF81C587FF7EC385FF317A
36FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0045954CFF85C78CFF82C689FF3682
3DFFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF004A9E53FF8ACA91FF87C98EFF3C8A
43FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0050A659FF8ECC95FF8BCB93FF4292
4AFFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0056AD5FFF93CF9AFF90CE98FF489A
50FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF005BB465FF96D29FFF94D09CFF4EA2
57FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF005FBB6AFF9AD4A3FF98D3A1FF53AA
5DFFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0063C06FFF9ED6A7FF9CD4A5FF59B2
63FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0066C572FFA2D8ABFFA0D7A9FF5DB8
68FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0068C774FF67C673FF65C270FF62BE
6DFFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 3
OnClick = PartInBtnClick
Spacing = 0
TabOrder = 7
end
object PartOutBtn: TBitBtn
AnchorSideLeft.Control = Bevel1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = VarList
AnchorSideTop.Side = asrBottom
Left = 100
Height = 28
Top = 253
Width = 28
BorderSpacing.Top = 8
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00286E2DFF256929FF216425FF1E60
22FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF002D7533FF74BD7AFF72BD78FF2265
26FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00337D39FF79C07EFF76BF7CFF266B
2BFFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0039853FFF7DC282FF7AC180FF2B72
30FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF003F8D46FF81C587FF7EC385FF317A
36FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0045954CFF85C78CFF82C689FF3682
3DFFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF004A9E53FF8ACA91FF87C98EFF3C8A
43FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0050A659FF8ECC95FF8BCB93FF4292
4AFFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0056AD5FFF93CF9AFF90CE98FF489A
50FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF005BB465FF96D29FFF94D09CFF5DAC
65FF499C5238FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF0065C371BB62BF6EF779C683FF9AD4A3FF98D3A1FF7DC3
86FF4FA458F74A9E53B8FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF0068C7740666C472DB7CCA87FF9ED6A7FF9CD4A5FF73C0
7DFF55AC5ED950A65906FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0066C572D17ECA88FF7BC885FF5DB8
68CFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0067C673C965C270C4FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 2
OnClick = PartOutBtnClick
Spacing = 0
TabOrder = 8
end
object DepVar: TEdit
AnchorSideLeft.Control = DepInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = DepOutBtn
AnchorSideBottom.Side = asrBottom
Left = 228
Height = 23
Top = 42
Width = 176
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
TabOrder = 3
Text = 'DepVar'
end
object PredList: TListBox
AnchorSideLeft.Control = PredInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = PredOutBtn
AnchorSideBottom.Side = asrBottom
Left = 229
Height = 109
Top = 136
Width = 175
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 9
BorderSpacing.Right = 8
Constraints.MinWidth = 175
ItemHeight = 0
TabOrder = 6
end
object PartList: TListBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label4
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = VarList
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel2
Left = 8
Height = 105
Top = 306
Width = 176
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
Constraints.MinHeight = 100
ItemHeight = 0
TabOrder = 9
end
object ResetBtn: TButton
AnchorSideRight.Control = CancelBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 111
Height = 25
Top = 427
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 11
end
object CancelBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 177
Height = 25
Top = 427
Width = 62
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Cancel'
ModalResult = 2
TabOrder = 12
end
object ComputeBtn: TButton
AnchorSideRight.Control = ReturnBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 251
Height = 25
Top = 427
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 13
end
object ReturnBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 339
Height = 25
Top = 427
Width = 61
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Return'
ModalResult = 1
TabOrder = 14
end
object HelpBtn: TButton
Tag = 136
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 48
Height = 25
Top = 427
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 10
end
object Bevel1: TBevel
AnchorSideLeft.Control = VarList
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
AnchorSideTop.Side = asrBottom
Left = 92
Height = 28
Top = 245
Width = 8
Shape = bsSpacer
end
object Bevel2: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ReturnBtn
Left = 0
Height = 8
Top = 411
Width = 412
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
end

View File

@ -0,0 +1,411 @@
unit PartialsUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons, ExtCtrls,
MainUnit, MatrixLib, FunctionsLib, OutputUnit, Globals, ContextHelpUnit;
type
{ TPartialsFrm }
TPartialsFrm = class(TForm)
Bevel1: TBevel;
Bevel2: TBevel;
DepInBtn: TBitBtn;
DepOutBtn: TBitBtn;
HelpBtn: TButton;
PredInBtn: TBitBtn;
PredOutBtn: TBitBtn;
PartInBtn: TBitBtn;
PartOutBtn: TBitBtn;
ResetBtn: TButton;
CancelBtn: TButton;
ComputeBtn: TButton;
ReturnBtn: TButton;
DepVar: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
PartList: TListBox;
PredList: TListBox;
VarList: TListBox;
procedure ComputeBtnClick(Sender: TObject);
procedure DepInBtnClick(Sender: TObject);
procedure DepOutBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
procedure PartInBtnClick(Sender: TObject);
procedure PartOutBtnClick(Sender: TObject);
procedure PredInBtnClick(Sender: TObject);
procedure PredOutBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
private
{ private declarations }
FAutoSized: Boolean;
public
{ public declarations }
end;
var
PartialsFrm: TPartialsFrm;
implementation
uses
Math;
{ TPartialsFrm }
procedure TPartialsFrm.ResetBtnClick(Sender: TObject);
VAR i : integer;
begin
DepVar.Text := '';
VarList.Clear;
PartList.Clear;
PredList.Clear;
DepInBtn.Enabled := true;
DepOutBtn.Enabled := false;
PredInBtn.Enabled := true;
PredOutBtn.Enabled := false;
PartInBtn.Enabled := true;
PartOutBtn.Enabled := false;
for i := 1 to OS3MainFrm.DataGrid.ColCount - 1 do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
end;
procedure TPartialsFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([HelpBtn.Width, ResetBtn.Width, CancelBtn.Width, ComputeBtn.Width, ReturnBtn.Width]);
HelpBtn.Constraints.MinWidth := w;
ResetBtn.Constraints.MinWidth := w;
CancelBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
ReturnBtn.Constraints.MinWidth := w;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TPartialsFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
if OutputFrm = nil then Application.CreateForm(TOutputFrm, OutputFrm);
end;
procedure TPartialsFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TPartialsFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).tag);
end;
procedure TPartialsFrm.PartInBtnClick(Sender: TObject);
VAR i, index : integer;
begin
index := VarList.Items.Count;
i := 0;
while i < index do
begin
if (VarList.Selected[i]) then
begin
PartList.Items.Add(VarList.Items.Strings[i]);
VarList.Items.Delete(i);
index := index - 1;
i := 0;
end
else i := i + 1;
end;
PartOutBtn.Enabled := true;
end;
procedure TPartialsFrm.PartOutBtnClick(Sender: TObject);
VAR index : integer;
begin
index := PartList.ItemIndex;
VarList.Items.Add(PartList.Items.Strings[index]);
PartList.Items.Delete(index);
if PartList.Items.Count = 0 then PartOutBtn.Enabled := false;
end;
procedure TPartialsFrm.PredInBtnClick(Sender: TObject);
VAR i, index : integer;
begin
index := VarList.Items.Count;
i := 0;
while i < index do
begin
if (VarList.Selected[i]) then
begin
PredList.Items.Add(VarList.Items.Strings[i]);
VarList.Items.Delete(i);
index := index - 1;
i := 0;
end
else i := i + 1;
end;
PredOutBtn.Enabled := true;
end;
procedure TPartialsFrm.PredOutBtnClick(Sender: TObject);
VAR index : integer;
begin
index := PredList.ItemIndex;
VarList.Items.Add(PredList.Items.Strings[index]);
PredList.Items.Delete(index);
if PredList.Items.Count = 0 then PredOutBtn.Enabled := false;
end;
procedure TPartialsFrm.DepInBtnClick(Sender: TObject);
VAR index : integer;
begin
index := VarList.ItemIndex;
if index < 0 then exit;
DepVar.Text := VarList.Items.Strings[index];
VarList.Items.Delete(index);
DepOutBtn.Enabled := true;
DepInBtn.Enabled := false;
end;
procedure TPartialsFrm.ComputeBtnClick(Sender: TObject);
var
rmatrix, workmat : DblDyneMat;
Means, Variances, StdDevs, W, Betas : DblDyneVec;
R2Full, R2Cntrl, SemiPart, Partial, df1, df2, F, Prob : double;
NoPredVars, NoCntrlVars, DepVarNo, TotNoVars, pcnt, ccnt, count : integer;
PredVars, CntrlVars : IntDyneVec;
MatVars : IntDyneVec;
outline, varstring : string;
i, j, K, L, NCases : integer;
errorcode : boolean;
vtimesw, W1, v : DblDyneMat;
begin
DepVarNo := 1;
errorcode := false;
// Get no. of predictor and control variables
NoPredVars := PredList.Items.Count;
NoCntrlVars := PartList.Items.Count;
if (NoPredVars = 0) or (NoCntrlVars = 0) then
begin
ShowMessage('You must select at least one predictor and one control variable!');
exit;
end;
TotNoVars := NoPredVars + NoCntrlVars + 1;
count := NoCases;
NCases := NoCases;
// Allocate space required
SetLength(vtimesw,NoVariables,NoVariables);
SetLength(v,NoVariables,NoVariables);
SetLength(W1,NoVariables,NoVariables);
SetLength(rmatrix,NoVariables+1,NoVariables+1); // augmented
SetLength(workmat,NoVariables+1,NoVariables+1); // augmented
SetLength(PredVars,NoVariables);
SetLength(CntrlVars,NoVariables);
SetLength(Means,NoVariables);
SetLength(Variances,NoVariables);
SetLength(StdDevs,NoVariables);
SetLength(W,NoVariables);
SetLength(Betas,NoVariables);
SetLength(MatVars,NoVariables);
OutputFrm.RichEdit.Clear;
OutputFrm.RichEdit.Lines.Add('Partial and Semi-Partial Correlation Analysis');
OutputFrm.RichEdit.Lines.Add('');
// Get column numbers of dependent, predictor and control variables
pcnt := 1;
for i := 0 to NoPredVars - 1 do
begin
varstring := PredList.Items.Strings[i];
for j := 1 to NoVariables do
begin
if varstring = OS3MainFrm.DataGrid.Cells[j,0] then
begin
PredVars[pcnt-1] := j;
pcnt := pcnt + 1;
end;
end;
end;
ccnt := 1;
for i := 0 to NoCntrlVars - 1 do
begin
varstring := PartList.Items.Strings[i];
for j := 1 to NoVariables do
begin
if varstring = OS3MainFrm.DataGrid.Cells[j,0] then
begin
CntrlVars[ccnt-1] := j;
ccnt := ccnt + 1;
end;
end;
end;
varstring := DepVar.Text;
for i := 1 to NoVariables do
if varstring = OS3MainFrm.DataGrid.Cells[i,0] then DepVarNo := i;
outline := format('Dependent variable = %s',[OS3MainFrm.DataGrid.Cells[DepVarNo,0]]);
OutputFrm.RichEdit.Lines.Add(outline);
OutputFrm.RichEdit.Lines.Add('');
OutputFrm.RichEdit.Lines.Add('Predictor Variables:');
for i := 1 to NoPredVars do
begin
outline := format('Variable %d = %s',[i+1,OS3MainFrm.DataGrid.Cells[PredVars[i-1],0]]);
OutputFrm.RichEdit.Lines.Add(outline);
end;
OutputFrm.RichEdit.Lines.Add('');
OutputFrm.RichEdit.Lines.Add('Control Variables:');
for i := 1 to NoCntrlVars do
begin
outline := format('Variable %d = %s',[i+1,OS3MainFrm.DataGrid.Cells[CntrlVars[i-1],0]]);
OutputFrm.RichEdit.Lines.Add(outline);
end;
OutputFrm.RichEdit.Lines.Add('');
if NoPredVars > 1 then
begin
outline := format('Higher order partialling at level = %d',[NoPredVars]);
OutputFrm.RichEdit.Lines.Add(outline);
OutputFrm.RichEdit.Lines.Add('');
end;
if NoCntrlVars > 1 then
begin
outline := format('Multiple partialling with %d variables.',[NoCntrlVars]);
OutputFrm.RichEdit.Lines.Add(outline);
OutputFrm.RichEdit.Lines.Add('');
end;
// Now, build the correlation matrix
MatVars[0] := DepVarNo;
for i := 1 to NoPredVars do MatVars[i] := PredVars[i-1];
for i := 1 to NoCntrlVars do MatVars[i + NoPredVars] := CntrlVars[i-1];
Correlations(TotNoVars, MatVars, rmatrix, Means, Variances, StdDevs, errorcode, count);
// Now do Multiple regression models required
// Full model first
for i := 2 to TotNoVars do
for j := 2 to TotNoVars do
workmat[i-2,j-2] := rmatrix[i-1,j-1];
matinv(workmat, vtimesw, v, W1, TotNoVars-1);
R2Full := 0.0;
for i := 1 to TotNoVars-1 do // rows
begin
W[i-1] := 0.0;
for j := 1 to TotNoVars - 1 do W[i-1] := W[i-1] + (workmat[i-1,j-1] * rmatrix[0,j]);
R2Full := R2Full + W[i-1] * rmatrix[0,i];
end;
outline := format('Squared Multiple Correlation with all variables = %6.3f',[R2Full]);
OutputFrm.RichEdit.Lines.Add(outline);
OutputFrm.RichEdit.Lines.Add('');
OutputFrm.RichEdit.Lines.Add('Standardized Regression Coefficients:');
for i := 1 to TotNoVars - 1 do
begin
outline := format('%10s = %6.3f',[OS3MainFrm.DataGrid.Cells[MatVars[i],0],W[i-1]]);
OutputFrm.RichEdit.Lines.Add(outline);
end;
OutputFrm.RichEdit.Lines.Add('');
// Now do model for Partial and Semi-partial
for i := 1 to NoCntrlVars do
begin
K := i + 1 + NoPredVars;
for j := 1 to NoCntrlVars do
begin
L := j + 1 + NoPredVars;
workmat[i-1,j-1] := rmatrix[K-1,L-1];
end;
end;
matinv(workmat, vtimesw, v, W1, NoCntrlVars);
R2Cntrl := 0.0;
for i := 1 to NoCntrlVars do
begin
L := i + 1 + NoPredVars;
W[i-1] := 0.0;
for j := 1 to NoCntrlVars do
begin
K := j + 1 + NoPredVars;
W[i-1] := W[i-1] + (workmat[i-1,j-1] * rmatrix[0,K-1]);
end;
R2Cntrl := R2Cntrl + W[i-1] * rmatrix[0,L-1];
end;
outline := format('Squared Multiple Correlation with control variables = %6.3f',[R2Cntrl]);
OutputFrm.RichEdit.Lines.Add(outline);
OutputFrm.RichEdit.Lines.Add('');
OutputFrm.RichEdit.Lines.Add('Standardized Regression Coefficients:');
for i := 1 to NoCntrlVars do
begin
outline := format('%10s = %6.3f',[OS3MainFrm.DataGrid.Cells[MatVars[i+NoPredVars],0],W[i-1]]);
OutputFrm.RichEdit.Lines.Add(outline);
end;
OutputFrm.RichEdit.Lines.Add('');
SemiPart := R2Full - R2Cntrl;
Partial := SemiPart / (1.0 - R2Cntrl);
df1 := TotNoVars - 1 - NoCntrlVars;
df2 := count - TotNoVars;
F := (SemiPart / (1.0 - R2Full)) * (df2 / df1);
Prob := probf(F,df1,df2);
// Report results
OutputFrm.RichEdit.Lines.Add('');
outline := format('Partial Correlation = %6.3f',[sqrt(Partial)]);
OutputFrm.RichEdit.Lines.Add(outline);
OutputFrm.RichEdit.Lines.Add('');
outline := format('Semi-Partial Correlation = %6.3f',[sqrt(SemiPart)]);
OutputFrm.RichEdit.Lines.Add(outline);
OutputFrm.RichEdit.Lines.Add('');
outline := format('F = %8.3f with probability = %6.4f, D.F.1 = %3.0f and D.F.2 = %3.0f',[F,Prob,df1,df2]);
OutputFrm.RichEdit.Lines.Add(outline);
OutputFrm.ShowModal;
// clean up the heap
MatVars := nil;
Betas := nil;
W := nil;
Variances := nil;
StdDevs := nil;
Means := nil;
CntrlVars := nil;
PredVars := nil;
workmat := nil;
rmatrix := nil;
v := nil;
W1 := nil;
vtimesw := nil;
end;
procedure TPartialsFrm.DepOutBtnClick(Sender: TObject);
begin
VarList.Items.Add(DepVar.Text);
DepVar.Text := '';
DepInBtn.Enabled := true;
DepOutBtn.Enabled := false;
end;
initialization
{$I partialsunit.lrs}
end.

View File

@ -0,0 +1,81 @@
object PointsFrm: TPointsFrm
Left = 506
Height = 470
Top = 217
Width = 736
Caption = 'Points Form'
ClientHeight = 470
ClientWidth = 736
OnActivate = FormActivate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Image1: TImage
Left = 0
Height = 424
Top = 0
Width = 736
Align = alClient
end
object Panel1: TPanel
Left = 0
Height = 46
Top = 424
Width = 736
Align = alBottom
AutoSize = True
BevelOuter = bvNone
BorderStyle = bsSingle
ClientHeight = 42
ClientWidth = 732
TabOrder = 0
object MsgEdit: TEdit
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrCenter
Left = 8
Height = 23
Top = 10
Width = 335
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Bottom = 8
TabOrder = 0
Text = 'MsgEdit'
end
object PrintBtn: TButton
AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = ReturnBtn
Left = 600
Height = 25
Top = 9
Width = 51
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Right = 12
Caption = 'Print'
OnClick = PrintBtnClick
TabOrder = 1
end
object ReturnBtn: TButton
AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 663
Height = 25
Top = 9
Width = 61
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Return'
ModalResult = 1
OnClick = ReturnBtnClick
TabOrder = 2
end
end
end

View File

@ -0,0 +1,227 @@
unit PointsUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
ExtCtrls, StdCtrls, Printers,
Globals;
type
{ TPointsFrm }
TPointsFrm = class(TForm)
Image1: TImage;
PrintBtn: TButton;
ReturnBtn: TButton;
MsgEdit: TEdit;
Panel1: TPanel;
// procedure FormPaint(Sender: TObject);
// procedure FormResize(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure PrintBtnClick(Sender: TObject);
procedure PtsPlot(Sender: TObject);
procedure ReturnBtnClick(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
pts : DblDyneVec;
avg : DblDyneVec;
LabelOne : string;
LabelTwo : string;
NoCases : integer;
Title : string;
// Caption : string;
end;
var
PointsFrm: TPointsFrm;
implementation
{ TPointsFrm }
uses
Math;
procedure TPointsFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
w := MaxValue([PrintBtn.Width, ReturnBtn.Width]);
PrintBtn.Constraints.MinWidth := w;
ReturnBtn.Constraints.MinWidth := w;
end;
procedure TPointsFrm.FormShow(Sender: TObject);
begin
// Image1.Canvas.Clear;
Image1.Canvas.Brush.Color := clWhite;
Image1.Canvas.FillRect(0, 0, Image1.Width, Image1.Height);
PtsPlot(self);
end;
procedure TPointsFrm.PrintBtnClick(Sender: TObject);
var
r : Trect;
begin
with Printer do
begin
Printer.Orientation := poPortrait;
r := Rect(20,20,printer.pagewidth-20,printer.pageheight div 2 + 20);
BeginDoc;
Canvas.StretchDraw(r,Image1.Picture.BitMap);
EndDoc;
end;
end;
procedure TPointsFrm.PtsPlot(Sender: TObject);
var
topmarg, botmarg, leftmarg, rightmarg, verthi, horizlong : integer;
X, Y, yincrement, labelheight, i: integer;
labelstring, labelstr : string;
Xstep, Ystep, yprop, scaley, xprop, scalex, Min, Max : double;
begin
height := Image1.Canvas.Height;
width := Image1.Canvas.Width;
topmarg := height div 10;
verthi := height - (2 * topmarg);
botmarg := topmarg + verthi;
botmarg := height;
leftmarg := width div 10;
horizlong := width - 2 * leftmarg;
rightmarg := leftmarg + horizlong;
// get max and min of values to plot
Max := -1000.0;
Min := 1000.0;
for i := 0 to NoCases - 1 do
begin
if (pts[i] > Max) then Max := pts[i];
if (avg[i] > Max) then Max := avg[i];
if (pts[i] < Min) then Min := pts[i];
if (avg[i] < Min) then Min := avg[i];
end;
yincrement := verthi div 20;
Image1.Canvas.Pen.Color := clBlack;
// print title at top, centered
labelstring := 'Plot of Original and ';
labelstring := labelstring + Title;
// labelstring := labelstring + DepVarEdit.Text;
X := (leftmarg + horizlong div 2) - (Image1.Canvas.TextWidth(labelstring) div 2);
Y := 1;
Image1.Canvas.TextOut(X,Y,labelstring);
// draw left axis
X := leftmarg;
Y := botmarg;
Image1.Canvas.MoveTo(X,Y);
Y := topmarg;
Image1.Canvas.LineTo(X,Y);
// scale to left of vertical axis
Ystep := (Max - Min) / 20;
for i := 0 to 20 do
begin
Y := topmarg + (i * yincrement);
labelstr := format('%4.2f -',[Max - (Ystep * i)]);
labelstring := labelstr;
X := leftmarg - Image1.Canvas.TextWidth(labelstring);
Image1.Canvas.TextOut(X,Y,labelstring);
end;
// Make legend axis on bottom
X := leftmarg;
Y := botmarg;
Xstep := horizlong / 20;
xprop := NoCases / 20;
Image1.Canvas.MoveTo(X,Y);
X := rightmarg;
Image1.Canvas.LineTo(X,Y);
for i := 0 to 20 do
begin
X := leftmarg + round(Xstep * i);
labelstring := '|';
Image1.Canvas.TextOut(X,Y,labelstring);
labelstring := IntToStr(round((xprop * i) + 1));
Y := Y + 5;
Image1.Canvas.TextOut(X,Y,labelstring);
Y := botmarg;
end;
labelstring := 'CASES';
X := (leftmarg + horizlong div 2) - (Canvas.TextWidth(labelstring) div 2);
Y := botmarg + Image1.Canvas.TextHeight(labelstring);
Image1.Canvas.TextOut(X,Y,labelstring);
// Plot lines from point to point
Image1.Canvas.Pen.Color := clRed;
for i := 0 to NoCases - 1 do
begin
yprop := (Max - pts[i]) / (Max - Min);
scaley := yprop * verthi;
xprop := i / NoCases;
scalex := xprop * horizlong;
X := leftmarg + round(scalex);
Y := topmarg + round(scaley);
if (i = 0) then Image1.Canvas.MoveTo(X,Y)
else Image1.Canvas.LineTo(X,Y);
Image1.Canvas.Ellipse(X-3,Y-3,X+3,Y+3);
end;
// Plot average points
Image1.Canvas.Pen.Color := clBlue;
for i := 0 to NoCases - 1 do
begin
yprop := (Max - avg[i]) / (Max - Min);
scaley := yprop * verthi;
xprop := i / NoCases;
scalex := xprop * horizlong;
X := leftmarg + round(scalex);
Y := topmarg + round(scaley);
if (i = 0) then Image1.Canvas.MoveTo(X,Y)
else Image1.Canvas.LineTo(X,Y);
Image1.Canvas.Ellipse(X-3,Y-3,X+3,Y+3);
end;
// Show legend at right
X := rightmarg;
labelstring := LabelOne;
labelheight := Image1.Canvas.TextHeight(labelstring);
Y := 5 * labelheight;
Image1.Canvas.Font.Color := clRed;
Image1.Canvas.TextOut(X,Y,labelstring);
labelstring := LabelTwo;
Y := 6 * labelheight;
Image1.Canvas.Font.Color := clBlue;
Image1.Canvas.TextOut(X,Y,labelstring);
end;
procedure TPointsFrm.ReturnBtnClick(Sender: TObject);
begin
PointsFrm.Hide;
end;
{
procedure TPointsFrm.FormPaint(Sender: TObject);
begin
PtsPlot;
end;
procedure TPointsFrm.FormResize(Sender: TObject);
begin
PtsPlot;
end;
}
initialization
{$I pointsunit.lrs}
end.

View File

@ -0,0 +1,128 @@
object PolynomialFrm: TPolynomialFrm
Left = 822
Height = 99
Top = 421
Width = 351
AutoSize = True
BorderStyle = bsDialog
Caption = 'Polynomial Regression Smoothing'
ClientHeight = 99
ClientWidth = 351
OnActivate = FormActivate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object CancelBtn: TButton
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = OKBtn
Left = 223
Height = 25
Top = 63
Width = 62
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Cancel'
ModalResult = 2
TabOrder = 2
end
object OKBtn: TButton
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 297
Height = 25
Top = 63
Width = 42
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'OK'
ModalResult = 1
TabOrder = 3
end
object HelpBtn: TButton
Tag = 139
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = CancelBtn
Left = 160
Height = 25
Top = 63
Width = 51
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 1
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Owner
Left = 99
Height = 23
Top = 16
Width = 152
AutoSize = True
BorderSpacing.Left = 100
BorderSpacing.Top = 16
BorderSpacing.Right = 100
BorderSpacing.Bottom = 8
BevelOuter = bvNone
ClientHeight = 23
ClientWidth = 152
TabOrder = 0
object Label1: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = PolyEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = PolyEdit
Left = 0
Height = 15
Top = 4
Width = 97
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Polynomial order :'
ParentColor = False
end
object PolyEdit: TEdit
AnchorSideTop.Control = Panel1
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 105
Height = 23
Top = 0
Width = 47
Alignment = taRightJustify
Anchors = [akTop, akRight]
TabOrder = 0
Text = 'PolyEdit'
end
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 8
Top = 47
Width = 351
Anchors = [akTop, akLeft, akRight]
Shape = bsBottomLine
end
end

View File

@ -0,0 +1,69 @@
unit PolynomialUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls,
ContextHelpUnit;
type
{ TPolynomialFrm }
TPolynomialFrm = class(TForm)
Bevel1: TBevel;
CancelBtn: TButton;
HelpBtn: TButton;
OKBtn: TButton;
Panel1: TPanel;
PolyEdit: TEdit;
Label1: TLabel;
procedure FormActivate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
PolynomialFrm: TPolynomialFrm;
implementation
uses
Math;
{ TPolynomialFrm }
procedure TPolynomialFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
w := MaxValue([HelpBtn.Width, CancelBtn.Width, OKBtn.Width]);
HelpBtn.Constraints.MinWidth := w;
CancelBtn.Constraints.MinWidth := w;
OKBtn.Constraints.MinWidth := w;
end;
procedure TPolynomialFrm.FormShow(Sender: TObject);
begin
PolyEdit.Text := '1';
end;
procedure TPolynomialFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).tag);
end;
initialization
{$I polynomialunit.lrs}
end.

View File

@ -0,0 +1,389 @@
object RMatFrm: TRMatFrm
Left = 597
Height = 482
Top = 185
Width = 409
AutoSize = True
Caption = 'Product-Moment Correlations'
ClientHeight = 482
ClientWidth = 409
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Label1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 8
Height = 15
Top = 8
Width = 114
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Variables to Correlate:'
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = ListBox1
AnchorSideTop.Control = Owner
Left = 235
Height = 15
Top = 8
Width = 96
BorderSpacing.Top = 8
Caption = 'Selected Variables:'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = AllBtn
AnchorSideBottom.Control = GroupBox1
Left = 8
Height = 223
Top = 25
Width = 165
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Constraints.MinHeight = 220
ItemHeight = 0
MultiSelect = True
TabOrder = 0
end
object InBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
Left = 190
Height = 28
Top = 29
Width = 28
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00216324B81D5E2006FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF002A702F38256929F7216324D9FFFFFF00FFFFFF00FFFFFF00FFFFFF0061BE
6DFF5DB868FF58B162FF53A95CFF4DA156FF47994FFF419149FF3B8842FF3580
3BFF3F8845FF59A15EFF448B49FF216324CFFFFFFF00FFFFFF00FFFFFF0065C3
71FFA0D7A9FF9CD5A5FF98D3A1FF94D09DFF90CE98FF8BCB93FF87C98EFF82C6
89FF7EC384FF7AC180FF76BE7CFF458C4AFF216324C4FFFFFF00FFFFFF0068C7
74FFA5DAAEFFA2D8ABFF9ED6A7FF9AD4A3FF96D29FFF93CF9AFF8ECC95FF89CA
90FF85C78BFF81C587FF7DC282FF4A9150FF256929C9FFFFFF00FFFFFF0068C7
74FF68C774FF65C371FF61BE6DFF5DB868FF58B162FF53A95CFF4DA156FF4799
4FFF419149FF5AA362FF559D5CFF2F7835D1FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00419149F73B8842DBFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0047994FBB41914906FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = InBtnClick
Spacing = 0
TabOrder = 1
end
object OutBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
Left = 190
Height = 28
Top = 64
Width = 28
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF004DA1560647994FB8FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0053A95CD94DA156F747994F38FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF005DB868CF71BE7BFF7AC183FF5BAA64FF47994FFF419149FF3B8842FF3580
3BFF2F7835FF2A702FFF256929FF216324FF1D5E20FFFFFFFF00FFFFFF0065C3
71C47BC886FF9CD5A5FF98D3A1FF94D09DFF90CE98FF8BCB93FF87C98EFF82C6
89FF7EC384FF7AC180FF76BE7CFF72BD78FF216324FFFFFFFF00FFFFFF0068C7
74C97FCC8AFFA2D8ABFF9ED6A7FF9AD4A3FF96D29FFF93CF9AFF8ECC95FF89CA
90FF85C78BFF81C587FF7DC282FF78C07EFF256929FFFFFFFF00FFFFFF00FFFF
FF0068C774D180CD8BFF7CC987FF5DB868FF58B162FF53A95CFF4DA156FF4799
4FFF419149FF3B8842FF35803BFF2F7835FF2A702FFFFFFFFF00FFFFFF00FFFF
FF00FFFFFF0068C774DB65C371F7FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0068C7740668C774BBFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = OutBtnClick
Spacing = 0
TabOrder = 2
end
object AllBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
Left = 181
Height = 25
Top = 120
Width = 46
AutoSize = True
Caption = 'ALL'
OnClick = AllBtnClick
Spacing = 0
TabOrder = 3
end
object ListBox1: TListBox
AnchorSideLeft.Control = AllBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = GroupBox1
Left = 235
Height = 223
Top = 25
Width = 166
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
ItemHeight = 0
TabOrder = 4
end
object GroupBox1: TGroupBox
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1
Left = 8
Height = 177
Top = 256
Width = 393
Anchors = [akLeft, akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Right = 8
Caption = 'Options:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.Layout = cclTopToBottomThenLeftToRight
ChildSizing.ControlsPerLine = 7
ClientHeight = 157
ClientWidth = 389
TabOrder = 5
object CPChkBox: TCheckBox
Left = 12
Height = 19
Top = 6
Width = 222
Caption = 'Show Cross-Products Matrix'
TabOrder = 0
end
object CovChkBox: TCheckBox
Left = 12
Height = 19
Top = 27
Width = 222
Caption = 'Show Variance-Covariance Matrix'
TabOrder = 1
end
object CorrsChkBox: TCheckBox
Left = 12
Height = 19
Top = 48
Width = 222
Caption = 'Show the Intercorrelation Matrix'
TabOrder = 2
end
object MeansChkBox: TCheckBox
Left = 12
Height = 19
Top = 69
Width = 222
Caption = 'Show Means'
TabOrder = 3
end
object VarChkBox: TCheckBox
Left = 12
Height = 19
Top = 90
Width = 222
Caption = 'Show Variances'
TabOrder = 4
end
object SDChkBox: TCheckBox
Left = 12
Height = 19
Top = 111
Width = 222
Caption = 'Show Standard Deviations'
TabOrder = 5
end
object PairsChkBox: TCheckBox
Left = 12
Height = 19
Top = 132
Width = 222
Caption = 'Pair-Wise Calculations'
TabOrder = 6
end
object AugmentChk: TCheckBox
Left = 234
Height = 19
Top = 6
Width = 143
Caption = 'Autmented'
TabOrder = 7
end
object GridMatChk: TCheckBox
Left = 234
Height = 19
Top = 27
Width = 143
Caption = 'Save Matrix to Grid'
TabOrder = 8
end
end
object ResetBtn: TButton
AnchorSideRight.Control = CancelBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 108
Height = 25
Top = 449
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 7
end
object CancelBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 174
Height = 25
Top = 449
Width = 62
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Cancel'
ModalResult = 2
TabOrder = 8
end
object ComputeBtn: TButton
AnchorSideRight.Control = ReturnBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 248
Height = 25
Top = 449
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 9
end
object ReturnBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 336
Height = 25
Top = 449
Width = 61
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Return'
ModalResult = 1
TabOrder = 10
end
object HelpBtn: TButton
Tag = 144
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 45
Height = 25
Top = 449
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 6
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ReturnBtn
Left = 0
Height = 8
Top = 433
Width = 409
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
end

View File

@ -0,0 +1,479 @@
unit RMatUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons, ExtCtrls,
MainUnit, Globals, MatrixLib, OutputUnit, DataProcs, FunctionsLib,
ContextHelpUnit;
type
{ TRMatFrm }
TRMatFrm = class(TForm)
Bevel1: TBevel;
GridMatChk: TCheckBox;
HelpBtn: TButton;
InBtn: TBitBtn;
OutBtn: TBitBtn;
AllBtn: TBitBtn;
AugmentChk: TCheckBox;
ResetBtn: TButton;
CancelBtn: TButton;
ComputeBtn: TButton;
ReturnBtn: TButton;
CPChkBox: TCheckBox;
CovChkBox: TCheckBox;
CorrsChkBox: TCheckBox;
MeansChkBox: TCheckBox;
VarChkBox: TCheckBox;
SDChkBox: TCheckBox;
PairsChkBox: TCheckBox;
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
ListBox1: TListBox;
VarList: TListBox;
procedure AllBtnClick(Sender: TObject);
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
procedure InBtnClick(Sender: TObject);
procedure OutBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
private
{ private declarations }
FAutoSized: Boolean;
procedure PairsCalc(NoVars : integer;
VAR ColNoSelected : IntDyneVec;
VAR Matrix : DblDyneMat;
VAR ColLabels : StrDyneVec);
public
{ public declarations }
end;
var
RMatFrm: TRMatFrm;
implementation
uses
Math;
{ TRMatFrm }
procedure TRMatFrm.ResetBtnClick(Sender: TObject);
VAR i : integer;
begin
VarList.Clear;
ListBox1.Clear;
for i := 1 to NoVariables do
begin
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
end;
InBtn.Enabled := true;
OutBtn.Enabled := false;
AugmentChk.Checked := false;
PairsChkBox.Checked := false;
CPChkBox.Checked := false;
CovChkBox.Checked := false;
CorrsChkBox.Checked := true;
MeansChkBox.Checked := true;
VarChkBox.Checked := false;
SDChkBox.Checked := true;
end;
procedure TRMatFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(Self);
end;
procedure TRMatFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([HelpBtn.Width, ResetBtn.Width, CancelBtn.Width, ComputeBtn.Width, ReturnBtn.Width]);
HelpBtn.Constraints.MinWidth := w;
ResetBtn.Constraints.MinWidth := w;
CancelBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
ReturnBtn.Constraints.MinWidth := w;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TRMatFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
if OutputFrm = nil then
Application.CreateForm(TOutputFrm, OutputFrm);
end;
procedure TRMatFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).tag);
end;
procedure TRMatFrm.AllBtnClick(Sender: TObject);
VAR count, index : integer;
begin
count := VarList.Items.Count;
for index := 0 to count-1 do
begin
ListBox1.Items.Add(VarList.Items.Strings[index]);
end;
VarList.Clear;
end;
procedure TRMatFrm.ComputeBtnClick(Sender: TObject);
label cleanit;
var
i, j : integer;
cellstring : string;
NoVars : integer;
ColNoSelected : IntDyneVec;
Matrix : DblDyneMat;
TestMat : DblDyneMat;
Means : DblDyneVec;
Variances : DblDyneVec;
StdDevs : DblDyneVec;
RowLabels, ColLabels : StrDyneVec;
Augment : boolean;
title : string;
errorcode : boolean;
Ngood : integer;
t, Probr, N: double;
begin
errorcode := false;
OutputFrm.RichEdit.Clear;
NoVars := ListBox1.Items.Count;
Augment := false;
Ngood := 0;
SetLength(ColNoSelected,NoVars+1);
SetLength(Matrix,NoVars+1,NoVars+1); // 1 more for possible augmentation
SetLength(TestMat,NoVars,NoVars);
SetLength(Means,NoVars+1);
SetLength(Variances,NoVars+1);
SetLength(StdDevs,NoVars+1);
SetLength(RowLabels,NoVars+1);
SetLength(ColLabels,NoVars+1);
// identify the included variable locations and their labels
for i := 1 to NoVars do
begin
cellstring := ListBox1.Items.Strings[i-1];
for j := 1 to NoVariables do
begin
if cellstring = OS3MainFrm.DataGrid.Cells[j,0] then
begin
ColNoSelected[i-1] := j;
RowLabels[i-1] := cellstring;
ColLabels[i-1] := cellstring;
end;
end;
end;
if PairsChkBox.Checked then
begin
PairsCalc(NoVars,ColNoSelected,Matrix,ColLabels);
goto cleanit;
end;
if AugmentChk.Checked then
begin
Augment := true;
ColLabels[NoVars] := 'Intercept';
RowLabels[NoVars] := 'Intercept';
end;
// get cross-products if elected
if CPChkBox.Checked = true then
begin
GridXProd(NoVars,ColNoSelected,Matrix,Augment,Ngood);
title := 'Cross-Products Matrix';
if NOT Augment then
MAT_PRINT(Matrix,NoVars,NoVars,title,RowLabels,ColLabels,Ngood)
else
MAT_PRINT(Matrix,NoVars+1,NoVars+1,title,RowLabels,ColLabels,Ngood);
end;
if CovChkBox.Checked = true then // get variance-covariance mat. if elected
begin
title := 'Variance-Covariance Matrix';
GridCovar(NoVars,ColNoSelected,Matrix,Means,Variances,StdDevs,errorcode, Ngood);
MAT_PRINT(Matrix,NoVars,NoVars,title,RowLabels,ColLabels,Ngood);
end;
if CorrsChkBox.Checked = true then // get correlations
begin
title := 'Product-Moment Correlations Matrix';
Correlations(NoVars,ColNoSelected,Matrix,Means,Variances,StdDevs,errorcode,Ngood);
MAT_PRINT(Matrix,NoVars,NoVars,title,RowLabels,ColLabels,Ngood);
N := Ngood;
for i := 1 to NoVars do
begin
for j := i+1 to NoVars do
begin
t := Matrix[i-1][j-1] * (sqrt((N-2.0) /
(1.0 - (Matrix[i-1][j-1] * Matrix[i-1][j-1]))));
TestMat[i-1,j-1] := t;
Probr := probt(t,N - 2.0);
TestMat[j-1,i-1] := Probr;
TestMat[i-1,i-1] := 0.0;
end;
end;
title := 't-test values (upper) and probabilities of t (lower)';
MAT_PRINT(TestMat,NoVars,NoVars,title,RowLabels,ColLabels,Ngood);
end;
title := 'Means';
if MeansChkBox.Checked = true then
DynVectorPrint(Means,NoVars,title,ColLabels,Ngood);
title := 'Variances';
if VarChkBox.Checked = true then
DynVectorPrint(Variances,NoVars,title,ColLabels,Ngood);
title := 'Standard Deviations';
if SDChkBox.Checked = true then
DynVectorPrint(StdDevs,NoVars,title,ColLabels,Ngood);
if errorcode then
OutputFrm.RichEdit.Lines.Add('One or more correlations could not be computed due to zero variance of a variable.');
OutputFrm.ShowModal;
if GridMatChk.Checked then MatToGrid(Matrix,NoVars);
// clean up the heap
cleanit:
ColLabels := nil;
RowLabels := nil;
StdDevs := nil;
Variances := nil;
Means := nil;
Matrix := nil;
ColNoSelected := nil;
end;
procedure TRMatFrm.InBtnClick(Sender: TObject);
VAR i, index : integer;
begin
index := VarList.Items.Count;
i := 0;
while i < index do
begin
if (VarList.Selected[i]) then
begin
ListBox1.Items.Add(VarList.Items.Strings[i]);
VarList.Items.Delete(i);
index := index - 1;
i := 0;
end
else i := i + 1;
end;
OutBtn.Enabled := true;
end;
procedure TRMatFrm.OutBtnClick(Sender: TObject);
VAR index : integer;
begin
index := ListBox1.ItemIndex;
VarList.Items.Add(ListBox1.Items.Strings[index]);
ListBox1.Items.Delete(index);
InBtn.Enabled := true;
end;
procedure TRMatFrm.PairsCalc(NoVars: integer; var ColNoSelected: IntDyneVec;
var Matrix: DblDyneMat; var ColLabels: StrDyneVec);
Label nextpart;
var
i, j, k, XCol, YCol, Npairs, N : integer;
X, Y, XMean, XVar, XSD, YMean, YVar, YSD, pmcorr, z, rprob : double;
strout : string;
NMatrix : IntDyneMat;
tMatrix : DblDyneMat;
ProbMat : DblDyneMat;
startpos, endpos : integer;
begin
OutputFrm.RichEdit.Clear;
SetLength(NMatrix,NoVars,NoVars);
SetLength(tMatrix,NoVars,NoVars);
SetLength(ProbMat,NoVars,NoVars);
for i := 1 to NoVars - 1 do
begin
for j := i + 1 to NoVars do
begin
XMean := 0.0;
XVar := 0.0;
XCol := ColNoSelected[i-1];
YMean := 0.0;
YVar := 0.0;
YCol := ColNoSelected[j-1];
pmcorr := 0.0;
Npairs := 0;
strout := ColLabels[i-1];
strout := strout + ' vs ';
strout := strout + ColLabels[j-1];
OutputFrm.RichEdit.Lines.Add(strout);
for k := 1 to NoCases do
begin
if not ValidValue(k,XCol) then continue;
if not ValidValue(k,YCol) then continue;
X := StrToFloat(OS3MainFrm.DataGrid.Cells[XCol,k]);
Y := StrToFloat(OS3MainFrm.DataGrid.Cells[YCol,k]);
pmcorr := pmcorr + (X * Y);
XMean := XMean + X;
YMean := YMean + Y;
XVar := XVar + (X * X);
YVar := YVar + (Y * Y);
Npairs := NPairs + 1;
end;
if CPChkBox.Checked then
begin
strout := format('CrossProducts[%d,%d]=%6.4f, N cases = %d',[i,j,pmcorr,Npairs]);
OutputFrm.RichEdit.Lines.Add(strout);
end;
pmcorr := pmcorr - (XMean * YMean) / Npairs;
pmcorr := pmcorr / (Npairs - 1);
if CovChkBox.Checked then
begin
strout := format('Covariance[%d,%d]=%6.4f, N cases = %d',[i,j,pmcorr,Npairs]);
OutputFrm.RichEdit.Lines.Add(strout);
end;
XVar := XVar - (XMean * XMean) / Npairs;
XVar := XVar / (Npairs - 1);
XSD := sqrt(XVar);
YVar := YVar - (YMean * YMean) / Npairs;
YVar := YVar / (Npairs - 1);
YSD := sqrt(YVar);
XMean := XMean / Npairs;
YMean := YMean / Npairs;
pmcorr := pmcorr / (XSD * YSD);
Matrix[i-1,j-1] := pmcorr;
Matrix[j-1,i-1] := pmcorr;
NMatrix[i-1,j-1] := Npairs;
NMatrix[j-1,i-1] := NPairs;
if CorrsChkBox.Checked then
begin
N := Npairs - 2;
z := abs(pmcorr) * (sqrt((N-2)/(1.0 - (pmcorr * pmcorr))));
rprob := probt(z,N);
// Using Fisher's z transform below gives SPSS results
// N := Npairs - 3;
// z := 0.5 * ln( (1.0 + pmcorr)/(1.0 - pmcorr) );
// z := z / sqrt(1.0/N);
// rprob := probz(z);
strout := format('r[%d,%d]=%6.4f, N cases = %d',[i,j,pmcorr,Npairs]);
OutputFrm.RichEdit.Lines.Add(strout);
strout := format('t value with d.f. %d = %8.4f with Probability > t = %6.4f',[Npairs-2,z,rprob]);
OutputFrm.RichEdit.Lines.Add(strout);
tMatrix[i-1,j-1] := z;
tMatrix[j-1,i-1] := z;
ProbMat[i-1,j-1] := rprob;
ProbMat[j-1,i-1] := rprob;
end;
if MeansChkBox.Checked or VarChkBox.Checked or SDChkBox.Checked then
begin
strout := format('Mean X = %8.4f, Variance X = %8.4f, Std.Dev. X = %8.4f',[XMean,XVar,XSD]);
OutputFrm.RichEdit.Lines.Add(strout);
strout := format('Mean Y = %8.4f, Variance Y = %8.4f, Std.Dev. Y = %8.4f',[YMean,YVar,YSD]);
OutputFrm.RichEdit.Lines.Add(strout);
end;
OutputFrm.RichEdit.Lines.Add('');
end; // next j variable
Matrix[i-1,i-1] := 1.0;
end; // next i variable
Matrix[NoVars-1,NoVars-1] := 1.0;
OutputFrm.ShowModal;
OutputFrm.RichEdit.Clear;
OutputFrm.RichEdit.Lines.Add('Intercorrelation Matrix and Statistics');
OutputFrm.RichEdit.Lines.Add('');
// strout := 'Correlation Matrix Summary (Ns in lower triangle)';
// MAT_PRINT(Matrix,NoVars,NoVars,strout,ColLabels,ColLabels,NoCases);
startpos := 1;
endpos := 6;
if endpos > NoVars then endpos := NoVars;
for i := 1 to NoVars do
begin
nextpart:
strout := ' ';
for j := startpos to endpos do
strout := strout + format(' %5d',[j]);
OutputFrm.RichEdit.Lines.Add(strout);
strout := format('%2d PMCorr.',[i]);
for j := startpos to endpos do
strout := strout + format(' %7.4f',[Matrix[i-1,j-1]]);
OutputFrm.RichEdit.Lines.Add(strout);
strout := format('%2d N Size ',[i]);
for j := startpos to endpos do
begin
if j <> i then
strout := strout + format(' %3d ',[NMatrix[i-1,j-1]])
else begin
Npairs := 0;
for k := 1 to NoCases do
begin
if ValidValue(k,ColNoSelected[j-1])
then Npairs := Npairs + 1;
end;
strout := strout + format(' %3d ',[Npairs]);
end;
end;
OutputFrm.RichEdit.Lines.Add(strout);
strout := format('%2d t Value',[i]);
for j := startpos to endpos do
begin
if j <> i then
strout := strout + format(' %7.4f',[tMatrix[i-1,j-1]])
else strout := strout + ' ';
end;
OutputFrm.RichEdit.Lines.Add(strout);
strout := format('%2d Prob. t',[i]);
for j := startpos to endpos do
begin
if j <> i then
strout := strout + format(' %7.4f',[ProbMat[i-1,j-1]])
else strout := strout + ' ';
end;
OutputFrm.RichEdit.Lines.Add(strout);
OutputFrm.RichEdit.Lines.Add('');
if endpos < NoVars then
begin
startpos := endpos + 1;
endpos := endpos + 6;
if endpos > NoVars then endpos := NoVars;
goto nextpart;
end;
end;
OutputFrm.ShowModal;
ProbMat := nil;
tMatrix := nil;
NMatrix := nil;
end;
initialization
{$I rmatunit.lrs}
end.

View File

@ -0,0 +1,528 @@
object ABCLogLinearFrm: TABCLogLinearFrm
Left = 596
Height = 432
Top = 216
Width = 371
AutoSize = True
Caption = 'Log Linear Analysis for AxBxC Classification Table'
ClientHeight = 432
ClientWidth = 371
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 162
Height = 25
Top = 399
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 3
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 224
Height = 25
Top = 399
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 4
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 308
Height = 25
Top = 399
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 5
end
object HelpBtn: TButton
Tag = 101
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 103
Height = 25
Top = 399
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 2
end
object Notebook1: TNotebook
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = FileFromGrp
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1
Left = 8
Height = 316
Top = 67
Width = 355
PageIndex = 0
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
TabOrder = 1
object Page1: TPage
object Label3: TLabel
AnchorSideLeft.Control = RowVarEdit
AnchorSideBottom.Control = RowVarEdit
Left = 199
Height = 15
Top = 8
Width = 67
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Row Variable'
ParentColor = False
end
object Label4: TLabel
AnchorSideLeft.Control = ColVarEdit
AnchorSideBottom.Control = ColVarEdit
Left = 199
Height = 15
Top = 84
Width = 87
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Column Variable'
ParentColor = False
end
object Label5: TLabel
AnchorSideLeft.Control = SliceVarEdit
AnchorSideBottom.Control = SliceVarEdit
Left = 199
Height = 15
Top = 160
Width = 68
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Slice Variable'
ParentColor = False
end
object Label6: TLabel
AnchorSideLeft.Control = FreqVarEdit
AnchorSideBottom.Control = FreqVarEdit
Left = 199
Height = 15
Top = 236
Width = 99
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Frequency Variable'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Page1
AnchorSideTop.Control = Page1
AnchorSideRight.Control = RowInBtn
AnchorSideBottom.Control = Page1
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 316
Top = 0
Width = 155
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Right = 8
ItemHeight = 0
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object RowInBtn: TBitBtn
AnchorSideLeft.Control = Page1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
Left = 163
Height = 28
Top = 0
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = RowInBtnClick
Spacing = 0
TabOrder = 1
end
object RowOutBtn: TBitBtn
AnchorSideLeft.Control = Page1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = RowInBtn
AnchorSideTop.Side = asrBottom
Left = 163
Height = 28
Top = 32
Width = 28
BorderSpacing.Top = 4
Enabled = False
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = RowOutBtnClick
Spacing = 0
TabOrder = 2
end
object ColInBtn: TBitBtn
AnchorSideLeft.Control = Page1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = RowOutBtn
AnchorSideTop.Side = asrBottom
Left = 163
Height = 28
Top = 76
Width = 28
BorderSpacing.Top = 16
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = ColInBtnClick
Spacing = 0
TabOrder = 4
end
object ColOutBtn: TBitBtn
AnchorSideLeft.Control = Page1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = ColInBtn
AnchorSideTop.Side = asrBottom
Left = 163
Height = 28
Top = 108
Width = 28
BorderSpacing.Top = 4
Enabled = False
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = ColOutBtnClick
Spacing = 0
TabOrder = 5
end
object SliceBtnIn: TBitBtn
AnchorSideLeft.Control = Page1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = ColOutBtn
AnchorSideTop.Side = asrBottom
Left = 163
Height = 28
Top = 152
Width = 28
BorderSpacing.Top = 16
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = SliceBtnInClick
Spacing = 0
TabOrder = 7
end
object SliceBtnOut: TBitBtn
AnchorSideLeft.Control = Page1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = SliceBtnIn
AnchorSideTop.Side = asrBottom
Left = 163
Height = 28
Top = 184
Width = 28
BorderSpacing.Top = 4
Enabled = False
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = SliceBtnOutClick
Spacing = 0
TabOrder = 8
end
object FreqInBtn: TBitBtn
AnchorSideLeft.Control = Page1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = SliceBtnOut
AnchorSideTop.Side = asrBottom
Left = 163
Height = 28
Top = 228
Width = 28
BorderSpacing.Top = 16
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = FreqInBtnClick
Spacing = 0
TabOrder = 10
end
object FreqOutBtn: TBitBtn
AnchorSideLeft.Control = Page1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = FreqInBtn
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 163
Height = 28
Top = 260
Width = 28
BorderSpacing.Top = 4
Enabled = False
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = FreqOutBtnClick
Spacing = 0
TabOrder = 11
end
object RowVarEdit: TEdit
AnchorSideLeft.Control = RowInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Page1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = RowOutBtn
AnchorSideBottom.Side = asrBottom
Left = 199
Height = 23
Top = 25
Width = 156
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 3
Text = 'RowVarEdit'
end
object ColVarEdit: TEdit
AnchorSideLeft.Control = ColInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Page1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ColOutBtn
AnchorSideBottom.Side = asrBottom
Left = 199
Height = 23
Top = 101
Width = 156
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 6
Text = 'ColVarEdit'
end
object SliceVarEdit: TEdit
AnchorSideLeft.Control = SliceBtnIn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Page1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = SliceBtnOut
AnchorSideBottom.Side = asrBottom
Left = 199
Height = 23
Top = 177
Width = 156
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 9
Text = 'SliceVarEdit'
end
object FreqVarEdit: TEdit
AnchorSideLeft.Control = FreqInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Page1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = FreqOutBtn
AnchorSideBottom.Side = asrBottom
Left = 199
Height = 23
Top = 253
Width = 156
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 12
Text = 'FreqVarEdit'
end
end
object Page2: TPage
object Label1: TLabel
AnchorSideLeft.Control = Page2
AnchorSideTop.Control = NRowsEdit
AnchorSideTop.Side = asrCenter
Left = 0
Height = 15
Top = 4
Width = 67
Caption = 'No. of Rows:'
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = NRowsEdit
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrCenter
Left = 134
Height = 15
Top = 4
Width = 65
BorderSpacing.Left = 16
Caption = 'No. of Cols.:'
ParentColor = False
end
object Label7: TLabel
AnchorSideLeft.Control = NColsEdit
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrCenter
Left = 270
Height = 15
Top = 4
Width = 68
BorderSpacing.Left = 16
Caption = 'No. of Slices:'
ParentColor = False
end
object NRowsEdit: TEdit
AnchorSideLeft.Control = Label1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Page2
Left = 75
Height = 23
Top = 0
Width = 43
Alignment = taRightJustify
BorderSpacing.Left = 8
OnKeyPress = NRowsEditKeyPress
TabOrder = 0
Text = 'NRowsEdit'
end
object NColsEdit: TEdit
AnchorSideLeft.Control = Label2
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Page2
Left = 207
Height = 23
Top = 0
Width = 47
Alignment = taRightJustify
BorderSpacing.Left = 8
OnKeyPress = NColsEditKeyPress
TabOrder = 1
Text = 'NColsEdit'
end
object Grid: TStringGrid
AnchorSideLeft.Control = Page2
AnchorSideTop.Control = NRowsEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Page2
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Page2
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 339
Top = 31
Width = 444
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 8
ColCount = 2
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goTabs, goSmoothScroll]
RowCount = 2
TabOrder = 2
end
object NslicesEdit: TEdit
AnchorSideLeft.Control = Label7
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Page2
Left = 346
Height = 23
Top = 0
Width = 39
Alignment = taRightJustify
BorderSpacing.Left = 8
OnKeyPress = NslicesEditKeyPress
TabOrder = 3
Text = 'NslicesEdit'
end
end
end
object FileFromGrp: TRadioGroup
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 8
Height = 51
Top = 8
Width = 354
AutoFill = True
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Enter Data From:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 16
ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2
ClientHeight = 31
ClientWidth = 350
Columns = 2
Items.Strings = (
'File Data in the Main Grid'
'Data Entered on this Form'
)
OnClick = FileFromGrpClick
TabOrder = 0
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 383
Width = 371
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object Bevel2: TBevel
Left = 1
Height = 12
Top = 434
Width = 10
Shape = bsSpacer
end
end

View File

@ -0,0 +1,449 @@
object LogLinScreenFrm: TLogLinScreenFrm
Left = 456
Height = 584
Top = 135
Width = 402
AutoSize = True
Caption = 'Cross-Classification Log Linear Screen'
ClientHeight = 584
ClientWidth = 402
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Label1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = CountVarChk
AnchorSideTop.Side = asrBottom
Left = 8
Height = 15
Top = 39
Width = 337
BorderSpacing.Left = 8
BorderSpacing.Top = 12
Caption = '1. Select the variables of the Grid that define your classifications'
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrBottom
Left = 8
Height = 15
Top = 208
Width = 97
BorderSpacing.Left = 8
BorderSpacing.Top = 12
Caption = 'Available Variables'
ParentColor = False
end
object Label3: TLabel
AnchorSideLeft.Control = SelectList
AnchorSideTop.Control = Label2
Left = 232
Height = 15
Top = 208
Width = 44
Caption = 'Selected'
ParentColor = False
end
object CountVarChk: TCheckBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 8
Height = 19
Top = 8
Width = 247
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Last Variable Selected is a Frequency Count'
TabOrder = 0
end
object Step2Btn: TButton
AnchorSideLeft.Control = Label10
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label10
AnchorSideTop.Side = asrCenter
Left = 234
Height = 25
Top = 55
Width = 52
AutoSize = True
BorderSpacing.Left = 16
Caption = 'Click'
OnClick = Step2BtnClick
TabOrder = 1
end
object VarList: TListBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = AllBtn
AnchorSideBottom.Control = GroupBox1
Left = 8
Height = 230
Top = 225
Width = 162
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Constraints.MinHeight = 220
ItemHeight = 0
MultiSelect = True
TabOrder = 3
end
object InBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
Left = 187
Height = 28
Top = 225
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = InBtnClick
Spacing = 0
TabOrder = 4
end
object OutBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = InBtn
AnchorSideTop.Side = asrBottom
Left = 187
Height = 28
Top = 257
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = OutBtnClick
Spacing = 0
TabOrder = 5
end
object AllBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = OutBtn
AnchorSideTop.Side = asrBottom
Left = 178
Height = 25
Top = 289
Width = 46
AutoSize = True
BorderSpacing.Top = 4
Caption = 'ALL'
OnClick = AllBtnClick
Spacing = 0
TabOrder = 6
end
object SelectList: TListBox
AnchorSideLeft.Control = AllBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = VarList
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = VarList
AnchorSideBottom.Side = asrBottom
Left = 232
Height = 230
Top = 225
Width = 162
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Right = 8
ItemHeight = 0
TabOrder = 7
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label11
AnchorSideTop.Side = asrBottom
Left = 24
Height = 85
Top = 111
Width = 244
AutoSize = True
BorderSpacing.Left = 24
BevelOuter = bvNone
ClientHeight = 85
ClientWidth = 244
TabOrder = 2
object Label7: TLabel
AnchorSideTop.Control = VarNoEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = VarNoEdit
Left = 137
Height = 15
Top = 12
Width = 44
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Variable:'
ParentColor = False
end
object Label8: TLabel
AnchorSideTop.Control = MinEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = MinEdit
Left = 98
Height = 15
Top = 39
Width = 87
Anchors = [akTop, akRight]
BorderSpacing.Right = 4
Caption = 'Minimum Value:'
ParentColor = False
end
object Label9: TLabel
AnchorSideTop.Control = MaxEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = MaxEdit
Left = 92
Height = 15
Top = 66
Width = 89
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Maximum Value:'
ParentColor = False
end
object ScrollBar1: TScrollBar
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = VarNoEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Label7
Left = 0
Height = 17
Top = 11
Width = 121
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Right = 16
PageSize = 0
TabOrder = 0
OnChange = ScrollBar1Change
end
object VarNoEdit: TEdit
AnchorSideTop.Control = Panel1
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 189
Height = 23
Top = 8
Width = 55
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Top = 8
TabOrder = 1
Text = 'VarNoEdit'
end
object MinEdit: TEdit
AnchorSideLeft.Control = VarNoEdit
AnchorSideTop.Control = VarNoEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 189
Height = 23
Top = 35
Width = 55
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 4
OnKeyPress = MinEditKeyPress
TabOrder = 2
Text = 'MinEdit'
end
object MaxEdit: TEdit
AnchorSideLeft.Control = VarNoEdit
AnchorSideTop.Control = MinEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 189
Height = 23
Top = 62
Width = 55
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 4
OnKeyPress = MaxEditKeyPress
TabOrder = 3
Text = 'MaxEdit'
end
end
object GroupBox1: TGroupBox
AnchorSideLeft.Control = Owner
AnchorSideBottom.Control = Bevel1
Left = 8
Height = 72
Top = 463
Width = 241
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 8
Caption = 'Options'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 52
ClientWidth = 237
TabOrder = 8
object MarginsChk: TCheckBox
Left = 12
Height = 19
Top = 6
Width = 213
Caption = 'Print Marginal Totals'
TabOrder = 0
end
object GenlModelChk: TCheckBox
Left = 12
Height = 19
Top = 27
Width = 213
Caption = 'Print General Linear Modle Estimates'
TabOrder = 1
end
end
object ResetBtn: TButton
AnchorSideRight.Control = CancelBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 101
Height = 25
Top = 551
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 10
end
object CancelBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 167
Height = 25
Top = 551
Width = 62
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Cancel'
ModalResult = 2
OnClick = CancelBtnClick
TabOrder = 11
end
object ComputeBtn: TButton
AnchorSideRight.Control = ReturnBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 241
Height = 25
Top = 551
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 12
end
object ReturnBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 329
Height = 25
Top = 551
Width = 61
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Return'
ModalResult = 1
OnClick = ReturnBtnClick
TabOrder = 13
end
object HelpBtn: TButton
Tag = 131
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 38
Height = 25
Top = 551
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 9
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ReturnBtn
Left = 0
Height = 8
Top = 535
Width = 402
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object Label10: TLabel
AnchorSideLeft.Control = Label1
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
Left = 8
Height = 15
Top = 60
Width = 210
BorderSpacing.Top = 6
Caption = '2. Click here when variables are selected'
ParentColor = False
end
object Label11: TLabel
AnchorSideTop.Control = Label10
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 8
Height = 30
Top = 81
Width = 386
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
BorderSpacing.Right = 8
Caption = '3. For each variable complete the specifications below. Press the ENTER key following each entry.'
ParentColor = False
WordWrap = True
end
end

View File

@ -0,0 +1,435 @@
object TwoWayLogLinFrm: TTwoWayLogLinFrm
Left = 494
Height = 352
Top = 237
Width = 425
AutoSize = True
Caption = 'Log Linear Analysis of a 2x2 Table'
ClientHeight = 352
ClientWidth = 425
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object FileFromGrp: TRadioGroup
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 8
Height = 51
Top = 8
Width = 354
AutoFill = False
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Enter Data From:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 16
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2
ClientHeight = 31
ClientWidth = 350
Columns = 2
Items.Strings = (
'File Data in the Main Grid'
'Data Entered on this Form'
)
OnClick = FileFromGrpClick
TabOrder = 0
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 216
Height = 25
Top = 319
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 3
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 278
Height = 25
Top = 319
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 4
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 362
Height = 25
Top = 319
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 5
end
object HelpBtn: TButton
Tag = 154
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 157
Height = 25
Top = 319
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 2
end
object Notebook1: TNotebook
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = FileFromGrp
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1
Left = 8
Height = 236
Top = 67
Width = 409
PageIndex = 0
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
TabOrder = 1
object Page1: TPage
object Label1: TLabel
AnchorSideLeft.Control = RowVarEdit
AnchorSideBottom.Control = RowVarEdit
Left = 226
Height = 15
Top = 16
Width = 67
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Row Variable'
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = ColVarEdit
AnchorSideBottom.Control = ColVarEdit
Left = 226
Height = 15
Top = 90
Width = 87
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Column Variable'
ParentColor = False
end
object Label3: TLabel
AnchorSideLeft.Control = FreqVarEdit
AnchorSideBottom.Control = FreqVarEdit
Left = 226
Height = 15
Top = 176
Width = 99
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Frequency Variable'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Page1
AnchorSideTop.Control = Page1
AnchorSideRight.Control = RowInBtn
AnchorSideBottom.Control = Page1
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 236
Top = 0
Width = 182
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Right = 8
ItemHeight = 0
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object RowInBtn: TBitBtn
AnchorSideLeft.Control = Page1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
Left = 190
Height = 28
Top = 8
Width = 28
BorderSpacing.Top = 8
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = RowInBtnClick
Spacing = 0
TabOrder = 1
end
object RowOutBtn: TBitBtn
AnchorSideLeft.Control = RowInBtn
AnchorSideTop.Control = RowInBtn
AnchorSideTop.Side = asrBottom
Left = 190
Height = 28
Top = 40
Width = 28
BorderSpacing.Top = 4
Enabled = False
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = RowOutBtnClick
Spacing = 0
TabOrder = 2
end
object ColInBtn: TBitBtn
AnchorSideLeft.Control = Page1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Label2
AnchorSideBottom.Control = ColVarEdit
AnchorSideBottom.Side = asrBottom
Left = 190
Height = 28
Top = 90
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = ColInBtnClick
Spacing = 0
TabOrder = 4
end
object ColOutBtn: TBitBtn
AnchorSideLeft.Control = ColInBtn
AnchorSideTop.Control = ColInBtn
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 190
Height = 28
Top = 122
Width = 28
BorderSpacing.Top = 4
Enabled = False
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = ColOutBtnClick
Spacing = 0
TabOrder = 5
end
object FreqInBtn: TBitBtn
AnchorSideLeft.Control = Page1
AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = FreqOutBtn
Left = 190
Height = 28
Top = 168
Width = 28
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 4
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = FreqInBtnClick
Spacing = 0
TabOrder = 7
end
object FreqOutBtn: TBitBtn
AnchorSideLeft.Control = FreqInBtn
AnchorSideBottom.Control = VarList
AnchorSideBottom.Side = asrBottom
Left = 190
Height = 28
Top = 200
Width = 28
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 8
Enabled = False
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = FreqOutBtnClick
Spacing = 0
TabOrder = 8
end
object RowVarEdit: TEdit
AnchorSideLeft.Control = RowInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Page1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = RowOutBtn
AnchorSideBottom.Side = asrBottom
Left = 226
Height = 23
Top = 33
Width = 183
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 3
Text = 'RowVarEdit'
end
object ColVarEdit: TEdit
AnchorSideLeft.Control = RowInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = VarList
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Page1
AnchorSideRight.Side = asrBottom
Left = 226
Height = 23
Top = 107
Width = 183
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
ReadOnly = True
TabOrder = 6
Text = 'ColVarEdit'
end
object FreqVarEdit: TEdit
AnchorSideLeft.Control = FreqInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Page1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = FreqOutBtn
AnchorSideBottom.Side = asrBottom
Left = 226
Height = 23
Top = 193
Width = 183
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 9
Text = 'FreqVarEdit'
end
end
object Page2: TPage
object NoRowsLabel: TLabel
AnchorSideLeft.Control = Page2
AnchorSideTop.Control = NoRowsEdit
AnchorSideTop.Side = asrCenter
Left = 0
Height = 15
Top = 4
Width = 67
Caption = 'No. of Rows:'
ParentColor = False
end
object NoColsLabel: TLabel
AnchorSideLeft.Control = NoRowsEdit
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = NoColsEdit
AnchorSideTop.Side = asrCenter
Left = 138
Height = 15
Top = 4
Width = 87
BorderSpacing.Left = 24
BorderSpacing.Right = 8
Caption = 'No. of Columns:'
ParentColor = False
end
object NoRowsEdit: TEdit
AnchorSideLeft.Control = NoRowsLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Page2
Left = 75
Height = 23
Top = 0
Width = 39
Alignment = taRightJustify
BorderSpacing.Left = 8
OnKeyPress = NoRowsEditKeyPress
TabOrder = 0
Text = 'NoRowsEdit'
end
object NoColsEdit: TEdit
AnchorSideLeft.Control = NoColsLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Page2
AnchorSideRight.Control = Page2
AnchorSideRight.Side = asrBottom
Left = 233
Height = 23
Top = 0
Width = 46
Alignment = taRightJustify
BorderSpacing.Left = 8
OnKeyPress = NoColsEditKeyPress
TabOrder = 1
Text = 'Edit1'
end
object Grid: TStringGrid
AnchorSideLeft.Control = Page2
AnchorSideTop.Control = NoRowsEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Page2
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Page2
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 235
Top = 31
Width = 373
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 8
ColCount = 2
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goColSizing, goEditing, goTabs, goThumbTracking, goSmoothScroll]
RowCount = 2
TabOrder = 2
end
end
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 303
Width = 425
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object Bevel2: TBevel
Left = 3
Height = 14
Top = 336
Width = 18
Shape = bsSpacer
end
end

View File

@ -0,0 +1,886 @@
unit TwoWayLogLinUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
ExtCtrls, StdCtrls, Buttons, Grids,
OutputUnit, MainUnit, Globals, DataProcs, ContextHelpUnit;
type
{ TTwoWayLogLinFrm }
TTwoWayLogLinFrm = class(TForm)
Bevel1: TBevel;
Bevel2: TBevel;
HelpBtn: TButton;
Notebook1: TNotebook;
Page1: TPage;
Page2: TPage;
ResetBtn: TButton;
ComputeBtn: TButton;
CloseBtn: TButton;
RowInBtn: TBitBtn;
RowOutBtn: TBitBtn;
ColInBtn: TBitBtn;
ColOutBtn: TBitBtn;
FreqInBtn: TBitBtn;
FreqOutBtn: TBitBtn;
NoRowsEdit: TEdit;
NoColsEdit: TEdit;
NoRowsLabel: TLabel;
NoColsLabel: TLabel;
RowVarEdit: TEdit;
ColVarEdit: TEdit;
FreqVarEdit: TEdit;
FileFromGrp: TRadioGroup;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Grid: TStringGrid;
VarList: TListBox;
procedure ColInBtnClick(Sender: TObject);
procedure ColOutBtnClick(Sender: TObject);
procedure ComputeBtnClick(Sender: TObject);
procedure FileFromGrpClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FreqInBtnClick(Sender: TObject);
procedure FreqOutBtnClick(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
procedure NoColsEditKeyPress(Sender: TObject; var Key: char);
procedure NoRowsEditKeyPress(Sender: TObject; var Key: char);
procedure ResetBtnClick(Sender: TObject);
procedure RowInBtnClick(Sender: TObject);
procedure RowOutBtnClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean);
private
{ private declarations }
FAutoSized: Boolean;
procedure UpdateBtnStates;
procedure PrintTable(Nrows, Ncols: integer; const Data: DblDyneMat;
const RowMarg, ColMarg: DblDyneVec; Total: double; AReport: TStrings);
procedure Iterate(Nrows, Ncols: integer;
const Data: DblDyneMat; const RowMarg, ColMarg: DblDyneVec;
var Total: double;
const Expected: DblDyneMat; const NewRowMarg, NewColMarg: DblDyneVec;
var NewTotal: double);
procedure PrintLamdas(Nrows, Ncols : integer; const CellLambdas: DblDyneCube;
mu: double; AReport: TStrings);
public
{ public declarations }
end;
var
TwoWayLogLinFrm: TTwoWayLogLinFrm;
implementation
uses
Math;
{ TTwoWayLogLinFrm }
procedure TTwoWayLogLinFrm.ResetBtnClick(Sender: TObject);
VAR i, j : integer;
begin
for i := 0 to Grid.RowCount - 1 do
for j := 0 to Grid.ColCount - 1 do
Grid.Cells[j,i] := '';
Grid.ColCount := 3;
Grid.RowCount := 2;
Grid.Cells[0,0] := 'ROW';
Grid.Cells[1,0] := 'COL';
Grid.Cells[2,0] := 'FREQ';
VarList.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
RowVarEdit.Text := '';
ColVarEdit.Text := '';
FreqVarEdit.Text := '';
NoRowsEdit.Text := '';
NoColsEdit.Text := '';
FileFromGrp.ItemIndex := -1;
Notebook1.Hide;
{
VarList.Visible := false;
RowInBtn.Enabled := false;
RowOutBtn.Enabled := false;
ColInBtn.Enabled := false;
ColOutBtn.Enabled := false;
FreqInBtn.Enabled := false;
FreqOutBtn.Enabled := false;
Label1.Visible := false;
Label2.Visible := false;
Label3.Visible := false;
RowVarEdit.Visible := false;
ColVarEdit.Visible := false;
FreqVarEdit.Visible := false;
// Memo1.Visible := false;
NoRowsLabel.Visible := false;
NoColsLabel.Visible := false;
NoRowsEdit.Visible := false;
NoColsEdit.Visible := false;
Grid.Visible := false;
}
end;
procedure TTwoWayLogLinFrm.RowInBtnClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (RowVarEdit.Text = '') then
begin
RowVarEdit.Text := VarList.Items[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TTwoWayLogLinFrm.RowOutBtnClick(Sender: TObject);
begin
if RowVarEdit.Text <> '' then
begin
VarList.Items.Add(RowVarEdit.Text);
RowVarEdit.Text := '';
end;
UpdateBtnStates;
end;
procedure TTwoWayLogLinFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
HelpBtn.Constraints.MinWidth := w;
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TTwoWayLogLinFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
if OutputFrm = nil then Application.CreateForm(TOutputFrm, OutputFrm);
end;
procedure TTwoWayLogLinFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(Self);
end;
procedure TTwoWayLogLinFrm.FreqInBtnClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (FreqVarEdit.Text = '') then
begin
FreqVarEdit.Text := VarList.Items[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TTwoWayLogLinFrm.FreqOutBtnClick(Sender: TObject);
begin
if FreqVarEdit.Text <> '' then
begin
VarList.Items.Add(FreqVarEdit.Text);
FreqVarEdit.Text := '';
end;
UpdateBtnStates;
end;
procedure TTwoWayLogLinFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).Tag);
end;
procedure TTwoWayLogLinFrm.NoColsEditKeyPress(Sender: TObject; var Key: char);
var
i, j, row : integer;
Ncols, Nrows : integer;
begin
if ord(Key) = 13 then
begin
Nrows := StrToInt(NoRowsEdit.Text);
Ncols := StrToInt(NoColsEdit.Text);
Grid.RowCount := (Nrows * Ncols) + 1;
// setup row and column values in the grid
row := 1;
for j := 1 to Ncols do
begin
for i := 1 to Nrows do
begin
Grid.Cells[0,row] := IntToStr(i);
Grid.Cells[1,row] := IntToStr(j);
row := row + 1;
end;
end;
Grid.SetFocus;
end;
end;
procedure TTwoWayLogLinFrm.NoRowsEditKeyPress(Sender: TObject; var Key: char);
begin
if ord(Key) = 13 then NoColsEdit.SetFocus;
end;
procedure TTwoWayLogLinFrm.ComputeBtnClick(Sender: TObject);
var
Data : DblDyneMat;
NewData : DblDyneMat;
Prop : DblDyneMat;
LogData : DblDyneMat;
Expected : DblDyneMat;
i, j, k : integer;
RowMarg : DblDyneVec;
NewRowMarg : DblDyneVec;
RowLogs : DblDyneVec;
ColMarg : DblDyneVec;
NewColMarg : DblDyneVec;
ColLogs : DblDyneVec;
CellLambdas : DblDyneCube;
Total : double;
NewTotal : double;
TotalLogs : double;
mu : double;
row, col : integer;
ModelTotal : double;
astr : string;
Ysqr : double;
DF : integer;
chisqr: double;
odds : double;
Nrows, Ncols : integer;
RowCol, ColCol, Fcol : integer;
GridPos : IntDyneVec;
value : integer;
Fx : double;
lReport: TStrings;
begin
Total := 0.0;
TotalLogs := 0.0;
Nrows := 0;
Ncols := 0;
if FileFromGrp.ItemIndex = 0 then // mainfrm input
begin
SetLength(GridPos,3);
for i := 1 to NoVariables do
begin
if RowVarEdit.Text = OS3MainFrm.DataGrid.Cells[i,0] then GridPos[0] := i;
if ColVarEdit.Text = OS3MainFrm.DataGrid.Cells[i,0] then GridPos[1] := i;
if FreqVarEdit.Text = OS3MainFrm.DataGrid.Cells[i,0] then GridPos[2] := i;
end;
// get no. of rows and columns
for i := 1 to OS3MainFrm.DataGrid.RowCount - 1 do
begin
value := StrToInt(OS3MainFrm.DataGrid.Cells[GridPos[0],i]);
if value > Nrows then Nrows := value;
value := StrToInt(OS3MainFrm.DataGrid.Cells[GridPos[1],i]);
if value > Ncols then Ncols := value;
end;
// Get data
SetLength(Data,Nrows+1,Ncols+1);
SetLength(CellLambdas,Nrows+1,Ncols+1,4);
SetLength(RowMarg,Nrows+1);
SetLength(RowLogs,Nrows+1);
SetLength(ColMarg,Ncols+1);
SetLength(ColLogs,Ncols+1);
SetLength(Prop,Nrows+1,Ncols+1);
SetLength(LogData,Nrows+1,Ncols+1);
SetLength(Expected,Nrows+1,Ncols+1);
SetLength(NewData,Nrows+1,Ncols+1);
SetLength(NewRowMarg,Nrows+1);
SetLength(NewColMarg,Ncols+1);
for i := 1 to Nrows do
for j := 1 to Ncols do
Data[i,j] := 0.0;
rowcol := GridPos[0];
colcol := GridPos[1];
Fcol := GridPos[2];
for i := 1 to OS3MainFrm.DataGrid.RowCount - 1 do
begin
if Not GoodRecord(i, 3, GridPos) then continue;
row := StrToInt(OS3MainFrm.DataGrid.Cells[rowcol,i]);
col := StrToInt(OS3MainFrm.DataGrid.Cells[colcol,i]);
Fx := StrToInt(OS3MainFrm.DataGrid.Cells[Fcol,i]);
Data[row,col] := Data[row,col] + Fx;
Total := Total + Fx;
end;
GridPos := nil;
end;
if FileFromGrp.ItemIndex = 1 then // form data
begin
Nrows := StrToInt(NoRowsEdit.Text);
Ncols := StrToInt(NoColsEdit.Text);
SetLength(Data,Nrows+1,Ncols+1);
SetLength(CellLambdas,Nrows+1,Ncols+1,4);
SetLength(RowMarg,Nrows+1);
SetLength(RowLogs,Nrows+1);
SetLength(ColMarg,Ncols+1);
SetLength(ColLogs,Ncols+1);
SetLength(Prop,Nrows+1,Ncols+1);
SetLength(LogData,Nrows+1,Ncols+1);
SetLength(Expected,Nrows+1,Ncols+1);
SetLength(NewData,Nrows+1,Ncols+1);
SetLength(NewRowMarg,Nrows+1);
SetLength(NewColMarg,Ncols+1);
end;
for i := 1 to Nrows do
for j := 1 to Ncols do
for k := 1 to 3 do CellLambdas[i,j,k] := 0.0;
for i := 1 to Nrows do
begin
RowMarg[i] := 0.0;
RowLogs[i] := 0.0;
end;
for j := 1 to Ncols do
begin
ColMarg[j] := 0.0;
ColLogs[j] := 0.0;
end;
if FileFromGrp.ItemIndex = 1 then // get data from grid
begin
for i := 1 to (Nrows * Ncols) do
begin
row := StrToInt(Grid.Cells[0,i]);
col := StrToInt(Grid.Cells[1,i]);
Data[row,col] := StrToFloat(Grid.Cells[2,i]);
Total := Total + Data[row,col];
end;
end;
for i := 1 to Nrows do
begin
for j := 1 to Ncols do
begin
RowMarg[i] := RowMarg[i] + Data[i,j];
ColMarg[j] := ColMarg[j] + Data[i,j];
Prop[i,j] := Prop[i,j] / Total;
LogData[i,j] := ln(Data[i,j]);
end;
end;
// report cross-products odds and log odds ratios
lReport := TStringList.Create;
try
lReport.Add('ANALYSES FOR AN I BY J CLASSIFICATION TABLE');
lReport.Add('');
lReport.Add('Reference: G.J.G. Upton, The Analysis of Cross-tabulated Data, 1980');
lReport.Add('');
if (Nrows = 2) and (Ncols = 2) then
begin
odds := (Data[1,1] * Data[2,2]) / (Data[1,2] * Data[2,1]);
lReport.Add('Cross-Products Odds Ratio: %6.3f', [odds]);
lReport.Add('Log odds of the cross-products ratio: %6.3f', [ln(odds)]);
lReport.Add('');
end;
for i := 1 to Nrows do
begin
for j := 1 to Ncols do
begin
RowLogs[i] := RowLogs[i] + LogData[i,j];
ColLogs[j] := ColLogs[j] + LogData[i,j];
TotalLogs := TotalLogs + LogData[i,j];
end;
end;
for i := 1 to Nrows do RowLogs[i] := RowLogs[i] / Ncols;
for j := 1 to Ncols do ColLogs[j] := ColLogs[j] / Nrows;
TotalLogs := TotalLogs / (Nrows * Ncols);
mu := TotalLogs;
for i := 1 to Nrows do
for j := 1 to Ncols do
begin
CellLambdas[i,j,1] := RowLogs[i] - TotalLogs;
CellLambdas[i,j,2] := ColLogs[j] - TotalLogs;
CellLambdas[i,j,3] := LogData[i,j] - RowLogs[i] - ColLogs[j] + TotalLogs;
end;
// Get expected values for saturated model
for i := 1 to Nrows do
begin
for j := 1 to Ncols do
begin
ModelTotal := mu;
for k := 1 to 3 do
ModelTotal := ModelTotal + CellLambdas[i,j,k];
Expected[i,j] := exp(ModelTotal);
end;
end;
// Get Y square for saturated model
Ysqr := 0.0;
for i := 1 to Nrows do
for j := 1 to Ncols do
Ysqr := Ysqr + Data[i,j] * (ln(Data[i,j]) - ln(Expected[i,j]));
Ysqr := 2.0 * Ysqr;
// write out values for saturated model
lReport.Add('Saturated Model Results');
lReport.Add('');
lReport.Add('Observed Frequencies');
PrintTable(Nrows, Ncols, Data, RowMarg, ColMarg, Total, lReport);
lReport.Add('Log frequencies, row average and column average of log frequencies');
PrintTable(Nrows, Ncols, LogData, RowLogs, ColLogs, TotalLogs, lReport);
lReport.Add('Expected Frequencies');
PrintTable(Nrows, Ncols, Expected, RowMarg, ColMarg, Total, lReport);
lReport.Add('Cell Parameters');
PrintLamdas(Nrows, Ncols, CellLambdas, mu, lReport);
lReport.Add('Y squared statistic for model fit: ' + format('%.3f',[Ysqr]) + ' D.F. 0');
lReport.Add('');
lReport.Add('=======================================================================');
lReport.Add('');
// Do the model of independence
lReport.Add('Independent Effects Model Results');
lReport.Add('');
lReport.Add('Expected Frequencies');
Iterate(Nrows,Ncols, Data, RowMarg, ColMarg, Total, Expected, NewRowMarg, NewColMarg, NewTotal);
PrintTable(Nrows, Ncols, Expected, NewRowMarg, NewColMarg, NewTotal, lReport);
for i := 1 to Nrows do
for j := 1 to Ncols do
LogData[i,j] := ln(Expected[i,j]);
for i := 1 to Nrows do RowLogs[i] := 0.0;
for j := 1 to Ncols do ColLogs[j] := 0.0;
TotalLogs := 0.0;
for i := 1 to Nrows do
for j := 1 to Ncols do
begin
RowLogs[i] := RowLogs[i] + LogData[i,j];
ColLogs[j] := ColLogs[j] + LogData[i,j];
TotalLogs := TotalLogs + LogData[i,j];
end;
for i := 1 to Nrows do RowLogs[i] := RowLogs[i] / Ncols;
for j := 1 to Ncols do ColLogs[j] := ColLogs[j] / Nrows;
TotalLogs := TotalLogs / (Nrows * Ncols);
mu := TotalLogs;
for i := 1 to Nrows do
for j := 1 to Ncols do
begin
CellLambdas[i,j,1] := RowLogs[i] - TotalLogs;
CellLambdas[i,j,2] := ColLogs[j] - TotalLogs;
CellLambdas[i,j,3] := LogData[i,j] - RowLogs[i] - ColLogs[j] + TotalLogs;
end;
lReport.Add('Cell Parameters');
PrintLamdas(Nrows, Ncols, CellLambdas, mu, lReport);
Ysqr := 0.0;
for i := 1 to Nrows do
for j := 1 to Ncols do
Ysqr := Ysqr + Data[i,j] * (ln(Data[i,j]) - ln(Expected[i,j]));
Ysqr := 2.0 * Ysqr;
lReport.Add('');
astr := 'Y squared statistic for model fit: ' + Format('%.3f',[Ysqr]);
DF := (NRows - 1) * (NCols - 1);
astr := astr + ', D.F. = ' + IntToStr(DF);
lReport.Add(astr);
chisqr := 0.0;
for i := 1 to Nrows do
for j := 1 to Ncols do
chisqr := chisqr + (power((Data[i,j] - Expected[i,j]),2) / Expected[i,j]);
lReport.Add('Chi-squared = %.3f with %d D.F.', [chisqr, DF]);
lReport.Add('');
lReport.Add('=======================================================================');
lReport.Add('');
// Do no Column Effects model
lReport.Add('No Column Effects Model Results');
lReport.Add('');
for i := 1 to Nrows do
for j := 1 to Ncols do
Expected[i,j] := RowMarg[i] / Ncols;
for i := 1 to Nrows do NewRowMarg[i] := 0.0;
for j := 1 to Ncols do NewColMarg[j] := 0.0;
for i := 1 to Nrows do
for j := 1 to Ncols do
begin
NewRowMarg[i] := NewRowMarg[i] + Expected[i,j];
NewColMarg[j] := NewColMarg[j] + Expected[i,j];
end;
lReport.Add('Expected Frequencies');
PrintTable(Nrows, Ncols, Expected, NewRowMarg, NewColMarg, NewTotal, lReport);
for i := 1 to Nrows do
for j := 1 to Ncols do
LogData[i,j] := ln(Expected[i,j]);
for i := 1 to Nrows do RowLogs[i] := 0.0;
for j := 1 to Ncols do ColLogs[j] := 0.0;
TotalLogs := 0.0;
for i := 1 to Nrows do
for j := 1 to Ncols do
begin
RowLogs[i] := RowLogs[i] + LogData[i,j];
ColLogs[j] := ColLogs[j] + LogData[i,j];
TotalLogs := TotalLogs + LogData[i,j];
end;
for i := 1 to Nrows do RowLogs[i] := RowLogs[i] / Ncols;
for j := 1 to Ncols do ColLogs[j] := ColLogs[j] / Nrows;
TotalLogs := TotalLogs / (Nrows * Ncols);
mu := TotalLogs;
for i := 1 to Nrows do
for j := 1 to Ncols do
begin
CellLambdas[i,j,1] := RowLogs[i] - TotalLogs;
CellLambdas[i,j,2] := ColLogs[j] - TotalLogs;
CellLambdas[i,j,3] := LogData[i,j] - RowLogs[i] - ColLogs[j] + TotalLogs;
end;
lReport.Add('Cell Parameters');
PrintLamdas(Nrows, Ncols, CellLambdas, mu, lReport);
Ysqr := 0.0;
for i := 1 to Nrows do
for j := 1 to Ncols do
Ysqr := Ysqr + Data[i,j] * (ln(Data[i,j]) - ln(Expected[i,j]));
Ysqr := 2.0 * Ysqr;
lReport.Add('');
astr := 'Y squared statistic for model fit: ' + Format('%.3f',[Ysqr]);
DF := (Nrows - 1) * Ncols;
astr := astr + ', D.F. ' + IntToStr(DF);
lReport.Add(astr);
lReport.Add('');
lReport.Add('=======================================================================');
lReport.Add('');
// Do no Row Effects model
lReport.Add('No Row Effects Model Results');
lReport.Add('');
for i := 1 to Nrows do
for j := 1 to Ncols do
Expected[i,j] := ColMarg[j] / Nrows;
for i := 1 to Nrows do NewRowMarg[i] := 0.0;
for j := 1 to Ncols do NewColMarg[j] := 0.0;
for i := 1 to Nrows do
for j := 1 to Ncols do
begin
NewRowMarg[i] := NewRowMarg[i] + Expected[i,j];
NewColMarg[j] := NewColMarg[j] + Expected[i,j];
end;
lReport.Add('Expected Frequencies');
PrintTable(Nrows, Ncols, Expected, NewRowMarg, NewColMarg, NewTotal, lReport);
for i := 1 to Nrows do
for j := 1 to Ncols do
LogData[i,j] := ln(Expected[i,j]);
for i := 1 to Nrows do RowLogs[i] := 0.0;
for j := 1 to Ncols do ColLogs[j] := 0.0;
TotalLogs := 0.0;
for i := 1 to Nrows do
for j := 1 to Ncols do
begin
RowLogs[i] := RowLogs[i] + LogData[i,j];
ColLogs[j] := ColLogs[j] + LogData[i,j];
TotalLogs := TotalLogs + LogData[i,j];
end;
for i := 1 to Nrows do RowLogs[i] := RowLogs[i] / Ncols;
for j := 1 to Ncols do ColLogs[j] := ColLogs[j] / Nrows;
TotalLogs := TotalLogs / (Nrows * Ncols);
mu := TotalLogs;
for i := 1 to Nrows do
for j := 1 to Ncols do
begin
CellLambdas[i,j,1] := RowLogs[i] - TotalLogs;
CellLambdas[i,j,2] := ColLogs[j] - TotalLogs;
CellLambdas[i,j,3] := LogData[i,j] - RowLogs[i] - ColLogs[j] + TotalLogs;
end;
lReport.Add('Cell Parameters');
PrintLamdas(Nrows, Ncols, CellLambdas, mu, lReport);
Ysqr := 0.0;
for i := 1 to Nrows do
for j := 1 to Ncols do
Ysqr := Ysqr + Data[i,j] * (ln(Data[i,j]) - ln(Expected[i,j]));
Ysqr := 2.0 * Ysqr;
lReport.Add('');
astr := 'Y squared statistic for model fit: ' + Format('%.3f', [Ysqr]);
DF := (Ncols - 1) * Nrows;
astr := astr + ', D.F. ' + IntToStr(DF);
lReport.Add(astr);
lReport.Add('');
lReport.Add('=======================================================================');
lReport.Add('');
// Do equiprobability model
lReport.Add('Equiprobability Effects Model Results');
lReport.Add('');
for i := 1 to Nrows do
for j := 1 to Ncols do
Expected[i,j] := Total / (Nrows * Ncols);
for i := 1 to Nrows do NewRowMarg[i] := Total / (Nrows * Ncols);
for j := 1 to 2 do NewColMarg[j] := Total / (Nrows * Ncols);
lReport.Add('Expected Frequencies');
PrintTable(Nrows, Ncols, Expected, NewRowMarg, NewColMarg, NewTotal, lReport);
for i := 1 to Nrows do
for j := 1 to Ncols do
LogData[i,j] := ln(Expected[i,j]);
for i := 1 to Nrows do RowLogs[i] := 0.0;
for j := 1 to Ncols do ColLogs[j] := 0.0;
TotalLogs := 0.0;
for i := 1 to Nrows do
for j := 1 to Ncols do
begin
RowLogs[i] := RowLogs[i] + LogData[i,j];
ColLogs[j] := ColLogs[j] + LogData[i,j];
TotalLogs := TotalLogs + LogData[i,j];
end;
for i := 1 to Nrows do RowLogs[i] := RowLogs[i] / Ncols;
for j := 1 to Ncols do ColLogs[j] := ColLogs[j] / Nrows;
TotalLogs := TotalLogs / (Nrows * Ncols);
mu := TotalLogs;
for i := 1 to Nrows do
for j := 1 to Ncols do
begin
CellLambdas[i,j,1] := RowLogs[i] - TotalLogs;
CellLambdas[i,j,2] := ColLogs[j] - TotalLogs;
CellLambdas[i,j,3] := LogData[i,j] - RowLogs[i] - ColLogs[j] + TotalLogs;
end;
lReport.Add('Cell Parameters');
PrintLamdas(Nrows, Ncols, CellLambdas, mu, lReport);
Ysqr := 0.0;
for i := 1 to Nrows do
for j := 1 to Ncols do
Ysqr := Ysqr + Data[i,j] * (ln(Data[i,j]) - ln(Expected[i,j]));
Ysqr := 2.0 * Ysqr;
lReport.Add('');
astr := 'Y squared statistic for model fit: ' + format('%.3f',[Ysqr]);
DF := Nrows * Ncols - 1;
astr := astr + ', D.F. ' + IntToStr(DF);
lReport.Add(astr);
DisplayReport(lReport);
finally
lReport.Free;
NewColMarg := nil;
NewRowMarg := nil;
NewData := nil;
Expected := nil;
LogData := nil;
Prop := nil;
ColLogs := nil;
ColMarg := nil;
RowLogs := nil;
RowMarg := nil;
CellLambdas := nil;
Data := nil;
end;
end;
procedure TTwoWayLogLinFrm.FileFromGrpClick(Sender: TObject);
begin
Notebook1.PageIndex := FileFromGrp.ItemIndex;
Notebook1.Show;
end;
procedure TTwoWayLogLinFrm.ColInBtnClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (ColVarEdit.Text = '') then
begin
ColVarEdit.Text := VarList.Items[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TTwoWayLogLinFrm.ColOutBtnClick(Sender: TObject);
begin
if ColVarEdit.Text <> '' then
begin
VarList.Items.Add(ColVarEdit.Text);
ColVarEdit.Text := '';
end;
UpdateBtnStates;
end;
procedure TTwoWayLogLinFrm.PrintTable(Nrows, Ncols : integer;
const Data: DblDyneMat; const RowMarg, ColMarg: DblDyneVec;
Total: double; AReport: TStrings);
var
astr: string;
i, j: integer;
begin
astr := 'ROW/COL ';
for j := 1 to Ncols do astr := astr + Format(' %3d ', [j]);
astr := astr + ' TOTAL';
AReport. Add(astr);
for i := 1 to Nrows do
begin
astr := Format(' %3d ', [i]);
for j := 1 to Ncols do
astr := astr + Format(' %8.2f ', [Data[i,j]]);
astr := astr + Format(' %8.2f ', [RowMarg[i]]);
AReport.Add(astr);
end;
astr := 'TOTAL ';
for j := 1 to Ncols do astr := astr + Format(' %8.2f ',[ColMarg[j]]);
astr := astr + Format(' %8.2f ', [Total]);
AReport.Add(astr);
AReport.Add('');
end;
procedure TTwoWayLogLinFrm.Iterate(Nrows, Ncols: integer;
const Data: DblDyneMat; const RowMarg, ColMarg: DblDyneVec; var Total: double;
const Expected: DblDyneMat; const NewRowMarg, NewColMarg: DblDyneVec; var NewTotal: double);
Label Step;
var
Aprevious: DblDyneMat;
i, j: integer;
delta: double;
difference: double;
begin
delta := 0.1;
difference := 0.0;
SetLength(Aprevious, Nrows+1, Ncols+1);
// initialize expected values
for i := 1 to Nrows do
for j := 1 to Ncols do
begin
expected[i,j] := 1.0;
Aprevious[i,j] := 1.0;
end;
Step:
// step 1: initialize new row margins and calculate expected value
for i := 1 to Nrows do
for j := 1 to Ncols do
newrowmarg[i] := newrowmarg[i] + expected[i,j];
for i := 1 to Nrows do
for j := 1 to Ncols do
expected[i,j] := (RowMarg[i] / newrowmarg[i]) * expected[i,j];
// step 2: initialize new col margins and calculate expected values
for i := 1 to Nrows do
for j := 1 to Ncols do
newcolmarg[j] := newcolmarg[j] + expected[i,j];
for i := 1 to Nrows do
for j := 1 to Ncols do
expected[i,j] := (ColMarg[j] / newcolmarg[j]) * expected[i,j];
// step 3: check for change and quit if smaller than delta
for i := 1 to Nrows do
for j := 1 to Ncols do
if abs(APrevious[i,j]-expected[i,j]) > difference then
difference := abs(APrevious[i,j]-expected[i,j]);
if difference < delta then
begin
newtotal := 0.0;
for i := 1 to Nrows do
for j := 1 to Ncols do
newtotal := newtotal + expected[i,j];
exit;
end else
begin
for i := 1 to Nrows do
for j := 1 to Ncols do
APrevious[i,j] := expected[i,j];
for i := 1 to Nrows do newrowmarg[i] := 0.0;
for j := 1 to Ncols do newcolmarg[j] := 0.0;
difference := 0.0;
goto step;
end;
Aprevious := nil;
end;
procedure TTwoWayLogLinFrm.PrintLamdas(Nrows,Ncols: integer;
const CellLambdas: DblDyneCube; mu: double; AReport: TStrings);
var
i, j, k: integer;
astr: string;
begin
AReport.Add('ROW COL MU LAMBDA ROW LAMBDA COL LAMBDA ROW x COL');
for i := 1 to Nrows do
begin
for j := 1 to Ncols do
begin
astr := Format('%3d %3d ', [i, j]);
astr := astr + Format('%6.3f ', [mu]);
for k := 1 to 3 do
astr := astr + format(' %6.3f ', [CellLambdas[i,j,k]]);
AReport.Add(astr);
end;
end;
AReport.Add('');
end;
procedure TTwoWayLogLinFrm.UpdateBtnStates;
begin
RowInBtn.Enabled := (VarList.ItemIndex > -1) and (RowVarEdit.Text = '');
ColInBtn.Enabled := (VarList.ItemIndex > -1) and (ColVarEdit.Text = '');
FreqInBtn.Enabled := (VarList.ItemIndex > -1) and (FreqVarEdit.Text = '');
RowOutBtn.Enabled := (RowVarEdit.Text <> '');
ColOutBtn.Enabled := (ColVarEdit.Text <> '');
FreqOutBtn.Enabled := (FreqVarEdit.Text <> '');
end;
procedure TTwoWayLogLinFrm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
initialization
{$I twowayloglinunit.lrs}
end.

View File

@ -0,0 +1,222 @@
object BoxPlotFrm: TBoxPlotFrm
Left = 440
Height = 365
Top = 119
Width = 361
AutoSize = True
Caption = 'Box Plot'
ClientHeight = 365
ClientWidth = 361
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 294
Height = 25
Top = 332
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 7
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 210
Height = 25
Top = 332
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 6
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 148
Height = 25
Top = 332
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 5
end
object HelpBtn: TButton
Tag = 108
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 89
Height = 25
Top = 332
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 4
end
object Bevel2: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 316
Width = 361
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object Label1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 8
Height = 15
Top = 8
Width = 97
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Available Variables'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = HorCenterBevel
AnchorSideBottom.Control = Bevel2
Left = 8
Height = 291
Top = 25
Width = 168
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
Constraints.MinHeight = 200
ItemHeight = 0
OnClick = VarListClick
TabOrder = 0
end
object HorCenterBevel: TBevel
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
Left = 176
Height = 78
Top = 55
Width = 8
Shape = bsSpacer
end
object Label2: TLabel
AnchorSideLeft.Control = HorCenterBevel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Owner
Left = 184
Height = 15
Top = 8
Width = 77
BorderSpacing.Top = 8
Caption = 'Group Variable'
ParentColor = False
end
object GroupEdit: TEdit
AnchorSideLeft.Control = HorCenterBevel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 184
Height = 23
Top = 25
Width = 169
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 2
BorderSpacing.Right = 8
TabOrder = 1
Text = 'GroupEdit'
end
object Label3: TLabel
AnchorSideLeft.Control = MeasEdit
AnchorSideBottom.Control = MeasEdit
Left = 184
Height = 15
Top = 142
Width = 112
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Meaurement Variable'
ParentColor = False
end
object MeasEdit: TEdit
AnchorSideLeft.Control = HorCenterBevel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = VarList
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 184
Height = 23
Top = 159
Width = 169
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Right = 8
TabOrder = 2
Text = 'MeasEdit'
end
object GroupBox1: TGroupBox
AnchorSideLeft.Control = HorCenterBevel
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = VarList
AnchorSideBottom.Side = asrBottom
Left = 184
Height = 51
Top = 265
Width = 143
Anchors = [akLeft, akBottom]
AutoSize = True
Caption = 'Options'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ClientHeight = 31
ClientWidth = 139
TabOrder = 3
object ShowChk: TCheckBox
Left = 12
Height = 19
Top = 6
Width = 115
Caption = 'Show Frequencies'
TabOrder = 0
end
end
end

View File

@ -0,0 +1,721 @@
// Use file "anova2.laz" for testing
unit BoxPlotUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, Printers,
MainUnit, Globals, DataProcs, OutputUnit, BlankFrmUnit, ContextHelpUnit;
type
{ TBoxPlotFrm }
TBoxPlotFrm = class(TForm)
HorCenterBevel: TBevel;
Bevel2: TBevel;
HelpBtn: TButton;
ResetBtn: TButton;
ComputeBtn: TButton;
CloseBtn: TButton;
ShowChk: TCheckBox;
GroupBox1: TGroupBox;
MeasEdit: TEdit;
GroupEdit: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
VarList: TListBox;
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure VarListClick(Sender: TObject);
private
{ private declarations }
FAutoSized: Boolean;
function Percentile(nscrgrps : integer;
pcnt : double;
VAR freq : DblDyneVec;
VAR cumfreq : DblDyneVec;
VAR scores : DblDyneVec) : double;
{
procedure pBoxPlot(nbars : integer;
max, min : double;
VAR lowqrtl : DblDyneVec;
VAR hiqrtl : DblDyneVec;
VAR tenpcnt : DblDyneVec;
VAR ninetypcnt : DblDyneVec;
VAR means : DblDyneVec;
VAR median : DblDyneVec);
}
procedure BoxPlot(nbars : integer;
max, min : double;
VAR lowqrtl : DblDyneVec;
VAR hiqrtl : DblDyneVec;
VAR tenpcnt : DblDyneVec;
VAR ninetypcnt : DblDyneVec;
VAR means : DblDyneVec;
VAR median : DblDyneVec);
public
{ public declarations }
end;
var
BoxPlotFrm: TBoxPlotFrm;
implementation
uses
Math;
{ TBoxPlotFrm }
procedure TBoxPlotFrm.ResetBtnClick(Sender: TObject);
var
i: integer;
begin
VarList.Clear;
GroupEdit.Text := '';
MeasEdit.Text := '';
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
end;
procedure TBoxPlotFrm.VarListClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if index > -1 then
begin
if (GroupEdit.Text = '') then
GroupEdit.Text := VarList.Items[index]
else
MeasEdit.Text := VarList.Items[index];
end;
end;
procedure TBoxPlotFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).tag);
end;
procedure TBoxPlotFrm.ComputeBtnClick(Sender: TObject);
var
i, j, k, GrpVar, MeasVar, mingrp, maxgrp, G, NoGrps, cnt : integer;
nscrgrps : integer;
X, tenpcnt, ninepcnt, qrtile1, qrtile2, qrtile3 : double;
minscr, maxscr, intvlsize, lastX : double;
cellstring: string;
means, lowqrtl, hiqrtl, tenpcntile, ninetypcntile, median : DblDyneVec;
freq : DblDyneVec;
Scores : DblDyneVec;
cumfreq : DblDyneVec;
prank : DblDyneVec;
grpsize : IntDyneVec;
scrgrp : DblDyneVec;
done : boolean;
NoSelected : integer;
ColNoSelected : IntDyneVec;
lReport: TStrings;
begin
lReport := TStringList.Create;
try
lReport.Add('BOX PLOTS OF GROUPS');
lReport.Add('');
GrpVar := 0;
MeasVar := 0;
for i := 1 to NoVariables do
begin
cellstring := OS3MainFrm.DataGrid.Cells[i,0];
if cellstring = GroupEdit.Text then GrpVar := i;
if cellstring = MeasEdit.Text then MeasVar := i;
end;
if GrpVar = 0 then
begin
MessageDlg('Group variable not selected.', mtError, [mbOK], 0);
exit;
end;
if MeasVar = 0 then
begin
MessageDlg('Measurement variable not selected.', mtError, [mbOK], 0);
exit;
end;
NoSelected := 2;
SetLength(ColNoSelected, NoSelected);
ColNoSelected[0] := GrpVar;
ColNoSelected[1] := MeasVar;
// get minimum and maximum group values
mingrp := 10000;
maxgrp := -10000;
for i := 1 to NoCases do
begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
G := round(StrToFloat(OS3MainFrm.DataGrid.Cells[GrpVar,i]));
if G < mingrp then mingrp := G;
if G > maxgrp then maxgrp := G;
end;
NoGrps := maxgrp - mingrp + 1;
if NoGrps > 30 then
begin
MessageDlg('Too many groups for meaningful plot.', mtError, [mbOK], 0);
exit;
end;
SetLength(freq,2 * NoCases + 1);
SetLength(Scores,2 * NoCases + 1);
SetLength(cumfreq,2 * NoCases + 1);
SetLength(prank,2 * NoCases + 1);
SetLength(grpsize,NoGrps+1);
SetLength(means,NoGrps+1);
SetLength(lowqrtl,NoGrps+1);
SetLength(hiqrtl,NoGrps+1);
SetLength(tenpcntile,NoGrps+1);
SetLength(ninetypcntile,NoGrps+1);
SetLength(median,NoGrps+1);
SetLength(scrgrp,NoGrps+1);
// initialize
for j := 1 to NoGrps do
begin
means[j-1] := 0.0;
grpsize[j-1] := 0;
end;
// get minimum and maximum scores and score interval
intvlsize := 10000.0;
lastX := 0.0;
X := StrToFloat(OS3MainFrm.DataGrid.Cells[MeasVar,1]);
minscr := X;
maxscr := X;
for i := 1 to NoCases do
begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
X := StrToFloat(OS3MainFrm.DataGrid.Cells[MeasVar,i]);
if X > maxscr then maxscr := X;
if X < minscr then minscr := X;
if i > 1 then // get interval size as minimum difference between 2 scores
begin
if (X <> lastX) and (abs(X - lastX) < intvlsize) then
intvlsize := abs(X - lastX);
lastX := X;
end else
lastX := X;
end;
// check for excess no. of intervals and reset if needed
nscrgrps := round((maxscr - minscr) / intvlsize);
if nscrgrps > 2 * NoCases then
intvlsize := (maxscr - minscr) / NoCases;
// setup score groups
done := false;
Scores[0] := minscr - intvlsize / 2.0;
nscrgrps := 0;
lastX := maxscr + intvlsize + intvlsize / 2.0;
while not done do
begin
nscrgrps := nscrgrps + 1;
Scores[nscrgrps] := minscr + (nscrgrps * intvlsize) - intvlsize / 2.0;
if Scores[nscrgrps] > lastX then done := true;
end;
Scores[nscrgrps+1] := Scores[nscrgrps] + intvlsize;
if Scores[0] < minscr then minscr := Scores[0];
if Scores[nscrgrps] > maxscr then maxscr := Scores[nscrgrps];
// do analysis for each group
for j := 1 to NoGrps do // group
begin
// get score groups for this group j
for i := 0 to nscrgrps do
begin
cumfreq[i] := 0.0;
freq[i] := 0.0;
end;
cnt := 0;
for i := 1 to NoCases do
begin // get scores for this group j
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
G := round(StrToFloat(OS3MainFrm.DataGrid.Cells[GrpVar,i]));
G := G - mingrp + 1;
if G = j then // subject in this group
begin
cnt := cnt + 1;
X := StrToFloat(OS3MainFrm.DataGrid.Cells[MeasVar,i]);
means[j-1] := means[j-1] + X;
// find score interval and add to the frequency
for k := 0 to nscrgrps do
if (X >= Scores[k]) and (X < Scores[k+1]) then
freq[k] := freq[k] + 1;
end;
end;
grpsize[j-1] := cnt;
if grpsize[j-1] > 0 then means[j-1] := means[j-1] / grpsize[j-1];
// accumulate frequencies
cumfreq[0] := freq[0];
for i := 1 to nscrgrps-1 do
cumfreq[i] := cumfreq[i-1] + freq[i];
cumfreq[nscrgrps] := cumfreq[nscrgrps-1];
// get percentile ranks
prank[0] := ((cumfreq[0] / 2.0) / grpsize[j-1]) * 100.0;
for i := 1 to nscrgrps-1 do
prank[i] := ((cumfreq[i-1] + (freq[i] / 2.0)) / grpsize[j-1]) * 100.0;
// get centiles required.
tenpcnt := 0.10 * grpsize[j-1];
tenpcntile[j-1] := Percentile(nscrgrps,tenpcnt,freq,cumfreq,scores);
ninepcnt := 0.90 * grpsize[j-1];
ninetypcntile[j-1] := Percentile(nscrgrps,ninepcnt,freq,cumfreq,scores);
qrtile1 := 0.25 * grpsize[j-1];
lowqrtl[j-1] := Percentile(nscrgrps,qrtile1,freq,cumfreq,scores);
qrtile2 := 0.50 * grpsize[j-1];
median[j-1] := Percentile(nscrgrps,qrtile2,freq,cumfreq,scores);
qrtile3 := 0.75 * grpsize[j-1];
hiqrtl[j-1] := Percentile(nscrgrps,qrtile3,freq,cumfreq,scores);
if ShowChk.Checked then
begin
if j > 1 then lReport.Add('');
lReport.Add('RESULTS FOR GROUP %d, MEAN = %.3f', [j, means[j-1]]);
lReport.Add('');
lReport.Add('Centile Value');
lReport.Add('------------ ------');
lReport.Add('Ten %6.3f', [tenpcntile[j-1]]);
lReport.Add('Twenty five %6.3f', [lowqrtl[j-1]]);
lReport.Add('Median %6.3f', [median[j-1]]);
lReport.Add('Seventy five %6.3f', [hiqrtl[j-1]]);
lReport.Add('Ninety %6.3f', [ninetypcntile[j-1]]);
lReport.Add('');
lReport.Add('Score Range Frequency Cum.Freq. Percentile Rank');
lReport.Add('--------------- --------- --------- ---------------');
for i := 0 to nscrgrps-1 do
lReport.Add('%6.2f - %6.2f %6.2f %6.2f %6.2f', [
Scores[i], Scores[i+1], freq[i], cumfreq[i], prank[i]
]);
lReport.Add('');
end;
end; // get values for next group
if ShowChk.Checked then
DisplayReport(lReport);
// plot the boxes
BoxPlot(NoGrps, maxscr, minscr, lowqrtl, hiqrtl, tenpcntile, ninetypcntile, means, median);
finally
lReport.Free;
// Clean up
scrgrp := nil;
median := nil;
ninetypcntile := nil;
tenpcntile := nil;
hiqrtl := nil;
lowqrtl := nil;
means := nil;
grpsize := nil;
cumfreq := nil;
scores := nil;
freq := nil;
ColNoSelected := nil;
end;
end;
procedure TBoxPlotFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
HelpBtn.Constraints.MinWidth := w;
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TBoxPlotFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
if BlankFrm = nil then Application.CreateForm(TBlankFrm, BlankFrm);
end;
procedure TBoxPlotFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
function TBoxPlotFrm.Percentile(nscrgrps: integer;
pcnt: double;
var freq: DblDyneVec;
var cumfreq: DblDyneVec;
var scores: DblDyneVec) : double;
var
i, interval: integer;
pcntile, Llimit, Ulimit, cumlower, intvlfreq: double;
begin
interval := 0;
for i := 0 to nscrgrps-1 do
begin
if cumfreq[i] > pcnt then
begin
interval := i;
Break;
end;
end;
if interval > 0 then
begin
Llimit := Scores[interval];
Ulimit := Scores[interval+1];
cumlower := cumfreq[interval-1];
intvlfreq := freq[interval];
end
else
begin // Percentile in first interval
Llimit := Scores[0];
Ulimit := Scores[1];
cumlower := 0.0;
intvlfreq := freq[0];
end;
if intvlfreq > 0 then
pcntile := Llimit + ((pcnt - cumlower) / intvlfreq) * (Ulimit- Llimit)
else
pcntile := Llimit;
Result := pcntile;
end;
//-------------------------------------------------------------------
{
procedure TBoxPlotFrm.pBoxPlot(nbars : integer;
max, min : double;
VAR lowqrtl : DblDyneVec;
VAR hiqrtl : DblDyneVec;
VAR tenpcnt : DblDyneVec;
VAR ninetypcnt : DblDyneVec;
VAR means : DblDyneVec;
VAR median : DblDyneVec);
var
i, HTickSpace, imagewide, imagehi, vtop, vbottom, offset : integer;
vhi, hleft, hright, hwide, barwidth, Xpos, Ypos, strhi, strwide : integer;
// coords : array [1..5] of TPoint;
X, Y, colcycle : integer;
X1, X2, X3, X9, X10 : integer; // X coordinates for box and lines
Y1, Y2, Y3, Y4, Y9 : integer; // Y coordinates for box and lines
Title : string;
valincr, Yvalue : double;
begin
Printer.Orientation := poLandscape;
Printer.BeginDoc;
Title := 'BOXPLOT FOR : ' + OS3MainFrm.FileNameEdit.Text;
imagewide := Printer.PageWidth;
imagehi := Printer.PageHeight;
vtop := 400;
vbottom := round(imagehi) - 400;
// vhi := vbottom - vtop;
hleft := 400;
hright := imagewide - 40;
hwide := hright - hleft;
// show title
Printer.Canvas.Brush.Color := clWhite;
strhi := Printer.Canvas.TextWidth(Title) div 2;
strhi := imagewide div 2 - strhi;
Printer.Canvas.TextOut(strhi,50,Title);
// show legend
Y := Printer.Canvas.TextHeight(Title) * 2;
Y := Y + 50;
Title := 'RED: mean, BLACK: median, BOX: 25th to 75th percentile, WISKERS: 10th and 90th percentile';
X := imagewide div 2 - Printer.Canvas.TextWidth(Title) div 2;
Printer.Canvas.TextOut(X,Y,Title);
Printer.Canvas.Pen.Color := clBlack;
Printer.Canvas.Brush.Color := clWhite;
// Draw chart border
Printer.Canvas.Rectangle(hleft,vtop,hright,vbottom);
vbottom := vbottom - 400; // decrease bottom
vhi := vbottom - vtop;
// Draw vertical axis
valincr := (max - min) / 20.0;
for i := 1 to 21 do
begin
Title := format('%8.2f',[max - ((i-1)*valincr)]);
strwide := Printer.Canvas.TextWidth(Title);
strhi := Printer.Canvas.TextHeight(Title);
xpos := 20 + hleft;
Yvalue := max - (valincr * (i-1));
ypos := round(vhi * ( (max - Yvalue) / (max - min)));
ypos := ypos + vtop - strhi div 2;
Printer.Canvas.TextOut(xpos,ypos,Title);
end;
Printer.Canvas.MoveTo(hleft + strwide + 50,vtop);
Printer.Canvas.LineTo(hleft + strwide + 50,vbottom+20);
hwide := hwide - (strwide + 50);
hleft := hleft + strwide + 50;
HTickSpace := hwide div (nbars + 1);
barwidth := HTickSpace div 2;
// draw horizontal axis
Printer.Canvas.MoveTo(hleft,vbottom + 20);
Printer.Canvas.LineTo(hright,vbottom + 20);
for i := 1 to nbars do
begin
ypos := vbottom + 10;
xpos := round((hwide / (nbars+1))* i + hleft);
Printer.Canvas.MoveTo(xpos,ypos);
ypos := ypos + 10;
Printer.Canvas.LineTo(xpos,ypos);
Title := format('%d',[i]);
offset := Printer.Canvas.TextWidth(Title) div 2;
strhi := Printer.Canvas.TextHeight(Title);
xpos := xpos - offset;
ypos := ypos + strhi;
Printer.Canvas.Pen.Color := clBlack;
Printer.Canvas.TextOut(xpos,ypos,Title);
xpos := hleft;
Printer.Canvas.TextOut(xpos,ypos,'GROUPS:');
end;
for i := 1 to nbars do
begin
colcycle := i mod 4; // select a color for box
if (colcycle = 0) then Printer.Canvas.Brush.Color := clBlue;
if (colcycle = 1) then Printer.Canvas.Brush.Color := clGreen;
if (colcycle = 2) then Printer.Canvas.Brush.Color := clFuchsia;
if (colcycle = 3) then Printer.Canvas.Brush.Color := clLime;
// plot the box front face
X9 := round(hleft + ((i) * HTickSpace) - (barwidth / 2));
X10 := X9 + barwidth;
X1 := X9;
X2 := X10;
Ypos:= round((((max - hiqrtl[i-1]) / (max - min)) * vhi) + vtop);
Y1 := Ypos;
Ypos := round((((max - lowqrtl[i-1]) / (max - min)) * vhi) + vtop);
Y2 := Ypos;
Printer.Canvas.Rectangle(X1,Y1,X2,Y2);
// draw upper 90th percentile line and end
X3 := round(X1 + barwidth / 2);
Printer.Canvas.MoveTo(X3,Y1);
Ypos := round((((max - ninetypcnt[i-1]) / (max - min)) * vhi) + vtop);
Y3 := Ypos;
Printer.Canvas.LineTo(X3,Y3);
Printer.Canvas.MoveTo(X1,Y3);
Printer.Canvas.LineTo(X2,Y3);
// draw lower 10th percentile line and end
Printer.Canvas.MoveTo(X3,Y2);
Ypos := round((((max - tenpcnt[i-1]) / (max - min)) * vhi) + vtop);
Y4 := Ypos;
Printer.Canvas.LineTo(X3,Y4);
Printer.Canvas.MoveTo(X1,Y4);
Printer.Canvas.LineTo(X2,Y4);
//plot the mean line
Printer.Canvas.Pen.Width := 10;
Printer.Canvas.Pen.Color := clRed;
Printer.Canvas.Pen.Style := psDot;
Ypos := round((((max - means[i-1]) / (max - min)) * vhi) + vtop);
Y9 := Ypos;
Printer.Canvas.MoveTo(X9,Y9);
Printer.Canvas.LineTo(X10,Y9);
Printer.Canvas.Pen.Color := clBlack;
Printer.Canvas.Pen.Style := psSolid;
//plot the median line
Printer.Canvas.Pen.Color := clBlack;
Ypos := round((((max - median[i-1]) / (max - min)) * vhi) + vtop);
Y9 := Ypos;
Printer.Canvas.MoveTo(X9,Y9);
Printer.Canvas.LineTo(X10,Y9);
Printer.Canvas.Pen.Color := clBlack;
end;
Printer.EndDoc;
Printer.Orientation := poPortrait;
end;
}
//--------------------------------------------------------------------------
procedure TBoxPlotFrm.BoxPlot(nbars: integer;
max, min: double;
var lowqrtl: DblDyneVec;
var hiqrtl: DblDyneVec;
var tenpcnt: DblDyneVec;
var ninetypcnt: DblDyneVec;
var means: DblDyneVec;
var median: DblDyneVec);
const
BOX_COLORS: Array[0..3] of TColor = (clBlue, clGreen, clFuchsia, clLime);
var
i, HTickSpace, imagewide, imagehi, vtop, vbottom, offset: integer;
vhi, hleft, hright, hwide, barwidth, Xpos, Ypos, strhi: integer;
XOffset, YOffset: integer;
X, Y: integer;
X1, X2, X3, X9, X10: integer; // X coordinates for box and lines
Y1, Y2, Y3, Y4, Y9: integer; // Y coordinates for box and lines
Title: string;
valincr, Yvalue: double;
begin
BlankFrm.Show;
//BlankFrm.Image1.Canvas.Clear;
imagewide := BlankFrm.Image1.width;
imagehi := BlankFrm.Image1.Height;
XOffset := imagewide div 10;
YOffset := imagehi div 10;
vtop := YOffset;
vbottom := imagehi - YOffset;
vhi := vbottom - vtop;
hleft := XOffset;
hright := imagewide - hleft - XOffset;
hwide := hright - hleft;
HTickSpace := hwide div nbars;
barwidth := HTickSpace div 2;
// Show title
Title := 'BOXPLOT FOR : ' + OS3MainFrm.FileNameEdit.Text;
BlankFrm.Caption := Title;
(*
// show legend
Y := BlankFrm.Image1.Canvas.TextHeight(Title) * 2;
Y := Y + vtop;
Title := 'RED: mean, BLACK: median, BOX: 25th to 75th percentile, WISKERS: 10th and 90th percentile';
X := imagewide div 2 - BlankFrm.Canvas.TextWidth(Title) div 2;
BlankFrm.Image1.Canvas.TextOut(X,Y,Title);
*)
// Draw chart background and border
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
BlankFrm.Image1.Canvas.Brush.Color := clWhite;
BlankFrm.Image1.Canvas.Rectangle(0,0,imagewide,imagehi);
// show legend
Y := 2;
Title := 'RED: mean, BLACK: median, BOX: 25th to 75th percentile, WISKERS: 10th and 90th percentile';
X := imagewide div 2 - BlankFrm.Canvas.TextWidth(Title) div 2;
BlankFrm.Image1.Canvas.TextOut(X,Y,Title);
// Draw vertical axis
valincr := (max - min) / 20.0;
for i := 1 to 21 do
begin
Title := format('%8.2f',[max - ((i-1)*valincr)]);
strhi := BlankFrm.Image1.Canvas.TextHeight(Title);
xpos := XOffset;
Yvalue := max - (valincr * (i-1));
ypos := round(vhi * ( (max - Yvalue) / (max - min)));
ypos := ypos + vtop - strhi div 2;
BlankFrm.Image1.Canvas.TextOut(xpos,ypos,Title);
end;
BlankFrm.Image1.Canvas.MoveTo(hleft,vtop);
BlankFrm.Image1.Canvas.LineTo(hleft,vbottom);
// draw horizontal axis
BlankFrm.Image1.Canvas.MoveTo(hleft,vbottom + 10 );
BlankFrm.Image1.Canvas.LineTo(hright,vbottom + 10);
for i := 1 to nbars do
begin
ypos := vbottom + 10;
xpos := round((hwide / nbars)* i + hleft);
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
ypos := ypos + 10;
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
Title := format('%d',[i]);
offset := BlankFrm.Image1.Canvas.TextWidth(Title) div 2;
strhi := BlankFrm.Image1.Canvas.TextHeight(Title);
xpos := xpos - offset;
ypos := ypos + strhi - 2;
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
BlankFrm.Image1.Canvas.TextOut(xpos,ypos,Title);
xpos := 20;
BlankFrm.Image1.Canvas.TextOut(xpos,ypos,'GROUPS:');
end;
for i := 1 to nbars do
begin
BlankFrm.Image1.Canvas.Brush.Color := BOX_COLORS[i mod 4];
// plot the box front face
X9 := round(hleft + ((i) * HTickSpace) - (barwidth / 2));
X10 := X9 + barwidth;
X1 := X9;
X2 := X10;
Y1 := round((((max - hiqrtl[i-1]) / (max - min)) * vhi) + vtop);
Y2 := round((((max - lowqrtl[i-1]) / (max - min)) * vhi) + vtop);
BlankFrm.Image1.Canvas.Rectangle(X1,Y1,X2,Y2);
// draw upper 90th percentile line and end
X3 := round(X1 + barwidth / 2);
BlankFrm.Image1.Canvas.MoveTo(X3,Y1);
Y3 := round((((max - ninetypcnt[i-1]) / (max - min)) * vhi) + vtop);
BlankFrm.Image1.Canvas.LineTo(X3,Y3);
BlankFrm.Image1.Canvas.MoveTo(X1,Y3);
BlankFrm.Image1.Canvas.LineTo(X2,Y3);
// draw lower 10th percentile line and end
BlankFrm.Image1.Canvas.MoveTo(X3,Y2);
Y4 := round((((max - tenpcnt[i-1]) / (max - min)) * vhi) + vtop);
BlankFrm.Image1.Canvas.LineTo(X3,Y4);
BlankFrm.Image1.Canvas.MoveTo(X1,Y4);
BlankFrm.Image1.Canvas.LineTo(X2,Y4);
//plot the means line
BlankFrm.Image1.Canvas.Pen.Color := clRed;
BlankFrm.Image1.Canvas.Pen.Style := psDot;
Y9 := round((((max - means[i-1]) / (max - min)) * vhi) + vtop);
BlankFrm.Image1.Canvas.MoveTo(X9,Y9);
BlankFrm.Image1.Canvas.LineTo(X10,Y9);
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
BlankFrm.Image1.Canvas.Pen.Style := psSolid;
//plot the median line
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
Y9 := round((((max - median[i-1]) / (max - min)) * vhi) + vtop);
BlankFrm.Image1.Canvas.MoveTo(X9,Y9);
BlankFrm.Image1.Canvas.LineTo(X10,Y9);
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
end;
end;
initialization
{$I boxplotunit.lrs}
end.

View File

@ -0,0 +1,305 @@
object BreakDownFrm: TBreakDownFrm
Left = 400
Height = 367
Top = 248
Width = 428
AutoSize = True
Caption = 'Breakdown'
ClientHeight = 367
ClientWidth = 428
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object CheckGroup1: TCheckGroup
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Panel2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1
Left = 8
Height = 51
Top = 267
Width = 140
Anchors = [akLeft, akBottom]
AutoFill = True
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Option'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 31
ClientWidth = 136
Items.Strings = (
'One Way ANOVA'
)
TabOrder = 1
Data = {
0100000002
}
end
object Panel2: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CheckGroup1
Left = 8
Height = 251
Top = 8
Width = 412
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 8
BevelOuter = bvNone
ClientHeight = 251
ClientWidth = 412
Constraints.MinHeight = 200
TabOrder = 0
object AvailLabel: TLabel
AnchorSideLeft.Control = Panel2
AnchorSideTop.Control = Panel2
Left = 0
Height = 15
Top = 0
Width = 97
Caption = 'Available Variables'
ParentColor = False
end
object AnalLabel: TLabel
AnchorSideLeft.Control = SelList
AnchorSideTop.Control = Panel2
Left = 228
Height = 15
Top = 0
Width = 104
Caption = 'Variables to Analyze'
ParentColor = False
end
object SelLabel: TLabel
AnchorSideLeft.Control = SelList
AnchorSideBottom.Control = DepVar
Left = 228
Height = 15
Top = 199
Width = 153
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Selected Continuous Variable'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Panel2
AnchorSideTop.Control = AvailLabel
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = InBtn
AnchorSideBottom.Control = Panel2
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 234
Top = 17
Width = 184
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Right = 8
ItemHeight = 0
MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object SelList: TListBox
AnchorSideLeft.Control = InBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = AnalLabel
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel2
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = SelVarInBtn
Left = 228
Height = 166
Top = 17
Width = 184
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Bottom = 8
ItemHeight = 0
OnSelectionChange = SelListSelectionChange
TabOrder = 3
end
object DepVar: TEdit
AnchorSideLeft.Control = SelList
AnchorSideTop.Control = SelLabel
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = SelList
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = SelVarOutBtn
AnchorSideBottom.Side = asrBottom
Left = 228
Height = 23
Top = 216
Width = 184
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 6
Text = 'DepVar'
end
object InBtn: TBitBtn
AnchorSideLeft.Control = Panel2
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
Left = 192
Height = 28
Top = 17
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = InBtnClick
Spacing = 0
TabOrder = 1
end
object OutBtn: TBitBtn
AnchorSideLeft.Control = Panel2
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = InBtn
AnchorSideTop.Side = asrBottom
Left = 192
Height = 28
Top = 49
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = OutBtnClick
Spacing = 0
TabOrder = 2
end
object SelVarInBtn: TBitBtn
AnchorSideLeft.Control = Panel2
AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = SelVarOutBtn
Left = 192
Height = 28
Top = 191
Width = 28
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 4
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = SelVarInBtnClick
Spacing = 0
TabOrder = 4
end
object SelVarOutBtn: TBitBtn
AnchorSideLeft.Control = Panel2
AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = VarList
AnchorSideBottom.Side = asrBottom
Left = 192
Height = 28
Top = 223
Width = 28
Anchors = [akLeft, akBottom]
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = SelVarOutBtnClick
Spacing = 0
TabOrder = 5
end
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 361
Height = 25
Top = 334
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 4
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 215
Height = 25
Top = 334
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 3
end
object HelpBtn: TButton
Tag = 109
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 156
Height = 25
Top = 334
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 2
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 318
Width = 428
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 277
Height = 25
Top = 334
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 5
end
end

View File

@ -0,0 +1,666 @@
// Use "twoway.laz" for testing
unit BreakDownUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, Buttons,
MainUnit, Globals, FunctionsLib, OutputUnit, DataProcs, ContextHelpUnit;
type
{ TBreakDownFrm }
TBreakDownFrm = class(TForm)
Bevel1: TBevel;
ComputeBtn: TButton;
HelpBtn: TButton;
InBtn: TBitBtn;
OutBtn: TBitBtn;
Panel2: TPanel;
SelVarInBtn: TBitBtn;
SelVarOutBtn: TBitBtn;
ResetBtn: TButton;
CloseBtn: TButton;
CheckGroup1: TCheckGroup;
DepVar: TEdit;
AvailLabel: TLabel;
AnalLabel: TLabel;
SelLabel: TLabel;
SelList: TListBox;
VarList: TListBox;
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
procedure InBtnClick(Sender: TObject);
procedure OutBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure SelListSelectionChange(Sender: TObject; User: boolean);
procedure SelVarInBtnClick(Sender: TObject);
procedure SelVarOutBtnClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean);
private
{ private declarations }
FAutoSized: Boolean;
Minimum, Maximum, levels, displace, subscript : IntDyneVec;
Freq : IntDyneVec;
Selected : IntDyneVec;
mean, variance, Stddev, SS : DblDyneVec;
index, NoSelected, ListSize, Dependentvar, X, length_array : integer;
ptr1, ptr2, sum, grandsum : integer;
xsumtotal, xsqrtotal, grandsumx, grandsumx2, value, SD : double;
SST, SSW, SSB, MSW, MSB, F, FProb, DF1, DF2 : double;
cellstring : string;
outline : string;
valstr : string;
dataread : boolean;
function Index_Pos(var X1: IntDyneVec; var displace1: IntDyneVec; ListSize1: integer): Integer;
procedure UpdateBtnStates;
public
{ public declarations }
end;
var
BreakDownFrm: TBreakDownFrm;
implementation
uses
Math;
{ TBreakDownFrm }
procedure TBreakDownFrm.ResetBtnClick(Sender: TObject);
var
i: integer;
begin
VarList.Clear;
SelList.Clear;
DepVar.Text := '';
InBtn.Enabled := true;
OutBtn.Enabled := false;
SelVarInBtn.Enabled := true;
SelVarOutBtn.Enabled := false;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
UpdateBtnStates;
end;
procedure TBreakDownFrm.SelListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
procedure TBreakDownFrm.SelVarInBtnClick(Sender: TObject);
var
index1 : integer;
begin
index1 := VarList.ItemIndex;
if (index1 > -1) and (DepVar.Text = '') then
begin
DepVar.Text := VarList.Items[index1];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TBreakDownFrm.SelVarOutBtnClick(Sender: TObject);
begin
if DepVar.Text <> '' then
VarList.Items.Add(DepVar.Text);
UpdateBtnStates;
end;
procedure TBreakDownFrm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
procedure TBreakDownFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).Tag);
end;
procedure TBreakDownFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
HelpBtn.Constraints.MinWidth := w;
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
//Panel2.Constraints.MinWidth := SelLabel.Width * 2 + InBtn.Width + 2 * VarList.BorderSpacing.Right;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TBreakDownFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
end;
procedure TBreakDownFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TBreakDownFrm.InBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while i < VarList.Items.Count do
begin
if (VarList.Selected[i]) then
begin
SelList.Items.Add(VarList.Items[i]);
VarList.Items.Delete(i);
i := 0;
end else
inc(i);
end;
UpdateBtnStates;
end;
procedure TBreakDownFrm.ComputeBtnClick(Sender: TObject);
label
Label1, Label3, Label4, NextStep, FirstOne, SecondOne, ThirdOne, LastStep;
var
i, j: integer;
tempval: string;
lReport: TStrings;
begin
// Identify columns of variables to analyze and the dependent var.
NoSelected := SelList.Items.Count;
if NoSelected = 0 then
begin
MessageDlg('No variables selected.', mtError, [mbOK], 0);
exit;
end;
// Get column no. of dependent variable
dependentVar := 0;
cellstring := DepVar.Text;
for i := 1 to NoVariables do
if cellstring = OS3MainFrm.DataGrid.Cells[i,0] then dependentvar := i;
if dependentVar = 0 then
begin
MessageDlg('Continuous variable is not specified.', mtError, [mbOK], 0);
exit;
end;
// Allocate heap
SetLength(Minimum,NoVariables);
SetLength(Maximum,NoVariables);
SetLength(levels,NoVariables);
SetLength(displace,NoVariables);
SetLength(subscript,NoVariables);
SetLength(Selected,NoVariables);
// Get selected variables
for i := 1 to NoSelected do
begin
cellstring := SelList.Items.Strings[i-1];
for j := 1 to NoVariables do
if cellstring = OS3MainFrm.DataGrid.Cells[j,0] then Selected[i-1] := j;
end;
Selected[NoSelected] := dependentvar;
ListSize := NoSelected;
// Get maximum and minimum levels in each variable
for i := 1 to ListSize do
begin
index := Selected[i-1];
Minimum[i-1] := round(StrToFloat(OS3MainFrm.DataGrid.Cells[index,1]));
Maximum[i-1] := Minimum[i-1];
for j := 1 to NoCases do
begin
if GoodRecord(j,NoSelected,Selected) then
begin
X := round(StrToFloat(OS3MainFrm.DataGrid.Cells[index,j]));
if X < Minimum[i-1] then Minimum[i-1] := X;
if X > Maximum[i-1] then Maximum[i-1] := X;
end;
end;
end;
// Calculate number of levels for each variable
for i := 1 to ListSize do
levels[i-1] := Maximum[i-1] - Minimum[i-1] + 1;
displace[ListSize-1] := 1;
if ListSize > 1 then
for i := ListSize-1 downto 1 do
displace[i-1] := levels[i] * displace[i];
// Now, tabulate
length_array := 1;
for i := 1 to ListSize do
length_array := Length_array * levels[i-1];
// initialize values
SetLength(Freq, length_array+1);
SetLength(mean, length_array+1);
SetLength(variance, length_array+1);
SetLength(Stddev, length_array+1);
SetLength(SS, length_array+1);
for i := 0 to length_array do
begin
Freq[i] := 0;
mean[i] := 0.0;
variance[i] := 0.0;
Stddev[i] := 0.0;
SS[i] := 0.0;
end;
// tabulate
for i := 1 to NoCases do
begin
dataread := false;
if GoodRecord(i,NoSelected,Selected) then
begin
for j := 1 to ListSize do
begin
index := Selected[j-1];
X := round(StrToFLoat(OS3MainFrm.DataGrid.Cells[index,i]));
X := X - Minimum[j-1] + 1;
subscript[j-1] := X;
dataread := true;
end;
end;
if dataread then
begin
j := Index_Pos(subscript,displace,ListSize);
Freq[j] := Freq[j] + 1;
index := dependentvar;
tempval := Trim(OS3MainFrm.DataGrid.Cells[index,i]);
if tempval <> '' then
begin
value := StrToFloat(tempval);
mean[j] := mean[j] + value;
variance[j] := variance[j] + (value * value);
end;
end;
end;
// setup the output
lReport := TStringList.Create;
try
lReport.Add('BREAKDOWN ANALYSIS PROGRAM');
lReport.Add('');
lReport.Add('VARIABLE SEQUENCE FOR THE BREAKDOWN:');
for i := 1 to ListSize do
begin
index := Selected[i-1];
lReport.Add('%-10s (Variable %3d) Lowest level = %2d Highest level = %2d', [
OS3MainFrm.DataGrid.Cells[index,0],i, Minimum[i-1], Maximum[i-1]
]);
end;
// Breakdown the data
ptr1 := ListSize - 1;
ptr2 := ListSize;
for i := 1 to ListSize do
subscript[i-1] := 1;
sum := 0;
xsumtotal := 0.0;
xsqrtotal := 0.0;
grandsum := 0;
grandsumx := 0.0;
grandsumx2 := 0.0;
Label1:
index := Index_Pos(subscript, displace, ListSize);
lReport.Add('Variable levels:');
for i := 1 to ListSize do
begin
j := Selected[i-1];
lReport.Add('%-10s level = %3d', [
OS3MainFrm.DataGrid.Cells[j,0], Minimum[i-1] + subscript[i-1] - 1
]);
end;
lReport.Add('');
sum := sum + Freq[index];
xsumtotal := xsumtotal + mean[index];
xsqrtotal := xsqrtotal + variance[index];
lReport.Add('Freq. Mean Std. Dev.');
outline := Format('%3d', [Freq[index]]);
if Freq[index] > 0 then
begin
valstr := Format(' %8.3f ',[mean[index] / Freq[index]]);
outline := outline + valstr;
end
else
outline := outline +' ******** ';
if Freq[index] > 1 then
begin
SS[index] := variance[index];
variance[index] := variance[index] - (mean[index] * mean[index] / Freq[index]);
variance[index] := variance[index] / (Freq[index] - 1);
Stddev[index] := sqrt(variance[index]);
valstr := Format('%8.3f ', [Stddev[index]]);
outline := outline + valstr;
end else
outline := outline + '********';
lReport.Add(outline);
lReport.Add('');
subscript[ptr2-1] := subscript[ptr2-1] + 1;
if subscript[ptr2-1] <= levels[ptr2-1] then goto Label1;
lReport.Add('Number of observations across levels = %d',[sum]);
if sum > 0 then
lReport.Add('Mean across levels = %8.3f',[ xsumtotal / sum])
else
lReport.Add('Mean across levels = ********');
if sum > 1 then
begin
SD := sqrt( (xsqrtotal - (xsumtotal * xsumtotal) / sum) / (sum - 1));
lReport.Add('Std. Dev. across levels = %8.3f', [SD]);
end else
lReport.Add('Std. Dev. across levels = *******');
lReport.Add('');
lReport.Add('===============================================================');
lReport.Add('');
//OutputFrm.ShowModal;
//OutputFrm.Clear;
grandsum := grandsum + sum;
grandsumx := grandsumx + xsumtotal;
grandsumx2 := grandsumx2 + xsqrtotal;
sum := 0;
xsumtotal := 0.0;
xsqrtotal := 0.0;
if ptr1 < 1 then
goto NextStep;
subscript[ptr1-1] :=subscript[ptr1-1] + 1;
if subscript[ptr1-1] <= levels[ptr1-1] then
goto Label4;
Label3:
ptr1 := ptr1 - 1;
if ptr1 < 1 then
goto NextStep;
if subscript[ptr1-1] > levels[ptr1-1] then
goto Label3;
subscript[ptr1-1] := subscript[ptr1-1] + 1;
if subscript[ptr1-1] > levels[ptr1-1] then
goto Label3;
Label4:
for i := ptr1+1 to ListSize do subscript[i-1] := 1;
ptr1 := ListSize - 1;
if ptr1 < 1 then goto
NextStep;
goto Label1;
NextStep:
lReport.Add('Grand number of observations across all categories = %3d', [grandsum]);
if grandsum > 0 then
lReport.Add('Overall Mean = %8.3f', [grandsumx / grandsum]);
if grandsum > 1 then
begin
SD := sqrt((grandsumx2 - (grandsumx * grandsumx) / grandsum) / (grandsum - 1));
lReport.Add('Overall standard deviation = %8.3f', [SD]);
end;
lReport.Add('');
lReport.Add('===============================================================');
lReport.Add('');
//OutputFrm.ShowModal;
//OutputFrm.Clear;
// Do ANOVA's if requested
if CheckGroup1.CheckEnabled[0] then
begin
lReport.Add('ANALYSES OF VARIANCE SUMMARY TABLES');
lReport.Add('');
ptr1 := ListSize - 1;
ptr2 := ListSize;
for i := 1 to ListSize do subscript[i-1] := 1;
SSB := 0.0;
SSW := 0.0;
MSB := 0.0;
MSW := 0.0;
grandsum := 0;
grandsumx := 0.0;
grandsumx2 := 0.0;
DF1 := 0.0;
DF2 := 0.0;
FirstOne:
index := Index_Pos(subscript, displace, ListSize);
if Freq[index] > 0 then
begin
lReport.Add('Variable levels: ');
for i := 1 to ListSize do
begin
j := Selected[i-1];
lReport.Add('%-10s level = %3d', [
OS3MainFrm.DataGrid.Cells[j,0], Minimum[i-1] + subscript[i-1] - 1
]);
end;
lReport.Add('');
// build sumsof squares for this set
DF1 := DF1 + 1;
DF2 := DF2 + Freq[index] - 1;
grandsum := grandsum + Freq[index];
grandsumx := grandsumx + mean[index];
grandsumx2 := grandsumx2 + SS[index];
SSW := SSW + SS[index] - (mean[index] * mean[index] / Freq[index]);
end;
subscript[ptr2-1] := subscript[ptr2-1] + 1;
if subscript[ptr2-1] <= levels[ptr2-1] then
goto FirstOne;
if ((grandsum > 0.0) and (DF1 > 1) and (DF2 > 1) and (SSW > 0.0)) then
begin
// build and show anova table
SST := grandsumx2 - (grandsumx * grandsumx / grandsum);
SSB := SST - SSW;
DF1 := DF1 - 1.0; // no. of groups - 1
MSB := SSB / DF1;
MSW := SSW / DF2;
F := MSB / MSW;
FProb := probf(DF1,DF2,F);
lReport.Add('SOURCE D.F. SS MS F Prob.>F');
lReport.Add('GROUPS %2.0f %8.2f %8.2f %8.3f %6.4f', [DF1,SSB,MSB,F,FProb]);
lReport.Add('WITHIN %2.0f %8.2f %8.2f', [DF2,SSW,MSW]);
lReport.Add('TOTAL %2d %8.2f', [grandsum-1,SST]);
//OutputFrm.ShowModal;
//OutputFrm.Clear;
end else
begin
lReport.Add('Insufficient data for ANOVA');
//OutputFrm.ShowModal;
//OutputFrm.Clear;
end;
lReport.Add('');
lReport.Add('=============================================================');
lReport.Add('');
SSB := 0.0;
SSW := 0.0;
MSB := 0.0;
MSW := 0.0;
grandsum := 0;
grandsumx := 0.0;
grandsumx2 := 0.0;
DF1 := 0.0;
DF2 := 0.0;
if ptr1 < 1 then
goto LastStep;
subscript[ptr1-1] := subscript[ptr1-1] + 1;
if subscript[ptr1-1] <= levels[ptr1-1] then
goto ThirdOne;
SecondOne:
ptr1 := ptr1 - 1;
if ptr1 < 1 then goto LastStep;
if subscript[ptr1-1] > levels[ptr1-1] then
goto SecondOne;
subscript[ptr1-1] := subscript[ptr1-1] + 1;
if subscript[ptr1-1] > levels[ptr1-1] then
goto SecondOne;
ThirdOne:
for i := ptr1+1 to ListSize do subscript[i-1] := 1;
ptr1 := ListSize - 1;
if ptr1 < 1 then
goto LastStep;
goto FirstOne;
LastStep:
// do anova for all cells
lReport.Add('ANOVA FOR ALL CELLS');
lReport.Add('');
SST := 0.0;
SSW := 0.0;
DF2 := 0.0;
DF1 := 0.0;
grandsumx := 0.0;
grandsum := 0;
for i := 1 to length_array do
begin
if Freq[i] > 0 then
begin
SST := SST + SS[i];
grandsum := grandsum + Freq[i];
grandsumx := grandsumx + mean[i];
SSW := SSW + (SS[i] - (mean[i] * mean[i] / Freq[i]));
DF1 := DF1 + 1.0;
DF2 := DF2 + (Freq[i] - 1);
end;
end;
if ( (DF1 > 1.0) and (DF2 > 1.0) and (SSW > 0.0)) then
begin
SST := SST - (grandsumx * grandsumx / grandsum);
SSB := SST - SSW;
DF1 := DF1 - 1;
MSB := SSB / DF1;
MSW := SSW / DF2;
F := MSB / MSW;
FProb := probf(DF1, DF2, F);
lReport.Add('SOURCE D.F. SS MS F Prob.>F');
lReport.Add('GROUPS %2.0f %8.2f %8.2f %8.3f %6.4f', [DF1, SSB, MSB, F, FProb]);
lReport.Add('WITHIN %2.0f %8.2f %8.2f', [DF2, SSW, MSW]);
lReport.Add('TOTAL %2d %8.2f', [grandsum-1, SST]);
lReport.Add('FINISHED');
end else
begin
lReport.Add('Only 1 group. No ANOVA possible.');
end;
end;
// Show report in output form
DisplayReport(lReport);
finally
lReport.Free;
SS := nil;
Stddev := nil;
variance := nil;
mean := nil;
Freq := nil;
selected := nil;
subscript := nil;
displace := nil;
levels := nil;
Maximum := nil;
Minimum := nil;
end;
end;
procedure TBreakDownFrm.OutBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while i < SelList.Items.Count do
begin
if (SelList.Selected[i]) then
begin
VarList.Items.Add(SelList.Items[i]);
SelList.Items.Delete(i);
i := 0;
end else
inc(i);
end;
UpdateBtnStates;
end;
function TBreakDownFrm.Index_Pos(var X1: IntDyneVec; var displace1: IntDyneVec;
ListSize1: integer): integer;
var
i: integer;
begin
Result := X1[ListSize-1];
for i := 1 to ListSize - 1 do
Result := Result + ((X1[i-1] - 1) * displace[i-1]);
end;
procedure TBreakDownFrm.UpdateBtnStates;
var
lSelected: Boolean;
i: Integer;
begin
lSelected := false;
for i := 0 to VarList.Count-1 do
if VarList.Selected[i] then
begin
lSelected := true;
break;
end;
InBtn.Enabled := lSelected;
lSelected := false;
for i := 0 to SelList.Count-1 do
if SelList.Selected[i] then
begin
lSelected := true;
break;
end;
OutBtn.Enabled := lSelected;
SelVarInBtn.Enabled := (VarList.ItemIndex > -1) and (DepVar.Text = '');
SelVarOutBtn.Enabled := (DepVar.Text <> '');
end;
initialization
{$I breakdownunit.lrs}
end.

View File

@ -0,0 +1,486 @@
object BubbleForm: TBubbleForm
Left = 473
Height = 454
Top = 253
Width = 500
AutoSize = True
Caption = 'Repeated Measures Bubble Plot'
ClientHeight = 454
ClientWidth = 500
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Label6: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = TitleEdit
AnchorSideTop.Side = asrCenter
Left = 8
Height = 15
Top = 316
Width = 55
BorderSpacing.Left = 8
Caption = 'Main Title:'
ParentColor = False
end
object Label7: TLabel
AnchorSideTop.Control = XLabelEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = XLabelEdit
Left = 22
Height = 15
Top = 347
Width = 41
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'X Label:'
ParentColor = False
end
object Label8: TLabel
AnchorSideTop.Control = YLabelEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = YLabelEdit
Left = 293
Height = 15
Top = 347
Width = 41
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Y Label:'
ParentColor = False
end
object TitleEdit: TEdit
AnchorSideLeft.Control = Label6
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = XLabelEdit
Left = 71
Height = 23
Top = 312
Width = 421
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 8
TabOrder = 1
TextHint = 'Title of the Diagram'
end
object XLabelEdit: TEdit
AnchorSideLeft.Control = TitleEdit
AnchorSideBottom.Control = TransformChk
Left = 71
Height = 23
Top = 343
Width = 150
Anchors = [akLeft, akBottom]
TabOrder = 2
TextHint = 'X Axis Title'
end
object YLabelEdit: TEdit
AnchorSideTop.Control = XLabelEdit
AnchorSideRight.Control = TitleEdit
AnchorSideRight.Side = asrBottom
Left = 342
Height = 23
Top = 343
Width = 150
Anchors = [akTop, akRight]
TabOrder = 3
TextHint = 'Y Axis Title'
end
object TransformChk: TCheckBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = Bevel1
Left = 8
Height = 19
Top = 378
Width = 365
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 12
BorderSpacing.Bottom = 8
Caption = 'Transform Data Grid for ANOVA (Treatments by Subjects ANOVA)'
TabOrder = 4
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = TitleEdit
Left = 8
Height = 296
Top = 8
Width = 484
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
BevelOuter = bvNone
ClientHeight = 296
ClientWidth = 484
TabOrder = 0
object Label1: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
Left = 0
Height = 15
Top = 0
Width = 49
Caption = 'Variables:'
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = BubbleEdit
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = BubbleEdit
Left = 264
Height = 15
Top = 23
Width = 201
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Bubble Identification Number Variable'
ParentColor = False
end
object Label3: TLabel
AnchorSideLeft.Control = XEdit
AnchorSideBottom.Control = XEdit
Left = 264
Height = 15
Top = 97
Width = 82
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'X Value Variable'
ParentColor = False
end
object Label4: TLabel
AnchorSideLeft.Control = YEdit
AnchorSideBottom.Control = YEdit
Left = 264
Height = 15
Top = 171
Width = 82
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Y Value Variable'
ParentColor = False
end
object Label5: TLabel
AnchorSideLeft.Control = SizeEdit
AnchorSideBottom.Control = SizeEdit
Left = 264
Height = 15
Top = 245
Width = 104
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Bubble Size Variable'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = IDInBtn
AnchorSideBottom.Control = Panel1
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 279
Top = 17
Width = 220
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Right = 8
ItemHeight = 0
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object IDInBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
Left = 228
Height = 28
Top = 17
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = IDInBtnClick
Spacing = 0
TabOrder = 1
end
object IDOutBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = IDInBtn
AnchorSideTop.Side = asrBottom
Left = 228
Height = 28
Top = 47
Width = 28
BorderSpacing.Top = 2
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = IDOutBtnClick
Spacing = 0
TabOrder = 2
end
object XInBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = IDOutBtn
AnchorSideTop.Side = asrBottom
Left = 228
Height = 28
Top = 91
Width = 28
BorderSpacing.Top = 16
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = XInBtnClick
Spacing = 0
TabOrder = 4
end
object XOutBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = XInBtn
AnchorSideTop.Side = asrBottom
Left = 228
Height = 28
Top = 121
Width = 28
BorderSpacing.Top = 2
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = XOutBtnClick
Spacing = 0
TabOrder = 5
end
object YInBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = XOutBtn
AnchorSideTop.Side = asrBottom
Left = 228
Height = 28
Top = 165
Width = 28
BorderSpacing.Top = 16
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = YInBtnClick
Spacing = 0
TabOrder = 7
end
object YOutBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = YInBtn
AnchorSideTop.Side = asrBottom
Left = 228
Height = 28
Top = 195
Width = 28
BorderSpacing.Top = 2
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = YOutBtnClick
Spacing = 0
TabOrder = 8
end
object SizeInBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = YOutBtn
AnchorSideTop.Side = asrBottom
Left = 228
Height = 28
Top = 239
Width = 28
BorderSpacing.Top = 16
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = SizeInBtnClick
Spacing = 0
TabOrder = 10
end
object SizeOutBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = SizeInBtn
AnchorSideTop.Side = asrBottom
Left = 228
Height = 28
Top = 269
Width = 28
BorderSpacing.Top = 2
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = SizeOutBtnClick
Spacing = 0
TabOrder = 11
end
object BubbleEdit: TEdit
AnchorSideLeft.Control = IDInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = IDOutBtn
AnchorSideBottom.Side = asrBottom
Left = 264
Height = 23
Top = 40
Width = 220
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 3
Text = 'BubbleEdit'
end
object XEdit: TEdit
AnchorSideLeft.Control = BubbleEdit
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = XOutBtn
AnchorSideBottom.Side = asrBottom
Left = 264
Height = 23
Top = 114
Width = 220
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 6
Text = 'XEdit'
end
object YEdit: TEdit
AnchorSideLeft.Control = BubbleEdit
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = YOutBtn
AnchorSideBottom.Side = asrBottom
Left = 264
Height = 23
Top = 188
Width = 220
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 9
Text = 'YEdit'
end
object SizeEdit: TEdit
AnchorSideLeft.Control = BubbleEdit
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = SizeOutBtn
AnchorSideBottom.Side = asrBottom
Left = 264
Height = 23
Top = 262
Width = 220
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 12
Text = 'SizeEdit'
end
end
object ReturnBtn: TButton
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 427
Height = 25
Top = 421
Width = 61
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Return'
ModalResult = 1
TabOrder = 8
end
object ComputeBtn: TButton
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ReturnBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 343
Height = 25
Top = 421
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 7
end
object ResetBtn: TButton
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 281
Height = 25
Top = 421
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 6
end
object HelpBtn: TButton
Tag = 110
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 222
Height = 25
Top = 421
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 5
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ReturnBtn
Left = 0
Height = 8
Top = 405
Width = 500
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
end

View File

@ -0,0 +1,628 @@
// Use file "bubbleplot2.laz" for testing.
unit BubblePlotUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Clipbrd, Buttons, ExtCtrls, Math,
MainUnit, Globals, OutputUnit, DataProcs, DictionaryUnit, ContextHelpUnit;
type
{ TBubbleForm }
TBubbleForm = class(TForm)
Bevel1: TBevel;
HelpBtn: TButton;
Panel1: TPanel;
TransformChk: TCheckBox;
YLabelEdit: TEdit;
Label8: TLabel;
XLabelEdit: TEdit;
Label7: TLabel;
TitleEdit: TEdit;
Label6: TLabel;
ResetBtn: TButton;
ComputeBtn: TButton;
ReturnBtn: TButton;
IDInBtn: TBitBtn;
IDOutBtn: TBitBtn;
XInBtn: TBitBtn;
XOutBtn: TBitBtn;
YInBtn: TBitBtn;
YOutBtn: TBitBtn;
SizeInBtn: TBitBtn;
SizeOutBtn: TBitBtn;
BubbleEdit: TEdit;
SizeEdit: TEdit;
YEdit: TEdit;
XEdit: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
VarList: TListBox;
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
procedure IDInBtnClick(Sender: TObject);
procedure IDOutBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure SizeInBtnClick(Sender: TObject);
procedure SizeOutBtnClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean);
procedure XInBtnClick(Sender: TObject);
procedure XOutBtnClick(Sender: TObject);
procedure YInBtnClick(Sender: TObject);
procedure YOutBtnClick(Sender: TObject);
private
{ private declarations }
FAutoSized: boolean;
procedure UpdateBtnStates;
public
{ public declarations }
end;
var
BubbleForm: TBubbleForm;
implementation
uses
BlankFrmUnit;
{ TBubbleForm }
procedure TBubbleForm.IDInBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while (BubbleEdit.Text = '') and (i < VarList.Items.Count) do
begin
if (VarList.Selected[i]) then
begin
BubbleEdit.Text := VarList.Items[i];
VarList.Items.Delete(i);
i := 0;
end else
inc(i);
end;
UpdateBtnStates;
end;
procedure TBubbleForm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).Tag);
end;
procedure TBubbleForm.ComputeBtnClick(Sender: TObject);
var
BubbleCol, XCol, YCol, SizeCol, i, j, LabelWide, TextHi, Xpos: integer;
ImageWide, ImageHi, Xstart, Xend, Ystart, Yend, Yincr, cell: integer;
Xmin, Xmax, Xrange, Xstep, intcell, noreplications, minrep, maxrep: integer;
nobubbles, yprop: integer;
varname, Xlabel, Ylabel, astring, Title: string;
Ymin, Ymax, Yrange, Ystep, cellvalue, xvalue: double;
BubMin, BubMax, BubRange, ratio, value: double;
valstr: string;
BubColor, place: integer;
X1, Y1, X2, Y2: integer;
dx, dy: Integer;
Data: DblDyneMat;
ncases, ncols, BubbleID, newcol : integer;
GrandYMean, GrandSizeMean, sizevalue, yvalue: double;
Ymeans: DblDyneVec;
CaseYMeans: DblDyneVec;
SizeMeans: DblDyneVec;
CaseSizeMeans: DblDyneVec;
outline: string;
labels: StrDyneVec;
lReport: TStrings;
begin
BubbleCol := 0;
XCol := 0;
YCol := 0;
SizeCol := 0;
for i := 1 to NoVariables do
begin
varname := OS3MainFrm.DataGrid.Cells[i,0];
if (varname = BubbleEdit.Text) then BubbleCol := i;
if (varname = XEdit.Text) then XCol := i;
if (varname = YEdit.Text) then YCol := i;
if (varname = SizeEdit.Text) then SizeCol := i;
end;
if ((BubbleCol = 0) or (XCol = 0) or (YCol = 0) or (SizeCol = 0)) then
begin
MessageDlg('One or more variables not found.', mtError, [mbOK], 0);
ModalResult := mrNone;
Exit;
end;
// get number of bubbles and replications per bubble (number of bubble id's)
minrep := 1000;
maxrep := -1;
for i := 1 to NoCases do
begin
intcell := StrToInt(OS3MainFrm.DataGrid.Cells[BubbleCol,i]);
if (intcell > maxrep) then maxrep := intcell;
if (intcell < minrep) then minrep := intcell;
end;
nobubbles := maxrep - minrep + 1;
noreplications := 1;
intcell := StrToInt(OS3MainFrm.DataGrid.Cells[BubbleCol,1]);
for i := 2 to NoCases do
begin
cell := StrToInt(OS3MainFrm.DataGrid.Cells[BubbleCol,i]);
if (cell = intcell) then noreplications := noreplications + 1;
end;
// get min, max and range of Y
Ymin := 1.0e308;
Ymax := -1.0e308;
for i := 1 to NoCases do
begin
cellvalue := StrToFloat(OS3MainFrm.DataGrid.Cells[YCol,i]);
if (cellvalue > Ymax) then Ymax := cellvalue;
if (cellvalue < Ymin) then Ymin := cellvalue;
end;
Yrange := Ymax - Ymin;
Ystep := Yrange / 10;
// get min, max and range of X
Xmin := 10000;
Xmax := -1;
for i := 1 to NoCases do
begin
intcell := StrToInt(OS3MainFrm.DataGrid.Cells[XCol,i]);
if (intcell > Xmax) then Xmax := intcell;
if (intcell < Xmin) then Xmin := intcell;
end;
Xrange := Xmax - Xmin;
Xstep := Xrange div (noreplications-1);
// get min, max, range, and increment of bubble sizes
BubMin := 1.0e308;
BubMax := -1.0e308;
for i := 1 to NoCases do
begin
cellvalue := StrToFloat(OS3MainFrm.DataGrid.Cells[SizeCol,i]);
if (cellvalue > BubMax) then BubMax := cellvalue;
if (cellvalue < BubMin) then BubMin := cellvalue;
end;
BubRange := BubMax - BubMin;
// Display basic statistics
ncases := NoCases div noreplications;
GrandYMean := 0.0;
GrandSizeMean := 0.0;
SetLength(CaseYMeans,ncases);
SetLength(CaseSizeMeans,ncases);
SetLength(Ymeans,noreplications);
SetLength(SizeMeans,noreplications);
for i := 0 to ncases - 1 do
begin
CaseYMeans[i] := 0.0;
CaseSizeMeans[i] := 0.0;
end;
for i := 0 to noreplications - 1 do
begin
Ymeans[i] := 0.0;
SizeMeans[i] := 0.0;
end;
i := 1;
while (i <= NoCases) do
begin
for j := 1 to noreplications do
begin
bubbleID := StrToInt(OS3MainFrm.DataGrid.Cells[BubbleCol,i]);
yvalue := StrToFloat(OS3MainFrm.DataGrid.Cells[YCol,i]);
sizevalue := StrToFloat(OS3MainFrm.DataGrid.Cells[SizeCol,i]);
GrandYMean := GrandYMean + yvalue;
GrandSizeMean := GrandSizeMean + sizevalue;
Ymeans[j-1] := Ymeans[j-1] + yvalue;
SizeMeans[j-1] := SizeMeans[j-1] + sizevalue;
CaseYMeans[bubbleID-1] := CaseYMeans[bubbleID-1] + yvalue;
CaseSizeMeans[bubbleID-1] := CaseSizeMeans[bubbleID-1] + sizevalue;
inc(i);
end;
end;
GrandYMean := GrandYMean / (ncases * noreplications);
GrandSizeMean := GrandSizeMean / (ncases * noreplications);
for j := 0 to noreplications - 1 do
begin
Ymeans[j] := Ymeans[j] / ncases;
SizeMeans[j] := SizeMeans[j] / ncases;
end;
for i := 0 to ncases - 1 do
begin
CaseYMeans[i] := CaseYMeans[i] / noreplications;
CaseSizeMeans[i] := CaseSizeMeans[i] / noreplications;
end;
lReport := TStringList.Create;
try
lReport.Add('MEANS FOR Y AND SIZE VARIABLES');
lReport.Add('');
lReport.Add('Grand Mean for Y := %8.3f', [GrandYMean]);
lReport.Add('Grand Mean for Size := %8.3f', [GrandSizeMean]);
lReport.Add('');
lReport.Add('REPLICATION MEAN Y VALUES (ACROSS OBJECTS)');
for j := 0 to noreplications - 1 do
lReport.Add('Replication %5d Mean := %8.3f', [j+1, Ymeans[j]]);
lReport.Add('');
lReport.Add('REPLICATION MEAN SIZE VALUES (ACROSS OBJECTS)');
for j := 0 to noreplications - 1 do
lReport.Add('Replication %5d Mean := %8.3f', [j+1, SizeMeans[j]]);
lReport.Add('');
lReport.Add('MEAN Y VALUES FOR EACH BUBBLE (OBJECT)');
for i := 0 to ncases - 1 do
lReport.Add('Object %5d Mean := %8.3f', [i+1, CaseYMeans[i]]);
lReport.Add('');
lReport.Add('MEAN SIZE VALUES FOR EACH BUBBLE (OBJECT)');
for i := 0 to ncases - 1 do
lReport.Add('Object %5d Mean := %8.3f', [i+1, CaseSizeMeans[i]]);
DisplayReport(lReport);
finally
lReport.Free;
SizeMeans := nil;
Ymeans := nil;
CaseSizeMeans := nil;
CaseYMeans := nil;
end;
//--------------------------------------------------------------------------
// Plotting Section
//---------------------------------------------------------------------------
//BlankFrm.Image1.Canvas.Clear;
BlankFrm.Show;
BlankFrm.Caption := 'BUBBLE PLOT of ' + OS3MainFrm.FileNameEdit.Text;
Xlabel := XlabelEdit.Text;
Ylabel := YlabelEdit.Text;
Title := TitleEdit.Text;
ImageHi := BlankFrm.Image1.Height;
ImageWide := BlankFrm.Image1.Width;
Xstart := ImageWide div 10;
Xend := (ImageWide * 9) div 10;
Ystart := ImageHi div 10;
Yend := (ImageHi * 8) div 10;
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
BlankFrm.Image1.Canvas.Brush.Color := clWhite;
BlankFrm.Image1.Canvas.Rectangle(0,0,ImageWide,ImageHi);
BlankFrm.Image1.Canvas.FloodFill(0,0,clWhite,fsBorder);
BlankFrm.Image1.Canvas.TextOut(Xstart-10,Ystart-30,Ylabel);
LabelWide := BlankFrm.Image1.Canvas.TextWidth(Xlabel);
BlankFrm.Image1.Canvas.TextOut((Xend-Xstart) div 2 - LabelWide,Yend + 40,Xlabel);
LabelWide := BlankFrm.Image1.Canvas.TextWidth(Title);
BlankFrm.Image1.Canvas.TextOut((Xend-Xstart) div 2 - LabelWide div 2, Ystart - 40,Title);
// draw axis lines
BlankFrm.Image1.Canvas.MoveTo(Xstart,Yend);
BlankFrm.Image1.Canvas.LineTo(Xend,Yend);
BlankFrm.Image1.Canvas.MoveTo(Xstart,Yend);
BlankFrm.Image1.Canvas.LineTo(Xstart,Ystart);
// create y axis values
Yincr := (Yend - Ystart) div 10;
for i := 0 to 10 do // print Y axis values
begin
place := Yend - (i * Yincr);
value := Ymin + (Ystep * i);
valstr := format('%.2f',[value]);
astring := valstr;
TextHi := BlankFrm.Image1.Canvas.TextHeight(astring);
BlankFrm.Image1.Canvas.TextOut(Xstart-30,place-TextHi,astring);
end;
// create x axis values
for i := 1 to noreplications do // print x axis
begin
value := Xmin + ((i-1) * Xstep);
ratio := i / noreplications;
Xpos := round(ratio * (Xend - Xstart));
valstr := format('%.0f',[value]);
astring := valstr;
BlankFrm.Image1.Canvas.TextOut(Xpos,Yend + 20,astring);
end;
// Plot the bubbles
for i := 1 to NoCases do
begin
intcell := StrToInt(OS3MainFrm.DataGrid.Cells[BubbleCol,i]);
xvalue := StrToFloat(OS3MainFrm.DataGrid.Cells[XCol,i]);
cellvalue := StrToFloat(OS3MainFrm.DataGrid.Cells[YCol,i]);
yprop := Yend - round(((cellvalue-Ymin) / Yrange) * (Yend - Ystart));
cellvalue := StrToFloat(OS3MainFrm.DataGrid.Cells[SizeCol,i]);
astring := Trim(OS3MainFrm.DataGrid.Cells[BubbleCol,i]);
cellvalue := ((cellvalue - BubMin) / BubRange) * 20;
cellvalue := cellvalue + 10;
ratio := ((xvalue - Xmin) / Xstep) + 1;
ratio := (ratio / noreplications) * (Xend - Xstart);
Xpos := ceil(ratio);
BubColor := intcell - 1;
while (Bubcolor > 11) do Bubcolor := 12 - Bubcolor;
BlankFrm.Image1.Canvas.Brush.Color := DATA_COLORS[Bubcolor];
X1 := Xpos - ceil(cellvalue);
Y1 := yprop - ceil(cellvalue);
X2 := Xpos + ceil(cellvalue);
Y2 := yprop + ceil(cellvalue);
BlankFrm.Image1.Canvas.Ellipse(X1,Y1,X2,Y2);
BlankFrm.Image1.Canvas.Brush.Color := clWhite;
dx := BlankFrm.Image1.Canvas.TextWidth(astring) div 2;
dy := BlankFrm.Image1.Canvas.TextHeight(astring) div 2;
BlankFrm.Image1.Canvas.TextOut(Xpos-dx, yprop-dy, astring);
end;
// Transform data matrix if elected
if (TransformChk.Checked = true) then
begin
ncases := nobubbles;
ncols := noreplications * 3 + 1;
// Note - columns: 1:=object ID, 2 to noreplications := X,
// next noreplications := Y, next noreplications := size
SetLength(Data,ncases,ncols);
i := 1;
while (i <= NoCases) do
begin
for j := 1 to noreplications do
begin
bubbleID := StrToInt(OS3MainFrm.DataGrid.Cells[BubbleCol,i]);
xvalue := StrToFloat(OS3MainFrm.DataGrid.Cells[XCol,i]);
yvalue := StrToFloat(OS3MainFrm.DataGrid.Cells[YCol,i]);
sizevalue := StrToFloat(OS3MainFrm.DataGrid.Cells[SizeCol,i]);
Data[bubbleID-1,0] := bubbleID;
Data[bubbleID-1,j] := xvalue;
Data[bubbleID-1,noreplications+j] := yvalue;
Data[bubbleID-1,noreplications*2+j] := sizevalue;
inc(i);
end;
end;
SetLength(labels,NoVariables+1);
for i := 1 to NoVariables do labels[i] := OS3MainFrm.DataGrid.Cells[i,0];
ClearGrid;
OS3MainFrm.DataGrid.RowCount := ncases + 1;
OS3MainFrm.DataGrid.ColCount := ncols + 1;
for i := 1 to ncases do
begin
OS3MainFrm.DataGrid.Cells[0,i] := IntToStr(i);
for j := 1 to ncols do
OS3MainFrm.DataGrid.Cells[j,i] := FloatToStr(Data[i-1,j-1]);
end;
OS3MainFrm.DataGrid.Cells[1,0] := labels[1];
for j := 2 to NoVariables do // clear dictionary
begin
for i := 0 to 7 do DictionaryFrm.DictGrid.Cells[i,j] := '';
DictionaryFrm.DictGrid.RowCount := DictionaryFrm.DictGrid.RowCount - 1;
VarDefined[j] := false;
end;
DictionaryFrm.DictGrid.Cells[1,1] := labels[1];
for j := 1 to noreplications do
begin
outline := labels[2] + IntToStr(j);
newcol := j + 1;
if (newcol+1 > DictionaryFrm.DictGrid.RowCount) then
DictionaryFrm.DictGrid.RowCount := DictionaryFrm.DictGrid.RowCount + 1;
DictionaryFrm.Defaults(Self,newcol);
VarDefined[newcol] := true;
DictionaryFrm.DictGrid.Cells[1,newcol] := outline;
OS3MainFrm.DataGrid.Cells[newcol,0] := outline;
end;
for j := 1 to noreplications do
begin
outline := labels[3] + IntToStr(j);
newcol := j + 1 + noreplications;
OS3MainFrm.DataGrid.Cells[newcol,0] := outline;
if (newcol+1 > DictionaryFrm.DictGrid.RowCount) then
DictionaryFrm.DictGrid.RowCount := DictionaryFrm.DictGrid.RowCount + 1;
DictionaryFrm.Defaults(Self,newcol);
VarDefined[newcol] := true;
DictionaryFrm.DictGrid.Cells[1,newcol] := outline;
end;
for j := 1 to noreplications do
begin
outline := labels[4] + IntToStr(j);
newcol := j + 1 + noreplications * 2;
OS3MainFrm.DataGrid.Cells[newcol,0] := outline;
if (newcol+1 > DictionaryFrm.DictGrid.RowCount) then
DictionaryFrm.DictGrid.RowCount := DictionaryFrm.DictGrid.RowCount + 1;
DictionaryFrm.Defaults(Self,newcol);
VarDefined[newcol] := true;
DictionaryFrm.DictGrid.Cells[1,newcol] := outline;
end;
NoVariables := ncols;
NoCases := ncases;
OS3MainFrm.NoCasesEdit.Text := IntToStr(NoCases);
OS3MainFrm.NoVarsEdit.Text := IntToStr(NoVariables);
Data := nil;
labels := nil;
end;
end;
procedure TBubbleForm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, ReturnBtn.Width]);
HelpBtn.Constraints.MinWidth := w;
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
ReturnBtn.Constraints.MinWidth := w;
Panel1.Constraints.MinHeight := SizeOutBtn.Top + SizeOutBtn.Height;
Panel1.Constraints.MinWidth := 2*Label2.Width + IDInBtn.Width + 2*VarList.BorderSpacing.Right;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := True;
end;
procedure TBubbleForm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
if DictionaryFrm = nil then Application.CreateForm(TDictionaryFrm, DictionaryFrm);
if BlankFrm = nil then Application.CreateForm(TBlankFrm, BlankFrm);
end;
procedure TBubbleForm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TBubbleForm.IDOutBtnClick(Sender: TObject);
begin
if BubbleEdit.Text <> '' then
VarList.Items.Add(BubbleEdit.Text);
UpdateBtnStates;
end;
procedure TBubbleForm.ResetBtnClick(Sender: TObject);
var
i: integer;
begin
BubbleEdit.Text := '';
XEdit.Text := '';
YEdit.Text := '';
SizeEdit.Text := '';
VarList.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
UpdateBtnStates;
end;
procedure TBubbleForm.SizeInBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while (SizeEdit.Text = '') and (i < VarList.Items.Count) do
begin
if VarList.Selected[i] then
begin
SizeEdit.Text := VarList.Items[i];
VarList.Items.Delete(i);
i := 0;
end else
inc(i);
end;
UpdateBtnStates;
end;
procedure TBubbleForm.SizeOutBtnClick(Sender: TObject);
begin
if SizeEdit.Text <> '' then
VarList.Items.Add(SizeEdit.Text);
UpdateBtnStates;
end;
procedure TBubbleForm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
procedure TBubbleForm.XInBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while (XEdit.Text = '') and (i < VarList.Items.Count) do
begin
if VarList.Selected[i] then
begin
XEdit.Text := VarList.Items[i];
VarList.Items.Delete(i);
i := 0;
end else
inc(i);
end;
UpdateBtnStates;
end;
procedure TBubbleForm.XOutBtnClick(Sender: TObject);
begin
if XEdit.Text <> '' then
VarList.Items.Add(XEdit.Text);
UpdateBtnStates;
end;
procedure TBubbleForm.YInBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while (YEdit.Text = '') and (i < VarList.Items.Count) do
begin
if VarList.Selected[i] then
begin
YEdit.Text := VarList.Items[i];
VarList.Items.Delete(i);
i := 0;
end else
inc(i);
end;
UpdateBtnStates;
end;
procedure TBubbleForm.YOutBtnClick(Sender: TObject);
begin
if YEdit.Text <> '' then
VarList.Items.Add(YEdit.Text);
UpdateBtnStates;
end;
procedure TBubbleForm.UpdateBtnStates;
var
i: Integer;
lSelected: Boolean;
begin
lSelected := false;
for i:=0 to VarList.Count-1 do
if VarList.Selected[i] then
begin
lSelected := true;
break;
end;
IDInBtn.Enabled := lSelected and (BubbleEdit.Text = '');
XInBtn.Enabled := lSelected and (XEdit.Text = '');
YInBtn.Enabled := lSelected and (YEdit.Text = '');
SizeInBtn.Enabled := lSelected and (SizeEdit.Text = '');
IDOutBtn.Enabled := BubbleEdit.Text <> '';
XOutBtn.Enabled := XEdit.Text <> '';
YOutBtn.Enabled := YEdit.Text <> '';
SizeOutBtn.Enabled := SizeEdit.Text <> '';
end;
initialization
{$I bubbleplotunit.lrs}
end.

View File

@ -0,0 +1,398 @@
object CompareDistFrm: TCompareDistFrm
Left = 462
Height = 375
Top = 227
Width = 516
AutoSize = True
Caption = 'Compare Cumulative Distributions'
ClientHeight = 375
ClientWidth = 516
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object CompareGroup: TRadioGroup
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 326
Height = 72
Top = 8
Width = 182
Anchors = [akTop, akRight]
AutoFill = True
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Compare To:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 52
ClientWidth = 178
ItemIndex = 0
Items.Strings = (
'A Theoretical Distribution'
'Another Variable'
)
OnClick = CompareGroupClick
TabOrder = 2
end
object DistGroup: TRadioGroup
AnchorSideLeft.Control = CompareGroup
AnchorSideTop.Control = CompareGroup
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 326
Height = 135
Top = 96
Width = 182
Anchors = [akTop, akLeft, akRight]
AutoFill = True
AutoSize = True
BorderSpacing.Top = 16
BorderSpacing.Right = 8
Caption = 'Theoretical Distributions:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 115
ClientWidth = 178
Items.Strings = (
'Normal Distribution'
't-Distribution'
'Chi Square Distribution'
'F Distribution'
'Poisson Distribution'
)
OnClick = DistGroupClick
TabOrder = 3
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 299
Height = 25
Top = 342
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 5
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 365
Height = 25
Top = 342
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 6
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 453
Height = 25
Top = 342
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 7
end
object PlotTypeGrp: TGroupBox
AnchorSideLeft.Control = CompareGroup
AnchorSideTop.Control = DistGroup
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 326
Height = 74
Top = 247
Width = 182
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 16
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Plot Type:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 54
ClientWidth = 178
TabOrder = 4
object PointsChk: TRadioButton
Left = 12
Height = 19
Top = 6
Width = 67
BorderSpacing.Left = 12
Caption = '3DPoints'
Checked = True
TabOrder = 0
TabStop = True
end
object LinesChk: TRadioButton
Left = 12
Height = 19
Top = 27
Width = 67
BorderSpacing.Left = 12
BorderSpacing.Bottom = 8
Caption = '3DLines'
TabOrder = 1
end
end
object GroupBox1: TGroupBox
AnchorSideLeft.Control = Owner
AnchorSideBottom.Control = Bevel1
Left = 8
Height = 47
Top = 279
Width = 298
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 8
Caption = 'Option:'
ClientHeight = 27
ClientWidth = 294
TabOrder = 1
object BothChk: TCheckBox
Left = 12
Height = 19
Top = 0
Width = 270
BorderSpacing.Left = 12
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Plot both Frequency and cumulative Frequency'
TabOrder = 0
end
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ResetBtn
Left = 0
Height = 8
Top = 326
Width = 516
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = CompareGroup
AnchorSideBottom.Control = GroupBox1
Left = 8
Height = 263
Top = 8
Width = 310
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
BevelOuter = bvNone
ClientHeight = 263
ClientWidth = 310
TabOrder = 0
object Label1: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
Left = 0
Height = 15
Top = 0
Width = 49
Caption = 'Variables:'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = VerticalCenterBevel
AnchorSideBottom.Control = Panel1
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 246
Top = 17
Width = 150
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
ItemHeight = 0
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object Var1InBtn: TBitBtn
AnchorSideLeft.Control = VerticalCenterBevel
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = Var1OutBtn
Left = 160
Height = 28
Top = 53
Width = 28
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 4
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = Var1InBtnClick
Spacing = 0
TabOrder = 1
end
object Var1OutBtn: TBitBtn
AnchorSideLeft.Control = Var1InBtn
AnchorSideBottom.Control = VerticalCenterBevel
Left = 160
Height = 28
Top = 85
Width = 28
Anchors = [akLeft, akBottom]
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = Var1OutBtnClick
Spacing = 0
TabOrder = 2
end
object Var2InBtn: TBitBtn
AnchorSideLeft.Control = VerticalCenterBevel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = VerticalCenterBevel
AnchorSideTop.Side = asrBottom
Left = 160
Height = 28
Top = 168
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = Var2InBtnClick
Spacing = 0
TabOrder = 3
end
object Var2OutBtn: TBitBtn
AnchorSideLeft.Control = Var2InBtn
AnchorSideTop.Control = Var2InBtn
AnchorSideTop.Side = asrBottom
Left = 160
Height = 28
Top = 200
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = Var2OutBtnClick
Spacing = 0
TabOrder = 4
end
object Label2: TLabel
AnchorSideLeft.Control = VarOneEdit
AnchorSideBottom.Control = VarOneEdit
Left = 196
Height = 15
Top = 61
Width = 66
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Variable One'
ParentColor = False
end
object Label3: TLabel
AnchorSideLeft.Control = VarTwoEdit
AnchorSideBottom.Control = VarTwoEdit
Left = 196
Height = 15
Top = 176
Width = 65
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Variable Two'
ParentColor = False
end
object VarOneEdit: TEdit
AnchorSideLeft.Control = Var1InBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Var1OutBtn
AnchorSideBottom.Side = asrBottom
Left = 196
Height = 23
Top = 78
Width = 114
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 5
Text = 'VarOneEdit'
end
object VarTwoEdit: TEdit
AnchorSideLeft.Control = Var2InBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Var2OutBtn
AnchorSideBottom.Side = asrBottom
Left = 196
Height = 23
Top = 193
Width = 114
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 6
Text = 'Edit1'
end
object VerticalCenterBevel: TBevel
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
AnchorSideTop.Side = asrCenter
Left = 150
Height = 55
Top = 113
Width = 10
Shape = bsSpacer
end
end
end

View File

@ -0,0 +1,594 @@
// Use file "cansas.laz" for testing
unit CompareDistUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons, ExtCtrls,
OutputUnit, FunctionsLib, Globals, GraphLib, DataProcs, MainUnit;
type
{ TCompareDistFrm }
TCompareDistFrm = class(TForm)
Bevel1: TBevel;
LinesChk: TRadioButton;
PointsChk: TRadioButton;
VerticalCenterBevel: TBevel;
BothChk: TCheckBox;
GroupBox1: TGroupBox;
Panel1: TPanel;
PlotTypeGrp: TGroupBox;
ResetBtn: TButton;
ComputeBtn: TButton;
CloseBtn: TButton;
CompareGroup: TRadioGroup;
DistGroup: TRadioGroup;
VarOneEdit: TEdit;
VarTwoEdit: TEdit;
Label2: TLabel;
Label3: TLabel;
Var1InBtn: TBitBtn;
Var1OutBtn: TBitBtn;
Var2InBtn: TBitBtn;
Var2OutBtn: TBitBtn;
Label1: TLabel;
VarList: TListBox;
procedure CompareGroupClick(Sender: TObject);
procedure ComputeBtnClick(Sender: TObject);
procedure DistGroupClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure Var1InBtnClick(Sender: TObject);
procedure Var1OutBtnClick(Sender: TObject);
procedure Var2InBtnClick(Sender: TObject);
procedure Var2OutBtnClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean);
private
{ private declarations }
compareto: integer;
disttype: integer;
FAutoSized: Boolean;
procedure UpdateBtnStates;
public
{ public declarations }
end;
var
CompareDistFrm: TCompareDistFrm;
implementation
uses
Math;
{ TCompareDistFrm }
procedure TCompareDistFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
Panel1.Constraints.MinWidth := Groupbox1.Width;
Panel1.Constraints.MinHeight := PlotTypeGrp.Top + PlotTypeGrp.Height - GroupBox1.Height - Panel1.BorderSpacing.Bottom - Panel1.Top;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TCompareDistFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
if GraphFrm = nil then Application.CreateForm(TGraphFrm, GraphFrm);
end;
procedure TCompareDistFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(nil);
end;
procedure TCompareDistFrm.CompareGroupClick(Sender: TObject);
begin
compareTo := CompareGroup.ItemIndex;
Label3.Enabled := (compareTo = 1);
VarTwoEdit.Enabled := (compareTo = 1);
Var2InBtn.Enabled := (compareTo = 1);
Var2OutBtn.Enabled := (compareTo = 1);
end;
procedure TCompareDistFrm.ComputeBtnClick(Sender: TObject);
var
Var1Freq : IntDyneVec;
Var2Freq : IntDyneVec;
XValue1 : DblDyneVec;
XValue2 : DblDyneVec;
Cumfreq1 : DblDyneVec;
Cumfreq2 : DblDyneVec;
i, j, k, col1, col2, Ncases, noints : integer;
min1, max1, min2, max2, range1, range2, value : double;
incrsize1, incrsize2, prob1,prob2, KS, mean, DegFree : double;
cellval, name1, name2 : string;
df1, df2 : integer;
xtitle : string;
msg: String;
lReport: TStrings;
begin
SetLength(Var1Freq, NoCases + 1);
SetLength(Var2Freq, NoCases + 1);
SetLength(XValue1, NoCases + 1);
SetLength(XValue2, NoCases + 1);
SetLength(Cumfreq1, NoCases + 1);
SetLength(Cumfreq2, NoCases + 1);
// Get columns of the variables
col1 := 0;
col2 := 0;
for i := 1 to NoVariables do
begin
if VarOneEdit.Text = OS3MainFrm.DataGrid.Cells[i,0] then col1 := i;
if compareto = 1 then
begin
if VarTwoEdit.Text = OS3MainFrm.DataGrid.Cells[i,0] then col2 := i;
end;
end;
msg := '';
case CompareTo of
0: if col1 = 0 then
msg := 'Variable not specified.';
1: if col1 = 0 then
msg := 'Variable One is not specified.'
else if col2 = 0 then
msg := 'Variable Two is not specified.';
end;
if msg <> '' then
begin
MessageDlg(msg, mtError, [mbOK], 0);
exit;
end;
// get min and max values for variable in col1
min1 := 1.0e308;
max1 := -1.0e308;
Ncases := 0;
for j := 1 to NoCases do
begin
if not ValidValue(j,col1) then continue;
value := StrToFloat(OS3MainFrm.DataGrid.Cells[col1,j]);
if value > max1 then max1 := value;
if value < min1 then min1 := value;
inc(Ncases);
end;
noints := NoCases - 1; // number of intervals
if noints > 20 then noints := 20;
range1 := max1 - min1 + 1.0;
incrsize1 := range1 / noints;
name1 := VarOneEdit.Text;
if compareTo = 1 then
begin
min2 := 1.0e32;
max2 := -1.0e32;
for j := 1 to NoCases do
begin
if Not ValidValue(j,col2) then continue;
value := StrToFloat(OS3MainFrm.DataGrid.Cells[col2,j]);
if value > max2 then max2 := value;
if value < min2 then min2 := value;
end;
range2 := max2 - min2 + 1.0;
incrsize2 := range2 / noints;
name2 := VarTwoEdit.Text;
end;
//Now, get frequency of cases in each interval
for j := 1 to noints+1 do
Var1Freq[j-1] := 0;
for j := 1 to NoCases do
begin
if Not ValidValue(j,col1) then continue;
value := StrToFloat(OS3MainFrm.DataGrid.Cells[col1,j]);
for k := 1 to noints do
begin
if (value >= min1 + ((k-1) * incrsize1)) and
(value < min1 + (k * incrsize1))
then
Var1Freq[k-1] := Var1Freq[k-1] + 1;
end;
end;
Cumfreq1[0] := Var1Freq[0];
for j := 1 to noints+1 do
XValue1[j-1] := min1 + (j-1) * incrsize1;
for j := 1 to noints do
Cumfreq1[j] := Cumfreq1[j-1] + Var1Freq[j];
if compareTo = 1 then // do same for second variable
begin
for j := 1 to noints+1 do
Var2Freq[j-1] := 0;
for j := 1 to NoCases do
begin
if Not ValidValue(j,col2) then continue;
value := StrToFloat(OS3MainFrm.DataGrid.Cells[col2,j]);
for k := 1 to noints do
begin
if (value >= min2 + ((k-1) * incrsize2)) and
(value < min2 + (k * incrsize2))
then
Var2Freq[k-1] := Var2Freq[k-1] + 1;
end;
end;
Cumfreq2[0] := Var2Freq[0];
for j := 1 to noints+1 do
XValue2[j-1] := min2 + (j-1) * incrsize2;
for j := 1 to noints do
Cumfreq2[j] := Cumfreq2[j-1] + Var2Freq[j];
end;
// Get theoretical distribution frequencies for selected dist.
if compareTo = 0 then
begin
if DistGroup.ItemIndex = 0 then // normal curve
begin
name2 := 'Normal';
min2 := -3.0;
max2 := 3.0;
range2 := max2 - min2;
incrsize2 := range2 / noints;
Xvalue2[0] := min2;
Xvalue2[noints] := max2;
for i := 1 to noints do
begin
Xvalue2[i-1] := min2 + (i-1) * incrsize2;
Xvalue2[i] := min2 + (i) * incrsize2;
prob1 := probz(abs(Xvalue2[i-1]));
prob2 := probz(abs(Xvalue2[i]));
if prob1 > prob2 then
Var2Freq[i-1] := round((prob1-prob2) * Ncases)
else
Var2Freq[i-1] := round((prob2-prob1) * Ncases)
end;
Cumfreq2[0] := Var2Freq[0];
for i := 1 to noints do
Cumfreq2[i] := Cumfreq2[i-1] + Var2Freq[i];
end
else
if DistGroup.ItemIndex = 1 then // t-distribution
begin
name2 := 't-Dist.';
min2 := -3.0;
max2 := 3.0;
df1 := Ncases - 1;
range2 := max2 - min2;
incrsize2 := range2 / noints;
Xvalue2[0] := min2;
Xvalue2[noints] := max2;
for i := 1 to noints do
begin
Xvalue2[i-1] := min2 + (i-1) * incrsize2;
Xvalue2[i] := min2 + (i) * incrsize2;
prob1 := 0.5 * probt(Xvalue2[i-1],df1);
prob2 := 0.5 * probt(Xvalue2[i],df1);
if prob1 > prob2 then
Var2Freq[i-1] := round((prob1-prob2) * Ncases)
else
Var2Freq[i-1] := round((prob2-prob1) * Ncases)
end;
Cumfreq2[0] := Var2Freq[0];
for i := 1 to noints do
Cumfreq2[i] := Cumfreq2[i-1] + Var2Freq[i];
end
else
if DistGroup.ItemIndex = 2 then // chi squared distribution
begin
cellval := InputBox('Deg. Freedom 1 Entry','DF 1','');
df1 := StrToInt(cellval);
name2 := 'Chi Sqrd';
min2 := 0.0;
max2 := 20.0;
range2 := max2 - min2;
incrsize2 := range2 / noints;
Xvalue2[0] := min2;
Xvalue2[noints] := max2;
for i := 1 to noints do
begin
Xvalue2[i-1] := min2 + (i-1) * incrsize2;
Xvalue2[i] := min2 + (i) * incrsize2;
prob1 := chisquaredprob(Xvalue2[i-1],df1);
prob2 := chisquaredprob(Xvalue2[i],df1);
if prob1 > prob2 then
Var2Freq[i-1] := round((prob1-prob2) * Ncases)
else
Var2Freq[i-1] := round((prob2-prob1) * Ncases)
end;
Cumfreq2[0] := Var2Freq[0];
for i := 1 to noints do
Cumfreq2[i] := Cumfreq2[i-1] + Var2Freq[i];
end
else
if DistGroup.ItemIndex = 3 then // F distribution
begin
// get degrees of freedom
cellval := InputBox('Deg. Freedom 1 Entry','DF 1','');
df1 := StrToInt(cellval);
cellval := InputBox('Deg. Freedom 2 Entry','DF 2','');
df2 := StrToInt(cellval);
name2 := 'F Dist.';
min2 := 0.0;
max2 := 3.0;
range2 := max2 - min2;
incrsize2 := range2 / noints;
Xvalue2[0] := min2;
Xvalue2[noints] := max2;
for i := 1 to noints do
begin
Xvalue2[i-1] := min2 + (i-1) * incrsize2;
Xvalue2[i] := min2 + (i) * incrsize2;
prob1 := probf(Xvalue2[i-1],df1,df2);
prob2 := probf(Xvalue2[i],df1,df2);
if prob1 > prob2 then
Var2Freq[i-1] := round((prob1-prob2) * Ncases)
else
Var2Freq[i-1] := round((prob2-prob1) * Ncases)
end;
Cumfreq2[0] := Var2Freq[0];
for i := 1 to noints do
Cumfreq2[i] := Cumfreq2[i-1] + Var2Freq[i];
end
else
if DistGroup.ItemIndex = 4 then // Poisson distribution
begin
name2 := 'Poisson';
mean := 0; // use as parameter a in pdf call
min2 := min1;
max2 := max1;
if max2 > 13 then
begin
MessageDlg('Value > 13 found. Factorial too large - exiting.', mtError, [mbOK], 0);
exit;
end;
for i := 1 to Ncases do
mean := mean + StrToFloat(OS3MainFrm.DataGrid.Cells[col1,i]);
mean := mean / Ncases;
cellval := IntToStr(round(mean));
cellval := InputBox('Parameter Entry (mean)','DF 1',cellval);
degfree := StrToFloat(cellval);
range2 := max2 - min2;
incrsize2 := range2 / noints;
// Xvalue2[0] := min2;
Xvalue2[noints] := max2;
for i := 1 to noints do
begin
Xvalue2[i-1] := min2 + (i-1) * incrsize2;
Xvalue2[i] := min2 + (i) * incrsize2;
poisson_pdf ( round(Xvalue2[i-1]), degfree, prob1 );
// prob1 := (Xvalue2[i-1],df1);
// prob2 := chisquaredprob(Xvalue2[i],df1);
// if prob1 > prob2 then
Var2Freq[i-1] := round((prob1) * Ncases);
// else Var2Freq[i-1] := round((prob2-prob1) * Ncases)
end;
Cumfreq2[0] := Var2Freq[0];
for i := 1 to noints do
Cumfreq2[i] := Cumfreq2[i-1] + Var2Freq[i];
end;
end;
lReport := TStringList.Create;
try
lReport.Add('DISTRIBUTION COMPARISON by Bill Miller');
lReport.Add('');
lReport.Add('%10s %10s %10s %10s %10s %10s', [
name1, name1, name1, name2, name2, name2
]);
lReport.Add('%10s %10s %10s %10s %10s %10s', [
'X1 Value','Frequency','Cum. Freq.','X2 Value','Frequency','Cum. Freq.'
]);
for i := 1 to noints do
lReport.Add('%10.3f %10d %10.3f %10.3f %10d %10.3f', [
XValue1[i-1],Var1Freq[i-1],Cumfreq1[i-1],XValue2[i-1],Var2Freq[i-1],Cumfreq2[i-1]
]);
cellval := 'D';
KS := KolmogorovTest(noints, Cumfreq1,noints, Cumfreq2, cellval);
// lReport.Add('Kolmogorov-Smirnov statistic := %5.3f', [KS]);
DisplayReport(lReport);
finally
lReport.Free;
end;
// plot the cdfs
xtitle := 'Red = ' + VarOneEdit.Text + ' Blue = ' + name2;
cellval := 'Plot of Cumulative Distributions';
if LinesChk.Checked then
GraphFrm.barwideprop := 1.0
else
GraphFrm.barwideprop := 0.5;
GraphFrm.nosets := 2;
GraphFrm.nbars := noints+1;
GraphFrm.Heading := cellval;
GraphFrm.XTitle := xtitle;
GraphFrm.YTitle := 'Frequency';
SetLength(GraphFrm.Ypoints,2,noints+1);
SetLength(GraphFrm.Xpoints,1,noints+1);
for k := 1 to noints+1 do
begin
GraphFrm.Ypoints[0,k-1] := Cumfreq1[k-1];
GraphFrm.Ypoints[1,k-1] := CumFreq2[k-1];
GraphFrm.Xpoints[0,k-1] := k;
end;
GraphFrm.AutoScaled := true;
if LinesChk.Checked then
GraphFrm.GraphType := 6 // 3d lines
else
GraphFrm.GraphType := 8; // 3D points
GraphFrm.BackColor := clYellow;
GraphFrm.WallColor := clBlue;
GraphFrm.FloorColor := clGray;
GraphFrm.ShowLeftWall := true;
GraphFrm.ShowRightWall := true;
GraphFrm.ShowBottomWall := true;
GraphFrm.ShowBackWall := true;
GraphFrm.ShowModal;
GraphFrm.Xpoints := nil;
GraphFrm.Ypoints := nil;
if BothChk.Checked then // plot the frequencies
begin
xtitle := 'Red = ' + VarOneEdit.Text + ' Blue = ' + name2;
cellval := 'Plot of Cumulative Distributions';
if LinesChk.Checked then
GraphFrm.BarWideProp := 1.0
else
GraphFrm.BarWideProp := 0.5;
GraphFrm.nosets := 2;
GraphFrm.nbars := noints+1;
GraphFrm.Heading := cellval;
GraphFrm.XTitle := xtitle;
GraphFrm.YTitle := 'Frequency';
SetLength(GraphFrm.Ypoints,2,noints+1);
SetLength(GraphFrm.Xpoints,1,noints+1);
for k := 1 to noints+1 do
begin
GraphFrm.Ypoints[0,k-1] := Var1Freq[k-1];
GraphFrm.Ypoints[1,k-1] := Var2Freq[k-1];
GraphFrm.Xpoints[0,k-1] := k;
end;
GraphFrm.AutoScaled := true;
if LinesChk.Checked then
GraphFrm.GraphType := 6 // 3d lines
else
GraphFrm.GraphType := 8; // 3D points
GraphFrm.BackColor := clYellow;
GraphFrm.WallColor := clBlue;
GraphFrm.FloorColor := clGray;
GraphFrm.ShowLeftWall := true;
GraphFrm.ShowRightWall := true;
GraphFrm.ShowBottomWall := true;
GraphFrm.ShowBackWall := true;
GraphFrm.ShowModal;
GraphFrm.Xpoints := nil;
GraphFrm.Ypoints := nil;
end;
// clean up
Cumfreq2 := nil;
Cumfreq1 := nil;
XValue1 := nil;
XValue2 := nil;
Var2Freq := nil;
Var1Freq := nil;
end;
procedure TCompareDistFrm.DistGroupClick(Sender: TObject);
begin
disttype := DistGroup.ItemIndex;
end;
procedure TCompareDistFrm.ResetBtnClick(Sender: TObject);
var
i: integer;
begin
VarList.Clear;
VarOneEdit.Text := '';
VarTwoEdit.Text := '';
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
Label3.Enabled := false;
CompareGroup.ItemIndex := 0;
DistGroup.ItemIndex := 0;
LinesChk.Checked := false;
PointsChk.Checked := true;
end;
procedure TCompareDistFrm.Var1InBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while (VarOneEdit.Text = '') and (i < VarList.Items.Count) do
begin
if VarList.Selected[i] then
begin
VarOneEdit.Text := VarList.Items[i];
VarList.Items.Delete(i);
i := 0;
end else
inc(i);
end;
UpdateBtnStates;
end;
procedure TCompareDistFrm.Var1OutBtnClick(Sender: TObject);
begin
if VarOneEdit.Text <> '' then
begin
VarList.Items.Add(VarOneEdit.Text);
VarOneEdit.Text := '';
end;
UpdateBtnStates;
end;
procedure TCompareDistFrm.Var2InBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while (VarTwoEdit.Text = '') and (i < VarList.Items.Count) do
begin
if VarList.Selected[i] then
begin
VarTwoEdit.Text := VarList.Items[i];
VarList.Items.Delete(i);
i := 0;
end else
inc(i);
end;
UpdateBtnStates;
end;
procedure TCompareDistFrm.Var2OutBtnClick(Sender: TObject);
begin
if VarTwoEdit.Text <> '' then
begin
VarList.Items.Add(VarTwoEdit.Text);
VarTwoEdit.Text := '';
end;
UpdateBtnStates;
end;
procedure TCompareDistFrm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
procedure TCompareDistFrm.UpdateBtnStates;
begin
Var1InBtn.Enabled := (VarList.ItemIndex > -1) and (VarOneEdit.Text = '');
Var2InBtn.Enabled := (VarList.ItemIndex > -1) and (VarTwoEdit.Text = '');
Var1OutBtn.Enabled := VarOneEdit.Text <> '';
Var2OutBtn.Enabled := VarTwoEdit.Text <> '';
end;
initialization
{$I comparedistunit.lrs}
end.

View File

@ -0,0 +1,218 @@
object CrossTabFrm: TCrossTabFrm
Left = 459
Height = 347
Top = 230
Width = 421
AutoSize = True
Caption = 'Cross Tabulation'
ClientHeight = 347
ClientWidth = 421
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Panel2: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel2
Left = 8
Height = 290
Top = 8
Width = 405
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BevelOuter = bvNone
ClientHeight = 290
ClientWidth = 405
Constraints.MinHeight = 200
TabOrder = 0
object Label1: TLabel
AnchorSideLeft.Control = Panel2
AnchorSideTop.Control = Panel2
Left = 0
Height = 15
Top = 0
Width = 97
Caption = 'Available Variables'
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = SelList
AnchorSideTop.Control = Panel2
Left = 224
Height = 15
Top = 0
Width = 104
Caption = 'Variables to Analyze'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Panel2
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = InBtn
AnchorSideBottom.Control = Panel2
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 273
Top = 17
Width = 180
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Right = 8
ItemHeight = 0
MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object SelList: TListBox
AnchorSideLeft.Control = InBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel2
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Panel2
AnchorSideBottom.Side = asrBottom
Left = 224
Height = 273
Top = 17
Width = 181
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
ItemHeight = 0
MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 3
end
object InBtn: TBitBtn
AnchorSideLeft.Control = Panel2
AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = VertCenterBevel
Left = 188
Height = 28
Top = 119
Width = 28
Anchors = [akLeft, akBottom]
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = InBtnClick
Spacing = 0
TabOrder = 1
end
object OutBtn: TBitBtn
AnchorSideLeft.Control = Panel2
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VertCenterBevel
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = VertCenterBevel
AnchorSideBottom.Side = asrBottom
Left = 188
Height = 28
Top = 159
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = OutBtnClick
Spacing = 0
TabOrder = 2
end
object VertCenterBevel: TBevel
AnchorSideLeft.Control = InBtn
AnchorSideTop.Control = VarList
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = OutBtn
AnchorSideRight.Side = asrBottom
Left = 188
Height = 12
Top = 147
Width = 28
Anchors = [akTop, akLeft, akRight]
Shape = bsSpacer
end
end
object Bevel2: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 298
Width = 421
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object CloseBtn: TButton
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 354
Height = 25
Top = 314
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 1
end
object ResetBtn: TButton
AnchorSideTop.Control = CloseBtn
AnchorSideRight.Control = ComputeBtn
Left = 200
Height = 25
Top = 314
Width = 54
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Right = 12
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 2
end
object HelpBtn: TButton
AnchorSideTop.Control = CloseBtn
AnchorSideRight.Control = ResetBtn
Left = 137
Height = 25
Top = 314
Width = 51
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Right = 12
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 3
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 266
Height = 25
Top = 314
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 4
end
end

View File

@ -0,0 +1,464 @@
// Use file "twoway.laz" for testing
unit CrossTabUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons, ExtCtrls,
Globals, OutputUnit, MainUnit, DataProcs, MatrixLib, ContextHelpUnit;
type
{ TCrossTabFrm }
TCrossTabFrm = class(TForm)
ComputeBtn: TButton;
VertCenterBevel: TBevel;
Bevel2: TBevel;
HelpBtn: TButton;
InBtn: TBitBtn;
OutBtn: TBitBtn;
Panel2: TPanel;
ResetBtn: TButton;
CloseBtn: TButton;
Label1: TLabel;
Label2: TLabel;
VarList: TListBox;
SelList: TListBox;
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
procedure InBtnClick(Sender: TObject);
procedure ComputeBtnClick(Sender: TObject);
procedure OutBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean);
private
{ private declarations }
FAutoSized: Boolean;
grandsum, sum, index : integer;
no_in_list, length_array, ptr1, ptr2 : integer ;
var_list, min_value, max_value, levels, displace, subscript : IntDyneVec;
freq : IntDyneVec;
outgrid : DblDyneMat;
rowlabels : StrDyneVec;
colLabels : StrDyneVec;
ColNoSelected : IntDyneVec;
NoSelected : integer;
NV, NC : integer;
procedure Initialize;
procedure GetLevels(AReport: TStrings);
function IndexPosition(x: IntDyneVec): integer;
Procedure Tabulate;
procedure BreakDown(AReport: TStrings);
procedure UpdateBtnStates;
public
{ public declarations }
end;
var
CrossTabFrm: TCrossTabFrm;
implementation
uses
Math;
{ TCrossTabFrm }
procedure TCrossTabFrm.ResetBtnClick(Sender: TObject);
var
i: integer;
begin
VarList.Clear;
SelList.Clear;
NV := NoVariables;
NC := NoCases;
for i := 1 to NV do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
UpdateBtnStates;
end;
procedure TCrossTabFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TCrossTabFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).Tag);
end;
procedure TCrossTabFrm.InBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while i < VarList.Items.Count do
begin
if VarList.Selected[i] then
begin
SelList.Items.Add(VarList.Items[i]);
VarList.Items.Delete(i);
i := 0;
end else
inc(i);
end;
UpdateBtnStates;
end;
procedure TCrossTabFrm.ComputeBtnClick(Sender: TObject);
var
cellvalue: string;
i, j: integer;
lReport: TStrings;
begin
if SelList.Items.Count = 0 then
begin
MessageDlg('No variables selected for analysis.', mtError, [mbOK], 0);
exit;
end;
SetLength(var_list, NV);
SetLength(min_value, NV);
SetLength(max_value, NV);
SetLength(levels, NC);
SetLength(displace, NC);
SetLength(subscript,NC);
SetLength(ColNoSelected, NV);
lReport := TStringList.Create;
try
lReport.Add('CROSSTAB RESULTS');
lReport.Add('');
lReport.Add('Analyzed data is from file ' + OS3MainFrm.FileNameEdit.Text);
lReport.Add('');
Initialize;
NoSelected := 0;
for i := 0 to SelList.Items.Count-1 do
begin
for j := 1 to NV do
begin
cellvalue := OS3MainFrm.DataGrid.Cells[j,0];
if cellvalue = SelList.Items[i] then
begin
var_list[i] := j;
ColNoSelected[i] := j;
NoSelected := NoSelected + 1;
break;
end;
end;
end;
no_in_list := SelList.Items.Count;
GetLevels(lReport);
Tabulate;
BreakDown(lReport);
lReport.Add('');
lReport.Add('Grand sum across all categories = %d', [grandsum]);
DisplayReport(lReport);
finally
lReport.Free;
ColNoSelected := nil;
freq := nil;
collabels := nil;
rowlabels := nil;
outgrid := nil;
subscript := nil;
displace := nil;
levels := nil;
max_value := nil;
min_value := nil;
var_list := nil;
end;
end;
procedure TCrossTabFrm.OutBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while i < SelList.Items.Count do
begin
if SelList.Selected[i] then
begin
VarList.Items.Add(SelList.Items[i]);
SelList.Items.Delete(i);
i := 0;
end else
inc(i);
end;
UpdateBtnStates;
end;
procedure TCrossTabFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
HelpBtn.Constraints.MinWidth := w;
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TCrossTabFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
end;
procedure TCrossTabFrm.Initialize;
var
i: integer;
begin
no_in_list := 0;
for i := 1 to NV do
begin
var_list[i-1] := 0;
min_value[i-1] := 0;
max_value[i-1] := 0;
levels[i-1] := 0;
displace[i-1] := 0;
subscript[i-1] := 0;
end;
index := 0;
length_array := 0;
grandsum := 0;
end; { initialize procedure }
procedure TCrossTabFrm.GetLevels(AReport: TStrings);
var
i, j, k: integer;
value: double;
begin
for i := 1 to no_in_list do
begin
j := var_list[i-1];
if not GoodRecord(1,NoSelected,ColNoSelected) then continue;
value := StrToFloat(OS3MainFrm.DataGrid.Cells[j,1]);
min_value[i-1] := round(value);
max_value[i-1] := round(value);
for k := 2 to NC do
begin
if not GoodRecord(k,NoSelected,ColNoSelected) then continue;
value := StrToFloat(OS3MainFrm.DataGrid.Cells[j,k]);
if value < min_value[i-1] then
min_value[i-1] := round(value);
if value > max_value[i-1] then
max_value[i-1] := round(value);
end;
end;
for i := 1 to no_in_list do
begin
j := var_list[i-1];
levels[i-1] := max_value[i-1] - min_value[i-1] + 1;
AReport.Add('%s min.=%3d, max.=%3d, no. levels = %3d', [
OS3MainFrm.DataGrid.Cells[j,0],min_value[i-1],max_value[i-1],levels[i-1]
]);
end;
AReport.Add('');
displace[no_in_list-1] := 1;
if no_in_list > 1 then
for i := (no_in_list - 1) downto 1 do
displace[i-1] := levels[i] * displace[i];
end;
function TCrossTabFrm.IndexPosition(x: IntDyneVec): integer;
var
i: integer;
begin
Result := x[no_in_list-1];
if no_in_list > 1 then
begin
for i := 1 to no_in_list - 1 do
Result := Result + (x[i-1] -1) * displace[i-1];
end;
end;
procedure TCrossTabFrm.Tabulate;
var
i, j, k: integer;
value: double;
x: integer;
begin
length_array := 1;
for i := 1 to no_in_list do
length_array := length_array * levels[i-1];
SetLength(freq,length_array+1);
for i := 0 to length_array do
freq[i] := 0;
for i := 1 to NC do
begin
if IsFiltered(i) then
continue;
for j := 1 to no_in_list do
begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
k := var_list[j-1];
value := StrToFloat(OS3MainFrm.DataGrid.Cells[k,i]);
x := round(value);
x := x - min_value[j-1] + 1;
subscript[j-1] := x;
end;
j := IndexPosition(subscript);
if (j < 1) or (j > length_array) then
continue
else
freq[j] := freq[j] + 1;
end;
end; { procedure TABULATE }
procedure TCrossTabFrm.BreakDown(AReport: TStrings);
label 1,2,3,4, printgrid;
var
i, j, row, col, bigmax: integer;
outline: string;
value: string;
title: String;
begin
bigmax := -1;
for i := 0 to no_in_list-1 do
if Levels[i] > bigmax then bigmax := Levels[i];
SetLength(colLabels,bigmax);
SetLength(outgrid,length_array,bigmax);
SetLength(rowlabels,length_array);
outline := OS3MainFrm.DataGrid.Cells[var_list[no_in_list-1], 0];
for col := 1 to Levels[no_in_list-1] do
collabels[col-1] := outline + Format(':%3d', [min_value[no_in_list-1] + col - 1]);
for row := 1 to length_array do
rowlabels[row-1] := '';
ptr1 := no_in_list - 1;
ptr2 := no_in_list;
for i := 1 to no_in_list do
subscript[i-1] := 1;
AReport.Add('FREQUENCIES BY LEVEL:');
sum := 0;
col := 1;
row := 1;
1:
index := IndexPosition(subscript);
outline := 'For cell levels: ';
for i := 1 to no_in_list do
begin
j := var_list[i-1];
value := Format('%s:%3d ',[OS3MainFrm.DataGrid.Cells[j,0], min_value[i-1] + subscript[i-1] - 1]);
outline := outline + value;
end;
sum := sum + freq[index];
outgrid[row-1,col-1] := freq[index];
outline := outline + Format(' Frequency = %3d', [freq[index]]);
AReport.Add(outline);
subscript[ptr2-1] := subscript[ptr2-1] + 1;
col := col + 1;
if subscript[ptr2-1] <= levels[ptr2-1] then
goto 1;
AReport.Add('Sum across levels = %3d', [sum]);
AReport.Add('');
AReport.Add('');
grandsum := grandsum + sum;
sum := 0;
row := row + 1;
2:
if ptr1 < 1 then
goto printgrid;
subscript[ptr1-1] := subscript[ptr1-1] + 1;
if subscript[ptr1-1] <= levels[ptr1-1] then
goto 4;
3:
ptr1 := ptr1 - 1;
if ptr1 < 1 then
goto printgrid;
if subscript[ptr1-1] >= levels[ptr1-1] then
goto 3;
subscript[ptr1-1] := subscript[ptr1-1] + 1;
4:
for i := ptr1 + 1 to no_in_list do
subscript[i-1] := 1;
ptr1 := no_in_list - 1;
col := 1;
goto 1;
printgrid:
title := 'Cell Frequencies by Levels';
for i := 1 to row - 1 do
begin
value := format('Block %d',[i]);
rowlabels[i-1] := value;
end;
MatPrint(outgrid,row-1,Levels[no_in_list-1],title,rowlabels,collabels,NC, AReport);
end; { Procedure BREAKDOWN }
procedure TCrossTabFrm.UpdateBtnStates;
var
lSelected: Boolean;
i: Integer;
begin
lSelected := false;
for i := 0 to VarList.Items.Count-1 do
if VarList.Selected[i] then
begin
lSelected := true;
break;
end;
InBtn.Enabled := lSelected;
lSelected := false;
for i := 0 to SelList.Items.Count-1 do
if SelList.Selected[i] then
begin
lSelected := true;
break;
end;
OutBtn.Enabled := lSelected;
end;
procedure TCrossTabFrm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
initialization
{$I crosstabunit.lrs}
end.

View File

@ -0,0 +1,305 @@
object DescriptiveFrm: TDescriptiveFrm
Left = 626
Height = 393
Top = 226
Width = 453
AutoSize = True
Caption = 'Descriptive Statistics'
ClientHeight = 393
ClientWidth = 453
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 390
Height = 25
Top = 360
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 9
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 244
Height = 25
Top = 360
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 8
end
object HelpBtn: TButton
Tag = 119
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 185
Height = 25
Top = 360
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 7
end
object Label1: TLabel
AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = CIEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = CIEdit
Left = 8
Height = 15
Top = 325
Width = 174
BorderSpacing.Right = 8
Caption = 'Confidence Interval for the Mean'
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 8
Height = 15
Top = 8
Width = 46
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Variables'
ParentColor = False
end
object Label3: TLabel
AnchorSideLeft.Control = SelList
AnchorSideTop.Control = Owner
Left = 257
Height = 15
Top = 8
Width = 44
BorderSpacing.Top = 8
Caption = 'Selected'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = AllBtn
AnchorSideBottom.Control = GroupBox1
Left = 8
Height = 208
Top = 25
Width = 187
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Constraints.MinHeight = 200
ItemHeight = 0
MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object SelList: TListBox
AnchorSideLeft.Control = AllBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label3
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = VarList
AnchorSideBottom.Side = asrBottom
Left = 257
Height = 208
Top = 25
Width = 188
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
ItemHeight = 0
OnSelectionChange = VarListSelectionChange
TabOrder = 4
end
object CIEdit: TEdit
AnchorSideLeft.Control = Label1
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1
Left = 190
Height = 23
Top = 321
Width = 41
Alignment = taRightJustify
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
TabOrder = 6
Text = '95.0'
end
object GroupBox1: TGroupBox
AnchorSideLeft.Control = Owner
AnchorSideBottom.Control = CIEdit
Left = 8
Height = 72
Top = 241
Width = 306
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Options'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 24
ChildSizing.VerticalSpacing = 2
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2
ClientHeight = 52
ClientWidth = 302
TabOrder = 5
object CaseChk: TCheckBox
Left = 12
Height = 19
Top = 6
Width = 138
BorderSpacing.Left = 12
BorderSpacing.Right = 12
Caption = 'Casewise Deletion'
TabOrder = 0
end
object CheckBox1: TCheckBox
AnchorSideTop.Side = asrBottom
Left = 174
Height = 19
Top = 6
Width = 116
BorderSpacing.Left = 12
BorderSpacing.Right = 12
Caption = 'z Scores to Grid'
TabOrder = 1
end
object PcntileChk: TCheckBox
AnchorSideTop.Side = asrBottom
Left = 12
Height = 19
Top = 27
Width = 138
BorderSpacing.Left = 12
BorderSpacing.Right = 12
Caption = 'Show Percentile Ranks'
TabOrder = 2
end
object AltQrtilesChk: TCheckBox
AnchorSideTop.Side = asrBottom
Left = 174
Height = 19
Top = 27
Width = 116
BorderSpacing.Left = 12
BorderSpacing.Right = 12
Caption = 'Show All Quartiles'
TabOrder = 3
end
end
object InBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
AnchorSideRight.Side = asrBottom
Left = 212
Height = 28
Top = 25
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = InBtnClick
Spacing = 0
TabOrder = 1
end
object OutBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = InBtn
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 212
Height = 28
Top = 57
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = OutBtnClick
Spacing = 0
TabOrder = 2
end
object AllBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = OutBtn
AnchorSideTop.Side = asrBottom
Left = 203
Height = 25
Top = 117
Width = 46
AutoSize = True
BorderSpacing.Top = 32
Caption = 'ALL'
OnClick = AllBtnClick
TabOrder = 3
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 344
Width = 453
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 306
Height = 25
Top = 360
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 10
end
end

View File

@ -0,0 +1,473 @@
unit DescriptiveUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, Buttons,
MainUnit, Globals, FunctionsLib, OutputUnit, DataProcs, DictionaryUnit, ContextHelpUnit;
type
{ TDescriptiveFrm }
TDescriptiveFrm = class(TForm)
Bevel1: TBevel;
ComputeBtn: TButton;
CaseChk: TCheckBox;
CheckBox1: TCheckBox;
AltQrtilesChk: TCheckBox;
HelpBtn: TButton;
Label2: TLabel;
Label3: TLabel;
PcntileChk: TCheckBox;
GroupBox1: TGroupBox;
InBtn: TBitBtn;
OutBtn: TBitBtn;
AllBtn: TBitBtn;
ResetBtn: TButton;
CloseBtn: TButton;
CIEdit: TEdit;
Label1: TLabel;
VarList: TListBox;
SelList: TListBox;
procedure AllBtnClick(Sender: TObject);
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
procedure InBtnClick(Sender: TObject);
procedure OutBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean);
private
{ private declarations }
FAutoSized: Boolean;
sum, variance, stddev, value, mean, min, max, range, skew, prob, df, CI : double;
kurtosis, z, semean, seskew, sekurtosis, deviation, devsqr, M2, M3, M4 : double;
Q1, Q2, Q3, Q12, Q13, Q14, Q15, Q16, Q17, Q18, Q22, Q23, Q24, Q25, Q26 : double;
Q27, Q28, Q32, Q33, Q34, Q35, Q36, Q37, Q38, IQrange : double;
ncases, noselected : integer;
cellstring, gridstring: string;
selected : IntDyneVec;
procedure UpdateBtnStates;
public
{ public declarations }
end;
var
DescriptiveFrm: TDescriptiveFrm;
implementation
uses
Math;
{ TDescriptiveFrm }
procedure TDescriptiveFrm.ResetBtnClick(Sender: TObject);
var
i: integer;
begin
CIEdit.Text := FormatFloat('0.0', DEFAULT_CONFIDENCE_LEVEL_PERCENT);
VarList.Clear;
SelList.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
Selected := nil;
UpdateBtnStates;
end;
procedure TDescriptiveFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
HelpBtn.Constraints.MinWidth := w;
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TDescriptiveFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
if DictionaryFrm = nil then Application.CreateForm(TDictionaryFrm, DictionaryFrm);
end;
procedure TDescriptiveFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TDescriptiveFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).tag);
end;
procedure TDescriptiveFrm.InBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while i < VarList.Items.Count do
begin
if VarList.Selected[i] then
begin
SelList.Items.Add(VarList.Items[i]);
VarList.Items.Delete(i);
i := 0;
end else
inc(i);
end;
UpdateBtnStates;
end;
procedure TDescriptiveFrm.ComputeBtnClick(Sender: TObject);
var
i, j, k, m: integer;
num, den, cases: double;
values, pcntrank: DblDyneVec;
lReport: TStrings;
begin
noselected := SelList.Items.Count;
if noSelected = 0 then
begin
MessageDlg('No variables selected.', mtError, [mbOK], 0);
exit;
end;
SetLength(Selected, noselected);
// Get selected variables
for i := 1 to noselected do
begin
cellstring := SelList.Items.Strings[i-1];
for j := 1 to NoVariables do
if cellstring = OS3MainFrm.DataGrid.Cells[j,0] then selected[i-1] := j;
end;
lReport := TStringList.Create;
try
lReport.Add('DISTRIBUTION PARAMETER ESTIMATES');
lReport.Add('');
SetLength(Values, NoCases);
SetLength(pcntrank, NoCases);
for j := 1 to noselected do
begin
deviation := 0.0;
devsqr := 0.0;
M2 := 0.0;
M3 := 0.0;
M4 := 0.0;
sum := 0.0;
variance := 0.0;
stddev := 0.0;
range := 0.0;
skew := 0.0;
kurtosis := 0.0;
ncases := 0;
df := 0.0;
seskew := 0.0;
kurtosis := 0.0;
sekurtosis := 0.0;
k := selected[j-1];
CI := StrToFloat(CIEdit.Text) / 100.0;
prob := CI;
CI := (1.0 - CI) / 2.0;
CI := 1.0 - CI;
if CheckBox1.Checked then // add a new column to the grid
begin
gridstring := OS3MainFrm.DataGrid.Cells[k,0];
gridstring := Gridstring + 'z';
DictionaryFrm.NewVar(NoVariables+1);
DictionaryFrm.DictGrid.Cells[1,NoVariables] := gridstring;
OS3MainFrm.DataGrid.Cells[NoVariables,0] := gridstring;
end;
// Accumulate sums of squares, sums, etc. for variable j
min := 1.0e308;
max := -1.0e308;
for i := 1 to NoCases do
begin
if not GoodRecord(i,noselected,selected) then
continue;
if CaseChk.Checked then
begin
if not ValidValue(i,selected[j-1]) then
continue;
end
else if not GoodRecord(i,noselected,selected) then
continue;
value := StrToFloat(OS3MainFrm.DataGrid.Cells[k,i]);
ncases := ncases + 1;
values[ncases-1] := value;
df := df + 1.0;
sum := sum + value;
variance := variance + (value * value);
if (value < min) then min := value;
if (value > max) then max := value;
end;
if ncases > 0 then
begin
mean := sum / ncases;
range := max - min;
end;
if ncases > 1 then
begin
variance := variance - (sum * sum) / ncases;
variance := variance / (ncases - 1);
stddev := sqrt(variance);
semean := sqrt(variance / ncases);
if ncases < 120 then
CI := semean * inverset(CI,df)
else
CI := semean * inversez(CI);
end;
if variance = 0.0 then
begin
cellstring := OS3MainFrm.DataGrid.Cells[k,0];
MessageDlg('No Variability in '+ cellstring + ' variable - ending analysis.', mtInformation, [mbOK], 0);
exit;
end;
if ncases > 3 then // obtain skew, kurtosis and z scores
begin
for i := 1 to NoCases do
begin
if CaseChk.Checked then
begin
if not ValidValue(i,selected[j-1]) then continue;
end else
if not GoodRecord(i,noselected,selected) then continue;
value := StrToFloat(OS3MainFrm.DataGrid.Cells[k,i]);
if stddev > 0.0 then
begin
deviation := value - mean;
devsqr := deviation * deviation;
M2 := M2 + devsqr;
M3 := M3 + (deviation * devsqr);
M4 := M4 + (devsqr * devsqr);
z := (value - mean) / stddev;
if CheckBox1.Checked then
begin
cellstring := format('%8.5f',[z]);
OS3MainFrm.DataGrid.Cells[NoVariables,i] := cellstring;
end;
end;
end;
if ncases > 2 then
begin
skew := (ncases * M3) / ((ncases - 1) * (ncases - 2) * stddev * variance);
cases := ncases;
num := 6.0 * cases * (cases - 1.0);
den := (cases - 2.0) * (cases + 1.0) * (cases + 3.0);
seskew := sqrt(num / den);
end;
if ncases > 3 then
begin
kurtosis := (ncases * (ncases + 1) * M4) - (3 * M2 * M2 * (ncases - 1));
kurtosis := kurtosis / ( (ncases - 1) * (ncases - 2) * (ncases - 3) * (variance * variance) );
sekurtosis := sqrt((4.0 * (ncases * ncases - 1) * (seskew * seskew)) / ((ncases - 3) * (ncases + 5)));
end;
end;
// output results for the kth variable
cellstring := OS3MainFrm.DataGrid.Cells[k,0];
if j > 1 then lReport.Add('');
lReport.Add('VARIABLE: %10s', ['"' + cellString + '"']);
lReport.Add('');
lReport.Add('Number of cases: %10d', [nCases]);
lReport.Add('Sum: %10.3f', [sum]);
lReport.Add('Mean: %10.3f', [mean]);
lReport.Add('Variance: %10.3f', [variance]);
lReport.Add('Std.Dev.: %10.3f', [stddev]);
lReport.Add('Std.Error of Mean %10.3f', [seMean]);
lReport.Add('%.2f%% Conf.Interval Mean: %10.3f to %.3f', [prob*100.0, mean - CI, mean + CI]);
lReport.Add('Range: %10.3f', [range]);
lReport.Add('Minimum: %10.3f', [min]);
lReport.Add('Maximum: %10.3f', [max]);
lReport.Add('Skewness: %10.3f', [skew]);
lReport.Add('Std.Error of Skew: %10.3f', [seSkew]);
lReport.Add('Kurtosis: %10.3f', [kurtosis]);
lReport.Add('Std. Error of Kurtosis: %10.3f', [seKurtosis]);
lReport.Add('');
if ncases > 4 then // get percentiles and quartiles
begin
// get percentile ranks
if pcntileChk.Checked then PRank(k, pcntRank);
// sort values and get quartiles
for i := 0 to ncases - 2 do
begin
for m := i + 1 to ncases -1 do
begin
if values[i] > values[m] then
begin
value := values[i];
values[i] := values[m];
values[m] := value;
end;
end;
end;
Q1 := Quartiles(2,0.25,ncases,values);
Q2 := Quartiles(2,0.5,ncases,values);
Q3 := Quartiles(2,0.75,ncases,values);
IQrange := Q3 - Q1;
lReport.Add('First Quartile: %10.3f', [Q1]);
lReport.Add('Median: %10.3f', [Q2]);
lReport.Add('Third Quartile: %10.3f', [Q3]);
lReport.Add('Interquartile range: %10.3f', [IQrange]);
lReport.Add('');
end;
if (AltQrtilesChk.Checked) then
begin
lReport.Add('Alternative Methods for Obtaining Quartiles');
lReport.Add(' Method 1 2 3 4 5 6 7 8');
lReport.Add('Pcntile');
Q1 := Quartiles(1,0.25,ncases,values);
Q12 := Quartiles(2,0.25,ncases,values);
Q13 := Quartiles(3,0.25,ncases,values);
Q14 := Quartiles(4,0.25,ncases,values);
Q15 := Quartiles(5,0.25,ncases,values);
Q16 := Quartiles(6,0.25,ncases,values);
Q17 := Quartiles(7,0.25,ncases,values);
Q18 := Quartiles(8,0.25,ncases,values);
lReport.Add('Q1 %8.3f%8.3f%8.3f%8.3f%8.3f%8.3f%8.3f%8.3f', [Q1,Q12,Q13,Q14,Q15,Q16,Q17,Q18]);
Q2 := Quartiles(1,0.5,ncases,values);
Q22 := Quartiles(2,0.5,ncases,values);
Q23 := Quartiles(3,0.5,ncases,values);
Q24 := Quartiles(4,0.5,ncases,values);
Q25 := Quartiles(5,0.5,ncases,values);
Q26 := Quartiles(6,0.5,ncases,values);
Q27 := Quartiles(7,0.5,ncases,values);
Q28 := Quartiles(8,0.5,ncases,values);
lReport.Add('Q2 %8.3f%8.3f%8.3f%8.3f%8.3f%8.3f%8.3f%8.3f', [Q2,Q22,Q23,Q24,Q25,Q26,Q27,Q28]);
Q3 := Quartiles(1,0.75,ncases,values);
Q32 := Quartiles(2,0.75,ncases,values);
Q33 := Quartiles(3,0.75,ncases,values);
Q34 := Quartiles(4,0.75,ncases,values);
Q35 := Quartiles(5,0.75,ncases,values);
Q36 := Quartiles(6,0.75,ncases,values);
Q37 := Quartiles(7,0.75,ncases,values);
Q38 := Quartiles(8,0.75,ncases,values);
lReport.Add('Q3 %8.3f%8.3f%8.3f%8.3f%8.3f%8.3f%8.3f%8.3f', [Q3,Q32,Q33,Q34,Q35,Q36,Q37,Q38]);
lReport.Add('NOTES:');
lReport.Add('Method 1 is the weighted average at X[np] where n is no. of cases, p is percentile / 100');
lReport.Add('Method 2 is the weighted average at X[(n+1)p] This is used in this program.');
lReport.Add('Method 3 is the empirical distribution function.');
lReport.Add('Method 4 is called the empirical distribution function - averaging.');
lReport.Add('Method 5 is called the empirical distribution function = Interpolation.');
lReport.Add('Method 6 is the closest observation method.');
lReport.Add('Method 7 is from the TrueBasic Statistics Graphics Toolkit.');
lReport.Add('Method 8 was used in an older Microsoft Excel version.');
lReport.Add('See the internet site http://www.xycoon.com/ for the above.');
lReport.Add('');
end; // end of experimental alternatives
lReport.Add('--------------------------------------------------------------');
end; // next j variable
DisplayReport(lReport);
finally
lReport.Free;
Selected := nil;
Values := nil;
pcntrank := nil;
end;
end;
procedure TDescriptiveFrm.OutBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while i < SelList.Items.Count do
begin
if SelList.Selected[i] then
begin
VarList.Items.Add(SelList.Items[i]);
SelList.Items.Delete(i);
i := 0;
end else
inc(i);
end;
UpdateBtnStates;
end;
procedure TDescriptiveFrm.AllBtnClick(Sender: TObject);
var
i : integer;
begin
for i := 0 to VarList.Items.Count-1 do
SelList.Items.Add(VarList.Items.Strings[i]);
VarList.Clear;
UpdateBtnStates;
end;
procedure TDescriptiveFrm.UpdateBtnStates;
var
lSelected: Boolean;
i: Integer;
begin
lSelected := false;
for i := 0 to VarList.Items.Count-1 do
if VarList.Selected[i] then
begin
lSelected := true;
break;
end;
InBtn.Enabled := lSelected;
lSelected := false;
for i := 0 to SelList.Items.Count-1 do
if SelList.Selected[i] then
begin
lSelected := true;
break;
end;
OutBtn.Enabled := lSelected;
AllBtn.Enabled := VarList.Count > 0;
end;
procedure TDescriptiveFrm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
initialization
{$I descriptiveunit.lrs}
end.

View File

@ -0,0 +1,266 @@
object FreqSpecsFrm: TFreqSpecsFrm
Left = 310
Height = 331
Top = 137
Width = 325
AutoSize = True
BorderStyle = bsSingle
Caption = 'Frequency Specifications'
ClientHeight = 331
ClientWidth = 325
OnActivate = FormActivate
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Label1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = VarName
AnchorSideTop.Side = asrCenter
Left = 8
Height = 15
Top = 84
Width = 44
BorderSpacing.Left = 8
Caption = 'Variable:'
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Minimum
AnchorSideTop.Side = asrCenter
Left = 8
Height = 15
Top = 115
Width = 53
BorderSpacing.Left = 8
Caption = 'Minimum'
ParentColor = False
end
object Label3: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Maximum
AnchorSideTop.Side = asrCenter
Left = 8
Height = 15
Top = 146
Width = 55
BorderSpacing.Left = 8
Caption = 'Maximum'
ParentColor = False
end
object Label4: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Range
AnchorSideTop.Side = asrCenter
Left = 8
Height = 15
Top = 177
Width = 33
BorderSpacing.Left = 8
Caption = 'Range'
ParentColor = False
end
object Label5: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = IntSize
AnchorSideTop.Side = asrCenter
Left = 8
Height = 15
Top = 208
Width = 62
BorderSpacing.Left = 8
Caption = 'Interval Size'
ParentColor = False
end
object Label6: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = NoInts
AnchorSideTop.Side = asrCenter
Left = 8
Height = 15
Top = 239
Width = 105
BorderSpacing.Left = 8
Caption = 'Number of Intervals'
ParentColor = False
end
object VarName: TEdit
AnchorSideLeft.Control = NoInts
AnchorSideTop.Control = Memo1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 137
Height = 23
Top = 80
Width = 180
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 12
BorderSpacing.Right = 8
ReadOnly = True
TabOrder = 0
end
object Minimum: TEdit
AnchorSideLeft.Control = NoInts
AnchorSideTop.Control = VarName
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 137
Height = 23
Top = 111
Width = 180
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
BorderSpacing.Right = 8
ReadOnly = True
TabOrder = 1
end
object Maximum: TEdit
AnchorSideLeft.Control = NoInts
AnchorSideTop.Control = Minimum
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 137
Height = 23
Top = 142
Width = 180
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
BorderSpacing.Right = 8
ReadOnly = True
TabOrder = 2
end
object Range: TEdit
AnchorSideLeft.Control = NoInts
AnchorSideTop.Control = Maximum
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 137
Height = 23
Top = 173
Width = 180
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
BorderSpacing.Right = 8
ReadOnly = True
TabOrder = 3
end
object IntSize: TEdit
AnchorSideLeft.Control = NoInts
AnchorSideTop.Control = Range
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 137
Height = 23
Top = 204
Width = 180
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
BorderSpacing.Right = 8
OnKeyPress = IntSizeKeyPress
TabOrder = 4
end
object NoInts: TEdit
AnchorSideLeft.Control = Label6
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = IntSize
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 137
Height = 23
Top = 235
Width = 180
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 24
BorderSpacing.Top = 8
BorderSpacing.Right = 8
TabOrder = 5
end
object CancelBtn: TButton
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = OKBtn
Left = 201
Height = 25
Top = 274
Width = 62
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Cancel'
ModalResult = 2
TabOrder = 7
end
object OKBtn: TButton
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 275
Height = 25
Top = 274
Width = 42
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'OK'
ModalResult = 1
OnClick = OKBtnClick
TabOrder = 8
end
object HelpBtn: TButton
Tag = 123
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = CancelBtn
Left = 138
Height = 25
Top = 274
Width = 51
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Left = 36
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 6
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = NoInts
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 8
Top = 258
Width = 325
Anchors = [akTop, akLeft, akRight]
Shape = bsBottomLine
end
object Memo1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 8
Height = 60
Top = 8
Width = 309
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 8
Caption = 'The number of intervals must be less than or equal to the number of cases. To change the number of intervals, change the interval size to a larger value. Press the Enter key to make the number of intervals smaller.'
ParentColor = False
WordWrap = True
end
end

View File

@ -0,0 +1,149 @@
unit FreqSpecsUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls,
ContextHelpUnit;
type
{ TFreqSpecsFrm }
TFreqSpecsFrm = class(TForm)
Bevel1: TBevel;
CancelBtn: TButton;
HelpBtn: TButton;
Memo1: TLabel;
OKBtn: TButton;
VarName: TEdit;
Minimum: TEdit;
Maximum: TEdit;
Range: TEdit;
IntSize: TEdit;
NoInts: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
procedure FormActivate(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
procedure IntSizeKeyPress(Sender: TObject; var Key: char);
procedure OKBtnClick(Sender: TObject);
private
{ private declarations }
FAutoSized: Boolean;
FNoCases: Integer;
function Validate(out AMsg: String; out AControl: TWinControl): Boolean;
public
{ public declarations }
property NoCases: Integer read FNoCases write FNoCases;
end;
var
FreqSpecsFrm: TFreqSpecsFrm;
implementation
uses
Math;
{ TFreqSpecsFrm }
procedure TFreqSpecsFrm.IntSizeKeyPress(Sender: TObject; var Key: char);
var
rangeval : double;
increment : double;
begin
if ord(Key) <> 13 then exit;
rangeval := StrToFloat(Range.Text);
increment := StrToFloat(IntSize.Text);
NoInts.Text := FloatToStr(rangeval / increment);
end;
procedure TFreqSpecsFrm.OKBtnClick(Sender: TObject);
var
msg: String;
C: TWinControl;
begin
if not Validate(msg, C) then begin
C.SetFocus;
MessageDlg(msg, mtError, [mbOK], 0);
ModalResult := mrNone;
end;
end;
function TFreqSpecsFrm.Validate(out AMsg: String;
out AControl: TWinControl): Boolean;
var
NoIntervals: Integer;
f: Double;
begin
Result := False;
if IntSize.Text = '' then
begin
AControl := IntSize;
AMsg := 'Interval size is not specified.';
exit;
end;
if not TryStrToFloat(IntSize.Text, f) then
begin
AControl := IntSize;
AMsg := 'No valid number given for interval size.';
exit;
end;
if NoInts.Text = '' then
begin
AControl := NoInts;
AMsg := 'Number of intervals not specified.';
exit;
end;
if not TryStrToInt(NoInts.Text, NoIntervals) then
begin
AControl := NoInts;
AMsg := 'No valid number given for number of intervals.';
exit;
end;
if NoIntervals + 1 > NoCases then begin
AControl := NoInts;
AMsg := Format('Number of intervals cannot be greater than the number of cases (%d).', [NoCases]);
exit;
end;
Result := true;
end;
procedure TFreqSpecsFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([OKBtn.Width, CancelBtn.Width, HelpBtn.Width]);
OKBtn.Constraints.MinWidth := w;
CancelBtn.Constraints.MinWidth := w;
HelpBtn.Constraints.MinWidth := w;
Constraints.MinHeight := Height;
Constraints.MaxHeight := Height;
HelpBtn.BorderSpacing.Left := NoInts.Left;
FAutoSized := true;
end;
procedure TFreqSpecsFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).tag);
end;
initialization
{$I freqspecsunit.lrs}
end.

View File

@ -0,0 +1,283 @@
object FreqFrm: TFreqFrm
Left = 490
Height = 388
Top = 228
Width = 502
Caption = 'Frequency Distribution'
ClientHeight = 388
ClientWidth = 502
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object PlotOptionsGroup: TRadioGroup
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 346
Height = 222
Top = 8
Width = 148
Anchors = [akTop, akRight]
AutoFill = True
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Plot Options'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 202
ClientWidth = 144
ItemIndex = 0
Items.Strings = (
'2D Vertical Bars'
'3D Vertical Bars'
'2D Pie Chart'
'Exploded Pie Chart'
'2D Line Chart'
'3D Line Chart'
'Plot 2D Points'
'Plot 3D Points'
'2D Horizontal Bars'
'3D Horizontal Bars'
)
OnSelectionChanged = PlotOptionsGroupSelectionChanged
TabOrder = 1
end
object BarTypeGroup: TRadioGroup
AnchorSideLeft.Control = PlotOptionsGroup
AnchorSideTop.Control = PlotOptionsGroup
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = PlotOptionsGroup
AnchorSideRight.Side = asrBottom
Left = 346
Height = 70
Top = 242
Width = 148
Anchors = [akTop, akLeft, akRight]
AutoFill = True
AutoSize = True
BorderSpacing.Top = 12
Caption = 'Bar Type'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 50
ClientWidth = 144
Enabled = False
ItemIndex = 0
Items.Strings = (
'Separated'
'Contiguous'
)
TabOrder = 2
end
object NormPltChk: TCheckBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1
Left = 8
Height = 19
Top = 320
Width = 149
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Plot Normal Distribution'
TabOrder = 3
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = PlotOptionsGroup
AnchorSideBottom.Control = NormPltChk
Left = 8
Height = 304
Top = 8
Width = 330
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 8
BevelOuter = bvNone
ClientHeight = 304
ClientWidth = 330
TabOrder = 0
object Label1: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
Left = 0
Height = 15
Top = 0
Width = 97
Caption = 'Available Variables'
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = SelList
AnchorSideTop.Control = Panel1
Left = 196
Height = 15
Top = 0
Width = 104
Caption = 'Variables to Analyze'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = AllBtn
AnchorSideBottom.Control = Panel1
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 287
Top = 17
Width = 134
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Right = 8
ItemHeight = 0
MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object SelList: TListBox
AnchorSideLeft.Control = AllBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Panel1
AnchorSideBottom.Side = asrBottom
Left = 196
Height = 287
Top = 17
Width = 134
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
ItemHeight = 0
OnSelectionChange = SelListSelectionChange
TabOrder = 4
end
object InBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
Left = 151
Height = 28
Top = 23
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = InBtnClick
Spacing = 0
TabOrder = 1
end
object OutBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
Left = 151
Height = 28
Top = 56
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = OutBtnClick
Spacing = 0
TabOrder = 2
end
object AllBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
Left = 142
Height = 25
Top = 136
Width = 46
AutoSize = True
Caption = 'ALL'
OnClick = AllBtnClick
TabOrder = 3
end
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 339
Width = 502
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object ResetBtn: TButton
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 289
Height = 25
Top = 355
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 4
end
object CloseBtn: TButton
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 435
Height = 25
Top = 355
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 1
TabOrder = 5
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 351
Height = 25
Top = 355
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 6
end
end

View File

@ -0,0 +1,443 @@
// Use "cansas.laz" for testing.
unit FreqUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons, ExtCtrls,
Globals, MainUnit, OutputUnit, FunctionsLib, GraphLib, DataProcs;
type
{ TFreqFrm }
TFreqFrm = class(TForm)
Bevel1: TBevel;
ComputeBtn: TButton;
Panel1: TPanel;
ResetBtn: TButton;
CloseBtn: TButton;
NormPltChk: TCheckBox;
InBtn: TBitBtn;
OutBtn: TBitBtn;
AllBtn: TBitBtn;
Label1: TLabel;
Label2: TLabel;
SelList: TListBox;
PlotOptionsGroup: TRadioGroup;
BarTypeGroup: TRadioGroup;
VarList: TListBox;
procedure AllBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure InBtnClick(Sender: TObject);
procedure ComputeBtnClick(Sender: TObject);
procedure PlotOptionsGroupSelectionChanged(Sender: TObject);
procedure SelListSelectionChange(Sender: TObject; User: boolean);
procedure OutBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean);
private
{ private declarations }
FAutoSized: Boolean;
procedure UpdateBtnStates;
public
{ public declarations }
end;
var
FreqFrm: TFreqFrm;
implementation
uses
Math,
FreqSpecsUnit;
{ TFreqFrm }
procedure TFreqFrm.ResetBtnClick(Sender: TObject);
var
i: integer;
begin
VarList.Clear;
SelList.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
BarTypeGroup.ItemIndex := 0;
PlotOptionsGroup.ItemIndex := 0;
NormPltChk.Checked := false;
UpdateBtnStates;
end;
procedure TFreqFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
Panel1.Constraints.MinHeight := BarTypeGroup.Top + BarTypeGroup.Height - Panel1.Top;
Panel1.Constraints.MinWidth := Label2.Width * 2 + AllBtn.Width + 2 * VarList.BorderSpacing.Right;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TFreqFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
if FreqSpecsFrm = nil then
Application.CreateForm(TFreqSpecsFrm, FreqSpecsFrm);
if GraphFrm = nil then
Application.CreateForm(TGraphFrm, GraphFrm);
end;
procedure TFreqFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TFreqFrm.AllBtnClick(Sender: TObject);
var
count, index : integer;
begin
count := VarList.Items.Count;
for index := 0 to count-1 do
SelList.Items.Add(VarList.Items[index]);
VarList.Clear;
UpdateBtnStates;
end;
procedure TFreqFrm.InBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while i < VarList.Items.Count do
begin
if (VarList.Selected[i]) then
begin
SelList.Items.Add(VarList.Items[i]);
VarList.Items.Delete(i);
i := 0;
end else
i := i + 1;
end;
UpdateBtnStates;
end;
procedure TFreqFrm.SelListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
procedure TFreqFrm.ComputeBtnClick(Sender: TObject);
var
i, j, k : integer;
freq : DblDyneVec;
pcnt : DblDyneVec;
cumpcnt : DblDyneVec;
pcntilerank : DblDyneVec;
cumfreq : DblDyneVec;
XValue : DblDyneVec;
value : double;
NoVars : integer;
plottype : integer;
cellval : string;
col : integer;
min, max : double;
range : double;
incrsize : double;
nointervals : double;
nints : integer;
// ColNoSelected : IntDyneVec;
NormDist : boolean;
Histogram : boolean;
Sumx, Sumx2, Mean, Variance, StdDev, zlow, zhi : double;
X, zproplow, zprophi, zfreq : double;
Ncases : integer;
lReport: TStrings;
begin
if BarTypeGroup.ItemIndex = 1 then Histogram := true else Histogram := false;
if NormPltChk.Checked = true then NormDist := true else NormDist := false;
SetLength(freq,NoCases);
SetLength(pcnt,NoCases);
SetLength(cumpcnt,NoCases);
SetLength(pcntilerank,NoCases);
SetLength(cumfreq,NoCases);
SetLength(XValue,NoCases);
lReport := TStringList.Create;
try
lReport.Add('FREQUENCY ANALYSIS BY BILL MILLER');
lReport.Add('');
{ Analyze each variable }
NoVars := SelList.Items.Count;
for i := 1 to NoVars do
begin
{ get column no. of variable }
col := 1;
cellval := SelList.Items.Strings[i-1];
for j := 1 to NoVariables do
begin
if OS3MainFrm.DataGrid.Cells[j,0] = cellval then
begin
col := j;
lReport.Add('Frequency Analysis for Variable "%s"', [cellval]);
break;
end;
end;
{ get min and max values for variable in col }
min := 1.0e32;
max := -1.0e32;
for j := 1 to NoCases do
begin
if not ValidValue(j,col) then continue;
value := StrToFloat(OS3MainFrm.DataGrid.Cells[col,j]);
if value > max then max := value;
if value < min then min := value;
end;
range := max - min + 1.0;
incrsize := 1.0;
{ if too many increments, set increment size for 15 increments }
if range > 200.0 then incrsize := range / 15;
nointervals := range / incrsize;
nints := round(nointervals);
{ Get user's approval and / or changes }
FreqSpecsFrm.VarName.Text := cellval;
FreqSpecsFrm.Minimum.Text := FloatToStr(min);
FreqSpecsFrm.Maximum.Text := FloatToStr(max);
FreqSpecsFrm.range.Text := FloatToStr(range);
FreqSpecsFrm.IntSize.Text := FloatToStr(incrsize);
FreqSpecsFrm.NoInts.Text := IntToStr(nints);
FreqSpecsFrm.NoCases := NoCases;
if FreqSpecsFrm.ShowModal <> mrOK then
exit;
incrsize := StrToFloat(FreqSpecsFrm.IntSize.Text);
nints := StrToInt(FreqSpecsFrm.NoInts.Text);
if nints > 200 then
nints := 200;
{Now, get frequency of cases in each interval }
for j := 1 to nints+1 do
freq[j-1] := 0;
Ncases := 0;
for j := 1 to NoCases do
begin
if not ValidValue(j,col) then continue;
inc(Ncases);
value := StrToFloat(OS3MainFrm.DataGrid.Cells[col,j]);
for k := 1 to nints do
begin
if (value >= min + ((k-1) * incrsize)) and
(value < min + (k * incrsize)) then freq[k-1] := freq[k-1] + 1;
end;
end;
for j := 1 to nints+1 do
XValue[j-1] := min + (j-1) * incrsize;
{ get cumulative frequencies and percents to midpoints }
cumfreq[0] := freq[0];
pcnt[0] := freq[0] / Ncases;
cumpcnt[0] := cumfreq[0] / Ncases;
pcntilerank[0] := (freq[0] / 2.0) / Ncases;
for k := 2 to nints do
begin
cumfreq[k-1] := cumfreq[k-2] + freq[k-1];
pcnt[k-1] := freq[k-1] / Ncases;
cumpcnt[k-1] := cumfreq[k-1] / Ncases;
pcntilerank[k-1] := (cumfreq[k-2] + freq[k-1] / 2.0) / Ncases;
end;
{ Now, print results to report }
lReport.Add(' FROM TO FREQ. PCNT CUM.FREQ. CUM.PCNT. %ILE RANK');
lReport.Add('');
for k := 1 to nints do
lReport.Add('%8.2f%8.2f%8.0f%8.2f %8.2f %8.2f %8.2f', [
min+(k-1)*incrsize, // from
min+k*incrsize, // to
freq[k-1], // freq
pcnt[k-1], // pcnt
cumfreq[k-1], // cum.freq.
cumpcnt[k-1], // cum.pcnt.
pcntilerank[k-1] // %ile rank
]);
{ Now, prepare plot values as indicated in options list }
if NormDist = false then
SetLength(GraphFrm.Ypoints,1,nints+1)
else
SetLength(GraphFrm.Ypoints,2,nints+1);
SetLength(GraphFrm.Xpoints,1,nints+1);
for k := 1 to nints+1 do
begin
GraphFrm.Ypoints[0,k-1] := freq[k-1];
GraphFrm.Xpoints[0,k-1] := XValue[k-1];
end;
// Create ND plot if checked.
// BUT: Only 3D-vertical plots when normal curve is desired
if NormDist then
begin
lReport.Add('');
lReport.Add('Interval ND Freq.');
// Only use 3Dvertical plots when normal curve desired
PlotOptionsGroup.ItemIndex := 1;
// get mean and standard deviation of xvalues, then height of
// the normal curve for each Normally distributed corresponding z score
sumx := 0.0;
sumx2 := 0.0;
for k := 1 to nints do
begin
sumx := sumx + (XValue[k-1] * freq[k-1]);
sumx2 := sumx2 + ((XValue[k-1] * XValue[k-1]) * freq[k-1]);
end;
Mean := sumx / Ncases;
Variance := sumx2 - ((sumx * sumx) / Ncases);
Variance := Variance / (Ncases - 1);
StdDev := sqrt(Variance);
for k := 1 to nints+1 do
begin
X := XValue[k-1] - (incrsize / 2.0);
if StdDev > 0.0 then
zlow := (X - Mean) / StdDev
else
zlow := 0.0;
X := XValue[k-1] + (incrsize / 2.0);
if StdDev > 0.0 then
zhi := (X - Mean) / StdDev
else
zhi := 0.0;
// get cum. prop. for this z and translate to frequency
zproplow := probz(zlow);
zprophi := probz(zhi);
zfreq := NoCases * abs(zprophi - zproplow);
GraphFrm.Ypoints[1,k-1] := zfreq;
lReport.Add(' %2d %6.2f', [k, GraphFrm.Ypoints[1,k-1]]);
end;
end;
// Show report in form
DisplayReport(lReport);
// Plot data
plottype := PlotOptionsGroup.ItemIndex + 1;
if Histogram then
GraphFrm.barwideprop := 1.0
else
GraphFrm.barwideprop := 0.5;
if NormDist then
GraphFrm.nosets := 2
else
GraphFrm.nosets := 1;
GraphFrm.nbars := nints+1;
GraphFrm.Heading := cellval;
GraphFrm.XTitle := 'Lower Limit Values';
GraphFrm.YTitle := 'Frequency';
GraphFrm.AutoScaled := true;
GraphFrm.GraphType := plotType;
GraphFrm.BackColor := clCream;
GraphFrm.WallColor := clDkGray;
GraphFrm.FloorColor := clLtGray;
GraphFrm.ShowBackWall := true;
if plotType in [2, 6, 8, 10] then
begin
GraphFrm.ShowLeftWall := true;
GraphFrm.ShowRightWall := true;
GraphFrm.ShowBottomWall := true;
end;
GraphFrm.ShowModal;
GraphFrm.Xpoints := nil;
GraphFrm.Ypoints := nil;
end; // for novars list
finally
lReport.Free;
XValue := nil;
cumfreq := nil;
pcntilerank := nil;
cumpcnt := nil;
pcnt := nil;
freq := nil;
end;
end;
procedure TFreqFrm.OutBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while i < SelList.Items.Count do
begin
if (SelList.Selected[i]) then
begin
VarList.Items.Add(SelList.Items[i]);
SelList.Items.Delete(i);
i := 0;
end else
i := i + 1;
end;
UpdateBtnStates;
end;
procedure TFreqFrm.PlotOptionsGroupSelectionChanged(Sender: TObject);
begin
BarTypeGroup.Enabled := PlotOptionsGroup.ItemIndex in [0, 1, 8, 9]; // Bar series only
end;
procedure TFreqFrm.UpdateBtnStates;
var
lSelected: Boolean;
i: Integer;
begin
lSelected := false;
for i := 0 to VarList.Items.Count-1 do
if VarList.Selected[i] then
begin
lSelected := true;
Break;
end;
InBtn.Enabled := lSelected;
lSelected := false;
for i := 0 to SelList.Items.Count-1 do
if SelList.Selected[i] then
begin
lSelected := true;
break;
end;
OutBtn.Enabled := lSelected;
AllBtn.Enabled := VarList.Items.Count > 0;
end;
procedure TFreqFrm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
initialization
{$I frequnit.lrs}
end.

View File

@ -0,0 +1,219 @@
object GroupFreqForm: TGroupFreqForm
Left = 513
Height = 341
Top = 233
Width = 444
AutoSize = True
Caption = 'Group Frequency Analysis'
ClientHeight = 341
ClientWidth = 444
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = ResetBtnClick
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Label1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Memo1
AnchorSideTop.Side = asrBottom
Left = 8
Height = 15
Top = 84
Width = 100
BorderSpacing.Left = 8
BorderSpacing.Top = 16
Caption = 'Available Variables:'
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = GrpInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = GrpVarEdit
Left = 237
Height = 15
Top = 109
Width = 77
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 12
BorderSpacing.Bottom = 2
Caption = 'Group Variable'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = GrpInBtn
AnchorSideBottom.Control = Bevel1
Left = 8
Height = 191
Top = 101
Width = 181
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
ItemHeight = 0
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object GrpInBtn: TBitBtn
AnchorSideLeft.Control = PlotOptionsBox
AnchorSideTop.Control = VarList
Left = 197
Height = 28
Top = 101
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = GrpInBtnClick
Spacing = 0
TabOrder = 1
end
object GrpOutBtn: TBitBtn
AnchorSideLeft.Control = GrpInBtn
AnchorSideTop.Control = GrpInBtn
AnchorSideTop.Side = asrBottom
Left = 197
Height = 28
Top = 133
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = GrpOutBtnClick
Spacing = 0
TabOrder = 2
end
object GrpVarEdit: TEdit
AnchorSideLeft.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = GrpOutBtn
AnchorSideBottom.Side = asrBottom
Left = 237
Height = 23
Top = 126
Width = 199
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Right = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 3
Text = 'GrpVarEdit'
end
object ResetBtn: TButton
AnchorSideTop.Control = CloseBtn
AnchorSideRight.Control = ComputeBtn
Left = 235
Height = 25
Top = 308
Width = 54
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 5
end
object ComputeBtn: TButton
AnchorSideTop.Control = CloseBtn
AnchorSideRight.Control = CloseBtn
Left = 297
Height = 25
Top = 308
Width = 76
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 6
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 381
Height = 25
Top = 308
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 7
end
object PlotOptionsBox: TRadioGroup
AnchorSideLeft.Control = GrpInBtn
AnchorSideTop.Control = GrpOutBtn
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 197
Height = 114
Top = 177
Width = 239
Anchors = [akTop, akRight]
AutoFill = True
AutoSize = True
BorderSpacing.Top = 16
BorderSpacing.Right = 8
Caption = 'Plot Options:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 94
ClientWidth = 235
Items.Strings = (
'Plot means using 2D Horizontal Bars'
'Plot means using 3D Horizontal Bars'
'Plot means using 2D Vertical Bars'
'Plot means using 3D Vertical Bars'
)
TabOrder = 4
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 292
Width = 444
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object Memo1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 8
Height = 60
Top = 8
Width = 428
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'This procedure plots the frequency of cases in each of the groups in a group variable. The group variable should be defined as an integer variable.'#13#10#13#10'Select the variable and type of plot and click the Compute button for the results.'
ParentColor = False
WordWrap = True
end
end

View File

@ -0,0 +1,235 @@
unit GroupFreqUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons, ExtCtrls,
MainUnit, GraphLib, Globals, DataProcs;
type
{ TGroupFreqForm }
TGroupFreqForm = class(TForm)
Bevel1: TBevel;
GrpInBtn: TBitBtn;
GrpOutBtn: TBitBtn;
ComputeBtn: TButton;
GrpVarEdit: TEdit;
Label1: TLabel;
Label2: TLabel;
Memo1: TLabel;
PlotOptionsBox: TRadioGroup;
ResetBtn: TButton;
CloseBtn: TButton;
VarList: TListBox;
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure GrpInBtnClick(Sender: TObject);
procedure GrpOutBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean);
private
{ private declarations }
FAutoSized: Boolean;
procedure UpdateBtnStates;
public
{ public declarations }
end;
var
GroupFreqForm: TGroupFreqForm;
implementation
uses
Math;
{ TGroupFreqForm }
procedure TGroupFreqForm.ResetBtnClick(Sender: TObject);
var
i: integer;
begin
VarList.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
GrpVarEdit.Text := '';
UpdateBtnStates;
end;
procedure TGroupFreqForm.GrpInBtnClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (GrpVarEdit.Text = '') then
begin
GrpVarEdit.Text := VarList.Items[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TGroupFreqForm.ComputeBtnClick(Sender: TObject);
VAR
nogroups, mingrp, maxgrp, grpcol, value, minfreq, maxfreq: integer;
labelstr: string;
i: integer;
strvalue: string;
freq: IntDyneVec;
plottype: integer;
begin
// get the variable to analyze
grpcol := 0;
for i := 1 to NoVariables do
begin
strvalue := OS3MainFrm.DataGrid.Cells[i,0];
if GrpVarEdit.Text = strvalue then
begin
grpcol := i;
break;
end;
end;
if grpcol = 0 then
begin
MessageDlg('No variable selected.', mtError, [mbOK], 0);
exit;
end;
labelstr := GrpVarEdit.Text;
mingrp := 1000;
maxgrp := -1000;
for i := 1 to NoCases do
begin
if not ValidValue(i,grpcol) then continue;
value := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[grpcol,i])));
if value < mingrp then mingrp := value;
if value > maxgrp then maxgrp := value;
end;
nogroups := maxgrp - mingrp + 1;
if nogroups < 2 then
begin
MessageDlg('One or fewer groups found.', mtError, [mbOK], 0);
exit;
end;
// setup frequency array and count cases in each group
SetLength(freq,NoGroups+1);
for i := 0 to NoGroups do
freq[i] := 0;
for i := 1 to NoCases do
begin
if not ValidValue(i,grpcol) then continue;
value := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[grpcol,i])));
value := value - mingrp;
freq[value] := freq[value] + 1;
end;
// get min and max frequencies and check for existence of a range
minfreq := 10000;
maxfreq := -10000;
for i := 0 to NoGroups-1 do
begin
if freq[i] < minfreq then minfreq := freq[i];
if freq[i] > maxfreq then maxfreq := freq[i];
end;
if minfreq = maxfreq then
begin
MessageDlg('All groups have equal frequencies. Cannot plot.', mtInformation, [mbOK], 0);
freq := nil;
exit;
end;
case PlotOptionsBox.ItemIndex of
0: plottype := 9;
1: plottype := 10;
2: plottype := 1;
3: plottype := 2;
end;
// plot the frequencies
SetLength(GraphFrm.Xpoints,1,nogroups+1);
SetLength(GraphFrm.Ypoints,1,nogroups+1);
GraphFrm.nosets := 1;
GraphFrm.nbars := nogroups;
GraphFrm.Heading := 'Frequency Distribution';
GraphFrm.XTitle := 'Values of ' + labelstr;
GraphFrm.YTitle := 'Frequency';
GraphFrm.barwideprop := 0.5;
GraphFrm.AutoScaled := false;
GraphFrm.miny := 0.0;
GraphFrm.maxy := maxfreq;
GraphFrm.GraphType := plottype;
GraphFrm.BackColor := clCream; // clYellow;
GraphFrm.WallColor := clDkGray; //Black;
GraphFrm.FloorColor := clLtGray;
GraphFrm.ShowBackWall := true;
for i := 0 to nogroups do
begin
GraphFrm.Ypoints[0,i] := freq[i];
GraphFrm.Xpoints[0,i] := mingrp + i;
end;
GraphFrm.ShowModal;
GraphFrm.Xpoints := nil;
GraphFrm.Ypoints := nil;
end;
procedure TGroupFreqForm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
VarList.Constraints.MinHeight := PlotOptionsBox.Top + PlotOptionsBox.Height - VarList.Top;
Varlist.Constraints.MinWidth := Label1.Width * 3 div 2;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TGroupFreqForm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
if GraphFrm = nil then Application.CreateForm(TGraphFrm, GraphFrm);
end;
procedure TGroupFreqForm.GrpOutBtnClick(Sender: TObject);
begin
if GrpVarEdit.Text <> '' then
begin
VarList.Items.Add(GrpVarEdit.Text);
GrpVarEdit.Text := '';
end;
UpdateBtnStates;
end;
procedure TGroupFreqForm.UpdateBtnStates;
begin
GrpInBtn.Enabled := VarList.ItemIndex > -1;
GrpOutBtn.Enabled := (GrpVarEdit.Text <> '');
end;
procedure TGroupFreqForm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
initialization
{$I groupfrequnit.lrs}
end.

View File

@ -0,0 +1,421 @@
object MultXvsYFrm: TMultXvsYFrm
Left = 814
Height = 416
Top = 216
Width = 395
Anchors = [akLeft]
AutoSize = True
Caption = 'Multiple X Versus Y Plot'
ClientHeight = 416
ClientWidth = 395
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Bevel1: TBevel
AnchorSideTop.Control = LabelEdit
Left = 0
Height = 8
Top = 367
Width = 395
Align = alBottom
Shape = bsBottomLine
end
object Panel2: TPanel
Left = 8
Height = 328
Top = 8
Width = 379
Align = alClient
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BevelOuter = bvNone
ClientHeight = 328
ClientWidth = 379
TabOrder = 0
object Label1: TLabel
AnchorSideLeft.Control = Panel2
AnchorSideTop.Control = Panel2
Left = 0
Height = 15
Top = 0
Width = 100
Caption = 'Available Variables:'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Panel2
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideBottom.Control = Panel2
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 311
Top = 17
Width = 190
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Right = 8
ItemHeight = 0
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object Panel1: TPanel
AnchorSideTop.Control = VarList
AnchorSideRight.Control = Panel2
AnchorSideRight.Side = asrBottom
Left = 198
Height = 310
Top = 17
Width = 181
Anchors = [akTop, akRight]
AutoSize = True
BevelOuter = bvNone
ClientHeight = 310
ClientWidth = 181
TabOrder = 1
object Label2: TLabel
AnchorSideLeft.Control = XEdit
AnchorSideBottom.Control = XEdit
Left = 36
Height = 15
Top = 8
Width = 51
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'X Variable'
ParentColor = False
end
object Label3: TLabel
AnchorSideLeft.Control = YEdit
AnchorSideBottom.Control = YEdit
Left = 36
Height = 15
Top = 92
Width = 51
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Y Variable'
ParentColor = False
end
object Label4: TLabel
AnchorSideLeft.Control = GroupEdit
AnchorSideBottom.Control = GroupEdit
Left = 36
Height = 15
Top = 176
Width = 77
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Group Variable'
ParentColor = False
end
object XInBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
Left = 0
Height = 28
Top = 0
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = XInBtnClick
Spacing = 0
TabOrder = 0
end
object XOutBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = XInBtn
AnchorSideTop.Side = asrBottom
Left = 0
Height = 28
Top = 32
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = XOutBtnClick
Spacing = 0
TabOrder = 1
end
object YInBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = XOutBtn
AnchorSideTop.Side = asrBottom
Left = 0
Height = 28
Top = 84
Width = 28
BorderSpacing.Top = 24
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = YInBtnClick
Spacing = 0
TabOrder = 3
end
object YOutBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = YInBtn
AnchorSideTop.Side = asrBottom
Left = 0
Height = 28
Top = 116
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = YOutBtnClick
Spacing = 0
TabOrder = 4
end
object GroupInBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = YOutBtn
AnchorSideTop.Side = asrBottom
Left = 0
Height = 28
Top = 168
Width = 28
BorderSpacing.Top = 24
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = GroupInBtnClick
Spacing = 0
TabOrder = 6
end
object GroupOutBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = GroupInBtn
AnchorSideTop.Side = asrBottom
Left = 0
Height = 28
Top = 200
Width = 28
BorderSpacing.Top = 4
BorderSpacing.Bottom = 8
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = GroupOutBtnClick
Spacing = 0
TabOrder = 7
end
object XEdit: TEdit
AnchorSideLeft.Control = XInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = XOutBtn
AnchorSideBottom.Side = asrBottom
Left = 36
Height = 23
Top = 25
Width = 145
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 2
Text = 'XEdit'
end
object YEdit: TEdit
AnchorSideLeft.Control = XInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = YOutBtn
AnchorSideBottom.Side = asrBottom
Left = 36
Height = 23
Top = 109
Width = 145
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 5
Text = 'YEdit'
end
object GroupEdit: TEdit
AnchorSideLeft.Control = XInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = GroupOutBtn
AnchorSideBottom.Side = asrBottom
Left = 36
Height = 23
Top = 193
Width = 145
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 8
Text = 'GroupEdit'
end
object GroupBox1: TGroupBox
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = GroupOutBtn
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 0
Height = 70
Top = 240
Width = 181
AutoSize = True
BorderSpacing.Top = 12
Caption = 'Options:'
ClientHeight = 50
ClientWidth = 177
TabOrder = 9
object DescChk: TCheckBox
AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = GroupBox1
Left = 12
Height = 19
Top = 2
Width = 159
BorderSpacing.Left = 12
BorderSpacing.Top = 2
BorderSpacing.Bottom = 2
Caption = 'Show Descriptive Statistics'
TabOrder = 0
end
object LinesChk: TCheckBox
AnchorSideLeft.Control = DescChk
AnchorSideTop.Control = DescChk
AnchorSideTop.Side = asrBottom
Left = 12
Height = 19
Top = 23
Width = 157
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Connect Points with Lines'
TabOrder = 1
end
end
end
end
object Panel3: TPanel
Left = 0
Height = 41
Top = 375
Width = 395
Align = alBottom
AutoSize = True
BevelOuter = bvNone
ClientHeight = 41
ClientWidth = 395
TabOrder = 2
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Side = asrBottom
Left = 178
Height = 25
Top = 8
Width = 54
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 1
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Side = asrBottom
Left = 244
Height = 25
Top = 8
Width = 76
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 2
end
object CloseBtn: TButton
AnchorSideRight.Control = Panel3
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 332
Height = 25
Top = 8
Width = 55
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 3
end
object HelpBtn: TButton
Tag = 134
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Side = asrBottom
Left = 115
Height = 25
Top = 8
Width = 51
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 0
end
end
object Panel4: TPanel
Left = 8
Height = 23
Top = 344
Width = 379
Align = alBottom
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BevelOuter = bvNone
ClientHeight = 23
ClientWidth = 379
TabOrder = 1
object Label5: TLabel
AnchorSideLeft.Control = Panel4
AnchorSideTop.Control = LabelEdit
AnchorSideTop.Side = asrCenter
Left = 0
Height = 15
Top = 4
Width = 46
Caption = 'Plot Title'
ParentColor = False
end
object LabelEdit: TEdit
AnchorSideLeft.Control = Label5
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel4
AnchorSideRight.Control = Panel4
AnchorSideRight.Side = asrBottom
Left = 54
Height = 23
Top = 0
Width = 325
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
TabOrder = 0
TextHint = 'Text above the plot'
end
end
end

View File

@ -0,0 +1,509 @@
// Use file "BubblePlot2.laz" for testing
unit MultXvsYUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, Buttons, Clipbrd,
MainUnit, Globals, OutputUnit, DataProcs, DictionaryUnit, ContextHelpUnit;
type
{ TMultXvsYFrm }
TMultXvsYFrm = class(TForm)
Bevel1: TBevel;
HelpBtn: TButton;
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
Panel4: TPanel;
XInBtn: TBitBtn;
XOutBtn: TBitBtn;
YInBtn: TBitBtn;
YOutBtn: TBitBtn;
GroupInBtn: TBitBtn;
GroupOutBtn: TBitBtn;
ResetBtn: TButton;
ComputeBtn: TButton;
CloseBtn: TButton;
DescChk: TCheckBox;
LinesChk: TCheckBox;
XEdit: TEdit;
YEdit: TEdit;
GroupEdit: TEdit;
GroupBox1: TGroupBox;
LabelEdit: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
VarList: TListBox;
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure GroupInBtnClick(Sender: TObject);
procedure GroupOutBtnClick(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean);
procedure XInBtnClick(Sender: TObject);
procedure XOutBtnClick(Sender: TObject);
procedure YInBtnClick(Sender: TObject);
procedure YOutBtnClick(Sender: TObject);
private
{ private declarations }
FAutoSized: Boolean;
procedure PlotXY(var XValues: DblDyneMat; YValues: DblDyneMat;
MaxX, MinX, MaxY, MinY: double; N, NoY, MinGrp: integer);
procedure UpdateBtnStates;
public
{ public declarations }
end;
var
MultXvsYFrm: TMultXvsYFrm;
implementation
uses
Math,
BlankFrmUnit;
{ TMultXvsYFrm }
procedure TMultXvsYFrm.ResetBtnClick(Sender: TObject);
VAR i : integer;
begin
VarList.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
XEdit.Text := '';
YEdit.Text := '';
GroupEdit.Text := '';
DescChk.Checked := false;
LinesChk.Checked := false;
XInBtn.Enabled := true;
YInBtn.Enabled := true;
GroupInBtn.Enabled := true;
XOutBtn.Enabled := false;
YOutBtn.Enabled := false;
GroupOutBtn.Enabled := false;
end;
procedure TMultXvsYFrm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
procedure TMultXvsYFrm.GroupInBtnClick(Sender: TObject);
var
i: integer;
begin
i := VarList.ItemIndex;
if (i > -1) and (GroupEdit.Text = '') then
begin
GroupEdit.Text := VarList.Items[i];
VarList.Items.Delete(i);
end;
UpdateBtnStates;
end;
procedure TMultXvsYFrm.ComputeBtnClick(Sender: TObject);
var
i, j, k, N, NoGrps, XCol, YCol, GrpCol, Grp, MinGrp, MaxGrp: integer;
NoSelected, MaxGrpSize: integer;
selected, NoInGrp: IntDyneVec;
YValues, XValues: DblDyneMat;
Means, StdDevs: DblDyneVec;
MinX, MaxX, MinY, MaxY, X, Y, temp: double;
cellstring: string;
lReport: TStrings;
begin
MaxGrpSize := 0;
SetLength(selected, 3);
MaxX := -1.0e308;
MinX := 1.0e308;
MaxY := -1.0e308;
MinY := 1.0e308;
MinGrp := MaxInt;
MaxGrp := -MaxInt;
XCol := 0;
YCol := 0;
GrpCol := 0;
N := 0;
// Get selected variables
for i := 1 to NoVariables do
begin
cellstring := OS3MainFrm.DataGrid.Cells[i,0];
if (cellstring = XEdit.Text) then selected[0] := i;
if (cellstring = YEdit.Text) then selected[1] := i;
if (cellstring = GroupEdit.Text) then selected[2] := i;
end;
XCol := selected[0];
YCol := selected[1];
GrpCol := selected[2];
NoSelected := 3;
if (XCol = 0) or (YCol = 0) or (GrpCol = 0) then
begin
MessageDlg('No variable selected.', mtError, [mbOK], 0);
exit;
end;
// Get number of groups
for i := 1 to NoCases do
begin
Grp := StrToInt(OS3MainFrm.DataGrid.Cells[GrpCol,i]);
if (Grp > MaxGrp) then MaxGrp := Grp;
if (Grp < MinGrp) then MinGrp := Grp;
end;
NoGrps := (MaxGrp - MinGrp) + 1;
lReport := TStringList.Create;
try
lReport.Add('X VERSUS Y FOR GROUPS PLOT');
lReport.Add('');
SetLength(YValues, NoCases+1, NoGrps+1);
SetLength(XValues, NoCases+1, NoGrps+1);
SetLength(Means, 2);
SetLength(StdDevs, 2);
SetLength(NoInGrp, NoGrps);
for i := 0 to 1 do
begin
Means[i] := 0.0;
StdDevs[i] := 0.0;
end;
for i := 0 to NoGrps - 1 do
NoInGrp[i] := 0;
for i := 1 to NoCases do
begin
if (not GoodRecord(i,NoSelected,selected))then continue;
inc(N);
X := StrToFloat(OS3MainFrm.DataGrid.Cells[XCol,i]);
if (X > MaxX) then MaxX := X;
if (X < MinX) then MinX := X;
Y := StrToFloat(OS3MainFrm.DataGrid.Cells[YCol,i]);
if (Y > MaxY) then MaxY := Y;
if (Y < MinY) then MinY := Y;
Grp := StrToInt(OS3MainFrm.DataGrid.Cells[GrpCol,i]);
Grp := Grp - MinGrp;
NoInGrp[Grp] := NoInGrp[Grp] + 1;
if (NoInGrp[Grp] > MaxGrpSize) then MaxGrpSize := NoInGrp[Grp];
YValues[NoInGrp[Grp]-1,Grp] := Y;
XValues[NoInGrp[Grp]-1,Grp] := StrToFloat(OS3MainFrm.DataGrid.Cells[XCol,i]);
end;
// get descriptive data
if (DescChk.Checked) then
begin
for i := 1 to NoCases do
begin
if (not GoodRecord(i,NoSelected,selected)) then continue;
Y := StrToFloat(OS3MainFrm.DataGrid.Cells[YCol,i]);
X := StrToFloat(OS3MainFrm.DataGrid.Cells[XCol,i]);
Means[0] := Means[0] + X;
StdDevs[0] := StdDevs[0] + X * X;
Means[1] := Means[1] + Y;
StdDevs[1] := StdDevs[1] + Y * Y;
end;
for i := 0 to 1 do
begin
StdDevs[i] := StdDevs[i] - (Means[i] * Means[i]) / N;
StdDevs[i] := sqrt(StdDevs[i] / (N - 1));
Means[i] := Means[i] / N;
end;
lReport.Add('VARIABLE MEAN STANDARD DEVIATION');
lReport.Add(' X %9.3f %14.3f', [Means[0], StdDevs[0]]);
lReport.Add(' Y %9.3f %14.3f', [Means[1], StdDevs[1]]);
lReport.Add('');
DisplayReport(lReport);
end;
// sort on X
for i := 0 to NoGrps - 1 do
begin
for j := 0 to MaxGrpSize-2 do
begin
for k := j+1 to MaxGrpSize - 1 do
begin
if (XValues[j,i] > XValues[k,i]) then // swap
begin
temp := XValues[j,i];
XValues[j,i] := XValues[k,i];
XValues[k,i] := temp;
temp := YValues[j,i];
YValues[j,i] := YValues[k,i];
YValues[k,i] := temp;
end;
end;
end;
end;
BlankFrm.Image1.Canvas.Clear;
BlankFrm.Show;
PlotXY(XValues, YValues, MaxX, MinX, MaxY, MinY, MaxGrpSize, NoGrps, MinGrp);
finally
lReport.Free;
NoInGrp := nil;
StdDevs := nil;
Means := nil;
XValues := nil;
YValues := nil;
end;
end;
procedure TMultXvsYFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
HelpBtn.Constraints.MinWidth := w;
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TMultXvsYFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
if DictionaryFrm = nil then Application.CreateForm(TDictionaryFrm, DictionaryFrm);
if BlankFrm = nil then Application.CreateForm(TBlankFrm, BlankFrm);
end;
procedure TMultXvsYFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TMultXvsYFrm.GroupOutBtnClick(Sender: TObject);
begin
if GroupEdit.Text <> '' then
begin
VarList.Items.Add(GroupEdit.Text);
GroupEdit.Text := '';
end;
UpdateBtnStates;
end;
procedure TMultXvsYFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).Tag);
end;
procedure TMultXvsYFrm.XInBtnClick(Sender: TObject);
var
i: integer;
begin
i := VarList.ItemIndex;
if (i > -1) and (XEdit.Text = '') then
begin
XEdit.Text := VarList.Items[i];
VarList.Items.Delete(i);
end;
UpdateBtnStates;
end;
procedure TMultXvsYFrm.XOutBtnClick(Sender: TObject);
begin
if XEdit.Text <> '' then
begin
VarList.Items.Add(XEdit.Text);
XEdit.Text := '';
end;
UpdateBtnStates;
end;
procedure TMultXvsYFrm.YInBtnClick(Sender: TObject);
var
i: integer;
begin
i := VarList.ItemIndex;
if (i > -1) and (YEdit.Text = '') then
begin
YEdit.Text := VarList.Items[i];
VarList.Items.Delete(i);
end;
UpdateBtnStates;
end;
procedure TMultXvsYFrm.YOutBtnClick(Sender: TObject);
begin
if YEdit.Text <> '' then
begin
VarList.Items.Add(YEdit.Text);
YEdit.Text := '';
end;
UpdateBtnStates;
end;
// routine to plot X versus multiple Y values
procedure TMultXvsYFrm.plotxy(var XValues: DblDyneMat; YValues: DblDyneMat;
MaxX, MinX, MaxY, MinY: double; N, NoY, MinGrp: integer);
var
xpos, ypos, hleft, hright, vtop, vbottom, imagewide : integer;
vhi, hwide, offset, strhi, imagehi, i, j, Grp : integer;
valincr, Yvalue, Xvalue, value : double;
Title: string;
begin
Title := LabelEdit.Text;
BlankFrm.Caption := Title;
BlankFrm.Show;
imagewide := BlankFrm.Image1.Width;
imagehi := BlankFrm.Image1.Height;
vtop := 40;
vbottom := ceil(imagehi) - 60;
vhi := vbottom - vtop;
hleft := 100;
hright := imagewide - 80;
hwide := hright - hleft;
// Draw chart border and background
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
BlankFrm.Image1.Canvas.Brush.Color := clWhite;
BlankFrm.Image1.Canvas.Rectangle(0, 0, imagewide, imagehi);
// Draw title
if Title <> '' then
begin
xpos := (imagewide - BlankFrm.Image1.Canvas.TextWidth(Title)) div 2;
yPos := 2;
BlankFrm.Image1.Canvas.TextOut(xpos, ypos, Title);
end;
// draw horizontal axis
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
BlankFrm.Image1.Canvas.MoveTo(hleft, vbottom);
BlankFrm.Image1.Canvas.LineTo(hright, vbottom);
valincr := (MaxX - MinX) / 10.0;
for i := 1 to 11 do
begin
ypos := vbottom;
Xvalue := MinX + valincr * (i - 1);
xpos := hLeft + ceil(hwide * ((Xvalue - MinX) / (MaxX - MinX)));
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
ypos := ypos + 10;
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
Title := Format('%.2f', [Xvalue]);
offset := BlankFrm.Image1.Canvas.TextWidth(Title) div 2;
xpos := xpos - offset;
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
BlankFrm.Image1.Canvas.TextOut(xpos, ypos, Title);
end;
xpos := hleft + (hwide - BlankFrm.Image1.Canvas.TextWidth(XEdit.Text)) div 2;
ypos := vbottom + 30;
BlankFrm.Image1.Canvas.TextOut(xpos, ypos, XEdit.Text);
// Draw vertical axis
Title := 'Y VALUES';
xpos := hleft - BlankFrm.Image1.Canvas.TextWidth(Title) div 2;
ypos := 8;
BlankFrm.Image1.Canvas.TextOut(xpos, ypos, Title);
xpos := hleft;
ypos := vtop;
BlankFrm.Image1.Canvas.MoveTo(xpos, ypos);
ypos := vbottom;
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
valincr := (MaxY - MinY) / 10.0;
for i := 1 to 11 do
begin
value := MaxY - ((i-1) * valincr);
Title := Format('%.2f',[value]);
strhi := BlankFrm.Image1.Canvas.TextHeight(Title);
xpos := hleft - 20 - BlankFrm.Image1.Canvas.TextWidth(Title);
Yvalue := MaxY - (valincr * (i-1));
ypos := ceil(vhi * ( (MaxY - Yvalue) / (MaxY - MinY)));
ypos := ypos + vtop - strhi div 2;
BlankFrm.Image1.Canvas.TextOut(xpos, ypos, Title);
xpos := hleft;
ypos := ypos + strhi div 2;
BlankFrm.Image1.Canvas.MoveTo(xpos, ypos);
xpos := hleft - 10;
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
end;
// draw points for x and y pairs
for j := 0 to NoY - 1 do
begin
BlankFrm.Image1.Canvas.Brush.Style := bsSolid;
BlankFrm.Image1.Canvas.Brush.Color := DATA_COLORS[j mod Length(DATA_COLORS)];
BlankFrm.Image1.Canvas.Pen.Color := DATA_COLORS[j mod Length(DATA_COLORS)];
BlankFrm.Image1.Canvas.Font.Color := DATA_COLORS[j mod Length(DATA_COLORS)];
Grp := MinGrp + j;
Title := 'GROUP ' + IntToStr(Grp);
for i := 1 to N do
begin
ypos := vtop + ceil(vhi * ( (MaxY - YValues[i-1,j]) / (MaxY - MinY)));
xpos := hleft + ceil(hwide * ( (XValues[i-1,j] - MinX) / (MaxX - MinX)));
if (i = 1) then
BlankFrm.Image1.Canvas.MoveTo(xpos, ypos);
if LinesChk.Checked then
BlankFrm.Image1.Canvas.LineTo(xpos, ypos);
BlankFrm.Image1.Canvas.Ellipse(xpos, ypos, xpos+5, ypos+5);
end;
strhi := BlankFrm.Image1.Canvas.TextHeight(Title);
BlankFrm.Image1.Canvas.Brush.Color := clWhite;
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
xpos := hwide + hleft;
BlankFrm.Image1.Canvas.MoveTo(xpos, ypos-strhi);
BlankFrm.Image1.Canvas.TextOut(xpos, ypos, Title);
end;
BlankFrm.Image1.Canvas.Font.Color := clBlack;
end;
procedure TMultXvsYFrm.UpdateBtnStates;
var
lSelected: Boolean;
i: Integer;
begin
lSelected := false;
for i:=0 to VarList.Items.Count-1 do
if VarList.Selected[i] then
begin
lSelected := true;
break;
end;
XInBtn.Enabled := lSelected and (XEdit.Text = '');
YInBtn.Enabled := lSelected and (YEdit.Text = '');
GroupInBtn.Enabled := lSelected and (GroupEdit.Text = '');
XOutBtn.Enabled := (XEdit.Text <> '');
YOutBtn.Enabled := (YEdit.Text <> '');
GroupOutBtn.Enabled := (GroupEdit.Text <> '');
end;
initialization
{$I multxvsyunit.lrs}
end.

View File

@ -0,0 +1,415 @@
object NormalityFrm: TNormalityFrm
Left = 721
Height = 396
Top = 294
Width = 402
Caption = 'Normality Tests'
ClientHeight = 396
ClientWidth = 402
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Label1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 8
Height = 15
Top = 8
Width = 49
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Variables:'
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = TestVarEdit
AnchorSideBottom.Control = VarInBtn
AnchorSideBottom.Side = asrBottom
Left = 261
Height = 15
Top = 36
Width = 93
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Test Normality of:'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = VarInBtn
AnchorSideBottom.Control = Bevel1
Left = 8
Height = 313
Top = 25
Width = 209
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
ItemHeight = 0
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object VarInBtn: TBitBtn
AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = VarList
AnchorSideRight.Control = VarList
AnchorSideRight.Side = asrBottom
Left = 225
Height = 28
Top = 25
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = VarInBtnClick
Spacing = 0
TabOrder = 1
end
object VarOutBtn: TBitBtn
AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = VarInBtn
AnchorSideTop.Side = asrBottom
Left = 225
Height = 28
Top = 57
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = VarOutBtnClick
Spacing = 0
TabOrder = 2
end
object TestVarEdit: TEdit
AnchorSideLeft.Control = VarOutBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 261
Height = 23
Top = 53
Width = 133
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
TabOrder = 3
Text = 'TestVarEdit'
end
object GroupBox1: TGroupBox
AnchorSideTop.Control = VarOutBtn
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 225
Height = 80
Top = 97
Width = 169
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 12
BorderSpacing.Right = 8
Caption = 'Shapiro-Wilkes Rresults'
ClientHeight = 60
ClientWidth = 165
TabOrder = 4
object Label3: TLabel
AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = WEdit
AnchorSideTop.Side = asrCenter
Left = 12
Height = 15
Top = 6
Width = 33
BorderSpacing.Left = 12
Caption = 'WWW'
ParentColor = False
end
object Label4: TLabel
AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = ProbEdit
AnchorSideTop.Side = asrCenter
Left = 12
Height = 15
Top = 33
Width = 57
BorderSpacing.Left = 12
Caption = 'Probability'
ParentColor = False
end
object WEdit: TEdit
AnchorSideLeft.Control = ProbEdit
AnchorSideTop.Control = GroupBox1
AnchorSideRight.Control = GroupBox1
AnchorSideRight.Side = asrBottom
Left = 77
Height = 23
Top = 2
Width = 80
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 2
BorderSpacing.Right = 8
ReadOnly = True
TabOrder = 0
Text = 'WEdit'
end
object ProbEdit: TEdit
AnchorSideLeft.Control = Label4
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = WEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = GroupBox1
AnchorSideRight.Side = asrBottom
Left = 77
Height = 23
Top = 29
Width = 80
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 4
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
ReadOnly = True
TabOrder = 1
Text = 'ProbEdit'
end
end
object GroupBox2: TGroupBox
AnchorSideLeft.Control = GroupBox1
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 225
Height = 155
Top = 191
Width = 169
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Right = 8
Caption = 'Lilliefors Test Results'
ClientHeight = 135
ClientWidth = 165
TabOrder = 5
object Label5: TLabel
AnchorSideLeft.Control = GroupBox2
AnchorSideTop.Control = SkewEdit
AnchorSideTop.Side = asrCenter
Left = 12
Height = 15
Top = 6
Width = 53
BorderSpacing.Left = 12
Caption = 'Skewness:'
ParentColor = False
end
object Label6: TLabel
AnchorSideLeft.Control = GroupBox2
AnchorSideTop.Control = KurtosisEdit
AnchorSideTop.Side = asrCenter
Left = 12
Height = 15
Top = 33
Width = 45
BorderSpacing.Left = 12
Caption = 'Kurtosis:'
ParentColor = False
end
object Label7: TLabel
AnchorSideLeft.Control = GroupBox2
AnchorSideTop.Control = StatEdit
AnchorSideTop.Side = asrCenter
Left = 12
Height = 15
Top = 60
Width = 67
BorderSpacing.Left = 12
Caption = 'Test Statistic:'
ParentColor = False
end
object SkewEdit: TEdit
AnchorSideLeft.Control = StatEdit
AnchorSideTop.Control = GroupBox2
AnchorSideRight.Control = GroupBox2
AnchorSideRight.Side = asrBottom
Left = 87
Height = 23
Top = 2
Width = 70
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 2
BorderSpacing.Right = 8
ReadOnly = True
TabOrder = 0
Text = 'SkewEdit'
end
object KurtosisEdit: TEdit
AnchorSideLeft.Control = StatEdit
AnchorSideTop.Control = SkewEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = GroupBox2
AnchorSideRight.Side = asrBottom
Left = 87
Height = 23
Top = 29
Width = 70
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 4
BorderSpacing.Right = 8
ReadOnly = True
TabOrder = 1
Text = 'KurtosisEdit'
end
object StatEdit: TEdit
AnchorSideLeft.Control = Label7
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = KurtosisEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = GroupBox2
AnchorSideRight.Side = asrBottom
Left = 87
Height = 23
Top = 56
Width = 70
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 4
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
ReadOnly = True
TabOrder = 2
Text = 'StatEdit'
end
object Label8: TLabel
AnchorSideLeft.Control = Label5
AnchorSideTop.Control = StatEdit
AnchorSideTop.Side = asrBottom
Left = 12
Height = 15
Top = 87
Width = 104
Caption = 'Lillifors Conclusion:'
ParentColor = False
WordWrap = True
end
object ConclusionEdit: TEdit
AnchorSideLeft.Control = Label8
AnchorSideTop.Control = Label8
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = GroupBox2
AnchorSideRight.Side = asrBottom
Left = 12
Height = 23
Top = 104
Width = 145
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 2
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
ReadOnly = True
TabOrder = 3
Text = 'ConclusionEdit'
end
end
object Panel1: TPanel
AnchorSideRight.Side = asrBottom
Left = 8
Height = 26
Top = 362
Width = 386
Align = alBottom
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
BevelOuter = bvNone
ClientHeight = 26
ClientWidth = 386
TabOrder = 6
object CloseBtn: TButton
AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 319
Height = 25
Top = 1
Width = 55
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Right = 12
Caption = 'Close'
ModalResult = 11
TabOrder = 3
end
object ApplyBtn: TButton
AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = CloseBtn
Left = 254
Height = 25
Top = 1
Width = 57
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Right = 8
Caption = 'Apply'
OnClick = ApplyBtnClick
TabOrder = 2
end
object PrintBtn: TButton
AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = ApplyBtn
Left = 195
Height = 25
Top = 1
Width = 51
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Right = 8
Caption = 'Print'
OnClick = PrintBtnClick
TabOrder = 1
end
object ResetBtn: TButton
AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = PrintBtn
Left = 133
Height = 25
Top = 1
Width = 54
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Right = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 0
end
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Panel1
Left = 0
Height = 8
Top = 346
Width = 402
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
end

View File

@ -0,0 +1,385 @@
// Use file "cansas.laz" for testing
unit NormalityUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons, ExtCtrls,
MainUnit, Globals, FunctionsLib, DataProcs, OutputUnit;
type
{ TNormalityFrm }
TNormalityFrm = class(TForm)
Bevel1: TBevel;
ResetBtn: TButton;
PrintBtn: TButton;
ApplyBtn: TButton;
CloseBtn: TButton;
ConclusionEdit: TEdit;
Label8: TLabel;
Panel1: TPanel;
StatEdit: TEdit;
KurtosisEdit: TEdit;
SkewEdit: TEdit;
GroupBox2: TGroupBox;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
ProbEdit: TEdit;
Label4: TLabel;
WEdit: TEdit;
GroupBox1: TGroupBox;
Label3: TLabel;
TestVarEdit: TEdit;
Label2: TLabel;
VarInBtn: TBitBtn;
VarOutBtn: TBitBtn;
Label1: TLabel;
VarList: TListBox;
procedure ApplyBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure PrintBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure VarInBtnClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean);
procedure VarOutBtnClick(Sender: TObject);
private
{ private declarations }
FAutoSized: boolean;
function Norm(z : double) : double;
procedure UpdateBtnStates;
public
{ public declarations }
end;
var
NormalityFrm: TNormalityFrm;
implementation
uses
Math;
{ TNormalityFrm }
procedure TNormalityFrm.PrintBtnClick(Sender: TObject);
var
lReport: TStrings;
begin
lReport := TStringList.Create;
try
lReport.Add('NORMALITY TESTS FOR '+ TestVarEdit.Text);
lReport.Add('');
lReport.Add('Shapiro-Wilkes W = ' + WEdit.Text);
lReport.Add('Shapiro-Wilkes Prob. = ' + ProbEdit.Text);
lReport.Add('');
lReport.Add('Skew = ' + SkewEdit.Text);
lReport.Add('Kurtosis = ' + KurtosisEdit.Text);
lReport.Add('Lilliefors Test Statistic = ' + StatEdit.Text);
lReport.Add('Conclusion: ' + ConclusionEdit.Text);
DisplayReport(lReport);
finally
lReport.Free;
end;
end;
procedure TNormalityFrm.ResetBtnClick(Sender: TObject);
var
i: integer;
begin
TestVarEdit.Text := '';
WEdit.Text := '';
ProbEdit.Text := '';
ConclusionEdit.Text := '';
SkewEdit.Text := '';
KurtosisEdit.Text := '';
StatEdit.Text := '';
VarList.Items.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
UpdateBtnStates;
end;
procedure TNormalityFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([ResetBtn.Width, PrintBtn.Width, ApplyBtn.Width, CloseBtn.Width]);
ResetBtn.Constraints.MinWidth := w;
PrintBtn.Constraints.MinWidth := w;
ApplyBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
FAutoSized := True;
end;
procedure TNormalityFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
end;
procedure TNormalityFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(nil);
end;
procedure TNormalityFrm.ApplyBtnClick(Sender: TObject);
var
w: Double = 0.0;
temp, pw : double;
skew, kurtosis : double;
mean, variance, stddev, deviation, devsqr, M2, M3, M4 : double;
i, j, n, n1, n2, ier : integer;
varlabel : string;
selcol : integer;
data, a, z, x : DblDyneVec;
freq : IntDyneVec;
fval, jval, DP : DblDyneVec;
F1, DPP, D, D1, A0, C1, D15, D10, D05, D025, t2 : double;
init : boolean;
msg : string;
procedure Cleanup;
begin
DP := nil;
jval := nil;
fval := nil;
data := nil;
a := nil;
freq := nil;
z := nil;
x := nil;
end;
begin
selcol := 0;
for i := 1 to NoVariables do
if OS3MainFrm.DataGrid.Cells[i,0] = TestVarEdit.Text then
begin
selcol := i;
break;
end;
if selCol = 0 then
begin
MessageDlg('No variable selected.', mtError, [mbOK], 0);
exit;
end;
init := false;
n := 0;
varlabel := TestVarEdit.Text;
// place values into the data array
SetLength(data, NoCases+1); // arrays start at 1
SetLength(a, NoCases+1);
SetLength(freq, NoCases+1);
SetLength(z, NoCases+1);
SetLength(x, NoCases+1);
SetLength(fval, NoCases+1);
SetLength(jval, NoCases+1);
SetLength(DP, NoCases+1);
for i := 1 to NoCases do
begin
if not ValidValue(i,selcol) then
continue;
n := n + 1;
data[n] := StrToFloat(OS3MainFrm.DataGrid.Cells[selcol,i]);
end;
n1 := n;
n2 := n div 2;
// sort into ascending order
for i := 1 to n - 1 do
begin
for j := i + 1 to n do
begin
if data[i] > data[j] then
begin
temp := data[i];
data[i] := data[j];
data[j] := temp;
end;
end;
end;
// call Shapiro-Wilks function
swilk(init, data, n, n1, n2, a, w, pw, ier);
if ier <> 0 then
begin
msg := 'Error encountered = ' + IntToStr(ier);
MessageDlg(msg, mtError, [mbOK], 0);
Cleanup;
exit;
end;
WEdit.Text := Format('%8.4f', [w]);
ProbEdit.Text := Format('%8.4f', [pw]);
// Now do Lilliefors
// Get unique scores and their frequencies
n1 := 1;
i := 1;
freq[1] := 1;
x[1] := data[1];
repeat
//again:
for j := i + 1 to n do
begin
if data[j] = x[n1] then freq[n1] := freq[n1] + 1;
end;
i := i + freq[n1];
if i <= n then
begin
n1 := n1 + 1;
x[n1] := data[i];
freq[n1] := 1;
//goto again;
end;
until i > n;
// now get skew and kurtosis of scores
mean := 0.0;
variance := 0.0;
for i := 1 to n do
begin
mean := mean + data[i];
variance := variance + (data[i] * data[i]);
end;
variance := variance - (mean * mean) / n;
variance := variance / (n - 1);
stddev := sqrt(variance);
mean := mean / n;
// obtain skew, kurtosis and z scores
M2 := 0.0;
M3 := 0.0;
M4 := 0.0;
for i := 1 to n do
begin
deviation := data[i] - mean;
devsqr := deviation * deviation;
M2 := M2 + devsqr;
M3 := M3 + (deviation * devsqr);
M4 := M4 + (devsqr * devsqr);
z[i] := (data[i] - mean) / stddev;
end;
for i := 1 to n1 do x[i] := (x[i] - mean) / stddev;
skew := (n * M3) / ((n - 1) * (n - 2) * stddev * variance);
kurtosis := (n * (n + 1) * M4) - (3 * M2 * M2 * (n - 1));
kurtosis := kurtosis /( (n - 1) * (n - 2) * (n - 3) * (variance * variance) );
SkewEdit.Text := Format('%8.3f', [skew]);
KurtosisEdit.Text := Format('%8.3f', [kurtosis]);
// obtain the test statistic
for i := 1 to n1 do
begin
F1 := Norm(x[i]);
if x[i] >= 0 then
fval[i] := 1.0 - (F1 / 2.0)
else
fval[i] := F1 / 2.0;
end;
// cumulative proportions
jval[1] := freq[1] / n;
for i := 2 to n1 do jval[i] := jval[i-1] + freq[i] / n;
for i := 1 to n1 do DP[i] := abs(jval[i] - fval[i]);
// sort DP
for i := 1 to n1-1 do
begin
for j := i+1 to n1 do
begin
if DP[j] < DP[i] then
begin
temp := DP[i];
DP[i] := DP[j];
DP[j] := temp;
end;
end;
end;
DPP := DP[n1];
D := DPP;
D1 := D;
StatEdit.Text := Format('%8.3f', [D]);
A0 := sqrt(n);
C1 := A0 - 0.01 + (0.85 / A0);
D15 := 0.775 / C1;
D10 := 0.819 / C1;
D05 := 0.895 / C1;
D025 := 0.995 / C1;
t2 := D;
if t2 > D025 then ConclusionEdit.Text := 'Strong evidence against normality.';
if ((t2 <= D025) and (t2 > D05)) then ConclusionEdit.Text := 'Sufficient evidence against normality.';
if ((t2 <= D05) and (t2 > D10)) then ConclusionEdit.Text := 'Suggestive evidence against normality.';
if ((t2 <= D10) and (t2 > D15)) then ConclusionEdit.Text := 'Little evidence against normality.';
if (t2 <= D15) then ConclusionEdit.Text := 'No evidence against normality.';
Cleanup;
end;
procedure TNormalityFrm.VarInBtnClick(Sender: TObject);
var
i: integer;
begin
i := VarList.ItemIndex;
if (i > -1) and (TestVarEdit.Text = '') then
begin
TestVarEdit.Text := VarList.Items.Strings[i];
VarList.Items.Delete(i);
end;
UpdateBtnStates;
end;
procedure TNormalityFrm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
procedure TNormalityFrm.VarOutBtnClick(Sender: TObject);
begin
if TestVarEdit.Text <> '' then
begin
VarList.Items.Add(TestVarEdit.Text);
TestVarEdit.Text := '';
end;
UpdateBtnStates;
end;
function TNormalityFrm.Norm(z : double) : double;
var
p : double;
begin
z := abs(z);
p := 1.0 + z * (0.04986735 + z * (0.02114101 + z * (0.00327763 +
z * (0.0000380036 + z * (0.0000488906 + z * 0.000005383)))));
p := p * p;
p := p * p;
p := p * p;
Result := 1.0 / (p * p);
end;
procedure TNormalityFrm.UpdateBtnStates;
begin
VarInBtn.Enabled := (VarList.ItemIndex > -1) and (TestVarEdit.Text = '');
VarOutBtn.Enabled := (TestVarEdit.Text <> '');
end;
initialization
{$I normalityunit.lrs}
end.

View File

@ -0,0 +1,337 @@
object PlotXYFrm: TPlotXYFrm
Left = 433
Height = 367
Top = 262
Width = 490
AutoSize = True
Caption = 'Plot X versus Y'
ClientHeight = 367
ClientWidth = 490
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Label1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 8
Height = 15
Top = 8
Width = 46
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Variables'
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = XEdit
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = XEdit
Left = 267
Height = 15
Top = 31
Width = 76
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'X Axis Variable'
ParentColor = False
end
object Label3: TLabel
AnchorSideLeft.Control = YEdit
AnchorSideBottom.Control = YEdit
Left = 267
Height = 15
Top = 117
Width = 76
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Y Axis Variable'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = XinBtn
AnchorSideBottom.Control = Bevel1
AnchorSideBottom.Side = asrBottom
Left = 8
Height = 293
Top = 25
Width = 215
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Bottom = 8
ItemHeight = 0
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object XinBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
AnchorSideRight.Control = XEdit
Left = 231
Height = 28
Top = 25
Width = 28
BorderSpacing.Left = 8
BorderSpacing.Right = 8
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = XinBtnClick
Spacing = 0
TabOrder = 1
end
object XOutBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = XinBtn
AnchorSideTop.Side = asrBottom
Left = 231
Height = 28
Top = 57
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = XOutBtnClick
Spacing = 0
TabOrder = 2
end
object YInBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = XOutBtn
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = YOutBtn
Left = 231
Height = 28
Top = 109
Width = 28
BorderSpacing.Top = 24
BorderSpacing.Bottom = 4
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = YInBtnClick
Spacing = 0
TabOrder = 3
end
object YOutBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = YInBtn
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = VarList
AnchorSideBottom.Side = asrBottom
Left = 231
Height = 28
Top = 141
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = YOutBtnClick
Spacing = 0
TabOrder = 4
end
object XEdit: TEdit
AnchorSideLeft.Control = XinBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = XOutBtn
AnchorSideBottom.Side = asrBottom
Left = 267
Height = 23
Top = 50
Width = 215
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 4
BorderSpacing.Right = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 5
Text = 'XEdit'
end
object YEdit: TEdit
AnchorSideLeft.Control = XEdit
AnchorSideRight.Control = XEdit
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = YOutBtn
AnchorSideBottom.Side = asrBottom
Left = 267
Height = 23
Top = 134
Width = 215
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 6
Text = 'YEdit'
end
object GroupBox1: TGroupBox
AnchorSideLeft.Control = YEdit
AnchorSideTop.Control = YEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 267
Height = 141
Top = 181
Width = 191
AutoSize = True
BorderSpacing.Top = 24
BorderSpacing.Right = 8
Caption = 'Options'
ChildSizing.LeftRightSpacing = 12
ClientHeight = 121
ClientWidth = 187
TabOrder = 7
object Label4: TLabel
AnchorSideLeft.Control = ConfChk
AnchorSideTop.Control = ConfEdit
AnchorSideTop.Side = asrCenter
Left = 36
Height = 15
Top = 94
Width = 74
BorderSpacing.Left = 24
BorderSpacing.Right = 8
Caption = '% Confidence'
ParentColor = False
end
object DescChk: TCheckBox
AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = GroupBox1
Left = 12
Height = 19
Top = 2
Width = 155
BorderSpacing.Left = 12
BorderSpacing.Top = 2
BorderSpacing.Right = 8
Caption = 'Print Descriptive Statistics'
TabOrder = 0
end
object ConfEdit: TEdit
AnchorSideLeft.Control = Label4
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ConfChk
AnchorSideTop.Side = asrBottom
Left = 118
Height = 23
Top = 90
Width = 57
Alignment = taRightJustify
BorderSpacing.Left = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
TabOrder = 1
Text = '95.0'
end
object LineChk: TCheckBox
AnchorSideLeft.Control = DescChk
AnchorSideTop.Control = DescChk
AnchorSideTop.Side = asrBottom
Left = 12
Height = 19
Top = 25
Width = 146
BorderSpacing.Top = 4
Caption = 'Plot the Regression Line'
TabOrder = 2
end
object MeansChk: TCheckBox
AnchorSideLeft.Control = LineChk
AnchorSideTop.Control = LineChk
AnchorSideTop.Side = asrBottom
Left = 12
Height = 19
Top = 48
Width = 99
BorderSpacing.Top = 4
Caption = 'Plot the Means'
TabOrder = 3
end
object ConfChk: TCheckBox
AnchorSideLeft.Control = MeansChk
AnchorSideTop.Control = MeansChk
AnchorSideTop.Side = asrBottom
Left = 12
Height = 19
Top = 71
Width = 155
BorderSpacing.Top = 4
BorderSpacing.Right = 8
Caption = 'Plot the Confidence Band'
TabOrder = 4
end
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 416
Height = 25
Top = 334
Width = 62
Anchors = [akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 8
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 332
Height = 25
Top = 334
Width = 76
Anchors = [akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 9
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 270
Height = 25
Top = 334
Width = 54
Anchors = [akRight, akBottom]
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 10
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 318
Width = 490
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
end

View File

@ -0,0 +1,774 @@
// Use file "cansas.laz" for testing
unit PlotXYUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, Buttons,
MainUnit, Globals, OutputUnit, FunctionsLib, DataProcs, BlankFrmUnit;
type
{ TPlotXYFrm }
TPlotXYFrm = class(TForm)
Bevel1: TBevel;
ConfEdit: TEdit;
Label4: TLabel;
ResetBtn: TButton;
ComputeBtn: TButton;
CloseBtn: TButton;
DescChk: TCheckBox;
LineChk: TCheckBox;
MeansChk: TCheckBox;
ConfChk: TCheckBox;
GroupBox1: TGroupBox;
YEdit: TEdit;
Label3: TLabel;
XEdit: TEdit;
Label2: TLabel;
XinBtn: TBitBtn;
XOutBtn: TBitBtn;
YInBtn: TBitBtn;
YOutBtn: TBitBtn;
Label1: TLabel;
VarList: TListBox;
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean);
procedure XinBtnClick(Sender: TObject);
procedure XOutBtnClick(Sender: TObject);
procedure YInBtnClick(Sender: TObject);
procedure YOutBtnClick(Sender: TObject);
private
{ private declarations }
FAutoSized: Boolean;
procedure plotxy(VAR Xpoints : DblDyneVec;
VAR Ypoints : DblDyneVec;
VAR UpConf : DblDyneVec;
VAR LowConf : DblDyneVec;
ConfBand : double;
Xmean, Ymean , R : double;
Slope, Intercept : double;
Xmax, Xmin, Ymax, Ymin : double;
N : integer);
{
procedure pplotxy(VAR Xpoints : DblDyneVec;
VAR Ypoints : DblDyneVec;
VAR UpConf : DblDyneVec;
VAR LowConf : DblDyneVec;
ConfBand : double;
Xmean, Ymean , R : double;
Slope, Intercept : double;
Xmax, Xmin, Ymax, Ymin : double;
N : integer);
}
procedure UpdateBtnStates;
function Validate(out AMsg: String; out AControl: TWinControl;
Xcol,Ycol: Integer): Boolean;
public
{ public declarations }
end;
var
PlotXYFrm: TPlotXYFrm;
implementation
uses
Math;
{ TPlotXYFrm }
procedure TPlotXYFrm.ResetBtnClick(Sender: TObject);
var
i: integer;
begin
XEdit.Text := '';
YEdit.Text := '';
ConfEdit.Text := FormatFloat('0.0', DEFAULT_CONFIDENCE_LEVEL_PERCENT);
DescChk.Checked := false;
LineChk.Checked := false;
MeansChk.Checked := false;
ConfChk.Checked := false;
//PrintChk.Checked := false;
VarList.Items.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
UpdateBtnStates;
end;
procedure TPlotXYFrm.XinBtnClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if index > -1 then
begin
XEdit.Text := VarList.Items[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TPlotXYFrm.XOutBtnClick(Sender: TObject);
begin
VarList.Items.Add(XEdit.Text);
XEdit.Text := '';
UpdateBtnStates;
end;
procedure TPlotXYFrm.YInBtnClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if index > -1 then
begin
YEdit.Text := VarList.Items[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TPlotXYFrm.YOutBtnClick(Sender: TObject);
begin
VarList.Items.Add(YEdit.Text);
YEdit.Text := '';
UpdateBtnStates;
end;
procedure TPlotXYFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TPlotXYFrm.ComputeBtnClick(Sender: TObject);
var
Xmin, Xmax, Ymin, Ymax, SSx, t, DF : double;
Xmean, Ymean, Xvariance, Yvariance, Xstddev, Ystddev, ConfBand : double;
X, Y, R, temp, SEPred, Slope, Intercept, predicted, sedata : double;
i, j : integer;
Xcol, Ycol, N, NoSelected : integer;
Xpoints : DblDyneVec;
Ypoints : DblDyneVec;
UpConf : DblDyneVec;
lowConf : DblDyneVec;
cellstring : string;
ColNoSelected : IntDyneVec;
C: TWinControl;
msg: String;
lReport: TStrings;
begin
SetLength(Xpoints,NoCases + 1);
SetLength(Ypoints,NoCases + 1);
SetLength(UpConf,NoCases + 1);
SetLength(lowConf,NoCases + 1);
SetLength(ColNoSelected,NoVariables);
Xcol := 0;
Ycol := 0;
for i := 1 to Novariables do
begin
cellstring := OS3MainFrm.DataGrid.Cells[i,0];
if cellstring = XEdit.Text then Xcol := i;
if cellstring = YEdit.Text then Ycol := i;
end;
// Validation
if not Validate(msg, C, Xcol, Ycol) then
begin
C.SetFocus;
MessageDlg(msg, mtError, [mbOK], 0);
ModalResult := mrNone;
exit;
end;
NoSelected := 2;
ColNoSelected[0] := Xcol;
ColNoSelected[1] := Ycol;
N := 0;
Xmax := -1.0e20;
Xmin := 1.0e20;
Ymax := -1.0e20;
Ymin := 1.0e20;
Xmean := 0.0;
Ymean := 0.0;
Xvariance := 0.0;
Yvariance := 0.0;
R := 0.0;
for i := 1 to NoCases do
begin
if Not GoodRecord(i,NoSelected,ColNoSelected) then continue;
N := N + 1;
X := StrToFloat(OS3MainFrm.DataGrid.Cells[Xcol,i]);
Y := StrToFloat(OS3MainFrm.DataGrid.Cells[Ycol,i]);
Xpoints[N] := X;
Ypoints[N] := Y;
if X > Xmax then Xmax := X;
if X < Xmin then Xmin := X;
if Y > Ymax then Ymax := Y;
if Y < Ymin then Ymin := Y;
Xmean := Xmean + X;
Ymean := Ymean + Y;
Xvariance := Xvariance + (X * X);
Yvariance := Yvariance + (Y * Y);
R := R + (X * Y);
end;
// sort on X
for i := 1 to N - 1 do
begin
for j := i + 1 to N do
begin
if Xpoints[i] > Xpoints[j] then //swap
begin
temp := Xpoints[i];
Xpoints[i] := Xpoints[j];
Xpoints[j] := temp;
temp := Ypoints[i];
Ypoints[i] := Ypoints[j];
Ypoints[j] := temp;
end;
end;
end;
// calculate statistics
Xvariance := Xvariance - (Xmean * Xmean / N);
SSx := Xvariance;
Xvariance := Xvariance / (N - 1);
Xstddev := sqrt(Xvariance);
Yvariance := Yvariance - (Ymean * Ymean / N);
Yvariance := Yvariance / (N - 1);
Ystddev := sqrt(Yvariance);
R := R - (Xmean * Ymean / N);
R := R / (N - 1);
R := R / (Xstddev * Ystddev);
SEPred := sqrt(1.0 - (R * R)) * Ystddev;
SEPred := SEPred * sqrt((N - 1) / (N - 2));
Xmean := Xmean / N;
Ymean := Ymean / N;
Slope := R * Ystddev / Xstddev;
Intercept := Ymean - Slope * Xmean;
// Now, print the descriptive statistics to the output form if requested
if DescChk.Checked then
begin
lReport := TStringList.Create;
try
lReport.Add('X vs. Y PLOT');
lReport.Add('');
lReport.Add('X = %s, Y = %s from file: %s',[Xedit.Text, YEdit.Text,OS3MainFrm.FileNameEdit.Text]);
lReport.Add('');
lReport.Add('Variable Mean Variance Std.Dev.');
lReport.Add('%-10s%8.2f %8.2f %8.2f', [XEdit.Text,Xmean,Xvariance,Xstddev]);
lReport.Add('%-10s%8.2f %8.2f %8.2f', [YEdit.Text,Ymean,Yvariance,Ystddev]);
lReport.Add('');
lReport.Add('Correlation: %8.3f', [R]);
lReport.Add('Slope: %8.3f', [Slope]);
lReport.Add('Intercept: %8.3f', [Intercept]);
lReport.Add('Standard Error of Estimate: %8.3f', [SEPred]);
lReport.Add('Number of good cases: %8d', [N]);
DisplayReport(lReport);
finally
lReport.Free;
end;
end;
// get upper and lower confidence points for each X value
if ConfChk.Checked then
begin
ConfBand := StrToFloat(ConfEdit.Text) / 100.0;
DF := N - 2;
t := inverset(ConfBand,DF);
for i := 1 to N do
begin
X := Xpoints[i];
predicted := slope * X + intercept;
sedata := SEPred * sqrt(1.0 + (1.0 / N) + (sqr(X - Xmean) / SSx));
UpConf[i] := predicted + (t * sedata);
lowConf[i] := predicted - (t * sedata);
if UpConf[i] > Ymax then Ymax := UpConf[i];
if lowConf[i] < Ymin then Ymin := lowConf[i];
end;
end
else ConfBand := 0.0;
// plot the values (and optional line and confidence band if elected)
plotxy(Xpoints, Ypoints, UpConf, LowConf, ConfBand, Xmean, Ymean, R,
Slope, Intercept, Xmax, Xmin, Ymax, Ymin, N);
Application.ProcessMessages;
{
// print the same if elected
if PrintChk.Checked then
pplotxy(Xpoints, Ypoints, UpConf, LowConf, ConfBand, Xmean, Ymean,
R, Slope, Intercept, Xmax, Xmin, Ymax, Ymin, N);
}
// cleanup
ColNoSelected := nil;
lowConf := nil;
UpConf := nil;
Ypoints := nil;
Xpoints := nil;
end;
procedure TPlotXYFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
VarList.Constraints.MinHeight := GroupBox1.Top + GroupBox1.Height - VarList.Top;
VarList.Constraints.MinWidth := GroupBox1.Width;
Constraints.MinWidth := GroupBox1.Width * 2 + XInBtn.Width + 4 * VarList.BorderSpacing.Left;
Constraints.MinHeight := Height;
FAutoSized := True;
end;
procedure TPlotXYFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
if BlankFrm = nil then Application.CreateForm(TBlankFrm, BlankFrm);
end;
procedure TPlotXYFrm.plotxy(VAR Xpoints : DblDyneVec;
VAR Ypoints : DblDyneVec;
VAR UpConf : DblDyneVec;
VAR LowConf : DblDyneVec;
ConfBand : double;
Xmean, Ymean , R : double;
Slope, Intercept : double;
Xmax, Xmin, Ymax, Ymin : double;
N : integer);
var
i, xpos, ypos, hleft, hright, vtop, vbottom, imagewide : integer;
vhi, hwide, offset, strhi, imagehi : integer;
valincr, Yvalue, Xvalue : double;
Title : string;
begin
BlankFrm.Image1.Canvas.Clear;
BlankFrm.Show;
Title := 'X versus Y PLOT Using File: ' + OS3MainFrm.FileNameEdit.Text;
BlankFrm.Caption := Title;
imagewide := BlankFrm.Image1.Width;
imagehi := BlankFrm.Image1.Height;
vtop := 20;
vbottom := round(imagehi) - 80;
vhi := vbottom - vtop;
hleft := 100;
hright := imagewide - 80;
hwide := hright - hleft;
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
BlankFrm.Image1.Canvas.Brush.Color := clWhite;
// Draw chart border
BlankFrm.Image1.Canvas.Rectangle(0,0,imagewide,imagehi);
// draw Means
if MeansChk.Checked then
begin
ypos := round(vhi * ( (Ymax - Ymean) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := hleft;
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
xpos := hright;
BlankFrm.Image1.Canvas.Pen.Color := clGreen;
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
Title := 'MEAN ';
Title := Title + YEdit.Text;
strhi := BlankFrm.Image1.Canvas.TextHeight(Title);
ypos := ypos - strhi div 2;
BlankFrm.Image1.Canvas.Brush.Color := clWhite;
BlankFrm.Image1.Canvas.TextOut(xpos,ypos,Title);
xpos := round(hwide * ( (Xmean - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
ypos := vtop;
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
ypos := vbottom;
BlankFrm.Image1.Canvas.Pen.Color := clGreen;
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
Title := 'MEAN ';
Title := Title + XEdit.Text;
strhi := BlankFrm.Image1.Canvas.TextWidth(Title);
xpos := xpos - strhi div 2;
ypos := vtop - BlankFrm.Image1.Canvas.TextHeight(Title);
BlankFrm.Image1.Canvas.Brush.Color := clWhite;
BlankFrm.Image1.Canvas.TextOut(xpos,ypos,Title);
end;
// draw slope line
if LineChk.Checked then
begin
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
Yvalue := (Xpoints[1] * slope) + intercept; // predicted score
ypos := round(vhi * ( (Ymax - Yvalue) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := round(hwide * ( (Xpoints[1]- Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
Yvalue := (Xpoints[N] * slope) + intercept; // predicted score
ypos := round(vhi * ( (Ymax - Yvalue) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := round(hwide * ( (Xpoints[N] - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
end;
// draw horizontal axis
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
BlankFrm.Image1.Canvas.MoveTo(hleft,vbottom);
BlankFrm.Image1.Canvas.LineTo(hright,vbottom);
valincr := (Xmax - Xmin) / 10.0;
for i := 1 to 11 do
begin
ypos := vbottom;
Xvalue := Xmin + valincr * (i - 1);
xpos := round(hwide * ((Xvalue - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
ypos := ypos + 10;
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
Title := format('%6.2f',[Xvalue]);
offset := BlankFrm.Image1.Canvas.TextWidth(Title) div 2;
xpos := xpos - offset;
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
BlankFrm.Image1.Canvas.TextOut(xpos,ypos,Title);
end;
xpos := hleft + (hwide div 2) - (BlankFrm.Image1.Canvas.TextWidth(XEdit.Text) div 2);
ypos := vbottom + 20;
BlankFrm.Image1.Canvas.TextOut(xpos,ypos,XEdit.Text);
Title := format('R(X,Y) = %5.3f, Slope = %6.2f, Intercept = %6.2f',
[R,Slope,Intercept]);
xpos := hleft + (hwide div 2) - (BlankFrm.Image1.Canvas.TextWidth(Title) div 2);
ypos := ypos + 15;
BlankFrm.Image1.Canvas.TextOut(xpos,ypos,Title);
// Draw vertical axis
Title := YEdit.Text;
xpos := hleft - BlankFrm.Image1.Canvas.TextWidth(Title) div 2;
ypos := vtop - BlankFrm.Image1.Canvas.TextHeight(Title);
BlankFrm.Image1.Canvas.TextOut(xpos,ypos,YEdit.Text);
xpos := hleft;
ypos := vtop;
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
ypos := vbottom;
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
valincr := (Ymax - Ymin) / 10.0;
for i := 1 to 11 do
begin
Title := format('%8.2f',[Ymax - ((i-1)*valincr)]);
strhi := BlankFrm.Image1.Canvas.TextHeight(Title);
xpos := 10;
Yvalue := Ymax - (valincr * (i-1));
ypos := round(vhi * ( (Ymax - Yvalue) / (Ymax - Ymin)));
ypos := ypos + vtop - strhi div 2;
BlankFrm.Image1.Canvas.TextOut(xpos,ypos,Title);
xpos := hleft;
ypos := ypos + strhi div 2;
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
xpos := hleft - 10;
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
end;
// draw points for x and y pairs
for i := 1 to N do
begin
ypos := round(vhi * ( (Ymax - Ypoints[i]) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := round(hwide * ( (Xpoints[i] - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
BlankFrm.Image1.Canvas.Brush.Color := clNavy;
BlankFrm.Image1.Canvas.Brush.Style := bsSolid;
BlankFrm.Image1.Canvas.Pen.Color := clNavy;
BlankFrm.Image1.Canvas.Ellipse(xpos,ypos,xpos+5,ypos+5);
end;
// draw confidence bands if requested
if ConfBand <> 0.0 then
begin
BlankFrm.Image1.Canvas.Pen.Color := clRed;
ypos := round(vhi * ((Ymax - UpConf[1]) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := round(hwide * ( (Xpoints[1] - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
for i := 2 to N do
begin
ypos := round(vhi * ((Ymax - UpConf[i]) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := round(hwide * ( (Xpoints[i] - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
end;
ypos := round(vhi * ((Ymax - lowConf[1]) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := round(hwide * ( (Xpoints[1] - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
for i := 2 to N do
begin
ypos := round(vhi * ((Ymax - lowConf[i]) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := round(hwide * ( (Xpoints[i] - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
end;
end;
end;
//-------------------------------------------------------------------
(*
procedure TPlotXYFrm.pplotxy(VAR Xpoints : DblDyneVec;
VAR Ypoints : DblDyneVec;
VAR UpConf : DblDyneVec;
VAR LowConf : DblDyneVec;
ConfBand : double;
Xmean, Ymean , R : double;
Slope, Intercept : double;
Xmax, Xmin, Ymax, Ymin : double;
N : integer);
var
i, xpos, ypos, hleft, hright, vtop, vbottom, imagewide : integer;
vhi, hwide, offset, strhi : integer;
imagehi, maxval, minval, valincr, Yvalue, Xvalue : double;
Title : string;
begin
if not PrintDialog.Execute then
exit;
Printer.Orientation := poLandscape;
Printer.BeginDoc;
Title := 'X versus Y PLOT Using File: ' + OS3MainFrm.FileNameEdit.Text;
strhi := Printer.Canvas.TextWidth(Title) div 2;
Printer.Canvas.TextOut(strhi,5,Title);
imagewide := Printer.PageWidth - 100;
imagehi := Printer.PageHeight - 100;
vtop := 120;
vbottom := round(imagehi) - 100;
vhi := vbottom - vtop;
hleft := 300;
hright := imagewide - 200;
hwide := hright - hleft;
Printer.Canvas.Pen.Color := clBlack;
Printer.Canvas.Brush.Color := clWhite;
// draw Means
if MeansChk.Checked then
begin
ypos := round(vhi * ( (Ymax - Ymean) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := hleft;
Printer.Canvas.MoveTo(xpos,ypos);
xpos := hright;
Printer.Canvas.Pen.Color := clGreen;
Printer.Canvas.LineTo(xpos,ypos);
Title := 'MEAN ';
Title := Title + YEdit.Text;
strhi := Printer.Canvas.TextHeight(Title);
ypos := ypos - strhi div 2;
Printer.Canvas.Brush.Color := clWhite;
Printer.Canvas.TextOut(xpos,ypos,Title);
xpos := round(hwide * ( (Xmean - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
ypos := vtop;
Printer.Canvas.MoveTo(xpos,ypos);
ypos := vbottom;
Printer.Canvas.Pen.Color := clGreen;
Printer.Canvas.LineTo(xpos,ypos);
Title := 'MEAN ';
Title := Title + XEdit.Text;
strhi := Printer.Canvas.TextWidth(Title);
xpos := xpos - strhi div 2;
ypos := vtop - Printer.Canvas.TextHeight(Title);
Printer.Canvas.Brush.Color := clWhite;
Printer.Canvas.TextOut(xpos,ypos,Title);
end;
// draw slope line
if LineChk.Checked then
begin
Printer.Canvas.Pen.Color := clBlack;
Yvalue := (Xpoints[1] * slope) + intercept; // predicted score
ypos := round(vhi * ( (Ymax - Yvalue) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := round(hwide * ( (Xpoints[1]- Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
Printer.Canvas.MoveTo(xpos,ypos);
Yvalue := (Xpoints[N] * slope) + intercept; // predicted score
ypos := round(vhi * ( (Ymax - Yvalue) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := round(hwide * ( (Xpoints[N] - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
Printer.Canvas.LineTo(xpos,ypos);
end;
// draw horizontal axis
Printer.Canvas.Pen.Color := clBlack;
Printer.Canvas.MoveTo(hleft,vbottom);
Printer.Canvas.LineTo(hright,vbottom);
valincr := (Xmax - Xmin) / 10.0;
for i := 1 to 11 do
begin
ypos := vbottom;
Xvalue := Xmin + valincr * (i - 1);
xpos := round(hwide * ((Xvalue - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
Printer.Canvas.MoveTo(xpos,ypos);
ypos := ypos + 10;
Printer.Canvas.LineTo(xpos,ypos);
Title := format('%6.2f',[Xvalue]);
offset := Printer.Canvas.TextWidth(Title) div 2;
xpos := xpos - offset;
Printer.Canvas.Pen.Color := clBlack;
Printer.Canvas.TextOut(xpos,ypos,Title);
end;
xpos := hleft + (hwide div 2) - (Printer.Canvas.TextWidth(XEdit.Text) div 2);
ypos := vbottom + 40;
Printer.Canvas.TextOut(xpos,ypos,XEdit.Text);
Title := format('R(X,Y) = %5.3f, Slope = %6.2f, Intercept = %6.2f',
[R,Slope,Intercept]);
xpos := hleft + (hwide div 2) - (Printer.Canvas.TextWidth(Title) div 2);
ypos := ypos + 40;
Printer.Canvas.TextOut(xpos,ypos,Title);
// Draw vertical axis
Title := YEdit.Text;
xpos := hleft - Printer.Canvas.TextWidth(Title) div 2;
ypos := vtop - Printer.Canvas.TextHeight(Title);
Printer.Canvas.TextOut(xpos,ypos,YEdit.Text);
xpos := hleft;
ypos := vtop;
Printer.Canvas.MoveTo(xpos,ypos);
ypos := vbottom;
Printer.Canvas.LineTo(xpos,ypos);
valincr := (Ymax - Ymin) / 10.0;
for i := 1 to 11 do
begin
Title := format('%8.2f',[Ymax - ((i-1)*valincr)]);
strhi := Printer.Canvas.TextHeight(Title);
xpos := 10;
Yvalue := Ymax - (valincr * (i-1));
ypos := round(vhi * ( (Ymax - Yvalue) / (Ymax - Ymin)));
ypos := ypos + vtop - strhi div 2;
Printer.Canvas.TextOut(xpos,ypos,Title);
xpos := hleft;
ypos := ypos + strhi div 2;
Printer.Canvas.MoveTo(xpos,ypos);
xpos := hleft - 10;
Printer.Canvas.LineTo(xpos,ypos);
end;
// draw points for x and y pairs
for i := 1 to N do
begin
ypos := round(vhi * ( (Ymax - Ypoints[i]) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := round(hwide * ( (Xpoints[i] - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
Printer.Canvas.Pen.Color := clBlack;
Printer.Canvas.Ellipse(xpos,ypos,xpos+15,ypos+15);
end;
// draw confidence bands if requested
if ConfBand <> 0.0 then
begin
Printer.Canvas.Pen.Color := clRed;
ypos := round(vhi * ((Ymax - UpConf[1]) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := round(hwide * ( (Xpoints[1] - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
Printer.Canvas.MoveTo(xpos,ypos);
for i := 2 to N do
begin
ypos := round(vhi * ((Ymax - UpConf[i]) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := round(hwide * ( (Xpoints[i] - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
Printer.Canvas.LineTo(xpos,ypos);
end;
ypos := round(vhi * ((Ymax - lowConf[1]) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := round(hwide * ( (Xpoints[1] - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
Printer.Canvas.MoveTo(xpos,ypos);
for i := 2 to N do
begin
ypos := round(vhi * ((Ymax - lowConf[i]) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := round(hwide * ( (Xpoints[i] - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
Printer.Canvas.LineTo(xpos,ypos);
end;
end;
Printer.EndDoc;
Printer.Orientation := poPortrait;
end;
//-------------------------------------------------------------------
*)
function TPlotXYFrm.Validate(out AMsg: String; out AControl: TWinControl;
Xcol, Ycol: Integer): Boolean;
begin
Result := false;
if (Xcol = 0) then
begin
AControl := XEdit;
AMsg := 'No case selected for X.';
exit;
end;
if (Ycol = 0) then
begin
AControl := YEdit;
AMsg := 'No case selected for Y.';
exit;
end;
Result := true;
end;
procedure TPlotXYFrm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
procedure TPlotXYFrm.UpdateBtnStates;
begin
XinBtn.Enabled := (VarList.ItemIndex > -1) and (XEdit.Text = '');
XoutBtn.Enabled := (XEdit.Text <> '');
YinBtn.Enabled := (VarList.ItemIndex > -1) and (YEdit.Text = '');
YoutBtn.Enabled := (YEdit.Text <> '');
end;
initialization
{$I plotxyunit.lrs}
end.

View File

@ -0,0 +1,568 @@
object ResistanceLineForm: TResistanceLineForm
Left = 581
Height = 480
Top = 301
Width = 535
Caption = 'Resistant Line for Bivariate Data'
ClientHeight = 480
ClientWidth = 535
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = ResetBtnClick
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Label1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = HorCenterBevel
AnchorSideTop.Side = asrBottom
Left = 8
Height = 15
Top = 144
Width = 46
BorderSpacing.Left = 8
Caption = 'Variables'
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = XEdit
AnchorSideTop.Control = Label1
Left = 188
Height = 15
Top = 144
Width = 93
Caption = 'Selected Variables'
ParentColor = False
end
object Label3: TLabel
AnchorSideLeft.Control = XEdit
AnchorSideBottom.Control = XEdit
Left = 188
Height = 15
Top = 183
Width = 51
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'X Variable'
ParentColor = False
end
object Label4: TLabel
AnchorSideLeft.Control = YEdit
AnchorSideBottom.Control = YEdit
Left = 188
Height = 15
Top = 300
Width = 51
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Y Variable'
ParentColor = False
end
object XEdit: TEdit
AnchorSideLeft.Control = XInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = GroupBox1
AnchorSideBottom.Control = XOutBtn
AnchorSideBottom.Side = asrBottom
Left = 188
Height = 23
Top = 200
Width = 136
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Right = 16
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 3
Text = 'XEdit'
end
object YEdit: TEdit
AnchorSideLeft.Control = XEdit
AnchorSideRight.Control = XEdit
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = YOutBtn
AnchorSideBottom.Side = asrBottom
Left = 188
Height = 23
Top = 317
Width = 136
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 6
Text = 'Edit1'
end
object XInBtn: TBitBtn
AnchorSideLeft.Control = HorCenterBevel
AnchorSideLeft.Side = asrCenter
AnchorSideRight.Control = XEdit
AnchorSideBottom.Control = XOutBtn
Left = 152
Height = 28
Top = 175
Width = 28
Anchors = [akLeft, akBottom]
BorderSpacing.Right = 8
BorderSpacing.Bottom = 4
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00216324B81D5E2006FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF002A702F38256929F7216324D9FFFFFF00FFFFFF00FFFFFF00FFFFFF0061BE
6DFF5DB868FF58B162FF53A95CFF4DA156FF47994FFF419149FF3B8842FF3580
3BFF3F8845FF59A15EFF448B49FF216324CFFFFFFF00FFFFFF00FFFFFF0065C3
71FFA0D7A9FF9CD5A5FF98D3A1FF94D09DFF90CE98FF8BCB93FF87C98EFF82C6
89FF7EC384FF7AC180FF76BE7CFF458C4AFF216324C4FFFFFF00FFFFFF0068C7
74FFA5DAAEFFA2D8ABFF9ED6A7FF9AD4A3FF96D29FFF93CF9AFF8ECC95FF89CA
90FF85C78BFF81C587FF7DC282FF4A9150FF256929C9FFFFFF00FFFFFF0068C7
74FF68C774FF65C371FF61BE6DFF5DB868FF58B162FF53A95CFF4DA156FF4799
4FFF419149FF5AA362FF559D5CFF2F7835D1FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00419149F73B8842DBFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0047994FBB41914906FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = XInBtnClick
Spacing = 0
TabOrder = 1
end
object YInBtn: TBitBtn
AnchorSideLeft.Control = HorCenterBevel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = YEdit
Left = 152
Height = 28
Top = 292
Width = 28
BorderSpacing.Right = 8
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00216324B81D5E2006FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF002A702F38256929F7216324D9FFFFFF00FFFFFF00FFFFFF00FFFFFF0061BE
6DFF5DB868FF58B162FF53A95CFF4DA156FF47994FFF419149FF3B8842FF3580
3BFF3F8845FF59A15EFF448B49FF216324CFFFFFFF00FFFFFF00FFFFFF0065C3
71FFA0D7A9FF9CD5A5FF98D3A1FF94D09DFF90CE98FF8BCB93FF87C98EFF82C6
89FF7EC384FF7AC180FF76BE7CFF458C4AFF216324C4FFFFFF00FFFFFF0068C7
74FFA5DAAEFFA2D8ABFF9ED6A7FF9AD4A3FF96D29FFF93CF9AFF8ECC95FF89CA
90FF85C78BFF81C587FF7DC282FF4A9150FF256929C9FFFFFF00FFFFFF0068C7
74FF68C774FF65C371FF61BE6DFF5DB868FF58B162FF53A95CFF4DA156FF4799
4FFF419149FF5AA362FF559D5CFF2F7835D1FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00419149F73B8842DBFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0047994FBB41914906FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = YInBtnClick
Spacing = 0
TabOrder = 4
end
object XOutBtn: TBitBtn
AnchorSideLeft.Control = XInBtn
AnchorSideBottom.Control = Bevel1
Left = 152
Height = 28
Top = 207
Width = 28
Anchors = [akLeft, akBottom]
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF004DA1560647994FB8FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0053A95CD94DA156F747994F38FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF005DB868CF71BE7BFF7AC183FF5BAA64FF47994FFF419149FF3B8842FF3580
3BFF2F7835FF2A702FFF256929FF216324FF1D5E20FFFFFFFF00FFFFFF0065C3
71C47BC886FF9CD5A5FF98D3A1FF94D09DFF90CE98FF8BCB93FF87C98EFF82C6
89FF7EC384FF7AC180FF76BE7CFF72BD78FF216324FFFFFFFF00FFFFFF0068C7
74C97FCC8AFFA2D8ABFF9ED6A7FF9AD4A3FF96D29FFF93CF9AFF8ECC95FF89CA
90FF85C78BFF81C587FF7DC282FF78C07EFF256929FFFFFFFF00FFFFFF00FFFF
FF0068C774D180CD8BFF7CC987FF5DB868FF58B162FF53A95CFF4DA156FF4799
4FFF419149FF3B8842FF35803BFF2F7835FF2A702FFFFFFFFF00FFFFFF00FFFF
FF00FFFFFF0068C774DB65C371F7FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0068C7740668C774BBFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = XOutBtnClick
Spacing = 0
TabOrder = 2
end
object YOutBtn: TBitBtn
AnchorSideLeft.Control = YInBtn
AnchorSideTop.Control = YInBtn
AnchorSideTop.Side = asrBottom
Left = 152
Height = 28
Top = 324
Width = 28
BorderSpacing.Top = 4
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF004DA1560647994FB8FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0053A95CD94DA156F747994F38FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF005DB868CF71BE7BFF7AC183FF5BAA64FF47994FFF419149FF3B8842FF3580
3BFF2F7835FF2A702FFF256929FF216324FF1D5E20FFFFFFFF00FFFFFF0065C3
71C47BC886FF9CD5A5FF98D3A1FF94D09DFF90CE98FF8BCB93FF87C98EFF82C6
89FF7EC384FF7AC180FF76BE7CFF72BD78FF216324FFFFFFFF00FFFFFF0068C7
74C97FCC8AFFA2D8ABFF9ED6A7FF9AD4A3FF96D29FFF93CF9AFF8ECC95FF89CA
90FF85C78BFF81C587FF7DC282FF78C07EFF256929FFFFFFFF00FFFFFF00FFFF
FF0068C774D180CD8BFF7CC987FF5DB868FF58B162FF53A95CFF4DA156FF4799
4FFF419149FF3B8842FF35803BFF2F7835FF2A702FFFFFFFFF00FFFFFF00FFFF
FF00FFFFFF0068C774DB65C371F7FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0068C7740668C774BBFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = YOutBtnClick
Spacing = 0
TabOrder = 5
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 326
Height = 25
Top = 447
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 11
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 388
Height = 25
Top = 447
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 12
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 472
Height = 25
Top = 447
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 13
end
object GroupBox1: TGroupBox
AnchorSideTop.Control = Label1
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 340
Height = 152
Top = 144
Width = 187
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Right = 8
Caption = 'Options'
ClientHeight = 132
ClientWidth = 183
Enabled = False
TabOrder = 7
object Label5: TLabel
AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = ConfEdit
AnchorSideTop.Side = asrCenter
Left = 32
Height = 15
Top = 101
Width = 74
BorderSpacing.Left = 32
Caption = '% Confidence'
ParentColor = False
end
object DescChk: TCheckBox
AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = PointsChk
AnchorSideTop.Side = asrBottom
Left = 12
Height = 19
Top = 21
Width = 155
BorderSpacing.Left = 12
Caption = 'Print Descriptive Statistics'
TabOrder = 1
end
object ConfEdit: TEdit
AnchorSideLeft.Control = Label5
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ConfChk
AnchorSideTop.Side = asrBottom
Left = 114
Height = 23
Top = 97
Width = 57
Alignment = taRightJustify
BorderSpacing.Left = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 12
TabOrder = 5
Text = '95.0'
end
object LineChk: TCheckBox
AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = DescChk
AnchorSideTop.Side = asrBottom
Left = 12
Height = 19
Top = 40
Width = 146
BorderSpacing.Left = 12
Caption = 'Plot the Regression Line'
TabOrder = 2
end
object MeansChk: TCheckBox
AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = LineChk
AnchorSideTop.Side = asrBottom
Left = 12
Height = 19
Top = 59
Width = 99
BorderSpacing.Left = 12
Caption = 'Plot the Means'
TabOrder = 3
end
object ConfChk: TCheckBox
AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = MeansChk
AnchorSideTop.Side = asrBottom
Left = 12
Height = 19
Top = 78
Width = 155
BorderSpacing.Left = 12
Caption = 'Plot the Confidence Band'
TabOrder = 4
end
object PointsChk: TCheckBox
AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = GroupBox1
Left = 12
Height = 19
Top = 2
Width = 153
BorderSpacing.Left = 12
BorderSpacing.Top = 2
Caption = 'Plot All of the points First'
TabOrder = 0
end
end
object VarList: TListBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = XInBtn
AnchorSideBottom.Control = StdCorChk
Left = 8
Height = 205
Top = 161
Width = 136
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Constraints.MinHeight = 200
ItemHeight = 0
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object StdCorChk: TCheckBox
AnchorSideLeft.Control = Owner
AnchorSideBottom.Control = PlotMediansChk
Left = 8
Height = 19
Top = 374
Width = 330
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
Caption = 'Option: Compute a standard product-moment correlation.'
OnChange = StdCorChkChange
TabOrder = 8
end
object PlotMediansChk: TCheckBox
AnchorSideLeft.Control = Owner
AnchorSideBottom.Control = GridChk
Left = 8
Height = 19
Top = 393
Width = 265
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
Caption = 'Plot the Three Medians and Slope Line (in Red)'
TabOrder = 9
end
object GridChk: TCheckBox
AnchorSideLeft.Control = Owner
AnchorSideBottom.Control = Bevel2
Left = 8
Height = 19
Top = 412
Width = 248
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
Caption = 'Enter Predicted Y and Residual Y in the Grid'
TabOrder = 10
end
object Bevel1: TBevel
AnchorSideLeft.Control = YInBtn
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
AnchorSideTop.Side = asrCenter
Left = 161
Height = 57
Top = 235
Width = 10
Shape = bsSpacer
end
object Bevel2: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 8
Top = 431
Width = 535
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object Memo1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 8
Height = 120
Top = 8
Width = 519
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'The Resistant Line procedure creates three equal groups by sorting on the X variable and obtaining the median value of each group.'#13#10#13#10'The median values for these three groups on both the X and Y variables are then plotted. The line from the low group median to the middle group median is plotted as well as the line from the middle group to the top group median. A comparison of the slope of these two lines gives an indication of the degree to which the data fit a straight line. Enter the X and Y variables to be analyzed and click the compute button.'
ParentColor = False
WordWrap = True
end
object HorCenterBevel: TBevel
AnchorSideLeft.Control = VarList
AnchorSideTop.Control = Memo1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = XEdit
AnchorSideRight.Side = asrBottom
Left = 8
Height = 16
Top = 128
Width = 316
Anchors = [akTop, akLeft, akRight]
Shape = bsSpacer
end
end

View File

@ -0,0 +1,747 @@
// Use file "Sickness.laz" for testing
unit ResistanceLineUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, Buttons, Printers,
MainUnit, Globals, FunctionsLib, OutputUnit, DataProcs, DictionaryUnit,
ContextHelpUnit, BlankFrmUnit;
type
{ TResistanceLineForm }
TResistanceLineForm = class(TForm)
Bevel1: TBevel;
Bevel2: TBevel;
HorCenterBevel: TBevel;
GridChk: TCheckBox;
Memo1: TLabel;
PlotMediansChk: TCheckBox;
StdCorChk: TCheckBox;
PointsChk: TCheckBox;
ConfChk: TCheckBox;
ConfEdit: TEdit;
DescChk: TCheckBox;
GroupBox1: TGroupBox;
Label5: TLabel;
LineChk: TCheckBox;
VarList: TListBox;
MeansChk: TCheckBox;
ResetBtn: TButton;
ComputeBtn: TButton;
CloseBtn: TButton;
XInBtn: TBitBtn;
YInBtn: TBitBtn;
XOutBtn: TBitBtn;
YOutBtn: TBitBtn;
XEdit: TEdit;
YEdit: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure StdCorChkChange(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean);
procedure XInBtnClick(Sender: TObject);
procedure XOutBtnClick(Sender: TObject);
procedure YInBtnClick(Sender: TObject);
procedure YOutBtnClick(Sender: TObject);
private
{ private declarations }
FAutoSized: Boolean;
function Median(var X: DblDyneVec; ASize: integer): double;
procedure PlotXY(var Xpoints, YPoints, UpConf, LowConf: DblDyneVec;
ConfBand: double; Xmean, Ymean, R, Slope, Intercept: double;
Xmax, Xmin, Ymax, Ymin: double; N, PlotNo: integer);
procedure UpdateBtnStates;
public
{ public declarations }
end;
var
ResistanceLineForm: TResistanceLineForm;
implementation
uses
Math;
{ TResistanceLineForm }
procedure TResistanceLineForm.ResetBtnClick(Sender: TObject);
var
i: integer;
begin
StdCorChk.Checked := false;
GridChk.Checked := false;
PlotMediansChk.Checked := false;
XEdit.Text := '';
YEdit.Text := '';
VarList.Clear;
ConfEdit.Text := FormatFloat('0.0', DEFAULT_CONFIDENCE_LEVEL_PERCENT);
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
UpdateBtnStates;
end;
procedure TResistanceLineForm.StdCorChkChange(Sender: TObject);
begin
if StdCorChk.Checked then GroupBox1.Enabled := true else GroupBox1.Enabled := false;
end;
procedure TResistanceLineForm.ComputeBtnClick(Sender: TObject);
var
XYPoints : DblDyneMat;
XYMedians : DblDyneMat;
XMedians : DblDyneVec;
YMedians : DblDyneVec;
XVector, YVector : DblDyneVec;
cellstring, outline : string;
ColNoSelected : IntDyneVec;
UpConf : DblDyneVec;
lowConf : DblDyneVec;
GrpSize : IntDyneVec;
Xcol, Ycol, N, NoSelected, i, j, size, size1, size2, size3 : integer;
X, Y, tempX, tempY : double;
Xmin, Xmax, Ymin, Ymax, SSx, t, DF : double;
Xmean, Ymean, Xvariance, Yvariance, Xstddev, Ystddev, ConfBand : double;
R, SEPred, Slope, Intercept, predicted, sedata : double;
slope1, slope2 : double;
c, c1, c2, c3 : double; // constants obtained from control points
lReport: TStrings;
begin
SetLength(XYPoints, NoCases, NoCases);
SetLength(XYMedians, 3, 3);
SetLength(XMedians, 3);
SetLength(YMedians, 3);
SetLength(XVector, NoCases);
SetLength(YVector, NoCases);
SetLength(ColNoSelected, NoVariables);
SetLength(UpConf, NoCases + 1);
SetLength(lowConf, NoCases + 1);
SetLength(GrpSize, 3);
Xcol := 0;
Ycol := 0;
Xmax := -1.0e20;
Xmin := 1.0e20;
Ymax := -1.0e20;
Ymin := 1.0e20;
Xmean := 0.0;
Ymean := 0.0;
Xvariance := 0.0;
Yvariance := 0.0;
R := 0.0;
for i := 1 to Novariables do
begin
cellstring := OS3MainFrm.DataGrid.Cells[i,0];
if cellstring = XEdit.Text then Xcol := i;
if cellstring = YEdit.Text then Ycol := i;
end;
NoSelected := 2;
ColNoSelected[0] := Xcol;
ColNoSelected[1] := Ycol;
N := 0;
for i := 1 to NoCases do
begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[Xcol,i]));
Y := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[Ycol,i]));
if X > Xmax then Xmax := X;
if X < Xmin then Xmin := X;
if Y > Ymax then Ymax := Y;
if Y < Ymin then Ymin := Y;
Xmean := Xmean + X;
Ymean := Ymean + Y;
Xvariance := Xvariance + X * X;
Yvariance := Yvariance + Y * Y;
R := R + X * Y;
XYPoints[N,0] := X;
XYPoints[N,1] := Y;
inc(N);
end;
// sort on X values
for i := 0 to N-2 do
begin
for j := i + 1 to N-1 do
begin
if XYPoints[i,0] > XYPoints[j,0] then // swap
begin
tempX := XYPoints[i,0];
tempY := XYPoints[i,1];
XYPoints[i,0] := XYPoints[j,0];
XYPoints[i,1] := XYPoints[j,1];
XYPoints[j,0] := tempX;
XYPoints[j,1] := tempY;
end;
end;
end;
// calculate statistics
Xvariance := Xvariance - Xmean * Xmean / N;
SSx := Xvariance;
Xvariance := Xvariance / (N - 1);
Xstddev := sqrt(Xvariance);
Yvariance := Yvariance - Ymean * Ymean / N;
Yvariance := Yvariance / (N - 1);
Ystddev := sqrt(Yvariance);
R := R - (Xmean * Ymean / N);
R := R / (N - 1);
R := R / (Xstddev * Ystddev);
SEPred := sqrt(1.0 - (R * R)) * Ystddev;
SEPred := SEPred * sqrt((N - 1) / (N - 2));
Xmean := Xmean / N;
Ymean := Ymean / N;
Slope := R * Ystddev / Xstddev;
Intercept := Ymean - Slope * Xmean;
// Now, print the descriptive statistics if requested
lReport := TStringList.Create;
try
if DescChk.Checked then
begin
lReport.Add('Original X versus Y Plot Data');
lReport.Add('');
lReport.Add('X = %s, Y = %s from file: %s',[
Xedit.Text, YEdit.Text, OS3MainFrm.FileNameEdit.Text
]);
lReport.Add('');
lReport.Add('Variable Mean Variance Std.Dev.');
lReport.Add('%-10s%8.2f %8.2f %8.2f', [XEdit.Text, Xmean, Xvariance, Xstddev]);
lReport.Add('%-10s%8.2f %8.2f %8.2f', [YEdit.Text, Ymean, Yvariance, Ystddev]);
lReport.Add('');
lReport.Add('Correlation: %8.4f', [R]);
lReport.Add('Slope: %8.2f', [Slope]);
lReport.Add('Intercept: %8.2f', [Intercept]);
lReport.Add('Standard Error of Estimate: %8.2f', [SEPred]);
lReport.Add('Number of good cases: %8d', [N]);
lReport.Add('');
end;
// get upper and lower confidence points for each X value
if ConfChk.Checked then
begin
ConfBand := StrToFloat(ConfEdit.Text) / 100.0;
DF := N - 2;
t := inverset(ConfBand,DF);
for i := 1 to N do
begin
X := XYpoints[i-1,0];
predicted := slope * X + intercept;
sedata := SEPred * sqrt(1.0 + (1.0 / N) + (sqr(X - Xmean) / SSx));
UpConf[i] := predicted + (t * sedata);
lowConf[i] := predicted - (t * sedata);
if UpConf[i] > Ymax then Ymax := UpConf[i];
if lowConf[i] < Ymin then Ymin := lowConf[i];
end;
end else
ConfBand := 0.0;
// plot the values (and optional line and confidence band if elected)
if PointsChk.Checked then
begin
for i := 0 to N-1 do
begin
XVector[i] := XYPoints[i,0];
YVector[i] := XYPoints[i,1];
end;
PlotXY(
XVector, YVector, UpConf, LowConf, ConfBand, Xmean, Ymean, R,
Slope, Intercept, Xmax, Xmin, Ymax, Ymin, N, 1
);
end;
//LineChk.Checked := false;
//ConfChk.Checked := false;
ConfBand := 0.0;
// Now do the resistant line analysis
// obtain 1/3 size
size := n div 3;
size1 := size;
size3 := size;
size2 := n - size1 - size3;
GrpSize[0] := size1;
GrpSize[1] := size2;
GrpSize[2] := size3;
// get median for each group of x and y values
// first group:
for i := 0 to size1-1 do
begin
XVector[i] := XYPoints[i,0];
YVector[i] := XYPoints[i,1];
end;
XMedians[0] := Median(XVector,size1);
YMedians[0] := Median(YVector,size1);
// second group
j := 0;
for i := size1 to size1 + size2 - 1 do
begin
XVector[j] := XYPoints[i,0];
YVector[j] := XYPoints[i,1];
inc(j);
end;
XMedians[1] := Median(XVector,size2);
YMedians[1] := Median(YVector,size2);
// third group
j := 0;
for i := (size1 + size2) to N-1 do
begin
XVector[j] := XYPoints[i,0];
YVector[j] := XYPoints[i,1];
inc(j);
end;
XMedians[2] := Median(XVector,size3);
YMedians[2] := Median(YVector,size3);
lReport.Add('Group X Median Y Median Size');
for i := 0 to 2 do
lReport.Add('%3d %5.3f %5.3f %d', [i+1, XMedians[i], YMedians[i], GrpSize[i]]);
lReport.Add('');
slope1 := (YMedians[1] - YMedians[0]) / (XMedians[1] - XMedians[0]);
slope2 := (YMedians[2] - YMedians[1]) / (XMedians[2] - XMedians[1]);
lReport.Add('Half Slopes: %10.3f and %.3f', [slope1, slope2]);
Slope := (YMedians[2] - YMedians[0]) / (XMedians[2] - XMedians[0]);
lReport.Add('Slope: %10.3f', [Slope]);
tempx := slope2 / slope1;
lReport.Add('Ratio of half slopes: %10.3f',[tempx]);
// obtain estimate of the constant for the prediction equation
c1 := slope * XMedians[0] - YMedians[0];
c2 := slope * XMedians[1] - YMedians[1];
c3 := slope * XMedians[2] - YMedians[2];
c := (c1 + c2 + c3) / 3.0;
lReport.Add('Equation: y := %.3f * X + (%.3f)', [slope, c]);
if GridChk.Checked then
begin
// Get the residuals (Y - predicted Y) for each X value and place in the grid
outline := 'Pred.' + OS3MainFrm.DataGrid.Cells[Ycol,0];
DictionaryFrm.NewVar(NoVariables+1);
DictionaryFrm.DictGrid.Cells[1,NoVariables] := outline;
OS3MainFrm.DataGrid.Cells[NoVariables,0] := outline;
outline := 'Residual';
DictionaryFrm.NewVar(NoVariables+1);
DictionaryFrm.DictGrid.Cells[1,NoVariables] := outline;
OS3MainFrm.DataGrid.Cells[NoVariables,0] := outline;
for i := 1 to NoCases do
begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[Xcol,i]));
Y := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[Ycol,i]));
if c >= 0 then
predicted := slope * X + c
else
predicted := slope * X - c;
Y := Y - predicted; // residual
outline := Format('%9.3f',[predicted]);
OS3MainFrm.DataGrid.Cells[NoVariables-1,i] := outline;
outline := Format('%9.3f',[Y]);
OS3MainFrm.DataGrid.Cells[NoVariables,i] := outline;
end;
end;
DisplayReport(lReport);
// plot the values (and optional line and confidence band if elected)
if PlotMediansChk.Checked then
PlotXY(
XMedians, YMedians, UpConf, LowConf, ConfBand, Xmean, Ymean, R,
Slope, Intercept, Xmax, Xmin, Ymax, Ymin, 3, 2
);
finally
lReport.Free;
GrpSize := nil;
LowConf := nil;
UpConf := nil;
ColNoSelected := nil;
YVector := nil;
XVector := nil;
YMedians := nil;
XMedians := nil;
XYMedians := nil;
XYPoints := nil;
end;
end;
procedure TResistanceLineForm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
//VarList.Constraints.MinWidth := XEdit.Width;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TResistanceLineForm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
if BlankFrm = nil then Application.CreateForm(TBlankFrm, BlankFrm);
if DictionaryFrm = nil then Application.CreateForm(TDictionaryFrm, DictionaryFrm);
end;
procedure TResistanceLineForm.XInBtnClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (XEdit.Text = '') then
begin
XEdit.Text := VarList.items[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TResistanceLineForm.XOutBtnClick(Sender: TObject);
begin
if XEdit.Text <> '' then
begin
VarList.Items.Add(XEdit.Text);
XEdit.Text := '';
end;
UpdateBtnStates;
end;
procedure TResistanceLineForm.YInBtnClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (YEdit.Text = '') then
begin
YEdit.Text := VarList.items[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TResistanceLineForm.YOutBtnClick(Sender: TObject);
begin
if YEdit.Text <> '' then
begin
VarList.Items.Add(YEdit.Text);
YEdit.Text := '';
end;
UpdateBtnStates;
end;
function TResistanceLineForm.Median(VAR X: DblDyneVec; ASize: integer): double;
var
midpt: integer;
value: double;
i, j: integer;
begin
// sort values
for i := 0 to ASize-2 do
begin
for j := i + 1 to ASize-1 do
begin
if X[i] > X[j] then // swap
begin
value := X[i];
X[i] := X[j];
X[j] := value;
end;
end;
end;
if ASize > 2 then
begin
midpt := ASize div 2;
if 2 * midpt = ASize then // even no. of values
begin
value := (X[midpt-1] + X[midpt]) / 2;
end else
value := X[midpt]; // odd no. of values
Median := value;
end else
if ASize = 2 then
Median := (X[0] + X[1]) / 2;
Result := Median;
end;
procedure TResistanceLineForm.PlotXY(var Xpoints, Ypoints, UpConf, LowConf: DblDyneVec;
ConfBand, XMean, YMean, R, Slope, Intercept: double;
Xmax, Xmin, Ymax, Ymin: double; N, PlotNo: integer);
var
i, xpos, ypos, hleft, hright, vtop, vbottom, imagewide: integer;
vhi, hwide, offset, strhi, imagehi: integer;
valincr, Yvalue, Xvalue: double;
Title: string;
YU, YL, XU, XL: double;
begin
BlankFrm.Image1.Canvas.Clear;
if PlotNo = 1 then
begin
Title := 'X versus Y PLOT Using File: ' + OS3MainFrm.FileNameEdit.Text;
BlankFrm.Caption := Title;
end
else
begin
Title := 'Median Plot for three groups';
BlankFrm.Caption := Title;
end;
imagewide := BlankFrm.Image1.Width;
imagehi := BlankFrm.Image1.Height;
vtop := 40;
vbottom := round(imagehi) - 80;
vhi := vbottom - vtop;
hleft := 100;
hright := imagewide - 80;
hwide := hright - hleft;
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
BlankFrm.Image1.Canvas.Brush.Color := clWhite;
// Draw chart border
BlankFrm.Image1.Canvas.Rectangle(0,0,imagewide,imagehi);
// draw Means
if MeansChk.Checked then
begin
ypos := round(vhi * ( (Ymax - Ymean) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := hleft;
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
xpos := hright;
BlankFrm.Image1.Canvas.Pen.Color := clGreen;
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
Title := 'MEAN ';
Title := Title + YEdit.Text;
strhi := BlankFrm.Image1.Canvas.TextHeight(Title);
ypos := ypos - strhi div 2;
BlankFrm.Image1.Canvas.Brush.Color := clWhite;
BlankFrm.Image1.Canvas.TextOut(xpos,ypos,Title);
xpos := round(hwide * ( (Xmean - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
ypos := vtop;
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
ypos := vbottom;
BlankFrm.Image1.Canvas.Pen.Color := clGreen;
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
Title := 'MEAN ';
Title := Title + XEdit.Text;
strhi := BlankFrm.Image1.Canvas.TextWidth(Title);
xpos := xpos - strhi div 2;
ypos := vtop - BlankFrm.Image1.Canvas.TextHeight(Title);
BlankFrm.Image1.Canvas.Brush.Color := clWhite;
BlankFrm.Image1.Canvas.TextOut(xpos,ypos,Title);
end;
// draw slope line
if LineChk.Checked then
begin
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
Yvalue := (Xpoints[0] * slope) + intercept; // predicted score
ypos := round(vhi * ( (Ymax - Yvalue) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := round(hwide * ( (Xpoints[0]- Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
Yvalue := (Xpoints[N-1] * slope) + intercept; // predicted score
ypos := round(vhi * ( (Ymax - Yvalue) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := round(hwide * ( (Xpoints[N-1] - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
end;
// draw horizontal axis
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
BlankFrm.Image1.Canvas.MoveTo(hleft,vbottom);
BlankFrm.Image1.Canvas.LineTo(hright,vbottom);
valincr := (Xmax - Xmin) / 10.0;
for i := 1 to 11 do
begin
ypos := vbottom;
Xvalue := Xmin + valincr * (i - 1);
xpos := round(hwide * ((Xvalue - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
ypos := ypos + 10;
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
Title := format('%.2f',[Xvalue]);
offset := BlankFrm.Image1.Canvas.TextWidth(Title) div 2;
xpos := xpos - offset;
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
BlankFrm.Image1.Canvas.TextOut(xpos,ypos,Title);
end;
if PlotNo = 1 then
begin
xpos := hleft + (hwide div 2) - (BlankFrm.Image1.Canvas.TextWidth(XEdit.Text) div 2);
ypos := vbottom + 20;
BlankFrm.Image1.Canvas.TextOut(xpos,ypos,XEdit.Text);
Title := format('R(X,Y) = %.3f, Slope = %.2f, Intercept = %.2f',
[R,Slope,Intercept]);
xpos := hleft + (hwide div 2) - (BlankFrm.Image1.Canvas.TextWidth(Title) div 2);
ypos := ypos + 15;
BlankFrm.Image1.Canvas.TextOut(xpos,ypos,Title);
end;
// Draw vertical axis
Title := YEdit.Text;
xpos := hleft - BlankFrm.Image1.Canvas.TextWidth(Title) div 2;
ypos := vtop - BlankFrm.Image1.Canvas.TextHeight(Title) - 10;
BlankFrm.Image1.Canvas.TextOut(xpos,ypos,YEdit.Text);
xpos := hleft;
ypos := vtop;
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
ypos := vbottom;
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
valincr := (Ymax - Ymin) / 10.0;
for i := 1 to 11 do
begin
Title := format('%.2f',[Ymax - ((i-1)*valincr)]);
strhi := BlankFrm.Image1.Canvas.TextHeight(Title);
xpos := hLeft - 20 - BlankFrm.Image1.Canvas.TextWidth(Title); //10;
Yvalue := Ymax - (valincr * (i-1));
ypos := round(vhi * ( (Ymax - Yvalue) / (Ymax - Ymin)));
ypos := ypos + vtop - strhi div 2;
BlankFrm.Image1.Canvas.TextOut(xpos,ypos,Title);
xpos := hleft;
ypos := ypos + strhi div 2;
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
xpos := hleft - 10;
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
end;
// draw points for x and y pairs
for i := 0 to N-1 do
begin
ypos := round(vhi * ( (Ymax - Ypoints[i]) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := round(hwide * ( (Xpoints[i] - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
BlankFrm.Image1.Canvas.Brush.Color := clYellow;
BlankFrm.Image1.Canvas.Brush.Style := bsSolid;
BlankFrm.Image1.Canvas.Pen.Color := clNavy;
BlankFrm.Image1.Canvas.Ellipse(xpos,ypos,xpos+5,ypos+5);
if ((PlotNo = 2) and (i = 0)) then
begin
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
BlankFrm.Image1.Canvas.TextOut(xpos,ypos,'M1');
end;
if ((PlotNo = 2) and (i > 0)) then
begin
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
Title := format('M%d',[i+1]);
BlankFrm.Image1.Canvas.TextOut(xpos,ypos,Title);
end;
end;
if ((PlotNo = 2) and (i > 0)) then
begin // draw slope line
BlankFrm.Image1.Canvas.Pen.Color := clRed;
ypos := round(vhi * ( (Ymax - Ypoints[0]) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := round(hwide * ( (Xpoints[0] - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
YL := Ypoints[0];
XL := xpoints[0];
ypos := round(vhi * ( (Ymax - Ypoints[2]) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := round(hwide * ( (Xpoints[2] - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
YU := Ypoints[2];
XU := xpoints[2];
slope := (YU - YL) / (XU - XL);
ypos := vbottom + 20;
BlankFrm.Image1.Canvas.Brush.Color := clYellow;
Title := format('Slope = %.2f',[Slope]);
xpos := hleft + (hwide div 2) - (BlankFrm.Image1.Canvas.TextWidth(Title) div 2);
ypos := ypos + 15;
BlankFrm.Image1.Canvas.TextOut(xpos,ypos,Title);
end;
// draw confidence bands if requested
if ConfBand <> 0.0 then
begin
BlankFrm.Image1.Canvas.Pen.Color := clRed;
ypos := round(vhi * ((Ymax - UpConf[1]) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := round(hwide * ( (Xpoints[0] - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
for i := 2 to N do
begin
ypos := round(vhi * ((Ymax - UpConf[i]) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := round(hwide * ( (Xpoints[i-1] - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
end;
ypos := round(vhi * ((Ymax - lowConf[1]) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := round(hwide * ( (Xpoints[0] - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
for i := 2 to N do
begin
ypos := round(vhi * ((Ymax - lowConf[i]) / (Ymax - Ymin)));
ypos := ypos + vtop;
xpos := round(hwide * ( (Xpoints[i-1] - Xmin) / (Xmax - Xmin)));
xpos := xpos + hleft;
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
end;
end;
BlankFrm.ShowModal;
end;
procedure TResistanceLineForm.UpdateBtnStates;
begin
XInBtn.Enabled := (VarList.ItemIndex > -1) and (XEdit.Text = '');
YInBtn.Enabled := (VarList.ItemIndex > -1) and (YEdit.Text = '');
XOutBtn.Enabled := (XEdit.Text <> '');
YOutBtn.Enabled := (YEdit.Text <> '');
end;
procedure TResistanceLineForm.VarListSelectionChange(Sender: TObject;
User: boolean);
begin
UpdateBtnStates;
end;
initialization
{$I resistancelineunit.lrs}
end.

View File

@ -0,0 +1,416 @@
object Rot3DFrm: TRot3DFrm
Left = 358
Height = 527
Top = 153
Width = 710
Caption = 'Three Dimension Rotation'
ClientHeight = 527
ClientWidth = 710
OnActivate = FormActivate
OnCreate = FormCreate
OnDestroy = FormDestroy
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Label1: TLabel
AnchorSideLeft.Control = VarList
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Owner
Left = 561
Height = 15
Top = 8
Width = 102
BorderSpacing.Top = 8
Caption = 'Click the X, Y and Z'
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = VarList
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
Left = 564
Height = 15
Top = 23
Width = 97
Caption = 'Variables to Rotate'
ParentColor = False
end
object Label3: TLabel
AnchorSideLeft.Control = XScroll
AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = Label6
Left = 530
Height = 15
Top = 188
Width = 7
Anchors = [akLeft, akBottom]
Caption = 'X'
ParentColor = False
end
object Label4: TLabel
AnchorSideLeft.Control = YScroll
AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = Label7
Left = 609
Height = 15
Top = 188
Width = 7
Anchors = [akLeft, akBottom]
Caption = 'Y'
ParentColor = False
end
object Label5: TLabel
AnchorSideLeft.Control = ZScroll
AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = Label8
Left = 689
Height = 15
Top = 188
Width = 7
Anchors = [akLeft, akBottom]
Caption = 'Z'
ParentColor = False
end
object Label6: TLabel
AnchorSideLeft.Control = XScroll
AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = XScroll
Left = 525
Height = 15
Top = 203
Width = 17
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 4
Caption = '-90'
ParentColor = False
end
object Label7: TLabel
AnchorSideLeft.Control = YScroll
AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = YScroll
Left = 604
Height = 15
Top = 203
Width = 17
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 4
Caption = '-90'
ParentColor = False
end
object Label8: TLabel
AnchorSideLeft.Control = ZScroll
AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = ZScroll
Left = 684
Height = 15
Top = 203
Width = 17
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 4
Caption = '-90'
ParentColor = False
end
object Label9: TLabel
AnchorSideLeft.Control = XScroll
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Label10
Left = 527
Height = 15
Top = 417
Width = 12
Caption = '90'
ParentColor = False
end
object Label10: TLabel
AnchorSideLeft.Control = YScroll
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = YScroll
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = Label12
Left = 606
Height = 15
Top = 417
Width = 12
Anchors = [akLeft, akBottom]
BorderSpacing.Top = 4
Caption = '90'
ParentColor = False
end
object Label11: TLabel
AnchorSideLeft.Control = ZScroll
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Label10
Left = 686
Height = 15
Top = 417
Width = 12
Caption = '90'
ParentColor = False
end
object Label12: TLabel
AnchorSideLeft.Control = YScroll
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Label10
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = YDegEdit
Left = 591
Height = 15
Top = 432
Width = 42
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 16
Caption = 'Degrees'
ParentColor = False
end
object Label13: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = XEdit
AnchorSideTop.Side = asrCenter
Left = 8
Height = 15
Top = 499
Width = 7
BorderSpacing.Left = 8
Caption = 'X'
ParentColor = False
end
object Label14: TLabel
AnchorSideLeft.Control = XEdit
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = YEdit
AnchorSideTop.Side = asrCenter
Left = 104
Height = 15
Top = 499
Width = 7
BorderSpacing.Left = 24
Caption = 'Y'
ParentColor = False
end
object Label15: TLabel
AnchorSideLeft.Control = YEdit
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ZEdit
AnchorSideTop.Side = asrCenter
Left = 200
Height = 15
Top = 499
Width = 7
BorderSpacing.Left = 24
Caption = 'Z'
ParentColor = False
end
object Image1: TImage
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = VarList
AnchorSideBottom.Control = CloseBtn
Left = 8
Height = 478
Top = 8
Width = 506
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
end
object VarList: TListBox
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Label4
Left = 522
Height = 140
Top = 40
Width = 180
Anchors = [akTop, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
ItemHeight = 0
OnClick = VarListClick
TabOrder = 0
end
object XScroll: TScrollBar
AnchorSideLeft.Control = VarList
AnchorSideBottom.Control = YScroll
AnchorSideBottom.Side = asrBottom
Left = 522
Height = 191
Top = 222
Width = 22
Anchors = [akLeft, akBottom]
Kind = sbVertical
PageSize = 0
TabOrder = 1
OnScroll = XScrollScroll
end
object YScroll: TScrollBar
AnchorSideLeft.Control = VarList
AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = Label10
Left = 601
Height = 191
Top = 222
Width = 22
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 4
Kind = sbVertical
PageSize = 0
TabOrder = 2
OnScroll = YScrollScroll
end
object ZScroll: TScrollBar
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = YScroll
AnchorSideBottom.Side = asrBottom
Left = 683
Height = 191
Top = 222
Width = 19
Anchors = [akRight, akBottom]
BorderSpacing.Right = 8
Kind = sbVertical
PageSize = 0
TabOrder = 3
OnScroll = ZScrollScroll
end
object XDegEdit: TEdit
AnchorSideLeft.Control = XScroll
AnchorSideTop.Control = YDegEdit
AnchorSideBottom.Control = CloseBtn
Left = 522
Height = 23
Top = 463
Width = 35
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 8
TabOrder = 4
Text = 'XDegEdit'
end
object YDegEdit: TEdit
AnchorSideLeft.Control = YScroll
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = XDegEdit
Left = 595
Height = 23
Top = 463
Width = 35
TabOrder = 5
Text = 'XDegEdit'
end
object ZDegEdit: TEdit
AnchorSideTop.Control = XDegEdit
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 667
Height = 23
Top = 463
Width = 35
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
TabOrder = 6
Text = 'XDegEdit'
end
object XEdit: TEdit
AnchorSideLeft.Control = Label13
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CloseBtn
AnchorSideTop.Side = asrCenter
Left = 23
Height = 23
Top = 495
Width = 57
BorderSpacing.Left = 8
TabOrder = 7
Text = 'XEdit'
end
object YEdit: TEdit
AnchorSideLeft.Control = Label14
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CloseBtn
AnchorSideTop.Side = asrCenter
Left = 119
Height = 23
Top = 495
Width = 57
BorderSpacing.Left = 8
TabOrder = 8
Text = 'YEdit'
end
object ZEdit: TEdit
AnchorSideLeft.Control = Label15
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CloseBtn
AnchorSideTop.Side = asrCenter
Left = 215
Height = 23
Top = 495
Width = 56
BorderSpacing.Left = 8
TabOrder = 9
Text = 'ZEdit'
end
object ResetBtn: TButton
AnchorSideRight.Control = PrintBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 526
Height = 25
Top = 494
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 10
end
object PrintBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 588
Height = 25
Top = 494
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Print'
OnClick = PrintBtnClick
TabOrder = 11
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 647
Height = 25
Top = 494
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 12
end
object PrintDialog: TPrintDialog
left = 320
top = 304
end
object PrinterSetupDialog1: TPrinterSetupDialog
left = 184
top = 304
end
end

View File

@ -0,0 +1,592 @@
unit Rot3dUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, Printers, PrintersDlgs,
MainUnit, Globals, DataProcs;
type
{ TRot3DFrm }
TRot3DFrm = class(TForm)
Image1: TImage;
PrintDialog: TPrintDialog;
PrinterSetupDialog1: TPrinterSetupDialog;
ResetBtn: TButton;
PrintBtn: TButton;
CloseBtn: TButton;
ZEdit: TEdit;
Label15: TLabel;
YEdit: TEdit;
Label14: TLabel;
XEdit: TEdit;
Label13: TLabel;
XDegEdit: TEdit;
Label1: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
XScroll: TScrollBar;
YScroll: TScrollBar;
ZScroll: TScrollBar;
VarList: TListBox;
YDegEdit: TEdit;
ZDegEdit: TEdit;
procedure CancelBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure PrintBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure VarListClick(Sender: TObject);
procedure XScrollScroll(Sender: TObject; ScrollCode: TScrollCode;
var ScrollPos: Integer);
procedure YScrollScroll(Sender: TObject; ScrollCode: TScrollCode;
var ScrollPos: Integer);
procedure ZScrollScroll(Sender: TObject; ScrollCode: TScrollCode;
var ScrollPos: Integer);
private
{ private declarations }
DXmax, DXmin, DYmax, DYmin : integer;
WXleft, WXright, WYtop, WYbottom, RX, RY, RZ : double;
SINRX, COSRX, SINRY, COSRY, SINRZ, COSRZ : double;
GridColX, GridColY, GridColZ : integer;
degX, degY, degZ : double;
XScaled : DblDyneVec;
YScaled : DblDyneVec;
ZScaled : DblDyneVec;
procedure Rotate(Sender: TObject);
function DegToRad(deg : double; Sender: TObject) : double;
function World3DToWorld2D(p : POINT3D; Sender: TObject) : POINT3D;
function World2DToDevice(p :POINT3D; Sender: TObject) : POINTint;
procedure DrawPoint( p1 : POINT3D; Sender: TObject);
procedure DrawLine(p1, p2 : POINT3D; Sender: TObject);
procedure DrawAxis(Sender: TObject);
procedure SetAxesAngles(rx1, ry1, rz1 : double; Sender: TObject);
procedure ScaleValues(Sender: TObject);
procedure EraseAxis(Sender: TObject);
public
{ public declarations }
end;
var
Rot3DFrm: TRot3DFrm;
implementation
uses
Math;
{ TRot3DFrm }
procedure TRot3DFrm.ResetBtnClick(Sender: TObject);
var i : integer;
begin
VarList.Items.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
XScroll.Position := 0;
YScroll.Position := 0;
ZScroll.Position := 0;
// set device limits
DXmin := 36;
DXmax := 436;
DYmin := 36;
DYmax := 436;
// set world limits
WXleft := -1.0;
WYbottom := -1.0;
WXright := 1.0;
WYtop := 1.0;
XDegEdit.Text := '0';
YDegEdit.Text := '0';
ZDegEdit.Text := '0';
XEdit.Text := '';
YEdit.Text := '';
ZEdit.Text := '';
end;
procedure TRot3DFrm.VarListClick(Sender: TObject);
var
i, index : integer;
Xvar, Yvar, Zvar : string;
begin
index := VarList.ItemIndex;
if XEdit.Text = '' then
begin
XEdit.Text := VarList.Items.Strings[index];
exit;
end;
if YEdit.Text = '' then
begin
YEdit.Text := VarList.Items.Strings[index];
exit;
end;
ZEdit.Text := VarList.Items.Strings[index];
// Get column no.s of selected variables
Xvar := XEdit.Text;
Yvar := YEdit.Text;
Zvar := ZEdit.Text;
for i := 1 to NoVariables do
begin
if Xvar = OS3MainFrm.DataGrid.Cells[i,0] then GridColX := i;
if Yvar = OS3MainFrm.DataGrid.Cells[i,0] then GridColY := i;
if Zvar = OS3MainFrm.DataGrid.Cells[i,0] then GridColZ := i;
end;
ScaleValues(self); // get scaled X, y and Z values (-1.0 to 1.0)
XScroll.Position := 20;
YScroll.Position := -15;
ZScroll.Position := -5;
Canvas.Pen.Color := clBlack;
Rotate(self);
end;
procedure TRot3DFrm.XScrollScroll(Sender: TObject; ScrollCode: TScrollCode;
var ScrollPos: Integer);
begin
Rotate(self);
end;
procedure TRot3DFrm.YScrollScroll(Sender: TObject; ScrollCode: TScrollCode;
var ScrollPos: Integer);
begin
Rotate(self);
end;
procedure TRot3DFrm.ZScrollScroll(Sender: TObject; ScrollCode: TScrollCode;
var ScrollPos: Integer);
begin
Rotate(self);
end;
procedure TRot3DFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TRot3DFrm.PrintBtnClick(Sender: TObject);
var
labelstr : string;
p1, p2, p, pa, pb : POINT3D;
p11, p22 : POINTint;
i, t, X : integer;
offset, Clwidth, Clheight : double;
begin
if not PrintDialog.Execute then
exit;
labelstr := '3D PLOT';
Clwidth := Printer.PageWidth;
Clheight := Clwidth;
offset := Clwidth / 20.0;
Clwidth := Clwidth - (Clwidth / 20.0);
Printer.BeginDoc;
try
// First, draw axis
p1.x := -1;
p1.y := 0;
p1.z := 0;
p2.x := 1;
p2.y := 0;
p2.z := 0;
Printer.Canvas.Pen.Color := clRed;
//draw a 3d line
p1.z := -p1.z;
p2.z := -p2.z;
pa := World3DToWorld2D(p1,self);
pb := World3DToWorld2D(p2,self);
// scale it up
p11.x := round((WXleft-pa.x)*(Clwidth-offset) / (WXleft - WXright)+ offset + 0.5);
p11.y := round((WYtop-pa.y)*(Clheight-offset) / (WYtop-WYbottom) + offset + 0.5);
p22.x := round((WXleft-pb.x)*(Clwidth-offset) / (WXleft - WXright) + offset + 0.5);
p22.y := round((WYtop-pb.y)*(Clheight-offset) / (WYtop-WYbottom) + offset + 0.5);
Printer.Canvas.MoveTo(p11.x,p11.y);
Printer.Canvas.LineTo(p22.x,p22.y);
p1.x := 0;
p1.y := -1;
p2.x := 0;
p2.y := 1;
p2.z := 0;
Printer.Canvas.Pen.Color := clBlue;
//draw a 3d line
p1.z := -p1.z;
p2.z := -p2.z;
pa := World3DToWorld2D(p1,self);
pb := World3DToWorld2D(p2,self);
// scale it up
p11.x := round((WXleft-pa.x)*(Clwidth-offset) / (WXleft - WXright)+ offset + 0.5);
p11.y := round((WYtop-pa.y)*(Clheight-offset) / (WYtop-WYbottom) + offset + 0.5);
p22.x := round((WXleft-pb.x)*(Clwidth-offset) / (WXleft - WXright) + offset + 0.5);
p22.y := round((WYtop-pb.y)*(Clheight-offset) / (WYtop-WYbottom) + offset + 0.5);
Printer.Canvas.MoveTo(p11.x,p11.y);
Printer.Canvas.LineTo(p22.x,p22.y);
p1.y := 0;
p1.z := -1;
p2.x := 0;
p2.y := 0;
p2.z := 1;
Printer.Canvas.Pen.Color := clGreen;
//draw a 3d line
p1.z := -p1.z;
p2.z := -p2.z;
pa := World3DToWorld2D(p1,self);
pb := World3DToWorld2D(p2,self);
// scale it up
p11.x := round((WXleft-pa.x)*(Clwidth-offset) / (WXleft - WXright)+ offset + 0.5);
p11.y := round((WYtop-pa.y)*(Clheight-offset) / (WYtop-WYbottom) + offset + 0.5);
p22.x := round((WXleft-pb.x)*(Clwidth-offset) / (WXleft - WXright) + offset + 0.5);
p22.y := round((WYtop-pb.y)*(Clheight-offset) / (WYtop-WYbottom) + offset + 0.5);
Printer.Canvas.MoveTo(p11.x,p11.y);
Printer.Canvas.LineTo(p22.x,p22.y);
Printer.Canvas.Pen.Color := clBlack;
//Now, plot points
for i := 1 to NoCases do
begin
p.x := XScaled[i];
p.y := YScaled[i];
p.z := ZScaled[i];
// draws a 3d point
p.z := -p.z;
pa := World3DToWorld2D(p,self);
// scale it up
p11.x := round((WXleft-pa.x)*(Clwidth-offset) / (WXleft - WXright) + offset + 0.5);
p11.y := round((WYtop-pa.y)*(Clheight-offset) / (WYtop-WYbottom) + offset + 0.5);
Printer.Canvas.Rectangle(p11.x - 4,p11.y - 4,p11.x + 4, p11.y + 4);
end;
// Print Heading
t := Printer.Canvas.TextWidth(labelstr);
X := round((Clwidth / 2.0) - (t / 2.0));
Printer.Canvas.TextOut(X,0,labelstr);
labelstr := 'RED := X, BLUE := Y, GREEN := Z';
t := Printer.Canvas.TextWidth(labelstr);
X := round((Clwidth / 2.0) - (t / 2.0));
Printer.Canvas.TextOut(X,round(Clheight),labelstr);
labelstr := XEdit.Text;
labelstr := labelstr + ' ';
labelstr := labelstr + YEdit.Text;
labelstr := labelstr + ' ';
labelstr := labelstr + ZEdit.Text;
t := Printer.Canvas.TextWidth(labelstr);
X := round((Clwidth / 2.0) - (t / 2.0));
Printer.Canvas.TextOut(X,round(Clheight+40.0),labelstr);
labelstr := 'ROTATION: X deg. := ';
labelstr := labelstr + XDegEdit.Text;
labelstr := labelstr + ' Y deg. := ';
labelstr := labelstr + YDegEdit.Text;
labelstr := labelstr + ' Z deg. := ';
labelstr := labelstr + ZDegEdit.Text;
t := Printer.Canvas.TextWidth(labelstr);
X := round((Clwidth / 2.0) - (t / 2));
Printer.Canvas.TextOut(X,round(Clheight+80.0),labelstr);
finally
Printer.EndDoc; // finish printing
end;
end;
procedure TRot3DFrm.CancelBtnClick(Sender: TObject);
begin
ZScaled := nil;
YScaled := nil;
XScaled := nil;
Close;
end;
procedure TRot3DFrm.Rotate(Sender: TObject);
var
p: POINT3D;
i: integer;
begin
Image1.Canvas.Brush.Style := bsSolid;
Image1.Canvas.Brush.Color := clLtGray;
Image1.Canvas.FillRect(0, 0, Image1.Width, Image1.Height);
Image1.Canvas.Brush.Color := clWhite;
Image1.Canvas.Pen.Color := clBlack;
Image1.Canvas.Rectangle(20,20,460,460);
//First, erase current points
Image1.Canvas.Pen.Color := clWhite;
Image1.Canvas.Brush.Color := clWhite;
for i := 1 to NoCases do
begin
p.x := XScaled[i];
p.y := YScaled[i];
p.z := ZScaled[i];
DrawPoint(p,self);
end;
EraseAxis(self);
Image1.Canvas.Brush.Color := clBlack;
Image1.Canvas.Pen.Color := clBlack;
degX := XScroll.Position;
degY := YScroll.Position;
degZ := ZScroll.Position;
XDegEdit.Text := IntToStr(XScroll.Position);
YDegEdit.Text := IntToStr(YScroll.Position);
ZDegEdit.Text := IntToStr(ZScroll.Position);
SetAxesAngles(degX, degY, degZ,self);
DrawAxis(self);
for i := 1 to NoCases do
begin
p.x := XScaled[i];
p.y := YScaled[i];
p.z := ZScaled[i];
DrawPoint(p,self);
end;
end;
//---------------------------------------------------------------------------
function TRot3DFrm.DegToRad(deg : double; Sender: TObject) : double;
begin
Result := deg * PI / 180.0;
end;
//---------------------------------------------------------------------------
function TRot3DFrm.World3DToWorld2D(p : POINT3D; Sender: TObject) : POINT3D;
var
ptemp : POINT3D;
begin
ptemp := p;
if RX <> 0.0 then begin
ptemp.x := p.x;
ptemp.y := COSRX * p.y - SINRX * p.z;
ptemp.z := SINRX * p.y + COSRX * p.z;
p := ptemp;
end;
if RY <> 0.0 then begin
ptemp.x := COSRY * p.x + SINRY * p.z;
ptemp.y := p.y;
ptemp.z := SINRY * p.x + COSRY * p.z;
p := ptemp;
end;
if RZ <> 0.0 then begin
ptemp.x := COSRZ * p.x - SINRZ * p.y;
ptemp.y := SINRZ * p.x + COSRZ * p.y;
ptemp.z := p.z;
end;
if abs(ptemp.x) < TOL then ptemp.x := 0.0;
if abs(ptemp.y) < TOL then ptemp.y := 0.0;
if abs(ptemp.z) < TOL then ptemp.z := 0.0;
Result := ptemp;
end;
//---------------------------------------------------------------------------
function TRot3DFrm.World2DToDevice(p :POINT3D; Sender: TObject) : POINTint;
var
ptemp : POINTint;
begin
ptemp.x := round((WXleft - p.x) * (DXmax - DXmin) / (WXleft - WXright) + DXmin + 0.5);
ptemp.y := round((WYtop - p.y) * (DYmax - DYmin) / (WYtop - WYbottom) + DYmin + 0.5);
Result := ptemp;
end;
//---------------------------------------------------------------------------
procedure TRot3DFrm.DrawPoint( p1 : POINT3D; Sender: TObject);
var
p2 : POINTint;
begin
// draws a 3d point
p1.z := -p1.z;
p2 := World2DToDevice(World3DToWorld2D(p1,self),self);
Image1.Canvas.Rectangle(p2.x - 2,p2.y - 2,p2.x + 2, p2.y + 2);
end;
//---------------------------------------------------------------------------
procedure TRot3DFrm.DrawLine(p1, p2 : POINT3D; Sender: TObject);
var
p11, p22 : POINTint;
begin
//draws a 3d line
p1.z := -p1.z;
p2.z := -p2.z;
p11 := World2DToDevice(World3DToWorld2D(p1,self),self);
p22 := World2DToDevice(World3DToWorld2D(p2,self),self);
Image1.Canvas.MoveTo(p11.x,p11.y);
Image1.Canvas.LineTo(p22.x,p22.y);
end;
//---------------------------------------------------------------------------
procedure TRot3DFrm.DrawAxis(Sender: TObject);
var
p1, p2 : POINT3D;
begin
p1.x := -1;
p1.y := 0;
p1.z := 0;
p2.x := 1;
p2.y := 0;
p2.z := 0;
Image1.Canvas.Pen.Color := clRed;
drawline(p1,p2,self);
p1.x := 0;
p1.y := -1;
p2.x := 0;
p2.y := 1;
p2.z := 0;
Image1.Canvas.Pen.Color := clBlue;
drawline(p1,p2,self);
p1.y := 0;
p1.z := -1;
p2.x := 0;
p2.y := 0;
p2.z := 1;
Image1.Canvas.Pen.Color := clGreen;
drawline(p1,p2,self);
Image1.Canvas.Pen.Color := clWhite;
end;
//---------------------------------------------------------------------------
procedure TRot3DFrm.SetAxesAngles(rx1, ry1, rz1 : double; Sender: TObject);
begin
RX := DegToRad(rx1,self);
RY := DegToRad(ry1,self);
RZ := DegToRad(rz1,self);
COSRX := cos(RX);
SINRX := sin(RX);
COSRY := cos(RY);
SINRY := sin(RY);
COSRZ := cos(RZ);
SINRZ := sin(RZ);
end;
//---------------------------------------------------------------------------
procedure TRot3DFrm.ScaleValues(Sender: TObject);
var
Xmax, Ymax, Zmax, Xmin, Ymin, Zmin, value, prop : double;
i, NoSelected : integer;
ColNoSelected : IntDyneVec;
begin
// This routine scales the X, Y and Z values in the grid to new
// values ranging from -1 to 1 for each. The arrays of scaled
// values are pointed to by the private float pointers XScaled,
// YScaled and ZScaled;
SetLength(ColNoSelected,NoVariables);
SetLength(XScaled,NoCases+1);
SetLength(YScaled,NoCases+1);
SetLength(ZScaled,NoCases+1);
ColNoSelected[0] := GridColX;
ColNoSelected[1] := GridColY;
ColNoSelected[2] := GridColZ;
NoSelected := 3;
Xmax := StrToFloat(OS3MainFrm.DataGrid.Cells[GridColX,1]);
Xmin := Xmax;
Ymin := StrToFloat(OS3MainFrm.DataGrid.Cells[GridColY,1]);
Ymax := Ymin;
Zmax := StrToFloat(OS3MainFrm.DataGrid.Cells[GridColZ,1]);
Zmin := Zmax;
for i := 1 to NoCases do
begin
if Not GoodRecord(i,NoSelected,ColNoSelected) then continue;
value := StrToFloat(OS3MainFrm.DataGrid.Cells[GridColX,i]);
if (value > Xmax) then Xmax := value;
if (value < Xmin) then Xmin := value;
value := StrToFloat(OS3MainFrm.DataGrid.Cells[GridColY,i]);
if (value > Ymax) then Ymax := value;
if (value < Ymin) then Ymin := value;
value := StrToFloat(OS3MainFrm.DataGrid.Cells[GridColZ,i]);
if (value > Zmax) then Zmax := value;
if (value < Zmin) then Zmin := value;
end;
// now scale values
for i := 1 to NoCases do
begin
if Not GoodRecord(i,NoSelected,ColNoSelected) then continue;
value := StrTofloat(OS3MainFrm.DataGrid.Cells[GridColX,i]);
prop := (Xmax - value) / (Xmax - Xmin);
XScaled[i] := prop - 0.5; //scale between -1 and +1
value := StrToFloat(OS3MainFrm.DataGrid.Cells[GridColY,i]);
prop := (Ymax - value) / (Ymax - Ymin);
YScaled[i] := prop - 0.5;
value := StrToFloat(OS3MainFrm.DataGrid.Cells[GridColZ,i]);
prop := (Zmax - value) / (Zmax - Zmin);
ZScaled[i] := prop - 0.5;
end;
ColNoSelected := nil;
end;
//-------------------------------------------------------------------
procedure TRot3DFrm.EraseAxis(Sender: TObject);
var
p1, p2 : POINT3D;
begin
p1.x := -1;
p1.y := 0;
p1.z := 0;
p2.x := 1;
p2.y := 0;
p2.z := 0;
Image1.Canvas.Pen.Color := clWhite;
drawline(p1,p2,self);
p1.x := 0;
p1.y := -1;
p2.x := 0;
p2.y := 1;
p2.z := 0;
drawline(p1,p2,self);
p1.y := 0;
p1.z := -1;
p2.x := 0;
p2.y := 0;
p2.z := 1;
drawline(p1,p2,self);
end;
procedure TRot3DFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
w := MaxValue([ResetBtn.Width, PrintBtn.Width, CloseBtn.Width]);
ResetBtn.Constraints.MinWidth := w;
PrintBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
end;
procedure TRot3DFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
end;
procedure TRot3DFrm.FormDestroy(Sender: TObject);
begin
ZScaled := nil;
YScaled := nil;
XScaled := nil;
end;
initialization
{$I rot3dunit.lrs}
end.

View File

@ -0,0 +1,215 @@
object DataSmoothingForm: TDataSmoothingForm
Left = 554
Height = 388
Top = 284
Width = 372
AutoSize = True
Caption = 'Smooth Data'
ClientHeight = 388
ClientWidth = 372
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = ResetBtnClick
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Label1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Memo1
AnchorSideTop.Side = asrBottom
Left = 8
Height = 15
Top = 80
Width = 49
BorderSpacing.Left = 8
BorderSpacing.Top = 12
Caption = 'Variables:'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = VarInBtn
AnchorSideBottom.Control = RepeatChk
Left = 8
Height = 211
Top = 97
Width = 184
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
Constraints.MinHeight = 200
ItemHeight = 0
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object VarInBtn: TBitBtn
AnchorSideTop.Control = VarList
AnchorSideRight.Control = SelectedEdit
Left = 200
Height = 28
Top = 97
Width = 28
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = VarInBtnClick
Spacing = 0
TabOrder = 1
end
object VarOutBtn: TBitBtn
AnchorSideLeft.Control = VarInBtn
AnchorSideTop.Control = VarInBtn
AnchorSideTop.Side = asrBottom
Left = 200
Height = 28
Top = 129
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = VarOutBtnClick
Spacing = 0
TabOrder = 2
end
object Label2: TLabel
AnchorSideLeft.Control = SelectedEdit
AnchorSideBottom.Control = SelectedEdit
Left = 236
Height = 15
Top = 105
Width = 47
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Selected:'
ParentColor = False
end
object SelectedEdit: TEdit
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = VarOutBtn
AnchorSideBottom.Side = asrBottom
Left = 236
Height = 23
Top = 122
Width = 128
Anchors = [akRight, akBottom]
BorderSpacing.Right = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 3
Text = 'SelectedEdit'
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 158
Height = 25
Top = 355
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Right = 9
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 4
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 221
Height = 25
Top = 355
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 5
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 305
Height = 25
Top = 355
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 6
end
object RepeatChk: TCheckBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = RepeatEdit
AnchorSideTop.Side = asrCenter
AnchorSideBottom.Control = Bevel1
Left = 8
Height = 19
Top = 316
Width = 188
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Bottom = 4
Caption = 'Repeat Smoothing No. Times = '
TabOrder = 7
end
object RepeatEdit: TEdit
AnchorSideLeft.Control = RepeatChk
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = RepeatChk
AnchorSideTop.Side = asrCenter
Left = 204
Height = 23
Top = 314
Width = 32
Alignment = taRightJustify
BorderSpacing.Left = 8
TabOrder = 8
Text = '1'
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 339
Width = 372
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Bottom = 8
Shape = bsBottomLine
end
object Memo1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 8
Height = 60
Top = 8
Width = 356
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'This procedure smooths data by averaging every three data points starting with the first three to the last three. The data smoothing can be repeated multiple times. The first and last data points are unchanged.'
ParentColor = False
WordWrap = True
end
end

View File

@ -0,0 +1,177 @@
unit SmoothDataUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons, ExtCtrls,
MainUnit, Globals, DictionaryUnit;
type
{ TDataSmoothingForm }
TDataSmoothingForm = class(TForm)
Bevel1: TBevel;
Memo1: TLabel;
RepeatEdit: TEdit;
RepeatChk: TCheckBox;
ResetBtn: TButton;
ComputeBtn: TButton;
CloseBtn: TButton;
SelectedEdit: TEdit;
Label2: TLabel;
VarInBtn: TBitBtn;
VarOutBtn: TBitBtn;
Label1: TLabel;
VarList: TListBox;
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure VarInBtnClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean);
procedure VarOutBtnClick(Sender: TObject);
private
{ private declarations }
FAutoSized: Boolean;
procedure UpdateBtnStates;
public
{ public declarations }
end;
var
DataSmoothingForm: TDataSmoothingForm;
implementation
uses
Math;
{ TDataSmoothingForm }
procedure TDataSmoothingForm.ResetBtnClick(Sender: TObject);
var
i : integer;
begin
VarList.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
RepeatEdit.Text := '1';
SelectedEdit.Text := '';
UpdateBtnStates;
end;
procedure TDataSmoothingForm.ComputeBtnClick(Sender: TObject);
var
DataPts, OutPts : DblDyneVec;
avalue, avg : double;
N, Reps, i, j, VarCol : integer;
VarLabel, strvalue : string;
begin
N := NoCases;
SetLength(DataPts,N);
SetLength(OutPts,N);
Reps := StrToInt(RepeatEdit.Text);
Varlabel := SelectedEdit.Text;
for i := 1 to NoVariables do
if VarLabel = OS3MainFrm.DataGrid.Cells[i,0] then VarCol := i;
for i := 0 to N - 1 do
begin
avalue := StrToFloat(OS3MainFrm.DataGrid.Cells[VarCol,i+1]);
DataPts[i] := avalue;
end;
// repeat smoothing for number of times elected
OutPts[0] := DataPts[0];
OutPts[N-1] := DataPts[N-1];
for j := 1 to Reps do
begin
for i := 1 to N - 2 do
begin
avg := (DataPts[i-1] + DataPts[i] + DataPts[i+1]) / 3.0;
OutPts[i] := avg;
end;
if j < reps then
for i := 0 to N - 1 do DataPts[i] := OutPts[i];
end;
// create a new variable and copy smoothed data into it
strvalue := 'Smoothed' + VarLabel;
DictionaryFrm.NewVar(NoVariables+1);
DictionaryFrm.DictGrid.Cells[1,NoVariables] := strvalue;
OS3MainFrm.DataGrid.Cells[NoVariables,0] := strvalue;
for i := 0 to N - 1 do
begin
strvalue := format('%9.3f',[OutPts[i]]);
OS3MainFrm.DataGrid.Cells[NoVariables,i+1] := strvalue;
end;
// clean up
OutPts := nil;
DataPts := nil;
end;
procedure TDataSmoothingForm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
FAutoSized := True;
end;
procedure TDataSmoothingForm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
if DictionaryFrm = nil then Application.CreateForm(TDictionaryFrm, DictionaryFrm);
end;
procedure TDataSmoothingForm.VarInBtnClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (SelectedEdit.Text = '') then
begin
SelectedEdit.Text := VarList.Items.Strings[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TDataSmoothingForm.VarListSelectionChange(Sender: TObject;
User: boolean);
begin
UpdateBtnStates;
end;
procedure TDataSmoothingForm.VarOutBtnClick(Sender: TObject);
begin
if SelectedEdit.Text <> '' then
begin
VarList.Items.Add(SelectedEdit.Text);
SelectedEdit.Text := '';
end;
UpdateBtnStates;
end;
procedure TDataSmoothingForm.UpdateBtnStates;
begin
VarInBtn.Enabled := (VarList.ItemIndex > -1) and (SelectedEdit.Text = '');
VarOutBtn.Enabled := (SelectedEdit.Text <> '');
end;
initialization
{$I smoothdataunit.lrs}
end.

View File

@ -0,0 +1,247 @@
object StemLeafFrm: TStemLeafFrm
Left = 519
Height = 296
Top = 257
Width = 407
AutoSize = True
Caption = 'Stem and Leaf Analysis'
ClientHeight = 296
ClientWidth = 407
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object TestChk: TCheckBox
AnchorSideLeft.Control = Owner
AnchorSideBottom.Control = Bevel1
AnchorSideBottom.Side = asrBottom
Left = 8
Height = 19
Top = 228
Width = 202
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 8
Caption = 'Show All Scaled Values and Srrings'
TabOrder = 0
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = TestChk
Left = 8
Height = 212
Top = 8
Width = 391
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
BevelOuter = bvNone
ClientHeight = 212
ClientWidth = 391
Constraints.MinHeight = 200
TabOrder = 1
object Label1: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
Left = 0
Height = 15
Top = 0
Width = 100
Caption = 'Available Variables:'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = AllBtn
AnchorSideBottom.Control = Panel1
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 195
Top = 17
Width = 167
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Right = 8
ItemHeight = 0
MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object InBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
Left = 181
Height = 28
Top = 17
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = InBtnClick
Spacing = 0
TabOrder = 1
end
object OutBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = InBtn
AnchorSideTop.Side = asrBottom
Left = 181
Height = 28
Top = 49
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = OutBtnClick
Spacing = 0
TabOrder = 2
end
object AllBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = OutBtn
AnchorSideTop.Side = asrBottom
Left = 175
Height = 25
Top = 101
Width = 40
AutoSize = True
BorderSpacing.Top = 24
Caption = 'All'
OnClick = AllBtnClick
TabOrder = 3
end
object Label2: TLabel
AnchorSideLeft.Control = SelectList
AnchorSideTop.Control = Panel1
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 223
Height = 15
Top = 0
Width = 96
Caption = 'Selected Variables:'
ParentColor = False
end
object SelectList: TListBox
AnchorSideLeft.Control = AllBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Panel1
AnchorSideBottom.Side = asrBottom
Left = 223
Height = 195
Top = 17
Width = 168
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
ItemHeight = 0
MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 4
end
end
object CloseBtn: TButton
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 340
Height = 25
Top = 263
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 2
end
object ComputeBtn: TButton
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 256
Height = 25
Top = 263
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 3
end
object ResetBtn: TButton
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 194
Height = 25
Top = 263
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 4
end
object HelpBtn: TButton
Tag = 148
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 135
Height = 25
Top = 263
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 5
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 247
Width = 407
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
end

View File

@ -0,0 +1,430 @@
unit StemLeafUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, Buttons, Math, Clipbrd,
MainUnit, Globals, OutputUnit, DataProcs, ContextHelpUnit;
type
{ TStemLeafFrm }
TStemLeafFrm = class(TForm)
Bevel1: TBevel;
HelpBtn: TButton;
InBtn: TBitBtn;
OutBtn: TBitBtn;
AllBtn: TBitBtn;
Panel1: TPanel;
ResetBtn: TButton;
ComputeBtn: TButton;
CloseBtn: TButton;
TestChk: TCheckBox;
Label1: TLabel;
Label2: TLabel;
VarList: TListBox;
SelectList: TListBox;
procedure AllBtnClick(Sender: TObject);
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
procedure InBtnClick(Sender: TObject);
procedure OutBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean);
private
{ private declarations }
FAutoSized: Boolean;
procedure UpdateBtnStates;
public
{ public declarations }
end;
var
StemLeafFrm: TStemLeafFrm;
implementation
{ TStemLeafFrm }
procedure TStemLeafFrm.ResetBtnClick(Sender: TObject);
var
i: integer;
begin
VarList.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
SelectList.Clear;
UpdateBtnStates;
end;
procedure TStemLeafFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
end;
procedure TStemLeafFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TStemLeafFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).Tag);
end;
procedure TStemLeafFrm.AllBtnClick(Sender: TObject);
var
i: integer;
begin
for i := 0 to VarList.Items.Count-1 do
SelectList.Items.Add(VarList.Items[i]);
VarList.Clear;
UpdateBtnStates;
end;
procedure TStemLeafFrm.ComputeBtnClick(Sender: TObject);
var
i, j, k, L, ncases, noselected, largest, smallest: integer;
minsize, maxsize, stem, minstem, maxstem, bin, index: integer;
leafvalue, counter, smallcount, testvalue, largestcount: integer;
cellstring, outline, astring: string;
selected: IntDyneVec;
bins: IntDyneVec;
frequency: IntDyneVec;
ValueString: StrDyneVec;
values: DblDyneVec;
leafcount: IntDyneMat;
min, max, temp, X, stemsize: double;
lReport: TStrings;
begin
noselected := SelectList.Items.Count;
if (noselected = 0) then
begin
MessageDlg('No variables were selected.', mtError, [mbOK], 0);
exit;
end;
SetLength(selected,noselected);
SetLength(values,NoCases);
SetLength(bins,100);
SetLength(frequency,100);
SetLength(ValueString,NoCases);
SetLength(leafcount,100,10);
// Get selected variables
for i := 1 to noselected do
begin
cellstring := SelectList.Items.Strings[i-1];
for j := 1 to NoVariables do
if (cellstring = OS3MainFrm.DataGrid.Cells[j,0]) then selected[i-1] := j;
end;
lReport := TStringList.Create;
try
lReport.Add('STEM AND LEAF PLOTS');
lReport.Add('');
// Analyze each variable selected
for j := 0 to noselected - 1 do
begin
k := selected[j];
lReport.Add('Stem and Leaf Plot for variable: %s', [OS3MainFrm.DataGrid.Cells[k,0]]);
ncases := 0;
min := 1.0e308;
max := -1.0e308;
minsize := 1000;
maxsize := -1000;
// Store values of the variable
for i := 1 to NoCases do
begin
if not ValidValue(i,k) then continue;
values[ncases] := StrToFloat(OS3MainFrm.DataGrid.Cells[k,i]);
ValueString[ncases] := Trim(OS3MainFrm.DataGrid.Cells[k,i]);
if (values[ncases] < min) then min := values[ncases];
if (values[ncases] > max) then max := values[ncases];
if Length(ValueString[ncases]) > maxsize then maxsize := Length(ValueString[ncases]);
if Length(ValueString[ncases]) < minsize then minsize := Length(ValueString[ncases]);
ncases := ncases + 1;
end;
largest := ceil(max);
smallest := ceil(min);
stemsize := 1.0;
if ((largest > 0) and (largest > 10)) then
begin
while (largest > 10)do
begin
largest := largest div 10;
stemsize := stemsize * 10.0;
end;
end else
if ((largest < 0) and (smallest < -10)) then // largest value is less than 0.0
begin
while (smallest < -10)do
begin
smallest := smallest * 10;
stemsize := stemsize / 10.0;
end;
end;
// rescale values by stemsize
for i := 0 to ncases - 1 do
values[i] := values[i] / stemsize;
// multiply values by 10, round and save value divided by 10
for i := 0 to ncases - 1 do
begin
temp := floor(values[i] * 10);
temp := temp / 10.0;
values[i] := temp;
astring := format('%4.1f',[values[i]]);
ValueString[i] := astring;
end;
// get max and min stem values for creating bins for stem values
minstem := 999;
maxstem := -999;
for i := 0 to ncases - 1 do
begin
stem := floor(values[i]);
if (stem < minstem) then minstem := stem;
if (stem > maxstem) then maxstem := stem;
end;
// create arrays for stem and leaf plot
for i := 0 to 19 do
frequency[i] := 0;
// sort values into ascending order
for i := 0 to ncases-2 do
begin
for k := i+1 to ncases - 1 do
begin
if (values[i] > values[k]) then // swap values
begin
X := values[i];
values[i] := values[k];
values[k] := X;
cellstring := ValueString[i];
ValueString[i] := ValueString[k];
ValueString[k] := cellstring;
end;
end;
end;
(*
// check sizes - delete if ok
outline := format('maxsize, minsize,stemsize: %10d %10d %10.2f',[maxsize, minsize, stemsize]);
OutputFrm.RichEdit.Lines.Add(outline);
OutputFrm.ShowModal;
OutputFrm.RichEdit.Clear;
*)
if TestChk.Checked then
begin // test output
lReport.Add('value ValueString');
for i := 0 to ncases - 1 do
lReport.Add('%10.1f %s',[values[i],ValueString[i]]);
end;
lReport.Add('');
lReport.Add('Frequency Stem & Leaf');
// initialize leaf count for the bins
for i := 0 to 99 do // bins
for k := 0 to 9 do leafcount[i,k] := 0; // leafs 0 to 9
// count leafs in each bin
for i := 0 to ncases - 1 do
begin
bin := floor(values[i]); // truncate to get stem value
bin := bin - minstem; // get the bin number between 0 and 100
if (bin < 100) and (bin >= 0) then
begin
bins[bin] := floor(values[i]);
frequency[bin] := frequency[bin] + 1; // count number of stem values
end else
begin
MessageDlg('Error in bin value', mtError, [mbOK], 0);
exit;
end;
// get leaf value
astring := ValueString[i];
index := Pos('.',astring);
leafvalue := StrToInt(astring[index+1]);
if (leafvalue < 10) and (leafvalue >= 0) then
leafcount[bin,leafvalue] := leafcount[bin,leafvalue] + 1
else
begin
MessageDlg('Error in leafvalue', mtError, [mbOK], 0);
exit;
end;
end;
// get max leaf counters
largestcount := 0;
for i := 0 to 99 do // bin
begin
if frequency[i] = 0 then continue; // skip empty bins
counter := 0;
for k := 0 to 9 do // leaf counts
counter := counter + leafcount[i,k];
if counter > largestcount then
largestcount := counter;
end;
// determine leaf depth needed to get counter <= 50
if (largestcount > 50) then
begin
smallcount := 2;
testvalue := largestcount;
while (testvalue > 50) do
begin
testvalue := largestcount div smallcount;
smallcount := smallcount + 1;
end;
smallcount := smallcount - 1; // leaf depth needed to reduce line lengths to 50 or less
end else
smallcount := 1;
// rescale leafs
for i := 0 to 99 do // bin
for k := 0 to 9 do // leaf
leafcount[i,k] := leafcount[i,k] div smallcount;
// plot results
for i := 0 to 99 do
begin
if frequency[i] = 0 then continue; // skip empty bins
outline := format('%6d %3d ',[frequency[i], bins[i]]);
for k := 0 to 9 do
begin
if leafcount[i,k] = 0 then continue;
for L := 1 to leafcount[i,k] do
outline := outline + Format('%d',[k]);
end;
lReport.Add(outline);
end;
// summarize values
lReport.Add('');
lReport.Add('Stem Width: %8.3f', [stemSize]);
lReport.Add('Max. Leaf Depth: %8d', [smallcount]);
lReport.Add('Min. Value: %8.3f', [min]);
lReport.Add('Max. Value: %8.3f', [max]);
lReport.Add('No. of good cases: %8d', [ncases]);
lReport.Add('');
lReport.Add('-------------------------------------------------------------');
lReport.Add('');
end; // next jth variable
DisplayReport(lReport);
finally
lReport.Free;
frequency := nil;
bins := nil;
ValueString := nil;
values := nil;
selected := nil;
leafcount := nil;
end;
end;
procedure TStemLeafFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
HelpBtn.Constraints.MinWidth := w;
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TStemLeafFrm.InBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while i < VarList.Items.Count do
begin
if VarList.Selected[i] then
begin
SelectList.Items.Add(VarList.Items[i]);
VarList.Items.Delete(i);
i := 0;
end else
inc(i);
end;
UpdateBtnStates;
end;
procedure TStemLeafFrm.OutBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while i < SelectList.Items.Count do
begin
if SelectList.Selected[i] then
begin
VarList.Items.Add(SelectList.Items[i]);
SelectList.items.Delete(i);
end else
inc(i);
end;
UpdateBtnStates;
end;
procedure TStemLeafFrm.UpdateBtnStates;
var
lSelected: Boolean;
i: Integer;
begin
lSelected := false;
for i := 0 to VarList.Items.Count-1 do
if VarList.Selected[i] then
begin
lSelected := true;
break;
end;
InBtn.Enabled := lSelected;
lSelected := false;
for i := 0 to SelectList.Items.Count-1 do
if SelectList.Selected[i] then
begin
lSelected := true;
break;
end;
OutBtn.Enabled := lSelected;
end;
procedure TStemLeafFrm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
initialization
{$I stemleafunit.lrs}
end.

View File

@ -0,0 +1,357 @@
object XvsMultYForm: TXvsMultYForm
Left = 288
Height = 467
Top = 117
Width = 452
Caption = 'X vs Multiple Y Plot'
ClientHeight = 467
ClientWidth = 452
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = ResetBtnClick
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Label4: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = PlotTitleEdit
AnchorSideTop.Side = asrCenter
Left = 8
Height = 15
Top = 332
Width = 49
BorderSpacing.Left = 8
Caption = 'Plot Title:'
ParentColor = False
end
object PlotTitleEdit: TEdit
AnchorSideLeft.Control = Label4
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = GroupBox1
Left = 65
Height = 23
Top = 328
Width = 379
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Right = 8
TabOrder = 1
TextHint = 'Title above the chart'
end
object GroupBox1: TGroupBox
AnchorSideLeft.Control = Owner
AnchorSideBottom.Control = Bevel2
Left = 8
Height = 51
Top = 359
Width = 336
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Bottom = 8
Caption = 'Options'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 24
ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsScaleChilds
ChildSizing.EnlargeVertical = crsScaleChilds
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2
ClientHeight = 31
ClientWidth = 332
TabOrder = 2
object DescChk: TCheckBox
Left = 12
Height = 19
Top = 6
Width = 127
BorderSpacing.Left = 12
BorderSpacing.Top = 2
Caption = 'Descriptive Statistics'
Checked = True
State = cbChecked
TabOrder = 0
end
object LinesBox: TCheckBox
AnchorSideTop.Side = asrBottom
Left = 163
Height = 19
Top = 6
Width = 157
BorderSpacing.Left = 12
BorderSpacing.Top = 2
BorderSpacing.Right = 6
BorderSpacing.Bottom = 6
Caption = 'Connect Points with Lines'
TabOrder = 1
end
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Memo1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = PlotTitleEdit
Left = 8
Height = 214
Top = 106
Width = 436
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
BevelOuter = bvNone
ClientHeight = 214
ClientWidth = 436
Constraints.MinHeight = 200
TabOrder = 0
object Label1: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
Left = 0
Height = 15
Top = 0
Width = 49
Caption = 'Variables:'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = XInBtn
AnchorSideBottom.Control = Panel1
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 197
Top = 17
Width = 196
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Right = 8
ItemHeight = 0
MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object XInBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
Left = 204
Height = 28
Top = 17
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = XInBtnClick
Spacing = 0
TabOrder = 1
end
object XOutBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = XInBtn
AnchorSideTop.Side = asrBottom
Left = 204
Height = 28
Top = 49
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = XOutBtnClick
Spacing = 0
TabOrder = 2
end
object YInBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = Bevel1
Left = 204
Height = 28
Top = 133
Width = 28
Anchors = [akLeft, akBottom]
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = YInBtnClick
Spacing = 0
TabOrder = 4
end
object YOutBtn: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
Left = 204
Height = 28
Top = 165
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = YOutBtnClick
Spacing = 0
TabOrder = 5
end
object Label2: TLabel
AnchorSideLeft.Control = XEdit
AnchorSideBottom.Control = XEdit
Left = 240
Height = 15
Top = 25
Width = 54
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'X Variable:'
ParentColor = False
end
object Label3: TLabel
AnchorSideLeft.Control = YBox
AnchorSideBottom.Control = YBox
Left = 240
Height = 15
Top = 95
Width = 64
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Y Variable(s)'
ParentColor = False
end
object XEdit: TEdit
AnchorSideLeft.Control = XInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = XOutBtn
AnchorSideBottom.Side = asrBottom
Left = 240
Height = 23
Top = 42
Width = 196
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 3
Text = 'XEdit'
end
object YBox: TListBox
AnchorSideLeft.Control = YInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Panel1
AnchorSideBottom.Side = asrBottom
Left = 240
Height = 102
Top = 112
Width = 196
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
ItemHeight = 0
MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 6
end
object Bevel1: TBevel
AnchorSideTop.Control = YBox
AnchorSideTop.Side = asrCenter
Left = 210
Height = 4
Top = 161
Width = 14
Shape = bsSpacer
end
end
object Memo1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 8
Height = 90
Top = 8
Width = 436
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Directions: '#13#10'1. Select the X variable common to all of the Y variables to be selected.'#13#10'2. Select the Y variables.'#13#10'3. Enter a label for the plot.'#13#10'4. Select the options desired.'#13#10'5. Click the Compute button to obtain results.'
ParentColor = False
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 385
Height = 25
Top = 434
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 3
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 297
Height = 25
Top = 434
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 4
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 235
Height = 25
Top = 434
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 5
end
object Bevel2: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 418
Width = 452
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
end

View File

@ -0,0 +1,449 @@
// Use file "SchoolsData.laz" for testing
unit XvsMultYUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons, ExtCtrls, Printers,
MainUnit, Globals, OutputUnit, DataProcs, BlankFrmUnit, MatrixLib;
type
{ TXvsMultYForm }
TXvsMultYForm = class(TForm)
Bevel1: TBevel;
Bevel2: TBevel;
LinesBox: TCheckBox;
DescChk: TCheckBox;
GroupBox1: TGroupBox;
Memo1: TLabel;
Panel1: TPanel;
ResetBtn: TButton;
ComputeBtn: TButton;
CloseBtn: TButton;
PlotTitleEdit: TEdit;
Label4: TLabel;
YBox: TListBox;
XEdit: TEdit;
Label2: TLabel;
Label3: TLabel;
XInBtn: TBitBtn;
YInBtn: TBitBtn;
Label1: TLabel;
XOutBtn: TBitBtn;
YOutBtn: TBitBtn;
VarList: TListBox;
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean);
procedure XInBtnClick(Sender: TObject);
procedure XOutBtnClick(Sender: TObject);
procedure YInBtnClick(Sender: TObject);
procedure YOutBtnClick(Sender: TObject);
private
{ private declarations }
FAutoSized: Boolean;
selected: IntDyneVec;
procedure PlotXY(XValues : DblDyneVec; YValues : DblDyneMat; MaxX, MinX,
MaxY, MinY : double; N, NoY : integer);
procedure UpdateBtnStates;
public
{ public declarations }
end;
var
XvsMultYForm: TXvsMultYForm;
implementation
uses
Math;
{ TXvsMultYForm }
procedure TXvsMultYForm.ResetBtnClick(Sender: TObject);
VAR i : integer;
begin
VarList.Clear;
YBox.Clear;
XEdit.Clear;
XInBtn.Enabled := true;
XOutBtn.Enabled := false;
YInBtn.Enabled := true;
YOutBtn.Enabled := false;
PlotTitleEdit.Text := '';
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
end;
procedure TXvsMultYForm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
procedure TXvsMultYForm.ComputeBtnClick(Sender: TObject);
var
i, j, k, N, NoY, XCol, NoSelected: integer;
YValues, RMatrix: DblDyneMat;
XValues, Means, Variances, StdDevs: DblDyneVec;
MinX, MaxX, MinY, MaxY, temp: double;
Title: string;
RowLabels, ColLabels: StrDyneVec;
lReport: TStrings;
errorcode: boolean = false;
Ncases: integer = 0;
begin
if XEdit.Text = '' then
begin
MessageDlg('No X variable selected.', mtError, [mbOK], 0);
exit;
end;
if YBox.Items.Count = 0 then
begin
MessageDlg('No Y variables selected.', mtError, [mbOK], 0);
exit;
end;
NoY := YBox.Items.Count;
MaxX := -10000;
MinX := 10000;
MaxY := -1000;
MinY := 1000;
N := 0;
SetLength(selected, NoY + 1);
SetLength(RowLabels,NoVariables);
SetLength(ColLabels,NoVariables);
XCol := 0;
for i := 1 to NoVariables do
if Trim(XEdit.Text) = Trim(OS3MainFrm.DataGrid.Cells[i,0]) then
begin
XCol := i;
break;
end;
for j := 0 to NoY-1 do
begin
selected[j] := 0;
for i := 1 to NoVariables do
if Trim(YBox.Items.Strings[j]) = Trim(OS3MainFrm.DataGrid.Cells[i,0]) then
begin
selected[j] := i;
Break;
end;
end;
selected[NoY] := XCol;
NoSelected := NoY + 1;
for i := 0 to NoSelected-1 do
begin
RowLabels[i] := Trim(OS3MainFrm.DataGrid.Cells[selected[i],0]);
ColLabels[i] := RowLabels[i];
end;
Caption := RowLabels[0] + ' ' + RowLabels[1];
lReport := TStringList.Create;
try
lReport.Add('X VERSUS MULTIPLE Y VALUES PLOT');
lReport.Add('');
SetLength(YValues, NoCases+1, NoY+1);
SetLength(XValues, NoCases+1);
SetLength(Means, NoSelected+1);
SetLength(Variances, NoSelected+1);
SetLength(StdDevs, NoSelected+1);
SetLength(RMatrix, NoSelected+1, NoSelected+1);
SetLength(selected, NoVariables);
for i := 0 to NoSelected - 1 do
begin
Means[i] := 0.0;
StdDevs[i] := 0.0;
for j := 0 to NoSelected-1 do RMatrix[i,j] := 0.0;
end;
for i := 1 to NoCases do
begin
if not GoodRecord(i,NoSelected,selected) then continue;
XValues[i] := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[XCol,i]));
if XValues[i] > MaxX then MaxX := XValues[i];
if XValues[i] < MinX then MinX := XValues[i];
for j := 0 to NoY - 1 do
begin
YValues[i-1,j] := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[selected[j],i]));
if YValues[i-1,j] > MaxY then MaxY := YValues[i-1,j];
if YValues[i-1,j] < MinY then MinY := YValues[i-1,j];
end;
end;
// get descriptive data
if DescChk.Checked then
begin
Correlations(NoSelected,selected,RMatrix,Means,Variances,StdDevs,errorcode,Ncases);
N := Ncases;
Title := 'CORRELATIONS';
MatPrint(RMatrix, NoSelected, NoSelected, Title, RowLabels, ColLabels, N, lReport);
Title := 'Means';
DynVectorPrint(Means, NoSelected, Title, RowLabels, N, lReport);
Title := 'Variances';
DynVectorPrint(Variances, NoSelected, Title, RowLabels, N, lReport);
Title := 'Standard Deviations';
DynVectorPrint(StdDevs, NoSelected, Title, RowLabels, N, lReport);
end;
DisplayReport(lReport);
// sort on X
for i := 0 to N-2 do
begin
for j := i+1 to N-1 do
begin
if XValues[i] > XValues[j] then // swap
begin
temp := XValues[i];
XValues[i] := XValues[j];
XValues[j] := temp;
for k := 0 to NoY-1 do
begin
temp := YValues[i,k];
YValues[i,k] := YValues[j,k];
YValues[j,k] := temp;
end;
end;
end;
end;
PlotXY(XValues, YValues, MaxX, MinX, MaxY, MinY, N, NoY);
finally
lReport.Free;
RMatrix := nil;
StdDevs := nil;
Variances := nil;
Means := nil;
XValues := nil;
YValues := nil;
selected := nil;
ColLabels := nil;
RowLabels := nil;
end;
end;
procedure TXvsMultYForm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TXvsMultYForm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
if BlankFrm = nil then
Application.CreateForm(TBlankFrm, BlankFrm);
end;
procedure TXvsMultYForm.XInBtnClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (XEdit.Text = '') then
begin
XEdit.Text := VarList.Items[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TXvsMultYForm.XOutBtnClick(Sender: TObject);
begin
if (XEdit.Text <> '') then
begin
VarList.Items.Add(XEdit.Text);
XEdit.Text := '';
end;
UpdateBtnStates;
end;
procedure TXvsMultYForm.YInBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while i < VarList.Items.Count do
begin
if VarList.Selected[i] then
begin
YBox.Items.Add(VarList.Items[i]);
VarList.Items.Delete(i);
i := 0;
end else
inc(i);
end;
UpdateBtnStates;
end;
procedure TXvsMultYForm.YOutBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while i < YBox.Items.Count do
begin
if (YBox.Selected[i]) then
begin
VarList.Items.Add(YBox.Items[i]);
YBox.Items.Delete(i);
i := 0;
end else
i := i + 1;
end;
UpdateBtnStates;
end;
// routine to plot X versus multiple Y values
procedure TXvsMultYForm.PlotXY(XValues: DblDyneVec; YValues: DblDyneMat;
MaxX, MinX, MaxY, MinY: double; N, NoY: integer);
var
i, j, xpos, ypos, hleft, hright, vtop, vbottom, imagewide: integer;
vhi, hwide, offset, strhi, imagehi: integer;
valincr, Yvalue, Xvalue: double;
Title: string;
begin
Title := PlotTitleEdit.Text;
BlankFrm.Caption := Title;
BlankFrm.Show;
imagewide := BlankFrm.Image1.Width;
imagehi := BlankFrm.Image1.Height;
vtop := 40;
vbottom := round(imagehi) - 60;
vhi := vbottom - vtop;
hleft := 100;
hright := imagewide - 80;
hwide := hright - hleft;
// Draw chart border and background
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
BlankFrm.Image1.Canvas.Brush.Color := clWhite;
BlankFrm.Image1.Canvas.Rectangle(0, 0, imagewide, imagehi);
// Draw title
Title := PlotTitleEdit.Text;
if Title <> '' then
begin
xpos := (imagewide - BlankFrm.Image1.Canvas.TextWidth(Title)) div 2;
yPos := 2;
BlankFrm.Image1.Canvas.TextOut(xpos, ypos, Title);
end;
// draw horizontal axis
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
BlankFrm.Image1.Canvas.MoveTo(hleft,vbottom);
BlankFrm.Image1.Canvas.LineTo(hright,vbottom);
valincr := (maxX - minX) / 10.0;
for i := 1 to 11 do
begin
ypos := vbottom;
Xvalue := minX + valincr * (i - 1);
xpos := hleft + round(hwide * ((Xvalue - minX) / (maxX - minX)));
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
ypos := ypos + 10;
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
Title := Format('%.2f', [Xvalue]);
offset := BlankFrm.Image1.Canvas.TextWidth(Title) div 2;
xpos := xpos - offset;
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
BlankFrm.Image1.Canvas.TextOut(xpos, ypos, Title);
end;
xpos := hleft + (hwide - BlankFrm.Image1.Canvas.TextWidth(XEdit.Text)) div 2;
ypos := vbottom + 30;
BlankFrm.Image1.Canvas.TextOut(xpos, ypos, XEdit.Text);
// draw vertical axis
Title := 'Y VALUES';
xpos := hleft - BlankFrm.Image1.Canvas.TextWidth(Title) div 2;
ypos := 8;
BlankFrm.Image1.Canvas.TextOut(xpos, ypos, Title);
xpos := hleft;
ypos := vtop;
BlankFrm.Image1.Canvas.MoveTo(xpos, ypos);
ypos := vbottom;
BlankFrm.Image1.Canvas.LineTo(xpos, ypos);
valincr := (maxY - minY) / 10.0;
for i := 1 to 11 do
begin
Title := Format('%.2f',[maxY - ((i-1)*valincr)]);
strhi := BlankFrm.Image1.Canvas.TextHeight(Title);
xpos := hleft - 20 - BlankFrm.Image1.Canvas.TextWidth(Title);
Yvalue := maxY - (valincr * (i-1));
ypos := round(vhi * ( (maxY - Yvalue) / (maxY - minY)));
ypos := ypos + vtop - strhi div 2;
BlankFrm.Image1.Canvas.TextOut(xpos, ypos, Title);
xpos := hleft;
ypos := ypos + strhi div 2;
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
xpos := hleft - 10;
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
end;
// draw points for x and y pairs
for j := 0 to NoY-1 do
begin
BlankFrm.Image1.Canvas.Brush.Style := bsSolid;
BlankFrm.Image1.Canvas.Brush.Color := DATA_COLORS[j mod Length(DATA_COLORS)];
BlankFrm.Image1.Canvas.Pen.Color := DATA_COLORS[j mod Length(DATA_COLORS)];
BlankFrm.Image1.Canvas.Font.Color := DATA_COLORS[j mod Length(DATA_COLORS)];
Title := Trim(OS3MainFrm.DataGrid.Cells[selected[j],0]);
for i := 1 to N do
begin
ypos := vtop + round(vhi * ( (maxY - YValues[i-1,j]) / (maxY - minY)));
xpos := hleft + round(hwide * ( (XValues[i-1]-minX) / (maxX - minX)));
if xpos < hleft then xpos := hleft;
if i = 1 then
BlankFrm.Image1.Canvas.MoveTo(xpos, ypos);
if LinesBox.Checked then
BlankFrm.Image1.Canvas.LineTo(xpos, ypos);
BlankFrm.Image1.Canvas.Ellipse(xpos, ypos, xpos+5, ypos+5);
end;
strhi := BlankFrm.Image1.Canvas.TextHeight(Title);
BlankFrm.Image1.Canvas.Brush.Color := clWhite;
xpos := hwide + hleft;
BlankFrm.Image1.Canvas.MoveTo(xpos, ypos-strhi);
BlankFrm.Image1.Canvas.TextOut(xpos, ypos, Title);
end;
BlankFrm.Image1.Canvas.Font.Color := clBlack;
end;
procedure TXvsMultYForm.UpdateBtnStates;
begin
end;
initialization
{$I xvsmultyunit.lrs}
end.

View File

@ -0,0 +1,254 @@
object DblDeclineFrm: TDblDeclineFrm
Left = 583
Height = 216
Top = 330
Width = 401
AutoSize = True
BorderStyle = bsDialog
Caption = 'Double Declining Value'
ClientHeight = 216
ClientWidth = 401
OnActivate = FormActivate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object ResetBtn: TButton
AnchorSideTop.Control = ReturnBtn
AnchorSideRight.Control = ComputeBtn
Left = 174
Height = 25
Top = 179
Width = 54
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Right = 12
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 2
end
object ComputeBtn: TButton
AnchorSideTop.Control = ReturnBtn
AnchorSideRight.Control = ReturnBtn
Left = 240
Height = 25
Top = 179
Width = 76
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Right = 12
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 3
end
object ReturnBtn: TButton
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 328
Height = 25
Top = 179
Width = 61
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Return'
ModalResult = 1
TabOrder = 4
end
object HelpBtn: TButton
Tag = 118
AnchorSideTop.Control = ReturnBtn
AnchorSideRight.Control = ResetBtn
Left = 111
Height = 25
Top = 179
Width = 51
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Right = 12
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 1
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 8
Top = 163
Width = 401
Anchors = [akTop, akLeft, akRight]
Shape = bsBottomLine
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Owner
Left = 87
Height = 155
Top = 8
Width = 227
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BevelOuter = bvNone
ClientHeight = 155
ClientWidth = 227
TabOrder = 0
object Label1: TLabel
AnchorSideTop.Control = CostEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Label5
AnchorSideRight.Side = asrBottom
Left = 63
Height = 15
Top = 4
Width = 56
Anchors = [akTop, akRight]
Caption = 'Initial Cost'
ParentColor = False
end
object Label2: TLabel
AnchorSideTop.Control = LifeEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Label5
AnchorSideRight.Side = asrBottom
Left = 37
Height = 15
Top = 35
Width = 82
Anchors = [akTop, akRight]
Caption = 'Life Expectancy'
ParentColor = False
end
object Label3: TLabel
AnchorSideTop.Control = EndEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Label5
AnchorSideRight.Side = asrBottom
Left = 68
Height = 15
Top = 66
Width = 51
Anchors = [akTop, akRight]
Caption = 'End Value'
ParentColor = False
end
object Label4: TLabel
AnchorSideTop.Control = PeriodEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Label5
AnchorSideRight.Side = asrBottom
Left = 15
Height = 15
Top = 97
Width = 104
Anchors = [akTop, akRight]
Caption = 'Depreciation Period'
ParentColor = False
end
object Label5: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = DeprecEdit
AnchorSideTop.Side = asrCenter
Left = 0
Height = 15
Top = 136
Width = 119
Caption = 'Obtained Depreciation'
ParentColor = False
end
object CostEdit: TEdit
AnchorSideLeft.Control = DeprecEdit
AnchorSideTop.Control = Panel1
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 127
Height = 23
Top = 0
Width = 100
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight]
TabOrder = 0
Text = 'CostEdit'
end
object LifeEdit: TEdit
AnchorSideLeft.Control = DeprecEdit
AnchorSideTop.Control = CostEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 127
Height = 23
Top = 31
Width = 100
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
TabOrder = 1
Text = 'Edit1'
end
object EndEdit: TEdit
AnchorSideLeft.Control = DeprecEdit
AnchorSideTop.Control = LifeEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 127
Height = 23
Top = 62
Width = 100
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
TabOrder = 2
Text = 'Edit1'
end
object PeriodEdit: TEdit
AnchorSideLeft.Control = DeprecEdit
AnchorSideTop.Control = EndEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 127
Height = 23
Top = 93
Width = 100
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
TabOrder = 3
Text = 'Edit1'
end
object DeprecEdit: TEdit
AnchorSideLeft.Control = Label5
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = PeriodEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 127
Height = 23
Top = 132
Width = 100
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 16
Constraints.MinWidth = 100
Font.Style = [fsBold]
ParentFont = False
ReadOnly = True
TabOrder = 4
Text = 'Edit1'
end
end
end

Some files were not shown because too many files have changed in this diff Show More