
Re: Linest_b, linest_m, tables and multiplications
Sunny Talwar Dec 18, 2017 10:13 AM (in response to Simone Trabattoni)
285409.qvf 192.0 K

Re: Linest_b, linest_m, tables and multiplications
Simone Trabattoni Dec 18, 2017 10:20 AM (in response to Sunny Talwar )Awesome as usual!! Thanks!


Re: Linest_b, linest_m, tables and multiplications
Martin Baculik Dec 18, 2017 10:14 AM (in response to Simone Trabattoni)Hi Simone,
have you tried something like LINEST_B(TOTAL x,y)?
BR
Martin

Re: Linest_b, linest_m, tables and multiplications
Simone Trabattoni Dec 18, 2017 10:28 AM (in response to Simone Trabattoni)If I can ask,
how could put it in a histogram?

Re: Linest_b, linest_m, tables and multiplications
Sunny Talwar Dec 18, 2017 10:29 AM (in response to Simone Trabattoni)First of all, do you agree with the numbers? I not not even sure if you get the right numerical output or not

Re: Linest_b, linest_m, tables and multiplications
Simone Trabattoni Dec 27, 2017 3:37 AM (in response to Sunny Talwar )I've double checked the formulae (qlik sense, theory and R) and it is better in this way
y(linest_b( total y,x))(LINEST_M(total y,x))*x
However the issue was the TOTAL, whom saves my day.


Re: Linest_b, linest_m, tables and multiplications
Martin Baculik Dec 18, 2017 10:55 AM (in response to Simone Trabattoni)Hi Simone,
use bar chart object, insert add Dimension: x(linest_b( total x,y))(LINEST_M(total x,y))*y as Dimension, and put Count(a) as Expression.
BR
Martin

Re: Linest_b, linest_m, tables and multiplications
Simone Trabattoni Dec 18, 2017 10:59 AM (in response to Martin Baculik)Hi Martin,
thanks. I'd like to use the Qlik Sense Histogram, not a barchart. It needs only one "field", nor a dimension, neither a measure specifically. Using a barchart works technically, bit it is going to count "one" for each value of the dimension, making it not useable. Generally a Histogram should have only a measure and you can vary the width of the bins.

Re: Linest_b, linest_m, tables and multiplications
Sunny Talwar Dec 18, 2017 11:05 AM (in response to Simone Trabattoni)May be create a new field in the script and use that to create your histogram
Table:
LOAD * INLINE [
a, x, y
a, 3, 4
b, 4, 5
c, 5, 9
d, 7, 1
];
Left Join (Table)
LOAD LINEST_B(x,y) as b,
LINEST_M(x,y) as m
Resident Table;
FinalTable:
LOAD *,
xbm*y as z
Resident Table;
DROP Table Table;
Now use z to create your histogram

Re: Linest_b, linest_m, tables and multiplications
Simone Trabattoni Dec 22, 2017 9:58 AM (in response to Sunny Talwar )Thanks Sunny (sorry for the delay),
but I need to have the solution alive, that is not possible to do it working on the load script. Those data are more simple than the real data, furthermore I'd like to have different regression at the variation of the selections.
There are some nice guide to bend a barplot to a histogram, but the problem is that I'd like to use the "new"features, being I hope more simple.
If they are not easy for their classical use (you know, histograms are used for the study of the residuals in a regression), probably I'm doing something wrong.

Re: Linest_b, linest_m, tables and multiplications
Sunny Talwar Dec 22, 2017 10:03 AM (in response to Simone Trabattoni)You want regression to change based on selection and yet you want it in the script? I am not sure how this would work.... May be someone else might have some good ideas for you

Re: Linest_b, linest_m, tables and multiplications
Simone Trabattoni Dec 27, 2017 3:36 AM (in response to Sunny Talwar )No, sorry, I was not clear: only in selections. Everything is ok till now with your help, the only issue is to put the results of this
y(linest_b( total y,x))(LINEST_M(total y,x))*x
in a histogram.

Re: Linest_b, linest_m, tables and multiplications
Sunny Talwar Dec 22, 2017 10:42 AM (in response to Simone Trabattoni)What would the result look like? Would you be able to draw a picture with the numbers you expect to see?

Re: Linest_b, linest_m, tables and multiplications
Simone Trabattoni Dec 22, 2017 11:00 AM (in response to Sunny Talwar )Sure!
we have those data
# this is a "load*inline" in R:
x < c(3,4,5,7)
y < c(3,5,9,1)
# here the model in R
model < lm(y~x)
#results intercept is the result of Qlik linest_b, x is the result of linest_m. (DONE!)
Coefficients:
(Intercept) x
6.9429 0.5143
#here the residuals: the result is equal to the Qlik formula x(linest_b( total x,y))(LINEST_M(total x,y))*y (DONE!)
residuals(model)
1 2 3 4
2.4000000 0.1142857 4.6285714 2.3428571
# Here what I want: an histogram of the residuals. i.e. (TO DO!)
hist(residuals(model))
With a quick and dirty result.

Re: Linest_b, linest_m, tables and multiplications
Sunny Talwar Dec 22, 2017 11:17 AM (in response to Simone Trabattoni)
Re: Linest_b, linest_m, tables and multiplications
Simone Trabattoni Dec 27, 2017 3:41 AM (in response to Sunny Talwar )Sorry for the delay!
They indicate each point of the model, in this case we have four units, so there are four residuals (1,2,3,4).
Residuals (the values under 1,2,3,4) are the difference between the estimates value of the regression (i.e. the points of the line of the regression for each unit) and the real value of the points.
They are one of the thing to look at to see if the regression is a good model or a bad one. For exaple is useful to see if they are distributed like a Normal variable, and the easiest way (not perfect) is to put them in an Histogram.
The formula should be something like (in our case)
y(6.9429)(0.5143)*x
In Qlik Sense
y(linest_b( total y,x))(LINEST_M(total y,x))*x // with your help
Where y and x are the data vector.
The result is the vector that you got after residuals(model).
(I'm going to edit some post, due I've inverted x and y in the model, but the reasoning is te same).

Re: Linest_b, linest_m, tables and multiplications
Sunny Talwar Dec 27, 2017 9:53 AM (in response to Simone Trabattoni)
285409.qvf 208.0 K

Re: Linest_b, linest_m, tables and multiplications
Simone Trabattoni Dec 27, 2017 10:06 AM (in response to Sunny Talwar )This is pretty awesome, I knew it, but I having it in this post great. Also, if you add a simple variable and use the extension that allows to put inputs, you can vary the number of the class a bit more dynamically.
My idea is to use the official "histogram".
I'll use your idea, I need a result and it is great, but in your opinion, why using the histogram (official one) is so problematic? It is quite absurd to use such a "complex" workaround!
Thanks in advance for your patience and wide competence.

Re: Linest_b, linest_m, tables and multiplications
Sunny Talwar Dec 27, 2017 10:10 AM (in response to Simone Trabattoni)I am not too familiar with the new Qlik Sense chart, but it appears that Histogram works with a field rather than a calculated dimension. If it worked with calculated dimension, the problem would have easily resolved. May be this is something in the pipeline for Qlik... I don't really know....












