Learn R Programming

MPV (version 1.64)

table5.9: Table 5.9

Description

The table5.9 data frame has 30 observations on wind income (dollars) and corresponding advertising expense. This is the Restaurant Food Sales Data of Example 5.5.

Usage

data(table5.9)

Arguments

Format

This data frame contains the following columns:

y

numeric vector of incomes

x

numeric vector of advertising expenses

Examples

Run this code
plot(y ~ x, xlab = "expense", ylab = "income", data = table5.9)
# carrying out the calculations in the example to obtain the regression
# weights:
indices <- rep(1:10, c(3, 2, 1, 5, 5, 1, 6, 2, 1, 4))
xbar <- sapply(split(table5.9$x, indices), mean)
yvarhat <- sapply(split(table5.9$y, indices), var)
xbar <- xbar[!is.na(yvarhat)]
yvarhat <- yvarhat[!is.na(yvarhat)]
eg55.lm <- lm(yvarhat ~ xbar)
wts <- 1/predict(eg55.lm, newdata = data.frame(xbar = table5.9$x))
# the values are different from those of the textbook; there seems
# to be some problem with either the calculations or the recorded values

Run the code above in your browser using DataLab