By Charles Flock on
4/14/2019 9:47 AM
Multiple Linear Regression (aka Ordinary Least Squares) usually calculates the best fit for a series of independent x-value and dependent y-values. Most of these linear systems have more rows than columns which will generate a unique solution. Those systems are called overdetermined systems. In this article, we look at underdetermined systems (where the number of rows is less than the number columns) and compare how they are handled in XLeratorDB, Excel, Google Sheets, and R. You will be surprised at what we discovered.
|
By Charles Flock on
4/30/2018 9:13 AM
Based on the paper ‘Estimating a Gamma Distribution’ by Thomas P. Minka we look at a very quick technique in SQL Server to estimate the alpha and beta parameters of a gamma distribution based on sample data.
|
By Charles Flock on
2/1/2018 10:56 PM
We are happy to announce the latest releases of XLeratorDB which are compatible with SQL Server 2017.
|
By Charles Flock on
11/30/2017 11:25 PM
On November 24th, 2017 The Wall Street Journal published an article by Tatyana Shumsky entitled Stop Using Excel, Finance Chiefs Tell Staffs. On November 30th, 2017 Ms. Shumsky followed up with The Finance Pros Say You’ll Have to Pry Excel Out of Their Cold, Dead Hands. We thought it was probably time to weigh in.
|
By Charles Flock on
10/5/2017 9:56 PM
In this article we take a deeper look into the XLeratorDB TWRR function which is a very easy-to-use aggregate function for calculating time-weighted rate-of-return in SQL Server. But, easy-to-use doesn’t necessarily mean easy to understand. In this article we take a deeper look into the mechanics of the calculation.
|
By Charles Flock on
9/5/2017 9:09 PM
A follow-up to our article on the General Birthday Problem, we look at some more interesting calculations relating to birthday ‘coincidences’.
|
By Charles Flock on
6/14/2017 4:47 PM
In November 2008, we wrote about the birthday paradox. In this article, we talk about techniques to solve birthday problems where we want to calculate the likelihood of 3, 4, 5, or more people in a room having the same birthday. We particularly focus on the techniques in E.H. McKinney’s 1966 paper and show easily SQL lends itself to exact solutions for these types of problems.
|
By Charles Flock on
5/10/2017 2:34 PM
In 2013 we introduced 3 XLeratorDB/windowing functions for inventory calculations: FIFO; LIFO; and WAC. In March of 2017 we added new table-valued functions to XLeratorDB/fin08 to do the same calculations as well as a few new functions to provide more detail about the ending inventory balances. In this article we go through some examples to explore the details of inventory valuation techniques and discuss the perils of triangular joins and why you probably don't want to try these calculations in native SQL.
|
By Charles Flock on
4/19/2017 9:58 AM
You should check out the new case study on the case study section of the site.
|
By Charles Flock on
4/4/2017 2:10 PM
You should check out the new case study on the case study section of the site.
|
By Charles Flock on
3/17/2017 4:01 PM
We have added a new Case Studies section to westclintech.com.
|
By Charles Flock on
2/2/2017 12:01 PM
In this overview we discuss the mechanics of the calculations of option-adjusted spread for corporate bonds. This overview is not a replacement for finance texts which give a far more detailed explanation of the theory behind the calculations. It is also not a substitute for reading the documentation about the individual functions, but is designed to give a somewhat higher and more integrated view of the how the functions work together.
|
By Charles Flock on
10/13/2016 4:00 PM
In our previous article we took a peek behind the curtain of the SWAPCURVE function gaining insight into the mechanics of turning cash rates, Eurodollar futures prices, and swaps rates into discount factors and continuously compounded zero coupon rates. In this article we attempt to do a little reverse engineering to see if it's possible to take those discount factors and turn them back into the supplied inputs or their associated spot rates.
|
By Charles Flock on
9/26/2016 1:48 PM
The XLeratorDB table-valued function SWAPCURVE takes cash, futures, and swaps rates as input and returns discount factors and continuously compounded zero coupon rates which can then be used in a variety of sophisticated financial calculations. In this article we take an in-depth look at the mechanics of SWAPCURVE calculation using SQL and other XLeratorDB functions to explain where the numbers come from. These alternative calculations are designed to be explanatory and not as a substitute for the SWAPCURVE function which will be, by far, the fastest and easiest way to generate the curve values.
|
By Charles Flock on
8/21/2016 3:30 PM
In this article we compare the XLeratorDLL/financial XNPV function to WorksheetFunction XNPV where we encounter some aspects of the WorksheetFunction that might give you pause.
|
By Charles Flock on
8/21/2016 3:29 PM
In this article we take a detailed look at the XLeratorDLL function XIRR and Worksheetfunction.XIRR. You might be surprised about some of the quirks in Worksheetfunction.XIRR
|
By Charles Flock on
8/21/2016 3:28 PM
In this article we compare the XLeratorDLL/financial YIELD function to Worksheetfunction YIELD where we encounter a few surprises and some things that made me scratch my head.
|
By Charles Flock on
8/21/2016 3:26 PM
XLeratorDB was developed to provide the best possible in-database analytics capability for SQL Server and we continue to believe that the best platform for doing sophisticated analytics on large datasets is SQL Server with XLeratorDB. Over the last 8 years, however, non-SQL Server users were also interested in having many of these functions and even some SQL Servers preferred the XLeratorDB functions in non-database applications. We are happy to announce the availability of XLeratorDLL/financial and in this article talk about the advantages of using this library in your .NET code and why should really never use Microsoft.Office.Interop.Excel,Worksheetfunction for financial calculations.
|
By Charles Flock on
7/26/2016 12:26 PM
XIRR is one of our most popular functions. In this article we look at some of the reasons why XIRR returns a NULL and why that's OK.
|
By Charles Flock on
4/26/2016 1:06 PM
Current Expected Credit Loss (CECL) is coming soon. In this article we talk about new functionality that we have added to XLeratorDB to makes loan level cash flow modeling simple. Using our new table-valued function CDRCASHFLOW in SQL Server you can create extremely sophisticated models using some very simple SQL which scales up for hundreds of thousands if not millions of individual loans. If your data already resides in SQL Server, you can implement this functionality without making any changes to your existing applications.
|
By Charles Flock on
1/28/2016 5:52 PM
|
By Charles Flock on
12/15/2015 11:26 AM
The XLeratorDB financial library contains more than three dozen functions related to the calculation of price, yield, and accrued interest on bonds, bills, and notes. Recently, one of our customers came to us to help him solve for the yield on a bond which incorporated a tax rate. As with most requirements for financial calculations, he attached a very complicated spreadsheet which contained the underlying math used in the local market to calculate the price from yield for the bond, including the tax rate.
|
By Charles Flock on
10/6/2015 3:33 PM
The hypergeometric distribution and its cousin the negative hypergeometric distribution are categorized as urn problems in statistics. In this article we look at some of the math behind urn problems.
|
By Charles Flock on
8/7/2015 2:33 PM
Our original blog on Calculating percentiles in SQL Server, published in 2011, is one of the most popular pages at westclintech.com. In this article, we talk about a table-valued approach to calculating percentiles which in some situations may improve performance dramatically over the PERCENTILE aggregate function.
|
By Charles Flock on
5/13/2015 3:27 PM
Calculating internal rates of return for many accounts or portfolios across many different time horizons is a laborious and error-prone task in a spreadsheet and the calculations are easily broken when new cash flows are added. In this article we look at how doing this calculation in SQL Server with just a few lines of SQL lets you calculate internal rates of return for millions of cash flows across all of your accounts or portfolios across multiple time horizons in just a few seconds.
|
By Charles Flock on
4/23/2015 3:18 PM
There are a lot of financial calculations that compute 'returns'. There are internal rates of return, return on investment, time-weighted rate of return, multiples of invested capital, compound annual growth rate, and many more. The good news is that you can perform all these calculations in SQL Server using XLeratorDB.
In this article we explore the difference between the two return calculations that we get the most questions about: internal rate of return and total return. You won't need an MBA in Finance to understand these examples; just follow along with SQL Server Management Studio and you will very quickly see how these calculations differ.
|
By Charles Flock on
4/10/2015 12:42 PM
XIRR is one of XLeratorDB's most popular financial functions. At Westclintech, we get more inquiries about XIRR than all of the other 200+ financial functions combined. To create a reliable version of XIRR for SQL Server we had to create, quite literally, millions of different test cases which were then tested against Excel.
One technique for creating test cases was to generate all the cash flows except the first one, then make the first cash flow equal and opposite in sign to the discounted cash flow value, or net present value, of all the other cash flows at some discount rate and check to if the internal rate of return, as calculated by the Excel XIRR function, is equal to the discount rate.
Mathematically that technique is absolutely sound, yet we discovered that Excel was not at all reliable in producing the expected result. In this article we share with you what we found.
|
By Charles Flock on
3/25/2015 10:24 AM
Diversification is the basis for any sound investment strategy and the heart of diversification is finding uncorrelated risk in different asset classes. In this article we show you how to do that using the XLeratorDB table-valued function CORRM.
|
By Charles Flock on
3/17/2015 2:41 PM
We have added 5 new functions to help you calculate internal rates of return (IRR) for a variety of day-count methods. Used in conjunction with our other day-counting functions, you can calculate IRR using actual/actual, actual/360, actual/364, business days / 252, no-leap-year / 365 and others as well as for 30/360.
|
By Charles Flock on
3/4/2015 10:08 AM
We have added 5 new functions in the latest release of XLeratorDB / statistics 2008. Four of these functions, LOGIT, LOGITSUM, LOGITPRED, and LOGITPROB are SQL Server implementations of the logistic regression, often referred to as the logit regression. The remaining function, VIF, estimates the variance inflation factor, tolerance, and R2 for a set of independent variables allowing you to test for collinearity.
|
By Charles Flock on
11/24/2014 1:11 PM
Bonds with an odd last coupon will arise infrequently in any portfolio. With XLeratorDB you can be confident that when they do show up in your portfolio you will be able to do all the necessary calculations just as easily as you can for bonds that pay regular periodic interest.
|
By Charles Flock on
11/18/2014 11:15 AM
In this article we look at shares which pay a quarterly dividend to the preferred shareholders and which are callable at some future date and discuss various techniques for calculating a yield-to-call and explain why using the YIELD function isn't one of them.
|
By Charles Flock on
9/25/2014 5:34 PM
We added 7 new table-valued functions to XLeratorDB/financial and XLeratorDB/financial 2008 that generate principal and interest payment schedules for different types of loans. This article provides insight into some of the calculations used in these new functions.
|
By Charles Flock on
7/29/2014 10:32 AM
We have previously written about calculating price, yield, and accrued interest for bonds that have regular periodic coupons. However, not all bonds fit that description. Some bonds have an odd first period, meaning that the first coupon period is either shorter or longer than all the other coupons. In this article we will discuss how that affects the calculation of price, yield, and accrued interest and why you should not use the Excel functions for these types of calculations.
|
By Charles Flock on
7/1/2014 2:36 PM
We look at some of the math behind the calculation of the price of a bond with regular periodic coupons, talk about how yield and accrued interest are calculated, and make some comparisons between the Excel functions and the XLeratorDB functions. We also talk about 2 new function that we have added to XLeratorDB that make it easier to see how PRICE and YIELD functions came up with their results.
|
By Charles Flock on
6/9/2014 1:54 PM
In this article we look at the Excel ACCRINT function, exploring the results returned by the function when it is used as documented, as well as looking at some ways of manipulating the input data so that you can get the result that you want, or at least a result that you can understand, and why you should be afraid of that data manipulation.
|
By Charles Flock on
5/8/2014 10:51 AM
As a follow up to our article on calculating a variance – covariance matrix in SQL Server, we look at a similar calculation to produce a correlation matrix and provide 2 relatively straightforward methods for calculating the correlation matrix in SQL Server, using the XLeratorDB function library, and compare them to the calculation provided in the Excel Data Analysis tool.
|
By Charles Flock on
4/15/2014 4:58 PM
In this article we look at 2 relatively straightforward methods for calculating a variance-covariance matrix in SQL Server, using the XLeratorDB function library, and compare them to the calculation provided in the Excel Data Analysis tool.
|
By Charles Flock on
4/3/2014 2:10 PM
The latest release of XLeratroDB/math contains 5 new functions for numerical integration, 12 new functions for the generation of non-uniform random numbers and, for users of SQL Server 2008 and above, 2 new functions for calculating the nth MIN or nth MAX of a data set.
|
By Charles Flock on
4/2/2014 3:23 PM
In the latest release of our math library (1.09) we introduce 5 new functions for numerical integration in SQL Server. In this second of two articles we follow up on some of the concepts behind numerical integration focusing specifically on integration over semi-infinite and infinite intervals. We will explain some of the general concepts behind numerical integration, also called quadrature, using Simpson's rule, and then look at functions for Gaussian and Double Exponential quadrature.
|
By Charles Flock on
3/31/2014 4:48 PM
In the latest release of our math library (1.09) we introduce 5 new functions for numerical integration in SQL Server. In this article we explore some of the concepts behind numerical integration and discuss the different techniques used in the new functions, focusing specifically on integration over finite intervals. We will explain some of the general concepts behind numerical integration, also called quadrature, using Simpson's rule, and then look at functions for Gauss-Kronrod, and Tanh-Sinh quadrature. In Part 2, we will look at integration over semi-infinite and infinite intervals.
|
By Charles Flock on
10/23/2013 10:55 AM
In this article we talk about the XLeratorDB GROWTHMX and LOGEST functions, compare them with the TRENDMX and LINEST functions, and describe some techniques to turbo-charge your predictive analytics in SQL Server.
|
By Charles Flock on
10/7/2013 11:16 AM
In this article we talk about the XLeratorDB TRENDMX and LINEST functions and describe some techniques to turbo-charge your predictive analytics in SQL Server.
|
By Charles Flock on
8/22/2013 4:39 PM
We have added a new function, MONOSPLINE, to the XLeratorDB/math 2008 library based on "Monotone Piecewise Cubic Interpolation," by Fritsch, F. N. and R. E. Carlson, SIAM J. Numerical Analysis, Vol. 17, 1980, pp.238-246. In this article we look at how the MONOSPLINE function works on monotonic data and compare it to linear, natural cubic spline, and polynomial interpolation in SQL Server.
|
By Charles Flock on
8/6/2013 1:50 PM
We have added new functions for calculating the statistics of inter-observer agreement, as well as enhancing existing aggregate functions which calculate descriptive statistics like variance, standard deviation, covariance, etc.
|
By Charles Flock on
6/29/2013 4:46 PM
With the release of SQL Server 2012, SQL Server users were finally able to use aggregate functions in a window, enabling calculations like running sums and moving averages. XLeratorDB/windowing put these capabilities into SQL Server 2005 and SQL Server 2008 as well as providing dozens of calculations that are not available in SQL Server 2012. With our latest release of XLeratorDB/windowing we add 14 new functions to the 38 existing functions.
|
By Charles Flock on
4/1/2013 3:32 PM
A demonstration of how to use the latest XLeratorDB / financial functions to perform yield curve construction in SQL Server.
|
By Charles Flock on
3/29/2013 4:53 PM
The latest release of XLeratorDB / finance contains a bunch of new functions for yield curve construction, 2 new bond pricing functions, and an addition to the list of Capital Asset Pricing model formulas.
|
By Charles Flock on
2/26/2013 6:27 PM
With the release of XLeratorDB/windowing 1.01 we introduce three new functions for calculating inventory values: FIFO; LIFO; and WAC. These functions calculate the quantity-on-hand, cost-of-goods sold, gross margin, and inventory value using the First In, First Out (FIFO), Last In, First Out (LIFO), or Weighted Average Cost (WAC) method. In this article we talk about how those calculations work and how you can incorporate these calculations into T-SQL statements without having to do a self-join.
|
By Charles Flock on
1/23/2013 11:57 AM
In this article we look at how moving a traditional spreadsheet calculation into SQL Server simplifies the calculation while also allowing you to analyze more data in more different ways than you would think possible
|