利用多发病例家族之单倍体资料进行遗传相关性研究课件_第1页
利用多发病例家族之单倍体资料进行遗传相关性研究课件_第2页
利用多发病例家族之单倍体资料进行遗传相关性研究课件_第3页
利用多发病例家族之单倍体资料进行遗传相关性研究课件_第4页
利用多发病例家族之单倍体资料进行遗传相关性研究课件_第5页
已阅读5页,还剩85页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

迴 歸 分 析迴 歸 分 析相關係數(Correlation)描述兩個變數X、Y之間的線性相關Example:data1中的身高及體重

2如何量化這樣的線性關係呢?Correlation!Linearcorrelation!相關係數(Correlation)描述兩個變數X、Y之間的相關係數(Correlation)Bydefinition,thecorrelationbetweenXandYisItsestimate,Pearson’scorrelationcoefficient3相關係數(Correlation)Bydefinitio相關係數(Correlation)r>o:positivelycorrelatedr<0:negativelycorrelatedr=0:nolinearcorrelationr=0不代表、Y之間沒有關係,有可能只是他們之間的關係不是線性的→畫圖還是必要的4相關係數(Correlation)r>o:positiv相關係數(Correlation)R程式:cor(x,y,method=c("pearson","kendall","spearman")))x:數值向量或是矩陣y:數值向量,當x是矩陣的時候,可以不需輸入5相關係數(Correlation)R程式:cor(x,y,相關係數(Correlation)若想進一步檢定vs.檢定統計量95%confidenceinterval:6相關係數(Correlation)若想進一步檢定相關係數(Correlation)R程式:cor.test(x,y,alternative=c("two.sided","less","greater"),method=c("pearson","kendall","spearman"),exact=NULL,conf.level=0.95,continuity=FALSE,...)x:數值向量y:數值向量exact:T或F,表示是否計算exactp-valuecontinuity:是否需要進行連續校正7所以身高與體重有統計顯著的正相關相關係數(Correlation)R程式:cor.testPractice8請畫出在Surgicaldata中,liver與clot的散佈圖。請問由圖中,可以看出liver與clot的關係嗎?請計算liver與clot的相關係數。請檢定liver與clot之相關係數是否為0。

Q:除了看相關性的強度,能不能看彼此如何影響?Regression!Practice8請畫出在Surgicaldata中,lLinearRegressionStep1:

血壓的分布,該分布是否男女有別;Step2:血壓是否和體重有線性相關;Step3:該線性關係如何描述;Step4:如何描述血壓和體重、性別、等等的關係。Y:responsevariable,dependentvariable(say,bp)X:covariate,explanatoryvariable,independentvariable(say,weight)9LinearRegressionStep1:血壓的分布,LinearRegressionQ:howdoesX

affectY?Canwefitalineinthescatterplot?Infact,weshouldsay,whereiscallederror,isnormalwithzeromeanandvariance2.10LinearRegressionQ:howdoesXRegression

model-simplelinearregression

11直線上的點是估的,叫fittedvalues,這是已知體重X之後,期望的血壓值,是期望值,故人稱regresstowardthemean;這和觀察值不同,有samplingvariationRegressionmodel-simplelineaEstimatecoefficientsHowtofind(intercept)and(slope)?LeastSquares!Minimizeresidualsumofsquares

Takederivative12“residual”isthedifferencebetweenfittedandobservedvalues;Y軸的差EstimatecoefficientsHowtofiEstimatecoefficientsRearrangetheterms,getnormalequationsSolvingthenormalequations,wegetestimates13EstimatecoefficientsRearrangeAretheseLSEgood?Aretheyunbiased?Standarderrorsoftheseestimates?14UnbiasedAretheseLSEgood?AretheyunAretheseLSEgood?Instatistics,toask“Aretheseestimatesgood?”isthesameasasking“Aretheyclosetothetruevalues?”Theyaregoodinthesensethattheyareunbiased.Theyarebestlinearunbiasedestimators(BLUE)Gauss-Markovtheorem:Undertheconditionsofregressionmodel(mean,constantvariance,uncorrelatederrors),theleastsquaresestimatorsareunbiasedandhaveminimumvarianceamongallunbiasedlinearestimators.15AretheseLSEgood?InstatistiEstimationofvariancecanbeestimatedbyTherefore16EstimationofvariancecanLinearregressionusingRR程式:lm(formula,data,...)formula:y~x,其中y是response,x是covariate

173.943=70.8432/17.9663LinearregressionusingRR程式:lLinearregressionConfidenceintervalofand?Uset-distributionwithdf=n-2Testingifthecoefficient=0?If=0?Usetwithdf=n-2Anincreaseof1kginWeightleadstoanincreaseof0.7167inBp.Ifsomeoneweighs70kg,thenhis/herbpisestimatedby70.84+0.7270=121.24---interpolation18LinearregressionConfidenceinLinearregressionMeaningfulwhenestimatingbpwith120kg?notreally,outsidetherangeofthedata,dangerousextrapolationRegressiondoesnotimplycausality.ItsimplyreflectstheregressionrelationbetweenX(weight)andY(bp).ThisregressiondoesnotsayXcausesY.Canweusebptopredictweight?yes,ifweightisthevariableofinterest19LinearregressionMeaningfulwhPractice想知道在Surgicaldata中,clot如何影響liver,請建立liver與clot之迴歸模式。如何解釋此模型呢?請問clot對liver的影響是顯著的嗎?20Practice想知道在Surgicaldata中,clHomework想知道在Surgicaldata中,enzyme如何影響SVtime,請建立enzyme與SVtime之迴歸模式。如何解釋此模型呢?請問enzyme對SVtime的影響是顯著的嗎?21Homework想知道在Surgicaldata中,enHowgoodistheregression?Howgooddoesthelineexplainallthevariationiny?Howgooddoesthefittedcorrelationof(X,Y)explainY?因為定義判斷係數(coefficientofdetermination):

Pearson’scorrelationcoefficientInsimplelinearregression,22totaldeviationinresponsesaroundthegrandmeandeviationofobservationsaroundfittedlinedeviationoffittedvaluesaroundthegrandmeanSSTOSSESSRpercentageofvariationexplainedbyregressionlineHowgoodistheregression?HowExample

23R2=0.4149Example23R2=0.4149AVOVAtableofregression

24SSESSRAVOVAtableofregression24SSEPractice在Surgicaldata中,模式為liver~clot請問在此模型中,判斷係數為多少25Practice在Surgicaldata中,模式為liDiagnostics26基本假設:殘差平均為0,相差變異數相同,殘差之間不相關看看殘差的分佈情況看殘差和index的關係(應該要沒關係)殘差應該要和fittedvalue無關殘差應該要與解釋變數無關Diagnostics26基本假設:殘差平均為0,相差變異DiagnosticsIf…27Randomlyscatteredaroundzero!Fromminustopositive!Modelmaynotbeproper.Timeeffect?(Ifx=time)Linearity有問題試試polynomial或transformX?Constantvar有問題;若X值大則var大;試試加別的X或是weightedLS?DiagnosticsIf…27RandomlyscaExample

28Example28Q-Qplot如果殘差服從常態分配,那麼除了它的長條圖像常態之外,它的排名的值和實際母體同排名的值像不像呢?Thequantileoftheresidualversusthenormalquantile:29OrderedStudentdizedResiduals,Q(quantiles)Rank/total(cumulativeprob.)c.p.FindzwhereP(Zz)=c.p.Usemodifiedc.p.*=(rank-0.375)/(n+0.25)getz*s.t.P(Zz*)=c.p.*

Qc.p.zc.p.*

z*-1.881/6=17%-0.9710%-1.28-1.332/6=33%-0.4326%-0.64-0.9

3/6=50%042%-0.20.34/6=67%0.4358%0.20.75/6=83%0.9774%0.641.76/6=100%inf90%1.28將殘差標準化,再排序,第2/6(=0.33)分位的quantile是-1.33即P(ei-1.33)=2/6算出排序的名次對常態來說,第2/6(=0.33)分位的quantile是-0.43;即P(Z-0.43)=2/6=33%對常態來說第0.26分位的quantile是-0.64;即P(Z-0.64)=26%PlotthesetwocolumnsQ-Qplot如果殘差服從常態分配,那麼除了它的長條圖像常Q-QplotIfclosetoaX=Ystraightline,thenresidualsclosetonormality!R程式:qqnorm(model1$”residuals”)30殘差中排名4/6的殘差值和N(0,1)中累積機率為4/6的值Q-Qplot30殘差中排名4/6的殘差值和N(0,1)中Q-Qplot

31YisrightskewedYisleftskewedQ-Qplot31YisrightskewedYDiagnosticsinR

32DiagnosticsinR32DiagnosticsplotstoexamineThelineareffectofeachpredictor:orConstantvariance:Independenceofsamples:orNormalityassumption:Q-QplotOtherimportantpredictors?Say:Arethereoutliers:,scatterplot,…IfYes,examineifitistrueoutlier,orgrosserror.IfYes,moredatanearthispoint.IfNo,deletethedatapointbeforeregressionanalysis.6→fittedmodel→2→3→1→4→533Diagnosticsplotstoexamine33Practice在Surgicaldata中,模式為liver~clot請問此模式符合迴歸的假設嗎?34Practice在Surgicaldata中,模式為liMultiplelinearregressionExtensionofSLR,includingmorethanonepredictorsinthemodel35Linear?Linear?Difference?MultiplelinearregressionExteMultiplelinearregressionModel::regressioncoefficients:observeddataareindependent

Inmatrixform36MultiplelinearregressionModeMultiplelinearregression哪些term可以放到X中呢?Predictors:如例子中的weight,age,sexTransformationsofpredictorsPolynomials:andDummyvariablesandfactorsInteractionsandothercombinationsofpredictors:37Multiplelinearregression哪些teExample38

Example38Inferenceofregressioncoefficients和SLR時一樣,用最小平方法satisfyGauss-MarkovThm39InferenceofregressioncoeffiInferenceofregressioncoefficients和在SLR中相同,我們想要估計

的confidenceinterval,或是進行檢定,需要先估計出

Recall,inSLR40Hiscalledhatmatrix

SST=SSE+SSRTherearep-1covariatesintheregressionmodel.Therearenobservationsandpparameters.InferenceofregressioncoeffiInferenceofregressioncoefficients想要知道整個模式fit如何:Under,E(MSR)=;otherwiseE(MSR)>Define,withdf=(p-1,n-p)在H0之下,,所以如果F偏離1太遠,我們就傾向拒絕H0H1是什麼呢?

41InferenceofregressioncoeffiInferenceofregressioncoefficients若是針對某個

,想知道

是否和

有線性關係在H0之下,所以拒絕H0,如果你可以由此推出

的confidentinterval嗎?42InferenceofregressioncoeffiExample

43Example43Practice44在Surgicaldata中想知道影響存活時間(SVtime)的因素,將存活時間取自然對數。有興趣的因素為clot、prog、enzyme與age請寫下此迴歸模式請問prog的係數為0嗎?請問此模式顯著嗎?Practice44在Surgicaldata中想知道影Homework在bodyfat資料中,共包含4個變項(Y、X1、X2、X3)請分別畫出Y與X1、X2、X3的散佈圖,請問Y和X1、X2、X3有線性關係嗎?請分別檢定X1、X2、X3的迴歸係數是否為0請問此模式是顯著的嗎?45Homework在bodyfat資料中,共包含4個變項(Y、迴 歸 分 析迴 歸 分 析相關係數(Correlation)描述兩個變數X、Y之間的線性相關Example:data1中的身高及體重

47如何量化這樣的線性關係呢?Correlation!Linearcorrelation!相關係數(Correlation)描述兩個變數X、Y之間的相關係數(Correlation)Bydefinition,thecorrelationbetweenXandYisItsestimate,Pearson’scorrelationcoefficient48相關係數(Correlation)Bydefinitio相關係數(Correlation)r>o:positivelycorrelatedr<0:negativelycorrelatedr=0:nolinearcorrelationr=0不代表、Y之間沒有關係,有可能只是他們之間的關係不是線性的→畫圖還是必要的49相關係數(Correlation)r>o:positiv相關係數(Correlation)R程式:cor(x,y,method=c("pearson","kendall","spearman")))x:數值向量或是矩陣y:數值向量,當x是矩陣的時候,可以不需輸入50相關係數(Correlation)R程式:cor(x,y,相關係數(Correlation)若想進一步檢定vs.檢定統計量95%confidenceinterval:51相關係數(Correlation)若想進一步檢定相關係數(Correlation)R程式:cor.test(x,y,alternative=c("two.sided","less","greater"),method=c("pearson","kendall","spearman"),exact=NULL,conf.level=0.95,continuity=FALSE,...)x:數值向量y:數值向量exact:T或F,表示是否計算exactp-valuecontinuity:是否需要進行連續校正52所以身高與體重有統計顯著的正相關相關係數(Correlation)R程式:cor.testPractice53請畫出在Surgicaldata中,liver與clot的散佈圖。請問由圖中,可以看出liver與clot的關係嗎?請計算liver與clot的相關係數。請檢定liver與clot之相關係數是否為0。

Q:除了看相關性的強度,能不能看彼此如何影響?Regression!Practice8請畫出在Surgicaldata中,lLinearRegressionStep1:

血壓的分布,該分布是否男女有別;Step2:血壓是否和體重有線性相關;Step3:該線性關係如何描述;Step4:如何描述血壓和體重、性別、等等的關係。Y:responsevariable,dependentvariable(say,bp)X:covariate,explanatoryvariable,independentvariable(say,weight)54LinearRegressionStep1:血壓的分布,LinearRegressionQ:howdoesX

affectY?Canwefitalineinthescatterplot?Infact,weshouldsay,whereiscallederror,isnormalwithzeromeanandvariance2.55LinearRegressionQ:howdoesXRegression

model-simplelinearregression

56直線上的點是估的,叫fittedvalues,這是已知體重X之後,期望的血壓值,是期望值,故人稱regresstowardthemean;這和觀察值不同,有samplingvariationRegressionmodel-simplelineaEstimatecoefficientsHowtofind(intercept)and(slope)?LeastSquares!Minimizeresidualsumofsquares

Takederivative57“residual”isthedifferencebetweenfittedandobservedvalues;Y軸的差EstimatecoefficientsHowtofiEstimatecoefficientsRearrangetheterms,getnormalequationsSolvingthenormalequations,wegetestimates58EstimatecoefficientsRearrangeAretheseLSEgood?Aretheyunbiased?Standarderrorsoftheseestimates?59UnbiasedAretheseLSEgood?AretheyunAretheseLSEgood?Instatistics,toask“Aretheseestimatesgood?”isthesameasasking“Aretheyclosetothetruevalues?”Theyaregoodinthesensethattheyareunbiased.Theyarebestlinearunbiasedestimators(BLUE)Gauss-Markovtheorem:Undertheconditionsofregressionmodel(mean,constantvariance,uncorrelatederrors),theleastsquaresestimatorsareunbiasedandhaveminimumvarianceamongallunbiasedlinearestimators.60AretheseLSEgood?InstatistiEstimationofvariancecanbeestimatedbyTherefore61EstimationofvariancecanLinearregressionusingRR程式:lm(formula,data,...)formula:y~x,其中y是response,x是covariate

623.943=70.8432/17.9663LinearregressionusingRR程式:lLinearregressionConfidenceintervalofand?Uset-distributionwithdf=n-2Testingifthecoefficient=0?If=0?Usetwithdf=n-2Anincreaseof1kginWeightleadstoanincreaseof0.7167inBp.Ifsomeoneweighs70kg,thenhis/herbpisestimatedby70.84+0.7270=121.24---interpolation63LinearregressionConfidenceinLinearregressionMeaningfulwhenestimatingbpwith120kg?notreally,outsidetherangeofthedata,dangerousextrapolationRegressiondoesnotimplycausality.ItsimplyreflectstheregressionrelationbetweenX(weight)andY(bp).ThisregressiondoesnotsayXcausesY.Canweusebptopredictweight?yes,ifweightisthevariableofinterest64LinearregressionMeaningfulwhPractice想知道在Surgicaldata中,clot如何影響liver,請建立liver與clot之迴歸模式。如何解釋此模型呢?請問clot對liver的影響是顯著的嗎?65Practice想知道在Surgicaldata中,clHomework想知道在Surgicaldata中,enzyme如何影響SVtime,請建立enzyme與SVtime之迴歸模式。如何解釋此模型呢?請問enzyme對SVtime的影響是顯著的嗎?66Homework想知道在Surgicaldata中,enHowgoodistheregression?Howgooddoesthelineexplainallthevariationiny?Howgooddoesthefittedcorrelationof(X,Y)explainY?因為定義判斷係數(coefficientofdetermination):

Pearson’scorrelationcoefficientInsimplelinearregression,67totaldeviationinresponsesaroundthegrandmeandeviationofobservationsaroundfittedlinedeviationoffittedvaluesaroundthegrandmeanSSTOSSESSRpercentageofvariationexplainedbyregressionlineHowgoodistheregression?HowExample

68R2=0.4149Example23R2=0.4149AVOVAtableofregression

69SSESSRAVOVAtableofregression24SSEPractice在Surgicaldata中,模式為liver~clot請問在此模型中,判斷係數為多少70Practice在Surgicaldata中,模式為liDiagnostics71基本假設:殘差平均為0,相差變異數相同,殘差之間不相關看看殘差的分佈情況看殘差和index的關係(應該要沒關係)殘差應該要和fittedvalue無關殘差應該要與解釋變數無關Diagnostics26基本假設:殘差平均為0,相差變異DiagnosticsIf…72Randomlyscatteredaroundzero!Fromminustopositive!Modelmaynotbeproper.Timeeffect?(Ifx=time)Linearity有問題試試polynomial或transformX?Constantvar有問題;若X值大則var大;試試加別的X或是weightedLS?DiagnosticsIf…27RandomlyscaExample

73Example28Q-Qplot如果殘差服從常態分配,那麼除了它的長條圖像常態之外,它的排名的值和實際母體同排名的值像不像呢?Thequantileoftheresidualversusthenormalquantile:74OrderedStudentdizedResiduals,Q(quantiles)Rank/total(cumulativeprob.)c.p.FindzwhereP(Zz)=c.p.Usemodifiedc.p.*=(rank-0.375)/(n+0.25)getz*s.t.P(Zz*)=c.p.*

Qc.p.zc.p.*

z*-1.881/6=17%-0.9710%-1.28-1.332/6=33%-0.4326%-0.64-0.9

3/6=50%042%-0.20.34/6=67%0.4358%0.20.75/6=83%0.9774%0.641.76/6=100%inf90%1.28將殘差標準化,再排序,第2/6(=0.33)分位的quantile是-1.33即P(ei-1.33)=2/6算出排序的名次對常態來說,第2/6(=0.33)分位的quantile是-0.43;即P(Z-0.43)=2/6=33%對常態來說第0.26分位的quantile是-0.64;即P(Z-0.64)=26%PlotthesetwocolumnsQ-Qplot如果殘差服從常態分配,那麼除了它的長條圖像常Q-QplotIfclosetoaX=Ystraightline,thenresidualsclosetonormality!R程式:qqnorm(model1$”residuals”)75殘差中排名4/6的殘差值和N(0,1)中累積機率為4/6的值Q-Qplot30殘差中排名4/6的殘差值和N(0,1)中Q-Qplot

76YisrightskewedYisleftskewedQ-Qplot31YisrightskewedYDiagnosticsinR

77DiagnosticsinR32DiagnosticsplotstoexamineThelineareffectofeach

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论