Probability with R. Jane M. Horgan
Чтение книги онлайн.
Читать онлайн книгу Probability with R - Jane M. Horgan страница 25
Название:
Автор:
Жанр:
Серия:
Издательство:
![Probability with R - Jane M. Horgan Probability with R - Jane M. Horgan](/cover_pre848404.jpg)
TABLE 3.2 The Testing Set
Observation Numbers | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|
8.5 | 9.4 | 5.4 | 11.7 | 6.5 | 10.3 | 12.7 | 11.0 | 15.4 | 2.8 |
|
49.4 | 43.0 | 19.3 | 56.4 | 28.3 | 53.7 | 58.1 | 28.7 | 80.7 | 13.6 |
Use the training set to obtain the line of best fit of
First, read the training set
x_train <- c(11.8, 10.8, 8.6, ..., 8.9) y_train <- c(31.3, 59.9, 27.6, ..., 38.5)
and the testing set
x_test <- c(8.5, 9.4, 5.4, …, 2.8) y_test <- c(49.4, 43.0, 19.3,…, 13.6)
Then, plot the training set, to establish if a linear trend exists.
plot(x_train, y_train, main = "Training Data", font.main = 1)
gives Fig. 3.17.
Figure 3.17 The Scatter of the Training Data
Since Fig. 3.17 shows a linear trend, we obtain the line of best fit of