Question
**Make sure you run this chunk before attempting any of the problems:** ```{r setup, message=FALSE, warning=FALSE} library(tidyverse) library(sjPlot) ``` # The demand for cocaine This
**Make sure you run this chunk before attempting any of the problems:**
```{r setup, message=FALSE, warning=FALSE}
library(tidyverse)
library(sjPlot)
```
# The demand for cocaine
This data on cocaine sales contain 56 observations on variables related to sales of cocaine powder in northeastern California over the period 1984-1991. The data come from a a study by Caulkins, J. P. and R. Padman (1993), Quantity Discounts and Quality Premia for Illicit Drugs, Journal of the American Statistical Association, 88, 748-757.
```{r cocaine data, message=FALSE, warning=FALSE}
cocaine = read_csv("https://query.data.world/s/k2dlmaj4mtn3swiqbjziqoyrux653g")
```
The variables are:
| **Variable name** | **Description** |
|-------------------|-------------------------------------------------------|
| `price` | price per gram in dollars for a cocaine sale |
| `quant` | number of grams of cocaine in a given sale |
| `qual` | quality of the cocaine expressed as percentage purity |
| `trend` | a time variable with 1984=1 up to 1991=8 |
**[Q1.1] [CODE] Plot a histogram of prices..**
```{r q1.1 code}
# hist(read_csv)
```
**[Q1.2] [CODE] Plot price as a function of quantity and comment on what you see (i.e. linear or nonlinear relationship). Include a regression line.**
```{r q1.2 code}
# your code here
```
**[Q1.2] [WRITE] If you were to estimate the following model, what signs (postive or negative) would you expect for $\beta_1$, $\beta_2$, and $\beta_3$, and why?:**
$$
price = \beta_0 + \beta_1quant + \beta_2 qual + \beta_3trend + \epsilon
$$
**[Q1.4] [CODE] Estimate the model and assign the output to the object `cocaine_model`. Then use `summary()` to view the results.**
```{r q1.4 code}
# your code here
```
**[Q1.5] [WRITE] It is claimed that the greater the number of sales, the higher the risk of getting caught. Thus, sellers are willing to accept a lower price if they can make sales in larger quantities. Based on the regression results, do sellers offer quantity discounts?**
**[Q1.6] [WRITE] Do consumers pay a premium for higher _quality_ cocaine? Why or why not?**
**[Q1.7] [WRITE] According to your model, do prices change over time? Why or why not?**
**[Q1.8] [WRITE] Explain two limitations with the data.**
**[Q1.9] [WRITE] Explain two limitations with the model**
**[Q1.10] [CODE] Use `sjPlot` to plot the predicted prices for different quantities.**
```{r q1.10 code}
# your code here
```
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started