Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Unveils New Agentic Capabilities Across Analytics, Data Engineering, and Trust: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
scribidouille
Contributor III
Contributor III

Graphique courbes / Courbes de tendance

J'ai créé une feuille avec un graphique en courbe et pour trouver le bon modèle, j'ai créé un variable input avec show as Buttons et des valeurs fixes pour chaque modèle (linéaire, logarithmique, puissance, exponentiel, polynomial 2nd degré et 3ème degré.

Mais je voudrais récupérer les coefficients du modèle et R² pour modéliser sur faire des prévisions.
Pour les modèles linéaires, logarithmique, puissance et exponentiel, je me sers des fonctions linest_M, linest_B et linest_R2

Mais pour les modèles polynomial 2nd et 3nd degré, je ne vois pas comment faire ? il y a t il d'autres fonctions ?

est il possible d'afficher, comme sous Excel, la formule du modèle. Par exemple Y=1000x + 5 ou Y = 5 X² + 10X - 15 sur le graphique en courbes ?

Je précise que je suis en mode contributeur et donc je n'ai pas les accès au script de chargement de l'application.

Labels (1)
1 Solution

Accepted Solutions
Daniel_Castella
Support
Support

Hi @scribidouille 

 

Unfortunately, there is not a function to provide you the coefficients for 2nd degree and 3rd degree regressions.

 

The 2n degree is relatively easy to calculate, you only need 12 variables like this:

n: Count(Y)

Sx: sum(X)

Sx2: sum(pow(X,2))

Sx3: sum(pow(X,3))

Sx4: sum(pow(X,4))

Sy: sum(Y)

Sxy: sum(X*Y)

Sx2y: sum(pow(X,2)*Y)

a: =($(Sy)*($(Sx2)*$(Sx4) - pow($(Sx3),2)) - $(Sx)*($(Sxy)*$(Sx4) - $(Sx3)*$(Sx2y)) + $(Sx2)*($(Sxy)*$(Sx3) - $(Sx2)*$(Sx2y))) / ($(n)*($(Sx2)*$(Sx4) - pow($(Sx3),2)) - $(Sx)*($(Sx)*$(Sx4) - $(Sx2)*$(Sx3)) + $(Sx2)*($(Sx)*$(Sx3)- pow($(Sx2),2)))

b: =($(n)*($(Sxy)*$(Sx4) - $(Sx3)*$(Sx2y)) - $(Sx)*($(Sy)*$(Sx4) - $(Sx2)*$(Sx2y)) + $(Sx2)*($(Sy)*$(Sx3) - $(Sx2)*$(Sxy))) / ($(n)*($(Sx2)*$(Sx4) - pow($(Sx3),2)) - $(Sx)*($(Sx)*$(Sx4) - $(Sx2)*$(Sx3)) + $(Sx2)*($(Sx)*$(Sx3)- pow($(Sx2),2)))

c: =($(n)*($(Sx2)*$(Sx2y) - $(Sx3)*$(Sxy)) - $(Sx)*($(Sx)*$(Sx2y) - $(Sx3)*$(Sy)) + $(Sx2)*($(Sx)*$(Sxy) - $(Sx2)*$(Sy))) / ($(n)*($(Sx2)*$(Sx4) - pow($(Sx3),2)) - $(Sx)*($(Sx)*$(Sx4) - $(Sx2)*$(Sx3)) + $(Sx2)*($(Sx)*$(Sx3)- pow($(Sx2),2)))

R2: 1 - (sum(pow(Y-($(a)+$(b)*X + $(c)*pow(X,2)),2))/sum(pow(Y-avg(total Y),2)))

 

Being X and Y your fields in the graph and a, b and c the coefficients of the second degree formula a + b*X + c*X^2

 

But for the 3rd degree the formulas are very long. It is not efficient to try to find it in this way. It is better to use matrixial calculus, but Qlik is not designed to do that.

 

Kind Regards

Daniel

View solution in original post

1 Reply
Daniel_Castella
Support
Support

Hi @scribidouille 

 

Unfortunately, there is not a function to provide you the coefficients for 2nd degree and 3rd degree regressions.

 

The 2n degree is relatively easy to calculate, you only need 12 variables like this:

n: Count(Y)

Sx: sum(X)

Sx2: sum(pow(X,2))

Sx3: sum(pow(X,3))

Sx4: sum(pow(X,4))

Sy: sum(Y)

Sxy: sum(X*Y)

Sx2y: sum(pow(X,2)*Y)

a: =($(Sy)*($(Sx2)*$(Sx4) - pow($(Sx3),2)) - $(Sx)*($(Sxy)*$(Sx4) - $(Sx3)*$(Sx2y)) + $(Sx2)*($(Sxy)*$(Sx3) - $(Sx2)*$(Sx2y))) / ($(n)*($(Sx2)*$(Sx4) - pow($(Sx3),2)) - $(Sx)*($(Sx)*$(Sx4) - $(Sx2)*$(Sx3)) + $(Sx2)*($(Sx)*$(Sx3)- pow($(Sx2),2)))

b: =($(n)*($(Sxy)*$(Sx4) - $(Sx3)*$(Sx2y)) - $(Sx)*($(Sy)*$(Sx4) - $(Sx2)*$(Sx2y)) + $(Sx2)*($(Sy)*$(Sx3) - $(Sx2)*$(Sxy))) / ($(n)*($(Sx2)*$(Sx4) - pow($(Sx3),2)) - $(Sx)*($(Sx)*$(Sx4) - $(Sx2)*$(Sx3)) + $(Sx2)*($(Sx)*$(Sx3)- pow($(Sx2),2)))

c: =($(n)*($(Sx2)*$(Sx2y) - $(Sx3)*$(Sxy)) - $(Sx)*($(Sx)*$(Sx2y) - $(Sx3)*$(Sy)) + $(Sx2)*($(Sx)*$(Sxy) - $(Sx2)*$(Sy))) / ($(n)*($(Sx2)*$(Sx4) - pow($(Sx3),2)) - $(Sx)*($(Sx)*$(Sx4) - $(Sx2)*$(Sx3)) + $(Sx2)*($(Sx)*$(Sx3)- pow($(Sx2),2)))

R2: 1 - (sum(pow(Y-($(a)+$(b)*X + $(c)*pow(X,2)),2))/sum(pow(Y-avg(total Y),2)))

 

Being X and Y your fields in the graph and a, b and c the coefficients of the second degree formula a + b*X + c*X^2

 

But for the 3rd degree the formulas are very long. It is not efficient to try to find it in this way. It is better to use matrixial calculus, but Qlik is not designed to do that.

 

Kind Regards

Daniel