A Little Book of Python for Multivariate Analysis ...

A Little Book of Python for Multivariate

Analysis Documentation

Release 0.1

Yiannis Gatsoulis

February 21, 2016

Contents

1

Notes

2

Contents

2.1 A Little Book of Python for Multivariate Analysis . . . . . . . . . . . . . . . . . . .

2.1.1

Setting up the python environment . . . . . . . . . . . . . . . . . . . . . . .

Install Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Importing the libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Python console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.1.2

Reading Multivariate Analysis Data into Python . . . . . . . . . . . . . . . .

2.1.3

Plotting Multivariate Data . . . . . . . . . . . . . . . . . . . . . . . . . . .

A Matrix Scatterplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

A Scatterplot with the Data Points Labelled by their Group . . . . . . . . . . .

A Profile Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.1.4

Calculating Summary Statistics for Multivariate Data . . . . . . . . . . . . .

Means and Variances Per Group . . . . . . . . . . . . . . . . . . . . . . . . .

Between-groups Variance and Within-groups Variance for a Variable . . . . . .

Between-groups Covariance and Within-groups Covariance for Two Variables .

Calculating Correlations for Multivariate Data? . . . . . . . . . . . . . . . . .

Standardising Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.1.5

Principal Component Analysis . . . . . . . . . . . . . . . . . . . . . . . . .

Deciding How Many Principal Components to Retain . . . . . . . . . . . . . .

Loadings for the Principal Components . . . . . . . . . . . . . . . . . . . . .

Scatterplots of the Principal Components . . . . . . . . . . . . . . . . . . . .

2.1.6

Linear Discriminant Analysis . . . . . . . . . . . . . . . . . . . . . . . . . .

Loadings for the Discriminant Functions . . . . . . . . . . . . . . . . . . . .

Separation Achieved by the Discriminant Functions . . . . . . . . . . . . . . .

A Stacked Histogram of the LDA Values . . . . . . . . . . . . . . . . . . . .

Scatterplots of the Discriminant Functions . . . . . . . . . . . . . . . . . . . .

Allocation Rules and Misclassification Rate . . . . . . . . . . . . . . . . . . .

2.1.7

Links and Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.1.8

Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.1.9

Contact . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.1.10 License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3

License

3

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

5

5

5

5

5

6

7

7

7

7

8

9

10

11

12

14

16

18

19

20

21

24

26

26

32

34

36

37

40

41

41

41

43

i

ii

A Little Book of Python for Multivariate Analysis Documentation, Release 0.1

This booklet tells you how to use the Python ecosystem to carry out some simple multivariate analyses, with a focus

on principal components analysis (PCA) and linear discriminant analysis (LDA).

The jupyter notebook can be found on its github repository.

Contents

1

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download