install.packages(c("tidyverse", "cassowaryr", "tourr", "GGally", "plotly", "colorspace", "mulgar"))
ETC5521 Tutorial 9
Going beyond two variables, exploring high dimensions
đŻ Objectives
These are exercises in plots to make to explore relationships between multiple variables. You will use interactive scatterplot matrices, interactive parallel coordinate plots and tours to explore the world beyond 2D.
đ§ Preparation
- The reading for this week is Cook and Laa (2023) âInteractively exploring high-dimensional data and models in Râ Chapter 1.
- Complete the weekly quiz, before the deadline!
- Install the following R-packages if you do not have them already:
- Open your RStudio Project for this unit, (the one you created in week 1,
ETC5521
). Create a.qmd
document for this weeks activities.
đ„ Exercises
Exercise 1: Melbourne housing
- Read in a copy of the Melbourne housing data from Nick Tierneyâs github repo which is a collation from the version at kaggle. Its fairly large, so letâs start simply, and choose two suburbs to focus on. I recommend âSouth Yarraâ and âBrightonâ. (Note: there are a number of missing values. I recommend removing these before making plots.)
<- read_csv("https://raw.githubusercontent.com/njtierney/melb-housing-data/master/data/housing.csv") %>%
mel_houses ::filter(suburb %in% c("South Yarra", "Brighton")) %>%
dplyr::filter(!is.na(bedroom2)) %>%
dplyr::filter(!is.na(bathroom)) %>%
dplyr::filter(!is.na(price)) dplyr
- Make a scatterplot matrix of price, rooms, bedroom2, bathroom, suburb, type. The order of variables can affect the readability. I advise that the plot will be easier to read if you order them with the numerical variables first, and then the categorical variables. Think about what associations can be seen?
- Subset the data to South Yarra only. Make an interactive scatterplot matrix of rooms, bedroom2, bathroom and price, coloured by type of property. There is a really high price property. Select this case, and determine whatâs special about it â why did it sell for so much? Select the outlier in bedrooms and bathrooms, and examine the other characteristics of this property.
Exercise 2: Parkinsons
This dataset is composed of a range of biomedical voice measurements from 31 people, 23 with Parkinsonâs disease (PD). Each column in the table is a particular voice measure, and each row corresponds one of 195 voice recording from these individuals (ânameâ column). The main aim of the data is to discriminate healthy people from those with PD, according to âstatusâ column which is set to 0 for healthy and 1 for PD.
The data is available at The UCI Machine Learning Repository in ASCII CSV format. The rows of the CSV file contain an instance corresponding to one voice recording. There are around six recordings per patient, the name of the patient is identified in the first column. There are 24 variables in the file, including the persons name in column 1.
The data are originally analysed in: Max A. Little, Patrick E. McSharry, Eric J. Hunter, Lorraine O. Ramig (2008), âSuitability of dysphonia measurements for telemonitoring of Parkinsonâs diseaseâ, IEEE Transactions on Biomedical Engineering (to appear).
library(cassowaryr)
# Load the data
data(pk)
- How many pairwise plots would you need to look at, to look at all of them?
- Compute several of the scagnostics (monotonic, outlying, clumpy2) for the first five variables of variables, except for
name
. (Note: We are using just five for computing speed, but the scagnostics could be calculated on all variables.)
# Compute the scagnostics on the relevant variables
<- calc_scags_wide(pk[,2:5],
s scags=c("outlying","monotonic",
"clumpy2"))
s
- Sort the scagnostics, separately by the values on (i) monotonic (ii) outlying (iii) clumpy2, and plot the pair of variables with the highest values on each.
- Make an interactive scatterplot matrix. Browse over it to choose other interesting pairs of variables and make the plots.
- The scagnostics help us to find interesting associations between pairs of variables. However, the problem here is to detect differences between Parkinsons patients and normal patients. How would you go about that? Think about some ideas long the line of scagnostics but look for differences between the two groups.
Exercise 3: Challenges
For each of the data sets, c1
, âŠ, c7
from the mulgar
package, use the grand tour to view and try to identify structure (outliers, clusters, non-linear relationships).
đ Finishing up
Make sure you say thanks and good-bye to your tutor. This is a time to also report what you enjoyed and what you found difficult.