数理统计程序集
源代码在线查看: 简单相关分析f2.frm
VERSION 5.00
Begin VB.Form frmCalculate
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "相关分析"
ClientHeight = 4020
ClientLeft = 60
ClientTop = 450
ClientWidth = 5610
LinkTopic = "Form1"
ScaleHeight = 4020
ScaleWidth = 5610
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdExit
Caption = "退 出"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1080
TabIndex = 1
Top = 0
Width = 1095
End
Begin VB.CommandButton cmdCheck
Caption = "计 算"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 0
TabIndex = 0
Top = 0
Width = 1095
End
Begin VB.Label lblR
Appearance = 0 'Flat
BackColor = &H80000005&
BeginProperty Font
Name = "宋体"
Size = 26.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 495
Left = 2640
TabIndex = 11
Top = 480
Width = 2895
End
Begin VB.Label Label9
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "相关系数="
BeginProperty Font
Name = "隶书"
Size = 26.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 615
Left = 0
TabIndex = 10
Top = 480
Width = 2775
End
Begin VB.Label lblD
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 375
Left = 120
TabIndex = 9
Top = 3360
Width = 5415
End
Begin VB.Label Label8
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "t检验结论"
BeginProperty Font
Name = "隶书"
Size = 26.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 615
Left = 120
TabIndex = 8
Top = 2760
Width = 5415
End
Begin VB.Label lbl001
Appearance = 0 'Flat
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 375
Left = 3720
TabIndex = 7
Top = 2160
Width = 1455
End
Begin VB.Label Label7
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "显著性水平为0.01的t临界值:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 375
Left = 0
TabIndex = 6
Top = 2160
Width = 3735
End
Begin VB.Label lbl005
Appearance = 0 'Flat
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 375
Left = 3720
TabIndex = 5
Top = 1680
Width = 1455
End
Begin VB.Label Label6
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "显著性水平为0.05的t临界值:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 375
Left = 0
TabIndex = 4
Top = 1680
Width = 3735
End
Begin VB.Label lblt
Appearance = 0 'Flat
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 375
Left = 3720
TabIndex = 3
Top = 1200
Width = 1455
End
Begin VB.Label Label5
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "t检验值:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 375
Left = 120
TabIndex = 2
Top = 1200
Width = 3615
End
End
Attribute VB_Name = "frmCalculate"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'相关分析
Option Explicit
Private Sub Form_Load()
Label5.Visible = False: Label6.Visible = False
Label7.Visible = False: Label8.Visible = False
Label9.Visible = False
lblD.Visible = False: lblt.Visible = False
lbl005.Visible = False: lbl001.Visible = False
End Sub
'计算
Private Sub cmdCheck_Click()
Dim R As Double, t As Double
Dim sngR As Single, sngt As Single
Dim t005 As Double, t001 As Double
Dim sngt005 As Single, sngt001 As Single
Dim m As Integer
Label5.Visible = True: Label6.Visible = True
Label7.Visible = True: Label8.Visible = True
Label9.Visible = True
lblD.Visible = True: lblt.Visible = True
lbl005.Visible = True: lbl001.Visible = True
Relation x, y, R, t '求相关系数和t值
sngR = R: sngt = t
lblR.Caption = Str(sngR): lblt.Caption = Str(sngt)
m = UBound(x, 1)
PT_DIST m - 2, 0.05 / 2, t005 '计算显著性为0.05的t临界值
PT_DIST m - 2, 0.01 / 2, t001 '计算显著性为0.01的t临界值
sngt005 = t005: sngt001 = t001
lbl005.Caption = Str(sngt005): lbl001.Caption = Str(sngt001)
If Abs(t) If Abs(t) > Abs(t005) And Abs(t) Then lblD = "变量间的线性关系显著"
If Abs(t) > Abs(t001) Then lblD = "变量间的线性关系特别显著"
End Sub
'退出
Private Sub cmdExit_Click()
Unload Me
End
End Sub