5th Answer Marios
5th Answer Marios
Marios Natsios
2025-03-13
Question
5. Now, please save the data points of the demand curve (price and demand) from question 4
in a new file and estimate a demand function using linear regression analysis. How well does
our regression model perform overall?
Introduction
Understanding how price affects demand is crucial in pricing strategy. In this analysis, we estimate a
demand function using linear regression. We use the demand curve data from Question 4, perform
regression modeling, and evaluate the model’s performance using various diagnostic tools.
A well-fitted regression model provides insights into price elasticity and helps determine the optimal pricing
strategy.
library(readr)
library(ggplot2)
library(dplyr)
library(tidyr)
library(broom)
library(ggpubr)
## # A tibble: 5 x 2
## Price Mean_Willingness
## <dbl> <dbl>
1
## 1 5 0.983
## 2 10 0.858
## 3 15 0.375
## 4 20 0.0917
## 5 25 0.0167
Summary of Data
##
## Call:
## lm(formula = Mean_Willingness ~ Price, data = demand_data)
##
## Residuals:
## 1 2 3 4 5
## -0.02167 0.12333 -0.09000 -0.10333 0.09167
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.27500 0.12536 10.171 0.00203 **
## Price -0.05400 0.00756 -7.143 0.00565 **
## ---
## Signif. codes: 0 ’***’ 0.001 ’**’ 0.01 ’*’ 0.05 ’.’ 0.1 ’ ’ 1
##
## Residual standard error: 0.1195 on 3 degrees of freedom
## Multiple R-squared: 0.9445, Adjusted R-squared: 0.926
## F-statistic: 51.03 on 1 and 3 DF, p-value: 0.005649
• The coefficient for Price indicates how demand changes as price increases.
• The R-squared value shows how well the model explains demand variations.
• The p-value tests the significance of the regression coefficients.
2
Model Diagnostics and Evaluation
## Warning: Using ‘size‘ aesthetic for lines was deprecated in ggplot2 3.4.0.
## i Please use ‘linewidth‘ instead.
## This warning is displayed once every 8 hours.
## Call ‘lifecycle::last_lifecycle_warnings()‘ to see where this warning was
## generated.
0.75
Percentage Willing to Buy
0.50
0.25
0.00
5 10 15 20 25
Price (Euro)
### Summary - The red points represent actual demand, while the blue line shows predicted demand.
- A good fit is observed when predictions closely follow actual values.
3
Residual Plot
# Compute residuals
demand_data$Residuals <- demand_data$Mean_Willingness - demand_data$Predicted_Willingness
Residual Plot
0.10
0.05
Residuals
0.00
−0.05
−0.10
5 10 15 20 25
Price (Euro)
### Summary - A random spread of residuals suggests a good model fit. - Patterns in residuals may
indicate missing nonlinear relationships.
4
labs(title = "Scatter Plot with Regression Line",
x = "Price (Euro)",
y = "Percentage Willing to Buy") +
theme_minimal()
0.75
Percentage Willing to Buy
0.50
0.25
0.00
5 10 15 20 25
Price (Euro)
### Summary - The regression line shows a downward trend, indicating a negative relationship
between price and demand. - The slope represents price elasticity.
Histogram of Residuals
5
Histogram of Residuals
2.0
1.5
Frequency
1.0
0.5
0.0
6
Q−Q Plot of Residuals
0.2
Sample
0.0
−0.2
Conclusion
This analysis estimates a demand function using linear regression. The model allows us to understand
how demand changes with price variations.
Key Takeaways:
Further improvements could include: - Testing nonlinear models to capture demand shifts. - Adding
external factors like competition or seasonal trends.