Python Programming for Biology: Bioinformatics and Beyond


Figure 22.9.  An example of simple linear regression applied to a linearly correlated



Download 7,75 Mb.
Pdf ko'rish
bet364/514
Sana30.12.2021
Hajmi7,75 Mb.
#91066
1   ...   360   361   362   363   364   365   366   367   ...   514
Bog'liq
[Tim J. Stevens, Wayne Boucher] Python Programming

Figure 22.9.  An example of simple linear regression applied to a linearly correlated

data set. The two random variables X and Y have been fitted by the minimisation of the

difference, at a specified X-value, between the Y-value of each point and the Y-value at the

line. The Y-intercept, α (where x = 0) and gradient, β were calculated as illustrated in the

Python example shown in the text.

Accordingly,  the  fitted  line  has  a  gradient  and  Y-intercept  close  to  the  artificial  test

values of −0.7 and 2.0. There is also a handy function in the scipy.stats function linregress

which  calculates  lots  of  useful  things  in  one  fell  swoop,  including  the  correlation

coefficient and the two-tailed probability of the hypothesis that the gradient is zero. Here

we do the linear regression and then plot the best-fit line on the same graph as the input

data (like

Figure 22.9

):

from scipy.stats import linregress



from matplotlib import pyplot

grad, yInt, corrCoeff, pValue, stdErr = linregress(xVals, yVals)

print('LR 2:', grad, yInt, corrCoeff, pValue, stdErr)

# Result for one run was: -0.711, 2.04, -0.949, 9.639e-51, 0.0240

xValsFit = [xVals.min(),xVals.max()]

yValsFit = [yInt + x*grad for x in xValsFit]

pyplot.plot(xVals, yVals, 'o')

pyplot.plot(xValsFit, yValsFit)

pyplot.show()

Tailed tests and confidence intervals may be calculated more generally for the gradient

using a T-test (with n−2 degrees of freedom). Here the T-statistic is calculated as follows,

where   is the estimated gradient and

is a y value estimated by the fit line:



1

The probability of a Type I error is usually denoted by α, and the probability of a Type

II  error  by  β.  We  sometimes  speak  of  the  power  of  a  statistical  analysis,  which  is  the

probability  that  the  null  hypothesis  has  been  rejected  when  it  really  is  false,  which  is

equivalent to 1 − β.


Download 7,75 Mb.

Do'stlaringiz bilan baham:
1   ...   360   361   362   363   364   365   366   367   ...   514




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish