regression
7 TopicsRegression Anlysis
Please assist. I want to display a regression analysis for: What proportion of staff are over-utilised (submitting more than their capacity) vs under-utilised (not using their full capacity)? https://drive.google.com/file/d/1w_-i4JvdcYApxtI3QD3MUOE52NYYvcxx/view?usp=sharing486Views0likes1CommentDAX Polynomial Regression Calculation Issue
I am attempting to implement a 2nd order polynomial regression to fit some data. It appears that I can calculate the coefficients for the regression equation correctly, but I just cannot figure out how to correctly return the correct result of the equation to use in a table/chart. Starting from this solution, I ended up with the following measure: values (poly fit) = // Reference: https://www.thedatascientists.com/polynomial-regression/ // https://metric.ma.ic.ac.uk/metric_public/matrices/inverses/inverses2.html // Because our Xs (dates) and Ys (measures) are in different tables, we have to temporarily create a new table (Known) with both of those values so we can perform SUMX operations easily. // To get the same polynomial fit as excel, the x values in the calculation are masked over with 1 thru n. Thus x-values in the calc are n+1-min(n) var countItems = COUNTX(VALUES(Table1[date]),Table1[date]) var Known = SELECTCOLUMNS ( ALLSELECTED(Table1[date]), "KnownX", [zSequence1ToN], "KnownY", CALCULATE(SUMX(Table1,[values])) ) var sumOfXs = SUMX(Known, [KnownX]) var sumOfYs = SUMX(Known, [KnownY]) var sumOfX2 = SUMX(Known, [KnownX] ^ 2) var sumOfX3 = SUMX(Known, [KnownX] ^ 3) var sumOfX4 = SUMX(Known, [KnownX] ^ 4) var sumOfXY = SUMX(Known, [KnownX] * [KnownY]) var sumOfX2Y = SUMX(Known, [KnownX] ^ 2 * [KnownY]) var determinant = countItems*((sumOfX2*sumOfX4)-(sumOfX3*sumOfX3))-sumOfXs*((sumOfXs*sumOfX4)-(sumOfX2*sumOfX3))+sumOfX2*((sumOfXs*sumOfX3)-(sumOfX2*sumOfX2)) //Calculate the inverse matrix (combining a few steps together) var M11 = ((sumOfX2*sumOfX4)-(sumOfX3*sumOfX3))/determinant var M12 = -((sumOfXs*sumOfX4)-(sumOfX3*sumOfX2))/determinant var M13 = -((sumOfX2*sumOfX2)-(sumOfXs*sumOfX3))/determinant //there was an error on this line i had to add a negative to fix. no idea why. EVERY other var evaluates correctly. var M21 = -((sumOfXs*sumOfX4)-(sumOfX2*sumOfX3))/determinant var M22 = ((countItems*sumOfX4)-(sumOfX2*sumOfX2))/determinant var M23 = -((countItems*sumOfX3)-(sumOfXs*sumOfX2))/determinant var M31 = ((sumOfXs*sumOfX3)-(sumOfX2*sumOfX2))/determinant var M32 = -((countItems*sumOfX3)-(sumOfX2*sumOfXs))/determinant var M33 = ((countItems*sumOfX2)-(sumOfXs*sumOfXs))/determinant //Assuming equation of: a*x^2 + b*x + c var c = M11*sumOfYs+M12*sumOfXY+M13*sumOfX2Y var b = M21*sumOfYs+M22*sumOfXY+M23*sumOfX2Y var a = M31*sumOfYs+M32*sumOfXY+M33*sumOfX2Y RETURN // SUMX( // DISTINCT(Table1[date]), // a * [zSequence1ToN] ^ 2 + b * [zSequence1ToN] + c // ) [a]*[zSequence1ToN]^2+[b]*[zSequence1ToN]+[c] Where [zSequence1ToN] is a RANKX of the date values zSequence1ToN = RANKX(ALLSELECTED(Table1[date]),CALCULATE(SUM(Table1[date])),,ASC) My issue is I cannot figure out how to correctly calculate this for each row in the table. The screenshot below is what I am getting (compared to what I should be getting - at least according to excel. I suspect my issue may be where I am returning the values, but at this point I am out of ideas and need advice. I have attached a sample pbix file and the excel file I was using for validation. What am I doing wrong? https://1drv.ms/u/s!Ah3VDq5HnODQgcArelYadi0cXQQZzA?e=8YdvQKSolved6.6KViews0likes8CommentsRegresion lineal multiple R studio Power Bi
Hola, ejecuté un script de r para calcular una regresión lineal multiple. Pude obtener el intercepto y slope y traspasarlos a una tabla utilizando library broom tidy(model). library(broom) model <- lm(Energía_electrica~ Grados + Transacciones,dataset) model <- tidy(model) esta es la base de datos Mes Energía_electrica Grados Transacciones Tienda ene-22 93.471 337 58.567 CD feb-22 82.053 319 51.095 CD mar-22 79.777 295 55.652 CD abr-22 67.907 204 49.633 CD may-22 71.634 185 49.520 CD jun-22 68.864 164 49.280 CD jul-22 69.559 159 50.992 CD ago-22 67.204 161 49.913 CD sept-22 63.007 172 43.913 CD oct-22 65.902 204 48.704 CD nov-22 66.469 256 46.081 CD dic-22 73.164 326 50.385 CD ene-22 132.321 354 66.405 hc feb-22 108.787 313 61.665 hc mar-22 114.572 304 65.195 hc abr-22 94.501 207 56.435 hc may-22 98.740 170 55.612 hc jun-22 87.222 151 52.630 hc jul-22 81.592 123 54.133 hc ago-22 74.998 142 50.118 hc sept-22 67.039 188 43.383 hc oct-22 77.155 212 49.618 hc nov-22 108.387 260 48.931 hc yo necesito calcular la regresión para cada tienda y que la tabla con slope e intercepto me haga una distinción de cual es para cada tienda o que con los filtros los números se actualicen (debo tener slope e intercepto en una tabla porque luego necesito ocupar esos numeros para formulas). Se puede hacer algo como un ciclo for o alguna distinción en esta nueva tabla para filtrar por tienda?1.3KViews0likes3CommentsDynamically select column based on slicer for regression/correlation calculation
Hi, I have approx 400 columns & thousand of rows. All column have numerical value. My Requirement is that, Two slicers which select dynamically two different column that will represent as x & y-axis in regression equation. Basically I need relation between any of two column out of 400 based on slicer selection. Unpivot option has challenge for big data. Also aggregation issue during unpivot. Kindly help to fix it. Thanks in advance.2.7KViews0likes15CommentsPrediction Line
I need to create a prediction line for how the progress bar should look like. (I am using a line and stacked column chart) In my data table I have begin dates and end dates. I need a measure to choose the earliest and latest dates and create a linear line between it. The yellow line is a new column, but it gives back the correct line in overall view. But as I use slicer or filter it doesn't change (as expected). Here is the code for it: Regression = VAR mind = MIN(Data_Table[Begin Date]) VAR maxd = MAX(Data_Table[End Date]) VAR dat = 'Calendar'[Date] VAR dated = DATEDIFF(mind,maxd,DAY) VAR todated = DATEDIFF(dat,maxd,DAY) VAR fromdated = DATEDIFF(mind,dat,DAY) RETURN IF(AND(fromdated>=0,todated>=0),(DIVIDE(todated,dated)-1)*(-1),IF(fromdated<0,0,1)) After this I tried to create the measure for it, but it doesn't work like it. Here is the code: Regression 2 = VAR mind = MIN(Data_Table[Begin Date]) VAR maxd = MAX(Data_Table[End Date]) VAR dat = SELECTEDVALUE('Calendar'[Date]) VAR dated = DATEDIFF(mind,maxd,DAY) VAR todated = DATEDIFF(dat,maxd,DAY) VAR fromdated = DATEDIFF(mind,dat,DAY) RETURN IF(AND(fromdated>=0,todated>=0),(DIVIDE(todated,dated)-1)*(-1),IF(fromdated<0,0,IF(todated<0,1,0))) I don't mind the spikes on the dates where there is no date (missing column), but the slope start later and before that the value is 1 rather 0. Any help with other approaches as well is much appricated it and have a lovely day.748Views0likes3CommentsDynamic Polynomial Regression
Hi, I'm wondering if I can have dynamic polynomial regression within Power BI. Regression would be as such: y = a + bx^3, where y and x are my columns. I would like to plot this regression but have the plot change based on the filter context. This is a time-stamped data, so when I filter for different date ranges, I would like to see the plot change.4.4KViews0likes3CommentsNonlinear Regression
Please would like to draw a nonlinear curve as in the figure below on a scatter plot with a curve that returns the curve's parameters to me. https://www.researchgate.net/figure/Figura-424-Curva-chave-do-posto-fluviomtrico-Monjolo-Fonte-autor-2013_fig5_3271897274.9KViews0likes3Comments