- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Explaining 'Vec Quadratic()'
Having discussed the JSL 'Vec Quadratic()' function with a computer scientist, we both agreed we didn't understand the exact workings of it. I've also checked the Scripting Index and Documentation Library:
The issue came up with the attached example of prediction and confidence interval calculation, where this function is used. Specifically, what none of use can read is the part after the covariance matrix, and why it involves a concatenation ('[1] || :X') (see also screenshot below).
If someone could explain or point me into a direction of further documentation, I'd appreciate that very much.
This post originally written in German and has been translated for your convenience. When you reply, it will also be translated back to German.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Explaining 'Vec Quadratic()'
Hi @Ressel ,
I hope that I'll be able to somewhat explain, or at least shed some more light on this issue.
If you go back through the Scripting Index and follow the example that they have for Vec Quadratic() it'll make a lot more sense. If you have a matrix X = [1 3 5, 2 4 6], which is a 2x3 matrix, and if you take it's transpose to get a 3x2 matrix, X' = [1 2, 3 4, 5 6].
The next step is to perform standard matrix dot product with the symmetric matrix, S = [1 3 5, 3 2 6 , 5 6 1], S*X':
S*X' = [1 3 5, 3 2 6 , 5 6 1]*[1 2, 3 4, 5 6] = [1+9+25 2+12+30, 3+6+30 6+8+36, 5+18+5 10+24+6] = [35 44, 39 50, 28 40].
The next step is to then do the dot product of this new matrix with X to get a new 2x2 matrix:
X*(S*X') = [1 3 5, 2 4 6]*[35 44, 39 50, 28 40] = [292 394, 394 528].
The Vec Quadratic function then simply takes the diagonal elements of this to give you the vector [292, 528].
The concatenate function || is there so that the formula can multiply the 2x2 symmetric matrix with a 2x1 transposed matrix for that row in the data table. For example, with row 1, the Vec Quadratic will end up looking like this Vec Quadratic( [2.33333333333333 -1, -1 0.5], [1] || 1 ). which is the same as Vec Quadratic( [2.33333333333333 -1, -1 0.5], [1,1] ). The [1]||:X for row 1 ends up looking like [1 1] and for row 2 looks like [1 2], etc. The formula needs to take the single row entry for :X and convert it to a matrix, so that's what the [1]||:X is doing in the formula.
I hope this makes sense.
Good luck!,
DS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Explaining 'Vec Quadratic()'
Hi @Ressel ,
I hope that I'll be able to somewhat explain, or at least shed some more light on this issue.
If you go back through the Scripting Index and follow the example that they have for Vec Quadratic() it'll make a lot more sense. If you have a matrix X = [1 3 5, 2 4 6], which is a 2x3 matrix, and if you take it's transpose to get a 3x2 matrix, X' = [1 2, 3 4, 5 6].
The next step is to perform standard matrix dot product with the symmetric matrix, S = [1 3 5, 3 2 6 , 5 6 1], S*X':
S*X' = [1 3 5, 3 2 6 , 5 6 1]*[1 2, 3 4, 5 6] = [1+9+25 2+12+30, 3+6+30 6+8+36, 5+18+5 10+24+6] = [35 44, 39 50, 28 40].
The next step is to then do the dot product of this new matrix with X to get a new 2x2 matrix:
X*(S*X') = [1 3 5, 2 4 6]*[35 44, 39 50, 28 40] = [292 394, 394 528].
The Vec Quadratic function then simply takes the diagonal elements of this to give you the vector [292, 528].
The concatenate function || is there so that the formula can multiply the 2x2 symmetric matrix with a 2x1 transposed matrix for that row in the data table. For example, with row 1, the Vec Quadratic will end up looking like this Vec Quadratic( [2.33333333333333 -1, -1 0.5], [1] || 1 ). which is the same as Vec Quadratic( [2.33333333333333 -1, -1 0.5], [1,1] ). The [1]||:X for row 1 ends up looking like [1 1] and for row 2 looks like [1 2], etc. The formula needs to take the single row entry for :X and convert it to a matrix, so that's what the [1]||:X is doing in the formula.
I hope this makes sense.
Good luck!,
DS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Explaining 'Vec Quadratic()'
Thanks, that makes a lot of sense, of course.