Function AntiTranspose(response As Single, blnNotMissing As Boolean, intTranspose As Long, intMW As Long, mw As Single, MVOL As Single, minData As Single, MaxData As Single, minMW As Single, maxMW As Single, MinVol As Single, MaxVol As Single) As Boolean ' coded Sept 2017-March 2018 by James Quinn ' this code is public domain, and has the standard open source license. (Free to use, Use at your own risk.) ' response = number to be transposed ' blnNotMissing - false if response value is missing. Do nothing except set AntiTranspose to false ' intTranspose - the transposition to undo. 1 = response, 2 = 1/response, 3 = log(response), 4 = 1/Log(response), 5 = sqrt(response), 6= 1/sqrt(response) ' 7= response^2, 8 = 1/response^2, 9 = logit(response), 10 = 1/logit(response) ' intmw = a number indicating whether the molecules should be multiplied or divided by molecular weight or molecular volume ' mw = molecular weight ' mvol = van der Waals molecular volume ' mindata = minimum response value in the whole dataset ' maxdata = maximum response value in the whole dataset ' minMW, maxMW - minimum and maximum molecular weights in the whole dataset ' minVol, maxVol - minimum and maximum molecular volumes in the whole dataset On Error GoTo AntiTransposeErr Dim i As Long Dim diff As Single Dim tmpMindata As Single, tmpMaxData As Single AntiTranspose = False If blnNotMissing = True Then Select Case intMW Case 1 tmpMindata = minData tmpMaxData = MaxData Case 2 If maxMW And minMW <> 0 Then tmpMindata = minData / minMW tmpMaxData = MaxData / maxMW If tmpMaxData < tmpMindata Then tmpMaxData = tmpMindata tmpMindata = MaxData / maxMW End If Else blnNotMissing = False End If Case 3 tmpMindata = minData * minMW tmpMaxData = MaxData * maxMW Case 4 If MaxVol And MinVol <> 0 Then tmpMindata = minData / MinVol tmpMaxData = MaxData / MaxVol If tmpMaxData < tmpMindata Then tmpMaxData = tmpMindata tmpMindata = MaxData / MaxVol End If Else blnNotMissing = False End If Case 5 tmpMindata = minData * MinVol tmpMaxData = MaxData * MaxVol Case 6 If MinVol <> 0 And minMW <> 0 Then tmpMindata = minData / (minMW / MinVol) tmpMaxData = MaxData / (maxMW / MaxVol) If tmpMaxData < tmpMindata Then tmpMaxData = tmpMindata tmpMindata = MaxData / (maxMW / MaxVol) End If Else blnNotMissing = False Exit Function End If Case 7 If MinVol <> 0 And minMW <> 0 Then tmpMindata = minData / (MinVol / minMW) tmpMaxData = MaxData / (MaxVol / maxMW) If tmpMaxData < tmpMindata Then tmpMaxData = tmpMindata tmpMindata = MaxData / (MaxVol / maxMW) End If Else blnNotMissing = False Exit Function End If End Select Select Case intTranspose Case 1 response = response Case 2 If response <> 0 Then response = 1 / response Else blnNotMissing = False End If Case 3 response = 10 ^ response If tmpMindata <= 0 Then diff = tmpMaxData - tmpMindata response = (response - (diff * 0.00001)) + tmpMindata End If Case 4 If response <> 0 Then response = 10 ^ (1 / response) If tmpMindata <= 0 Then diff = tmpMaxData - tmpMindata response = (response - (diff * 0.00001)) + tmpMindata End If Else blnNotMissing = False End If Case 5 response = response * response Case 6 If response > 0 Then response = (1 / response) * (1 / response) If tmpMindata <= 0 Then diff = tmpMaxData - tmpMindata response = (response - (diff * 0.00001)) + tmpMindata End If Else blnNotMissing = False End If Case 7 response = Sqr(response) Case 8 If response <> 0 Then response = Sqr(1 / response) Else blnNotMissing = False End If Case 9 response = Exp(response) response = response / (1 + response) If tmpMindata >= 0 And tmpMindata < 0.1 And tmpMaxData <= 1 And tmpMaxData > 0.9 Then tmpMindata = 0 tmpMaxData = 1 ElseIf tmpMindata >= 0 And tmpMindata < 10 And tmpMaxData <= 100 And tmpMaxData > 90 Then tmpMindata = 0 tmpMaxData = 100 End If diff = tmpMaxData - tmpMindata response = response * diff If tmpMindata < 0 Then response = response + tmpMindata End If Case 10 If response = 0 Then response = 0.5 Else response = Exp(1 / response) response = response / (response + 1) End If If tmpMindata >= 0 And tmpMindata < 0.1 And tmpMaxData <= 1 And tmpMaxData > 0.9 Then tmpMindata = 0 tmpMaxData = 1 ElseIf tmpMindata >= 0 And tmpMindata < 10 And tmpMaxData <= 100 And tmpMaxData > 90 Then tmpMindata = 0 tmpMaxData = 100 End If diff = tmpMaxData - tmpMindata response = response * diff If tmpMindata < 0 Then response = response + tmpMindata End If End Select Select Case intMW Case 1 'no modification by mw or mvol Case 2 response = response * mw Case 3 If mw <> 0 Then response = response / mw Else blnNotMissing = False End If Case 4 response = response * MVOL Case 5 If MVOL <> 0 Then response = response / MVOL Else blnNotMissing = False End If Case 6 If mw <> 0 Then response = response * (MVOL / mw) Else blnNotMissing = False End If Case 7 If MVOL <> 0 Then response = response * (mw / MVOL) Else blnNotMissing = False End If End Select End If If blnNotMissing = True Then AntiTranspose = True Else AntiTranspose = False End If Exit Function AntiTransposeErr: AntiTranspose = False blnNotMissing = False End Function