You've already forked lazarus-ccr
LazStats: Inherit GenKappaUnit from TBasicStatsReportForm.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7821 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1,162 +1,78 @@
|
||||
object GenKappaFrm: TGenKappaFrm
|
||||
inherited GenKappaFrm: TGenKappaFrm
|
||||
Left = 641
|
||||
Height = 356
|
||||
Height = 306
|
||||
Top = 378
|
||||
Width = 468
|
||||
Width = 452
|
||||
HelpType = htKeyword
|
||||
HelpKeyword = 'html/GeneralizedKappa.htm'
|
||||
AutoSize = True
|
||||
Caption = 'Generalized Kappa Coefficient'
|
||||
ClientHeight = 356
|
||||
ClientWidth = 468
|
||||
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 = 259
|
||||
Height = 25
|
||||
Top = 323
|
||||
Width = 54
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 8
|
||||
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 = 321
|
||||
Height = 25
|
||||
Top = 323
|
||||
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 = 405
|
||||
Height = 25
|
||||
Top = 323
|
||||
Width = 55
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Close'
|
||||
ModalResult = 11
|
||||
TabOrder = 4
|
||||
end
|
||||
object HelpBtn: TButton
|
||||
Tag = 125
|
||||
AnchorSideRight.Control = ResetBtn
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 200
|
||||
Height = 25
|
||||
Top = 323
|
||||
Width = 51
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Help'
|
||||
OnClick = HelpBtnClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object Bevel1: TBevel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = ComputeBtn
|
||||
Left = 0
|
||||
Height = 8
|
||||
Top = 307
|
||||
Width = 468
|
||||
Anchors = [akLeft, akRight, akBottom]
|
||||
Shape = bsBottomLine
|
||||
end
|
||||
object Panel1: TPanel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = Owner
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = Bevel1
|
||||
Left = 8
|
||||
Height = 299
|
||||
Top = 8
|
||||
Width = 452
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 8
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 299
|
||||
ClientWidth = 452
|
||||
TabOrder = 0
|
||||
object Label1: TLabel
|
||||
ClientHeight = 306
|
||||
ClientWidth = 452
|
||||
inherited ParamsPanel: TPanel
|
||||
Height = 290
|
||||
Width = 296
|
||||
ClientHeight = 290
|
||||
ClientWidth = 296
|
||||
inherited CloseBtn: TButton
|
||||
Left = 241
|
||||
Top = 265
|
||||
end
|
||||
inherited ComputeBtn: TButton
|
||||
Left = 157
|
||||
Top = 265
|
||||
end
|
||||
inherited ResetBtn: TButton
|
||||
Left = 95
|
||||
Top = 265
|
||||
end
|
||||
inherited HelpBtn: TButton
|
||||
Tag = 125
|
||||
Left = 36
|
||||
Top = 265
|
||||
end
|
||||
inherited ButtonBevel: TBevel
|
||||
Top = 249
|
||||
Width = 296
|
||||
end
|
||||
object Label1: TLabel[5]
|
||||
AnchorSideLeft.Control = CatEdit
|
||||
AnchorSideBottom.Control = CatEdit
|
||||
Left = 248
|
||||
Left = 167
|
||||
Height = 15
|
||||
Top = 25
|
||||
Top = 21
|
||||
Width = 117
|
||||
Anchors = [akLeft, akBottom]
|
||||
BorderSpacing.Bottom = 2
|
||||
Caption = 'Category Code (1,2,...)'
|
||||
ParentColor = False
|
||||
end
|
||||
object Label2: TLabel
|
||||
object Label2: TLabel[6]
|
||||
AnchorSideLeft.Control = ObjectEdit
|
||||
AnchorSideBottom.Control = ObjectEdit
|
||||
Left = 248
|
||||
Left = 167
|
||||
Height = 15
|
||||
Top = 117
|
||||
Top = 109
|
||||
Width = 144
|
||||
Anchors = [akLeft, akBottom]
|
||||
BorderSpacing.Bottom = 2
|
||||
Caption = 'Object or Subject Classified'
|
||||
ParentColor = False
|
||||
end
|
||||
object Label3: TLabel
|
||||
object Label3: TLabel[7]
|
||||
AnchorSideLeft.Control = RaterEdit
|
||||
AnchorSideBottom.Control = RaterEdit
|
||||
Left = 248
|
||||
Left = 167
|
||||
Height = 15
|
||||
Top = 209
|
||||
Top = 197
|
||||
Width = 101
|
||||
Anchors = [akLeft, akBottom]
|
||||
BorderSpacing.Bottom = 2
|
||||
Caption = 'Rater Codes (1,2,...)'
|
||||
ParentColor = False
|
||||
end
|
||||
object Label4: TLabel
|
||||
AnchorSideLeft.Control = Panel1
|
||||
AnchorSideTop.Control = Panel1
|
||||
object Label4: TLabel[8]
|
||||
AnchorSideLeft.Control = ParamsPanel
|
||||
AnchorSideTop.Control = ParamsPanel
|
||||
Left = 0
|
||||
Height = 15
|
||||
Top = 0
|
||||
@ -164,173 +80,177 @@ object GenKappaFrm: TGenKappaFrm
|
||||
Caption = 'Variables:'
|
||||
ParentColor = False
|
||||
end
|
||||
object VarList: TListBox
|
||||
AnchorSideLeft.Control = Panel1
|
||||
object VarList: TListBox[9]
|
||||
AnchorSideLeft.Control = ParamsPanel
|
||||
AnchorSideTop.Control = Label4
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = CatIn
|
||||
AnchorSideBottom.Control = Panel1
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 0
|
||||
Height = 282
|
||||
Height = 232
|
||||
Top = 17
|
||||
Width = 204
|
||||
Width = 129
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Top = 2
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Right = 6
|
||||
ItemHeight = 0
|
||||
OnDblClick = VarListDblClick
|
||||
OnSelectionChange = VarListSelectionChange
|
||||
TabOrder = 0
|
||||
TabOrder = 4
|
||||
end
|
||||
object CatIn: TBitBtn
|
||||
AnchorSideLeft.Control = Panel1
|
||||
object CatIn: TBitBtn[10]
|
||||
AnchorSideLeft.Control = ParamsPanel
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = VarList
|
||||
Left = 212
|
||||
Height = 28
|
||||
Left = 135
|
||||
Height = 26
|
||||
Top = 17
|
||||
Width = 28
|
||||
Width = 26
|
||||
Images = MainDataModule.ImageList
|
||||
ImageIndex = 1
|
||||
OnClick = CatInClick
|
||||
Spacing = 0
|
||||
TabOrder = 1
|
||||
TabOrder = 5
|
||||
end
|
||||
object CatOut: TBitBtn
|
||||
AnchorSideLeft.Control = Panel1
|
||||
object CatOut: TBitBtn[11]
|
||||
AnchorSideLeft.Control = ParamsPanel
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = CatIn
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 212
|
||||
Height = 28
|
||||
Top = 49
|
||||
Width = 28
|
||||
Left = 135
|
||||
Height = 26
|
||||
Top = 47
|
||||
Width = 26
|
||||
BorderSpacing.Top = 4
|
||||
Images = MainDataModule.ImageList
|
||||
ImageIndex = 0
|
||||
OnClick = CatOutClick
|
||||
Spacing = 0
|
||||
TabOrder = 2
|
||||
TabOrder = 6
|
||||
end
|
||||
object ObjIn: TBitBtn
|
||||
AnchorSideLeft.Control = Panel1
|
||||
object ObjIn: TBitBtn[12]
|
||||
AnchorSideLeft.Control = ParamsPanel
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = CatOut
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 212
|
||||
Height = 28
|
||||
Top = 109
|
||||
Width = 28
|
||||
Left = 135
|
||||
Height = 26
|
||||
Top = 105
|
||||
Width = 26
|
||||
BorderSpacing.Top = 32
|
||||
Images = MainDataModule.ImageList
|
||||
ImageIndex = 1
|
||||
OnClick = ObjInClick
|
||||
Spacing = 0
|
||||
TabOrder = 4
|
||||
TabOrder = 7
|
||||
end
|
||||
object ObjOut: TBitBtn
|
||||
AnchorSideLeft.Control = Panel1
|
||||
object ObjOut: TBitBtn[13]
|
||||
AnchorSideLeft.Control = ParamsPanel
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = ObjIn
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 212
|
||||
Height = 28
|
||||
Top = 141
|
||||
Width = 28
|
||||
Left = 135
|
||||
Height = 26
|
||||
Top = 135
|
||||
Width = 26
|
||||
BorderSpacing.Top = 4
|
||||
Images = MainDataModule.ImageList
|
||||
ImageIndex = 0
|
||||
OnClick = ObjOutClick
|
||||
Spacing = 0
|
||||
TabOrder = 5
|
||||
TabOrder = 8
|
||||
end
|
||||
object RaterIn: TBitBtn
|
||||
AnchorSideLeft.Control = Panel1
|
||||
object RaterIn: TBitBtn[14]
|
||||
AnchorSideLeft.Control = ParamsPanel
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = ObjOut
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 212
|
||||
Height = 28
|
||||
Top = 201
|
||||
Width = 28
|
||||
Left = 135
|
||||
Height = 26
|
||||
Top = 193
|
||||
Width = 26
|
||||
BorderSpacing.Top = 32
|
||||
Images = MainDataModule.ImageList
|
||||
ImageIndex = 1
|
||||
OnClick = RaterInClick
|
||||
Spacing = 0
|
||||
TabOrder = 7
|
||||
TabOrder = 9
|
||||
end
|
||||
object RaterOut: TBitBtn
|
||||
AnchorSideLeft.Control = Panel1
|
||||
object RaterOut: TBitBtn[15]
|
||||
AnchorSideLeft.Control = ParamsPanel
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = RaterIn
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 212
|
||||
Height = 28
|
||||
Top = 233
|
||||
Width = 28
|
||||
Left = 135
|
||||
Height = 26
|
||||
Top = 223
|
||||
Width = 26
|
||||
BorderSpacing.Top = 4
|
||||
Images = MainDataModule.ImageList
|
||||
ImageIndex = 0
|
||||
OnClick = RaterOutClick
|
||||
Spacing = 0
|
||||
TabOrder = 8
|
||||
TabOrder = 10
|
||||
end
|
||||
object CatEdit: TEdit
|
||||
object CatEdit: TEdit[16]
|
||||
AnchorSideLeft.Control = CatIn
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = Panel1
|
||||
AnchorSideRight.Control = ParamsPanel
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = CatOut
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 248
|
||||
Left = 167
|
||||
Height = 23
|
||||
Top = 42
|
||||
Width = 204
|
||||
Top = 38
|
||||
Width = 129
|
||||
Anchors = [akLeft, akRight, akBottom]
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Bottom = 12
|
||||
ReadOnly = True
|
||||
TabOrder = 3
|
||||
TabOrder = 11
|
||||
Text = 'CatEdit'
|
||||
end
|
||||
object ObjectEdit: TEdit
|
||||
AnchorSideLeft.Control = ObjOut
|
||||
object ObjectEdit: TEdit[17]
|
||||
AnchorSideLeft.Control = CatIn
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideRight.Control = Panel1
|
||||
AnchorSideRight.Control = ParamsPanel
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = ObjOut
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 248
|
||||
Left = 167
|
||||
Height = 23
|
||||
Top = 134
|
||||
Width = 204
|
||||
Top = 126
|
||||
Width = 129
|
||||
Anchors = [akLeft, akRight, akBottom]
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Bottom = 12
|
||||
ReadOnly = True
|
||||
TabOrder = 6
|
||||
TabOrder = 12
|
||||
Text = 'ObjectEdit'
|
||||
end
|
||||
object RaterEdit: TEdit
|
||||
AnchorSideLeft.Control = RaterOut
|
||||
object RaterEdit: TEdit[18]
|
||||
AnchorSideLeft.Control = CatIn
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = RaterIn
|
||||
AnchorSideRight.Control = Panel1
|
||||
AnchorSideRight.Control = ParamsPanel
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = RaterOut
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 248
|
||||
Left = 167
|
||||
Height = 23
|
||||
Top = 226
|
||||
Width = 204
|
||||
Top = 214
|
||||
Width = 129
|
||||
Anchors = [akLeft, akRight, akBottom]
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Bottom = 12
|
||||
ReadOnly = True
|
||||
TabOrder = 9
|
||||
TabOrder = 13
|
||||
Text = 'RaterEdit'
|
||||
end
|
||||
end
|
||||
inherited ParamsSplitter: TSplitter
|
||||
Left = 308
|
||||
Height = 306
|
||||
end
|
||||
end
|
||||
|
@ -9,21 +9,15 @@ unit GenKappaUnit;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, ExtCtrls, Buttons, MainUnit,
|
||||
Globals, OutputUnit, FunctionsLib, ContextHelpUnit;
|
||||
Globals, FunctionsLib, BasicStatsReportFormUnit;
|
||||
type
|
||||
|
||||
{ TGenKappaFrm }
|
||||
|
||||
TGenKappaFrm = class(TForm)
|
||||
Bevel1: TBevel;
|
||||
HelpBtn: TButton;
|
||||
TGenKappaFrm = class(TBasicStatsReportForm)
|
||||
Label4: TLabel;
|
||||
Panel1: TPanel;
|
||||
ResetBtn: TButton;
|
||||
ComputeBtn: TButton;
|
||||
CloseBtn: TButton;
|
||||
CatIn: TBitBtn;
|
||||
CatOut: TBitBtn;
|
||||
CatEdit: TEdit;
|
||||
@ -39,20 +33,14 @@ type
|
||||
VarList: TListBox;
|
||||
procedure CatInClick(Sender: TObject);
|
||||
procedure CatOutClick(Sender: TObject);
|
||||
procedure ComputeBtnClick(Sender: TObject);
|
||||
procedure FormActivate(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure HelpBtnClick(Sender: TObject);
|
||||
procedure ObjInClick(Sender: TObject);
|
||||
procedure ObjOutClick(Sender: TObject);
|
||||
procedure RaterInClick(Sender: TObject);
|
||||
procedure RaterOutClick(Sender: TObject);
|
||||
procedure ResetBtnClick(Sender: TObject);
|
||||
procedure VarListSelectionChange(Sender: TObject; User: boolean);
|
||||
procedure VarListDblClick(Sender: TObject);
|
||||
procedure VarListSelectionChange(Sender: TObject; {%H-}User: boolean);
|
||||
|
||||
private
|
||||
{ private declarations }
|
||||
FAutoSized: Boolean;
|
||||
NoCats: integer;
|
||||
NoObjects: integer;
|
||||
NoRaters: integer;
|
||||
@ -62,11 +50,14 @@ type
|
||||
function compute_partial_pchance(R: IntDyneCube; i, j: integer; denom: double): double;
|
||||
function compute_partial_pobs(R: IntDyneCube; k, l: integer): double;
|
||||
function KappaVariance(R: IntDyneCube; n, m, K1: integer): double;
|
||||
|
||||
procedure UpdateBtnStates;
|
||||
|
||||
protected
|
||||
procedure AdjustConstraints; override;
|
||||
procedure Compute; override;
|
||||
procedure UpdateBtnStates; override;
|
||||
|
||||
public
|
||||
{ public declarations }
|
||||
procedure Reset; override;
|
||||
end;
|
||||
|
||||
var
|
||||
@ -74,28 +65,27 @@ var
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
Math, Utils;
|
||||
Math,
|
||||
Utils, GridProcs;
|
||||
|
||||
|
||||
{ TGenKappaFrm }
|
||||
|
||||
procedure TGenKappaFrm.ResetBtnClick(Sender: TObject);
|
||||
VAR i : integer;
|
||||
procedure TGenKappaFrm.AdjustConstraints;
|
||||
begin
|
||||
CatIn.Enabled := true;
|
||||
CatOut.Enabled := false;
|
||||
ObjIn.Enabled := true;
|
||||
ObjOut.Enabled := false;
|
||||
RaterIn.Enabled := true;
|
||||
RaterOut.Enabled := false;
|
||||
CatEdit.Text := '';
|
||||
ObjectEdit.Text := '';
|
||||
RaterEdit.Text := '';
|
||||
VarList.Clear;
|
||||
for i := 0 to NoVariables - 1 do
|
||||
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i+1,0]);
|
||||
inherited;
|
||||
ParamsPanel.Constraints.MinWidth := Max(
|
||||
4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left,
|
||||
Label2.Width *2 + CatIn.Width + 2*VarList.BorderSpacing.Right
|
||||
);
|
||||
ParamsPanel.Constraints.MinHeight := RaterOut.Top + RaterOut.Height +
|
||||
ButtonBevel.Height + CloseBtn.BorderSpacing.Top + CloseBtn.Height;
|
||||
end;
|
||||
|
||||
|
||||
procedure TGenKappaFrm.CatInClick(Sender: TObject);
|
||||
var
|
||||
index: integer;
|
||||
@ -109,6 +99,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TGenKappaFrm.CatOutClick(Sender: TObject);
|
||||
begin
|
||||
if CatEdit.Text <> '' then
|
||||
@ -119,13 +110,14 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TGenKappaFrm.ComputeBtnClick(Sender: TObject);
|
||||
|
||||
procedure TGenKappaFrm.Compute;
|
||||
var
|
||||
CatCol, ObjCol, RaterCol, frequency, i, j, k, l: integer;
|
||||
value, rater, category, anobject: integer;
|
||||
R: IntDyneCube;
|
||||
R: IntDyneCube = nil;
|
||||
pobs, pchance, kappa, num, denom, partial_pchance, a_priori: double;
|
||||
average_frequency: DblDyneVec;
|
||||
average_frequency: DblDyneVec = nil;
|
||||
z: double;
|
||||
lReport: TStrings;
|
||||
begin
|
||||
@ -137,18 +129,12 @@ begin
|
||||
lReport.Add('');
|
||||
|
||||
// get columns for the variables
|
||||
CatCol := 0;
|
||||
ObjCol := 0;
|
||||
RaterCol := 0;
|
||||
for i := 1 to NoVariables do
|
||||
CatCol := GetVariableIndex(OS3MainFrm.DataGrid, CatEdit.Text);
|
||||
ObjCol := GetVariableIndex(OS3MainFrm.DataGrid, ObjectEdit.Text);
|
||||
RaterCol := GetVariableIndex(OS3MainFrm.DataGrid, RaterEdit.Text);
|
||||
if ((CatCol = -1) or (RaterCol = -1) or (ObjCol = -1)) then
|
||||
begin
|
||||
if (OS3MainFrm.DataGrid.Cells[i, 0] = CatEdit.Text) then CatCol := i;
|
||||
if (OS3MainFrm.DataGrid.Cells[i, 0] = RaterEdit.Text) then RaterCol := i;
|
||||
if (OS3MainFrm.DataGrid.Cells[i, 0] = ObjectEdit.Text) then ObjCol := i;
|
||||
end;
|
||||
if ((CatCol = 0) or (RaterCol = 0) or (ObjCol = 0)) then
|
||||
begin
|
||||
MessageDlg('One or more variables not defined.', mtError, [mbOK], 0);
|
||||
ErrorMsg('One or more variables not defined.');
|
||||
exit;
|
||||
end;
|
||||
|
||||
@ -171,19 +157,19 @@ begin
|
||||
lReport.Add('%d Raters using %d Categories to rate %d Objects', [NoRaters, NoCats, NoObjects]);
|
||||
lReport.Add('');
|
||||
|
||||
// get memory for R and set to zero
|
||||
// Get memory for R and set to zero
|
||||
SetLength(R, NoRaters+1, NoCats+1, NoObjects+1);
|
||||
for i := 0 to NoRaters - 1 do
|
||||
for k := 0 to NoCats - 1 do
|
||||
for l := 0 to NoObjects - 1 do
|
||||
R[i,k,l] := 0;
|
||||
R[i, k, l] := 0;
|
||||
|
||||
// get memory for average_frequency
|
||||
// Get memory for average_frequency
|
||||
SetLength(average_frequency, NoCats+1);
|
||||
for k := 0 to NoCats - 1 do
|
||||
average_frequency[k] := 0.0;
|
||||
|
||||
// read data and store in R
|
||||
// Read data and store in R
|
||||
for i := 1 to NoCases do
|
||||
begin
|
||||
rater := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[RaterCol, i])));
|
||||
@ -192,7 +178,7 @@ begin
|
||||
R[rater-1, category-1, anobject-1] := 1;
|
||||
end;
|
||||
|
||||
//compute chance probability of agreement pchance for all raters
|
||||
// Compute chance probability of agreement pchance for all raters
|
||||
pchance := 0.0;
|
||||
denom := compute_denom(R);
|
||||
for i := 0 to NoRaters - 1 do
|
||||
@ -226,7 +212,7 @@ begin
|
||||
|
||||
lReport.Add('PChance: %f', [pchance]);
|
||||
|
||||
// compute observed probability of agreement among all raters
|
||||
// Compute observed probability of agreement among all raters
|
||||
num := 0.0;
|
||||
for k := 0 to NoCats - 1 do
|
||||
for l := 0 to NoObjects - 1 do
|
||||
@ -244,49 +230,13 @@ begin
|
||||
if (z > 0.0) then z := kappa / sqrt(z);
|
||||
lReport.Add('z for Kappa: %.3f with probability > %.3f', [z, 1.0-probz(z)]);
|
||||
|
||||
DisplayReport(lReport);
|
||||
FReportFrame.DisplayReport(lReport);
|
||||
|
||||
finally
|
||||
lReport.Free;
|
||||
average_frequency := nil;
|
||||
R := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TGenKappaFrm.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 TGenKappaFrm.FormCreate(Sender: TObject);
|
||||
begin
|
||||
Assert(OS3MainFrm <> nil);
|
||||
end;
|
||||
|
||||
procedure TGenKappaFrm.FormShow(Sender: TObject);
|
||||
begin
|
||||
ResetBtnClick(self);
|
||||
end;
|
||||
|
||||
procedure TGenKappaFrm.HelpBtnClick(Sender: TObject);
|
||||
begin
|
||||
if ContextHelpForm = nil then
|
||||
Application.CreateForm(TContextHelpForm, ContextHelpForm);
|
||||
ContextHelpForm.HelpMessage((Sender as TButton).Tag);
|
||||
end;
|
||||
|
||||
function TGenKappaFrm.compute_term1(R: IntDyneCube; i, j, k: integer): double;
|
||||
var
|
||||
@ -318,6 +268,7 @@ begin
|
||||
result := (num_i * num_j) / (denom_i * denom_j); //((num_i / denom_i) * (num_j / denom_j));
|
||||
end;
|
||||
|
||||
|
||||
function TGenKappaFrm.compute_term2(R: IntDyneCube; i, j, l: integer): double;
|
||||
var
|
||||
sum_i, sum_j, k: integer;
|
||||
@ -334,9 +285,10 @@ begin
|
||||
Result := sum_i * sum_j;
|
||||
end;
|
||||
|
||||
|
||||
function TGenKappaFrm.compute_denom(R: IntDyneCube): double;
|
||||
var
|
||||
sum: IntDyneVec;
|
||||
sum: IntDyneVec = nil;
|
||||
i, k, l: integer;
|
||||
begin
|
||||
Result := 0;
|
||||
@ -356,6 +308,7 @@ begin
|
||||
sum := nil;
|
||||
end;
|
||||
|
||||
|
||||
function TGenKappaFrm.compute_partial_pchance(R: IntDyneCube; i, j: integer;
|
||||
denom: double): double;
|
||||
var
|
||||
@ -377,6 +330,7 @@ begin
|
||||
Result := 0.0;
|
||||
end;
|
||||
|
||||
|
||||
function TGenKappaFrm.compute_partial_pobs(R: IntDyneCube; k, l: integer): double;
|
||||
var
|
||||
sum, i: integer;
|
||||
@ -388,21 +342,22 @@ begin
|
||||
Result := sum * (sum - 1);
|
||||
end;
|
||||
|
||||
|
||||
{ Calculates the variance of Kappa
|
||||
R contains 1's or 0's for raters, categories and objects (row, col, slice)
|
||||
m is number of raters
|
||||
n is number of subjects
|
||||
K1 is the number of categories }
|
||||
function TGenKappaFrm.KappaVariance(R : IntDyneCube; n, m, K1: integer): double;
|
||||
function TGenKappaFrm.KappaVariance(R: IntDyneCube; n, m, K1: integer): double;
|
||||
var
|
||||
xij, term1, term2: double;
|
||||
i, j, k: integer;
|
||||
pj: DblDyneVec;
|
||||
pj: DblDyneVec = nil;
|
||||
begin
|
||||
term1 := 0.0;
|
||||
term2 := 0.0;
|
||||
|
||||
SetLength(pj,K1);
|
||||
SetLength(pj, K1);
|
||||
for j := 0 to K1 - 1 do pj[j] := 0.0;
|
||||
|
||||
// get proportion of values in each category
|
||||
@ -433,6 +388,7 @@ begin
|
||||
pj := nil;
|
||||
end;
|
||||
|
||||
|
||||
procedure TGenKappaFrm.ObjInClick(Sender: TObject);
|
||||
var
|
||||
index: integer;
|
||||
@ -446,6 +402,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TGenKappaFrm.ObjOutClick(Sender: TObject);
|
||||
begin
|
||||
if ObjectEdit.Text <> '' then
|
||||
@ -456,6 +413,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TGenKappaFrm.RaterInClick(Sender: TObject);
|
||||
var
|
||||
index: integer;
|
||||
@ -469,6 +427,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TGenKappaFrm.RaterOutClick(Sender: TObject);
|
||||
begin
|
||||
if RaterEdit.Text <> '' then
|
||||
@ -479,10 +438,29 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TGenKappaFrm.Reset;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
CatEdit.Clear;
|
||||
ObjectEdit.Clear;
|
||||
RaterEdit.Clear;
|
||||
VarList.Clear;
|
||||
for i := 1 to NoVariables do
|
||||
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i, 0]);
|
||||
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
|
||||
|
||||
procedure TGenKappaFrm.UpdateBtnStates;
|
||||
var
|
||||
lSelected: Boolean;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
lSelected := AnySelected(VarList);
|
||||
|
||||
CatIn.Enabled := lSelected and (CatEdit.Text = '');
|
||||
@ -495,14 +473,33 @@ begin
|
||||
RaterOut.Enabled := (RaterEdit.Text <> '');
|
||||
end;
|
||||
|
||||
|
||||
procedure TGenKappaFrm.VarListDblClick(Sender: TObject);
|
||||
var
|
||||
index: Integer;
|
||||
s: String;
|
||||
begin
|
||||
index := VarList.ItemIndex;
|
||||
if index > -1 then
|
||||
begin
|
||||
s := VarList.Items[index];
|
||||
if CatEdit.Text = '' then
|
||||
CatEdit.Text := s
|
||||
else if ObjectEdit.Text = '' then
|
||||
ObjectEdit.Text := s
|
||||
else if RaterEdit.Text = '' then
|
||||
RaterEdit.Text := s;
|
||||
VarList.Items.Delete(index);
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TGenKappaFrm.VarListSelectionChange(Sender: TObject; User: boolean);
|
||||
begin
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
{$I genkappaunit.lrs}
|
||||
|
||||
end.
|
||||
|
||||
|
Reference in New Issue
Block a user