' Copyright (c) 2011-2013 Claude Rubinson ' ' Licensed under the Apache License, Version 2.0 (the "License"); ' you may not use this file except in compliance with the License. ' You may obtain a copy of the License at ' ' http://www.apache.org/licenses/LICENSE-2.0 ' ' Unless required by applicable law or agreed to in writing, software ' distributed under the License is distributed on an "AS IS" BASIS, ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or ' implied. See the License for the specific language governing ' permissions and limitations under the License. Function FUZZ(value, lower_thresh, crossover, upper_thresh) ' FUZZ - calibrate fuzzy-sets for QCA ' This function implements the "direct" method of transforming an ' interval-ratio variable into a fuzzy set, as described in Ragin, ' Charles C. (2008) _Redesigning Social Inquiry_, Chapter 5 ' ("Calibrating Fuzzy Sets") ' To use, enter "=FUZZ(value, lower_thresh, crossover, upper_thresh)" ' in a cell, parameters may be literals or cell references. Note that ' the FUZZ function will NOT be available in the Function Wizard; neither ' can it be specified as part of a formula within the Function ' Wizard. (If somebody knows how to implement this, please contact me.) ' To install as an OpenOffice/LibreOffice Calc macro: ' ' In Calc, "Tools" -> "Macros" -> "Organize Macros" ' -> "OpenOffice (or LibreOffice) Basic" ' ' In the dialog box that opens, navigate to "My Macros" -> "Standard" ' -> "Module1" and click "Module1" to highlight it. Click "Edit". ' ' Paste the contents of this file to the end of the window that opens ' (from the "Function FUZZ" statement above through "End Function", below) ' ' Save the file and close it. ' ' The FUZZ function should now be available in all instances of Calc (for ' your user). scalar_above = 3.0/(upper_thresh - crossover) scalar_below = -3.0/(lower_thresh - crossover) scalar_at = 0 deviation = value - crossover if deviation < 0 then log_odds = deviation * scalar_below elseif deviation = 0 then log_odds = deviation * scalar_at else ' deviation > 0 log_odds = deviation * scalar_above endif ' I don't know how to generate a proper error if (upper_thresh <= crossover) or (crossover <= lower_thresh) then FUZZ = "#Err1" else FUZZ = exp(log_odds)/(1+(exp(log_odds))) endif End Function