14 Interactions
library(tidyverse)
source("~/rstudioshared/IRamler/scripts/slunova.R") # for ANOVA test
GFclocks.csv contains information on auctions of antique grandfather clocks, including the age of the grandfather clock, the number of people bidding on the clock, and the auction price.
= read_csv("data/GFclocks.CSV") GFclocks
A collector of antique grandfather clocks knows that the price received for the clocks increases linearly with the age of the clocks. Moreover, the collector hypothesizes that the auction price of the clocks will increase linearly as the number of bidders increases.
= ggplot(GFclocks, aes(x=Bidders, y=AuctionPrice)) +
g geom_point() +
labs(x="Number of Bidders",y="Auction Price (USD)")
g
- Fit a model that uses both age and number of bidders as predictors of auction price. Write the fitted prediction equation in the space provided.
<- lm(AuctionPrice ~ Age + Bidders,data=GFclocks)
mod summary(mod)
Is there evidence that the model is useful?
Interpret the estimated coefficient on bidders.
= coef(mod)[1]
b0 = coef(mod)[3] # slope for bidders
b1 = coef(mod)[2]
b2
+
g geom_abline(slope = b1, intercept = b0 + b2 * 115,col="red") +
geom_abline(slope = b1, intercept = b0 + b2 * 125,col="blue") +
geom_abline(slope = b1, intercept = b0 + b2 * 135,col="brown") +
geom_abline(slope = b1, intercept = b0 + b2 * 145,col="black") +
geom_abline(slope = b1, intercept = b0 + b2 * 155,col="magenta")
Suppose the collector, having observed many auctions, believes that the rate of increase of the auction price with bidders will be driven upward by older clocks (i.e., he believes that the rate of increase of the auction price with bidders depends on how old the clock is and with for older clocks the rate of increase will be larger).
Write out the population model for predicting auction price that uses age, number of bidders, and their interaction.
Fit the model that includes an interaction between age and bidders and write the fitted prediction equation in the space provided.
<- lm(AuctionPrice~ Age + Bidders + Age*Bidders ,data=GFclocks)
mod2 summary(mod2)
Is there evidence that the interaction between age and number of bidders is significant?
What is the slope of the regression equation between auction price and bidders for 115 year old clocks? Provide an interpretation.
320.458 + 0.8781*115
-93.2648 + 1.2978*115
- What is the slope of the regression equation between auction price and bidders for 150 year old clocks? Provide an interpretation.
320.458 + 0.8781*150
-93.2648 + 1.2978*150
+
g geom_abline(slope=-93.2648 + 1.2978*115, intercept = 320.458 + 0.8781*115,col="red") +
geom_abline(slope=-93.2648 + 1.2978*125, intercept = 320.458 + 0.8781*125,col="blue") +
geom_abline(slope=-93.2648 + 1.2978*135, intercept = 320.458 + 0.8781*135,col="brown") +
geom_abline(slope=-93.2648 + 1.2978*145, intercept = 320.458 + 0.8781*145,col="black") +
geom_abline(slope=-93.2648 + 1.2978*155, intercept = 320.458 + 0.8781*155,col="magenta") +
geom_abline(slope=-93.2648 + 1.2978*150, intercept = 320.458 + 0.8781*150,col="green")