Database Reference
In-Depth Information
Figure 3.1 Graphically examining the data
Each point corresponds to the number of orders and the total sales for each
customer. The plot indicates that the annual sales are proportional to the number
of orders placed. Although the observed relationship between these two variables
is not purely linear, the analyst decided to apply linear regression using the lm()
function as a first step in the modeling process.
results <- lm(sales$sales_total ˜ sales$num_of_orders)
results
Call:
lm(formula = sales$sales_total ˜ sales$num_of_orders)
Coefficients:
(Intercept) sales$num_of_orders
-154.1 166.2
The resulting intercept and slope values are -154.1 and 166.2, respectively, for the
fitted linear equation. However, results stores considerably more information
that can be examined with the summary() function. Details on the contents of
results are examined by applying the attributes() function. Because
regression analysis is presented in more detail later in the topic, the reader should
not overly focus on interpreting the following output.
summary(results)
Call:
lm(formula = sales$sales_total ˜ sales$num_of_orders)
Residuals:
Min 1Q Median 3Q Max
-666.5 -125.5 -26.7 86.6 4103.4
Coefficients:
Search WWH ::




Custom Search