CB.Fit Example 4

This example fits a dataset to a gamma distribution while locking the location and shape parameter.

' First fit with locking set but switched off
' Location is locked to 0, and shape to 3
CB.SetFitRange ("A1:A30")
' Fit to a gamma distribution
' Switch off all the locked parameters
CB.LockFitParm cbDfaGamma, False
' Report the locked parameter values
Sheet1.Cells(6, 12).Value = cb.GetLockFitParm(cbDfaGamma, 1)	' Location
Sheet1.Cells(8, 12).Value = cb.GetLockFitParm(cbDfaGamma, 3)	' Shape
' Get result
Result = CB.Fit(cbDfaGamma, cbFitAndersonDarling)
' Write the parameters and results
Sheet1.Cells(6, 9).Value = cb.GetFitParm(1)
Sheet1.Cells(7, 9).Value = cb.GetFitParm(2)
Sheet1.Cells(8, 9).Value = cb.GetFitParm(3)
Sheet1.Cells(9, 9).Value = Result

' Now perform fit with locking
' First lock only the location parameter
CB.LockFitParm cbDfaGamma, True, 1, 0
' Shape is not locked (we could have omitted this line)
CB.LockFitParm cbDfaGamma, True, 3, cbParmUndefined
' Get fit result
Result = CB.Fit(cbDfaGamma, cbFitAndersonDarling, False)
' Write the parameters and results
Sheet1.Cells(6, 10).Value = cb.GetFitParm(1)
Sheet1.Cells(7, 10).Value = cb.GetFitParm(2)
Sheet1.Cells(8, 10).Value = cb.GetFitParm(3)
Sheet1.Cells(9, 10).Value = Result

' Now lock the shape as well
CB.LockFitParm cbDfaGamma, True, 3, 3
' Get fit result
Result = CB.Fit(cbDfaGamma, cbFitAndersonDarling, False)
' Write the parameters and results
Sheet1.Cells(6, 11).Value = cb.GetFitParm(1)
Sheet1.Cells(7, 11).Value = cb.GetFitParm(2)
Sheet1.Cells(8, 11).Value = cb.GetFitParm(3)
Sheet1.Cells(9, 11).Value = Result