linear regression

Back to topics list To post a new topic, please log in or register
avatar
70
Keelan 2015.12.30 20:13
 

Does anyone know how to get the angle from the line of best fit. The arctan of the gradient is tiny and im not sure how to make the x and the y axis proportionate. 

Conversely the correlation co-efficient arctan inverted seems to be very close.  The only difference is one is co-variance over x variance ^ 2 while the co-efficient is the co-variance over standard dev X * standard dev Y. the deviations are rooted and obviously account for the Y axis but the angle still isnt a perfect fit, infact the straighter the line the less accurate i think and the length of X used. 

 

Anyone got a quick fix?? 

avatar
13006
WHRoeder 2015.12.30 20:34 #
 
Can't be done.
  1. There is no angle from 2 anchor points. An angle requires distance/distance a unitless number. A chart has price/time. What is the angle of going 30 miles in 45 minutes? Meaningless!
  2. You can get the slope from a trendline. Delta price/ delta time.  Changing the axes scales changes the apparent angle, the slope is constant. Angle is meaningless.
  3. You can create a angled line using one point and setting the angle. The line is drawn that angle in pixels. Changing the axes scales does NOT change the angle.
avatar
70
Keelan 2015.12.30 20:51 #
 

Yeh i tried with triangles too but the numbers didnt fit, strange how close the correlation co-efficient is to the angle of the least squares though, atleast to the eye. like it might be a 34" theta and draw a 40" theta line. It does seem to diminish the straighter the line though ughh. With values about 1 the angle seems to bear more resemblance. 1-500 on the x and y is 1 gradient per x and gives 45", 1-250 is 0.5 gradient and gives 23",  i guess thats just a perfect example though. Well damnnnn.

 

I thought there might be some abstract solution :/ 

avatar
2017
gooly 2015.12.30 21:03 #
 

1) You have to know atan(). It is limited to +/- pi/2! To get grades you have to do this: atan(m)*180.0/M_PI!

2) It is important to choose a correct 'magnifier'! If the gradient is 5 points => m=0.00005 - what do you think you'll get as angel?

avatar
70
Keelan 2015.12.30 22:30 #
 

i had a function for counting digits and multiplying out didnt work either, i was guessing its the proportionality of the x given they're positive integers, doing the standard deviation on the Y axis normalizes to some extent, well in some cases almost exactly it depends on the length used for the x, the larger the x the less accurate the inverse arctan of the co-efficient. Ive got rads to degree's and degree's to rads also, from my looking your switching rads to degree's but the arctan is still tiny.

arctan finds the length given the angle but you somehow have to quantify the axis to fully normalize it, given there's no absolute scale its either a ratio or an exponential but neither worked for me.

I'll try arctan(0.00005)*180/pi, arctan takes rads and gives rads and your multiplying by rads again.  Let me check.

 

 

Your using degreestorads where i use radstodegress. 

double radstodegrees(double val){
        //This function converts radians to degrees     
        //6.2 / 360 gives 0.0172 which is the unit ratio to degree's
        double units = 0;
        double rads = 3.14169266;
        double degrees = 180;
        double deguse = 0;

        
        deguse = (val / rads) * 180;    

        
        return deguse;
}

double degreestorads(double val){
        //This one turns degrees into radians
        double units = 0;
        double rads = 3.14169266;
        double degrees = 180;
        double deguse = 0;      
        
        
        
        units = (rads / degrees);
        deguse = units * val;   
        
        
        return deguse;
        
}

 

avatar
70
Keelan 2015.12.30 23:35 #
 
Well i've had no luck, tried all permutations, the length of x is offsetting everything
Back to topics list  

To add comments, please log in or register