1 / 125

Summarizing Variation Matrix Algebra

This session aims to introduce summary statistics, basics of matrix algebra, and reinforce basic OpenMx syntax. It will also cover the computation of mean using different formulas, calculation of variance, and covariance between variables.

joram
Download Presentation

Summarizing Variation Matrix Algebra

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Summarizing Variation Matrix Algebra Benjamin Neale Analytic and Translational Genetics Unit, Massachusetts General Hospital Program in Medical and Population Genetics, Broad Institute of Harvard and MIT

  2. Goals of the session • Introduce summary statistics • Learn basics of matrix algebra • Reinforce basic OpenMx syntax • Introduction to likelihood

  3. Computing Mean • Formula Σ(xi)/N

  4. Computing Mean • Formula Σ(xi)/N Sum

  5. Computing Mean • Formula Σ(xi)/N Sum Each individual score (the i refers to the ith individual)

  6. Computing Mean • Formula Σ(xi)/N Sum Sample size Each individual score (the i refers to the ith individual)

  7. Computing Mean • Formula Σ(xi)/N • Can compute with

  8. Computing Mean • Formula Σ(xi)/N • Can compute with • Pencil • Calculator • SAS • SPSS • Mx • R, others….

  9. Means and matrices • For all continuous traits we will have a mean • Let’s say we have 100 traits (a lot!) • If we had to specify each mean separately we would have something like this: • M1 M2 M3 … M99 M100 (without “…”!) • This is where matrices are useful: they are boxes to hold numbers

  10. Means and matrices cont’d • So rather than specify all 100 means in OpenMx we can define a matrix to hold all of our means:

  11. Means and matrices cont’d • So rather than specify all 100 means in OpenMx we can define a matrix to hold all of our means: mxMatrix(type=“Full”, nrow=1, ncol=100, free=TRUE, values=5, name=“M”)

  12. Means and matrices cont’d • So rather than specify all 100 means in OpenMx we can define a matrix to hold all of our means: mxMatrix(type=“Full”, nrow=1, ncol=100, free=TRUE, values=5, name=“M”) Quick note on specification of matrices in text: Matrix M has dimension 1,100 meaning 1 row And 100 columns – two mnemonics – like a procession rows first then columns, or RC = Roman Catholic

  13. To the Variance! We’ll start with coin tossing…

  14. One Coin toss 2 outcomes Probability 0.6 0.5 0.4 0.3 0.2 0.1 0 Heads Tails Outcome

  15. Two Coin toss 3 outcomes Probability 0.6 0.5 0.4 0.3 0.2 0.1 0 HH HT/TH TT Outcome

  16. Four Coin toss 5 outcomes Probability 0.4 0.3 0.2 0.1 0 HHHH HHHT HHTT HTTT TTTT Outcome

  17. Ten Coin toss 11 outcomes Probability 0.3 0.25 0.2 0.15 0.1 0.05 0 Outcome

  18. Fort Knox Toss Infinite outcomes 0.5 0.4 0.3 0.2 0.1 0 -4 -3 -2 -1 0 1 2 3 4 Heads-Tails Series 1 Gauss 1827 de Moivre 1738

  19. Variance • Measure of Spread • Easily calculated • Individual differences

  20. Average squared deviation Normal distribution : 0.5 0.4 0.3 Φ(xi) 0.2 0.1 0 -4 -3 -2 -1 0 1 2 3 4 μ xi (Heads-Tails) Gauss 1827 de Moivre 1738

  21. Measuring Variation Weighs & Means • Absolute differences? • Squared differences? • Absolute cubed? • Squared squared?

  22. Measuring Variation Ways & Means • Squared differences Fisher (1922) Squared has minimum variance under normal distribution

  23. Variance calculation • Calculate mean

  24. Variance calculation • Calculate mean • Calculate each squared deviation:

  25. Variance calculation • Calculate mean • Calculate each squared deviation: • Subtract the mean from each observations and square individually: (xi-μ)2

  26. Variance calculation • Calculate mean • Calculate each squared deviation: • Subtract the mean from each observations and square individually: (xi-μ)2 • Sum up all the squared deviations

  27. Variance calculation • Calculate mean • Calculate each squared deviation: • Subtract the mean from each observations and square individually: (xi-μ)2 • Sum up all the squared deviations • Divide sum of squared deviations by (N-1)

  28. Your turn to calculate Data • Calculate mean • Calculate each deviation from the mean • Square each deviation individually • Sum the squared deviations • Divide by number of subjects - 1

  29. Your turn to calculate Data • Calculate mean (80) • Calculate each deviation from the mean (0,-10,-5,5,10) • Square each deviation individually (0,100,25,25,100) • Sum the squared deviations (250) • Divide by number of subjects – 1 (250/(5-1))=(250/4)=62.5

  30. Covariance • Measure of association between two variables

  31. Covariance • Measure of association between two variables • Closely related to variance

  32. Covariance • Measure of association between two variables • Closely related to variance • Useful to partition variance

  33. Deviations in two dimensions μx + + + + + + + + + + + + + + μy + + + + + + + + + + + + + + + + + + +

  34. Deviations in two dimensions μx dx + dy μy

  35. Different covariance Covariance .3 Covariance .5 Covariance .7

  36. Covariance calculation • Calculate mean for each variables: (μx,μy)

  37. Covariance calculation • Calculate mean for each variables: (μx,μy) • Calculate each deviation:

  38. Covariance calculation • Calculate mean for each variables: (μx,μy) • Calculate each deviation: • Subtract the mean for variable 1 from each observations of variable 1 (xi - μx )

  39. Covariance calculation • Calculate mean for each variables: (μx,μy) • Calculate each deviation: • Subtract the mean for variable 1 from each observations of variable 1 (xi - μx ) • Likewise for variable 2, making certain to keep the variables paired within subject (yi - μy )

  40. Covariance calculation • Calculate mean for each variables: (μx,μy) • Calculate each deviation: • Subtract the mean for variable 1 from each observations of variable 1 (xi - μx ) • Likewise for variable 2, making certain to keep the variables paired within subject (yi - μy ) • Multiply the deviation for variable 1 and variable 2: (xi - μx )* (yi - μy )

  41. Covariance calculation • Calculate mean for each variables: (μx,μy) • Calculate each deviation: • Subtract the mean for variable 1 from each observations of variable 1 (xi - μx ) • Likewise for variable 2, making certain to keep the variables paired within subject (yi - μy ) • Multiply the deviation for variable 1 and variable 2: (xi - μx )* (yi - μy ) • Sum up all the multiplied deviations:Σ(xi - μx )* (yi - μy )

  42. Covariance calculation • Calculate mean for each variables: (μx,μy) • Calculate each deviation: • Subtract the mean for variable 1 from each observations of variable 1 (xi - μx ) • Likewise for variable 2, making certain to keep the variables paired within subject (yi - μy ) • Multiply the deviation for variable 1 and variable 2: (xi - μx )* (yi - μy ) • Sum up all the multiplied deviations: Σ(xi - μx )* (yi - μy ) • Divide sum of the multiplied deviations by (N-1): Σ((xi - μx )* (yi - μy ))/(N-1)

  43. Your turn to calculate Data: • Calculate means • Calculate each deviation: • Subtract the mean X from each observations of X • Likewise for Y • Multiply the deviation for X and Y pair-wise • Sum up all the multiplied deviation • Divide sum of the multiplied deviations by (N-1)

  44. Your turn to calculate Data: • Calculate means: (80,180) • Calculate each deviation: • Subtract the mean for variable 1 from each observations of variable 1 (0,-10,-5,5,10) • Likewise for variable 2, making certain to keep the variables paired within subject (0,-5,-10,10,5)

  45. Your turn to calculate Data: • Multiply the deviation for variable 1 and variable 2: (0,-10,-5,5,10)*(0,-5,-10,10,5) (0,50,50,50,50) • Sum up all the multiplied deviation 0+50+50+50+50=200 • Divide sum of the multiplied deviations by (N-1): 200/4=50

  46. Measuring Covariation Covariance Formula σxy = Σ(xi - μx) * (yi - μy) (N-1)

  47. Measuring Covariation Covariance Formula σxy = Σ(xi - μx) * (yi - μy) (N-1) Sum

  48. Measuring Covariation Covariance Formula σxy = Σ(xi - μx) * (yi - μy) (N-1) Each individual score on trait x (the i refers to the ith pair)

  49. Measuring Covariation Covariance Formula σxy = Σ(xi - μx) * (yi - μy) (N-1) Mean of x

  50. Measuring Covariation Covariance Formula σxy = Σ(xi - μx) * (yi - μy) (N-1) Number of pairs

More Related