Book Image

Learning Bayesian Models with R

By : Hari Manassery Koduvely
Book Image

Learning Bayesian Models with R

By: Hari Manassery Koduvely

Overview of this book

Table of Contents (16 chapters)
Learning Bayesian Models with R
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Exercises


For the following exercises in this chapter, we use the Auto MPG dataset from the UCI Machine Learning repository (references 5 and 6 in the References section of this chapter). The dataset can be downloaded from https://archive.ics.uci.edu/ml/datasets.html. The dataset contains the fuel consumption of cars in the US measured during 1970-1982. Along with consumption values, there are attribute variables, such as the number of cylinders, displacement, horse power, weight, acceleration, year, origin, and the name of the car:

  • Load the dataset into R using the read.table() function.

  • Produce a box plot of mpg values for each car name.

  • Write a function that will compute the scaled value (subtract the mean and divide by standard deviation) of a column whose name is given as an argument of the function.

  • Use the lapply() function to compute scaled values for all variables.

  • Produce a scatter plot of mgp versus acceleration for each car name using coplot(). Use legends to annotate the graph.