Reputation: 3
I'm trying to plot ad odr regression. I used the code from this post as an example: sample code this is my code:
# regressione ODR
import scipy.odr as odr
def funzione(B,x):
return B[0]*x+B[1]
linear= odr.Model(funzione)
variabili=odr.Data(database.valore_rut,database.valore_cap)
regressione_ortogonale=odr.ODR(variabili,linear,beta0=[1., 2.])
output=regressione_ortogonale.run()
output.pprint()
this is the output
Beta: [ 1.00088365 1.78267543]
Beta Std Error: [ 0.04851125 0.41899546]
Beta Covariance: [[ 0.00043625 -0.00154797]
[-0.00154797 0.03254372]]
Residual Variance: 5.39450361153
Inverse Condition #: 0.109803542662
Reason(s) for Halting:
Sum of squares convergence
where can i find the intercept and the slope to draw the line?
Thanks
Upvotes: 0
Views: 1394
Reputation: 114921
The attribute output.beta
holds the coefficients, which you called B
in your code. So the slope is output.beta[0]
and the intercept is output.beta[1]
.
To draw a line, you could do something like:
# xx holds the x limits of the line to draw. The graph is a straight line,
# so we only need the endpoints to draw it.
xx = np.array([start, stop])
yy = funzione(output.beta, xx)
plot(xx, yy)
Upvotes: 1