1a) If a firm lowers the price, they gain money on the extensive margin and lose on the intensive margin. This is because the intensive margin represents the money from units they were already selling, so as price decreases the revenue from these units decreases. Extensive margin is the money from the additional units sold, which increases because the lower price increases demand.

1b) If a firm increases price they lose money on the extensive margin and gain on the intensive margin. This is because the firm gains money on the units they are already selling because the price is higher and loses money from additional units sold, because the higher price decreases demand.

2a) Q = 4-(1/3)P \[Q-4 =-\frac13P \iff -3Q+12=P\] 2b)excel file

2ci) at the highest level of revenue, marginal revenue is -3. The number becomes negative because after the highest point total revenue begins to decrease.

2cii) The bar should charge the revenue maximizing price of $6.

2di)The bar should charge $6. The demand curve represents the quantities bought by a person given different prices; if all 100 consumers have this demand curve the maximal price for each is $6.

2ei) The marginal revenue remains unchanged. Only marginal profit changes from imposed costs.

2eii) If price changes from $9 to $6 for all 100 customers, each customer buys one additional unit(Quantity goes from 1 to 2), which leads to extensive margins of $600. Simultaneously, the customers all would have bought 1 unit at the price of $9, but now they only pay $6 for this unit. This leads to $300 for intensive margins. 3a) No. Elasticity represents the change in consumer behavior in response to a change in prices, so if prices don’t change neither elasticity nor optimal price cannot be properly analyzed.

3b) While elasticities can never be known with certainty, two years of information on the price and quantity sold allows for an economist to analyze how price impacts the quantity sold as long as the price changes within this time.

3c) Supply shifts lead to different prices so economists can analyze the impact on quantity of the change in price, which is informative for studying optimal pricing and elasticities.

3d) Economists can use the Lerner equation to determine the optimal price

4)If consumers are willing to buy 3 martinis at a price of $10, the minimum consumer surplus when the price is $8 is $6 of utility. If the consumers are willing to purchase 3 martinis at a price of $10, in the worst case consumers are gaining 0 utility from this transaction, meaning that the 3 martinis provide $30 of utility at the minimum, so if the 3 martinis are purchased for $8 each, there must be a minimum of $6 of utility provided. I cannot make a claim about the upper bound because without the elasticity demand of martinis, I don’t know how much utility each martini individually provides.

5a and b) option iii, -1 is the most reasonable. Coffee and coffee filters are likely complements, which implies that the price of one good will decrease if the other increases.

5c) Using the Lerner equation for coffee beans: \[\frac{P-1}{P}=-\frac1{-2} \iff P-1 =\frac P2\iff \frac P 2 =1 \iff P =2\] and for coffee filters:\[\frac{P-2}{P}=-\frac{1}{-3}\iff P-2 = \frac P 3 \iff \frac {2P} 3 =2 \iff P = 3\] 5d) If the firm sets prices for both goods jointly, I believe the prices will be lower than the ones calculated in the last part. Coffee beans and filters are complementary goods, so decreasing the price of both is similar to bundling, and incentivizes customers to buy both products. 6) I used read.csv instead because read.table didn’t work. I removed savehistory() because it doesn’t run in rmarkdown.

x <- c(1,3,2,5)
x
## [1] 1 3 2 5
x=c(1,6,2)
x
## [1] 1 6 2
y = c(1,4,3)
length(x)
## [1] 3
length(y)
## [1] 3
x+y
## [1]  2 10  5
ls()
## [1] "x" "y"
rm(x,y)
ls()
## character(0)
rm(list=ls())


x=matrix(data=c(1,2,3,4), nrow=2, ncol=2)
x
##      [,1] [,2]
## [1,]    1    3
## [2,]    2    4
x=matrix(c(1,2,3,4),2,2)
x
##      [,1] [,2]
## [1,]    1    3
## [2,]    2    4
matrix(c(1,2,3,4),2,2,byrow=TRUE)
##      [,1] [,2]
## [1,]    1    2
## [2,]    3    4
sqrt(x)
##          [,1]     [,2]
## [1,] 1.000000 1.732051
## [2,] 1.414214 2.000000
x^2
##      [,1] [,2]
## [1,]    1    9
## [2,]    4   16
x=rnorm(50)
y=x+rnorm(50, mean=50, sd=.1)
cor(x,y)
## [1] 0.9937375
set.seed(1303)
rnorm(50)
##  [1] -1.1439763145  1.3421293656  2.1853904757  0.5363925179  0.0631929665
##  [6]  0.5022344825 -0.0004167247  0.5658198405 -0.5725226890 -1.1102250073
## [11] -0.0486871234 -0.6956562176  0.8289174803  0.2066528551 -0.2356745091
## [16] -0.5563104914 -0.3647543571  0.8623550343 -0.6307715354  0.3136021252
## [21] -0.9314953177  0.8238676185  0.5233707021  0.7069214120  0.4202043256
## [26] -0.2690521547 -1.5103172999 -0.6902124766 -0.1434719524 -1.0135274099
## [31]  1.5732737361  0.0127465055  0.8726470499  0.4220661905 -0.0188157917
## [36]  2.6157489689 -0.6931401748 -0.2663217810 -0.7206364412  1.3677342065
## [41]  0.2640073322  0.6321868074 -1.3306509858  0.0268888182  1.0406363208
## [46]  1.3120237985 -0.0300020767 -0.2500257125  0.0234144857  1.6598706557
set.seed(3)
y=rnorm(100)
mean(y)
## [1] 0.01103557
var(y)
## [1] 0.7328675
sqrt(var(y))
## [1] 0.8560768
sd(y)
## [1] 0.8560768
x=rnorm(100)
y=rnorm(100)
plot(x,y)

plot(x,y, xlab="this is the x-axis", ylab="this is the y-axis", main="Plot of X vs Y")

pdf("Figure.pdf")
plot(x,y,col="green")
dev.off()
## png 
##   2
x=seq(1,10)
x
##  [1]  1  2  3  4  5  6  7  8  9 10
x=1:10
x
##  [1]  1  2  3  4  5  6  7  8  9 10
x=seq(-pi, pi, length=50)

y=x
f=outer(x,y,function(x,y)cos(y)/(1+x^2))
contour(x,y,f)
contour(x,y,f,nlevels(45),add=T)

fa=(f-t(f))/2
contour(x,y,fa,nlevels=15)

image(x,y,fa)

persp(x,y,fa)

persp(x,y,fa,theta=30)

persp(x,y,fa,theta=30, phi=20)

persp(x,y,fa,theta=30, ph=70)

persp(x,y,fa,theta=30,phi=40)

A=matrix(1:16,4,4)
A
##      [,1] [,2] [,3] [,4]
## [1,]    1    5    9   13
## [2,]    2    6   10   14
## [3,]    3    7   11   15
## [4,]    4    8   12   16
A[2,3]
## [1] 10
A[c(1,3), c(2,4)]
##      [,1] [,2]
## [1,]    5   13
## [2,]    7   15
A[1:3,2:4]
##      [,1] [,2] [,3]
## [1,]    5    9   13
## [2,]    6   10   14
## [3,]    7   11   15
A[1:2,]
##      [,1] [,2] [,3] [,4]
## [1,]    1    5    9   13
## [2,]    2    6   10   14
A[,1:2]
##      [,1] [,2]
## [1,]    1    5
## [2,]    2    6
## [3,]    3    7
## [4,]    4    8
A[1,]
## [1]  1  5  9 13
A[-c(1,3),]
##      [,1] [,2] [,3] [,4]
## [1,]    2    6   10   14
## [2,]    4    8   12   16
A[-c(1,3), -c(1,3,4)]
## [1] 6 8
dim(A)
## [1] 4 4
Auto=read.csv("C:/Users/miaca/OneDrive/Desktop/Auto.csv")
View(Auto)
head(Auto)
##   mpg cylinders displacement horsepower weight acceleration year origin
## 1  18         8          307        130   3504         12.0   70      1
## 2  15         8          350        165   3693         11.5   70      1
## 3  18         8          318        150   3436         11.0   70      1
## 4  16         8          304        150   3433         12.0   70      1
## 5  17         8          302        140   3449         10.5   70      1
## 6  15         8          429        198   4341         10.0   70      1
##                        name
## 1 chevrolet chevelle malibu
## 2         buick skylark 320
## 3        plymouth satellite
## 4             amc rebel sst
## 5               ford torino
## 6          ford galaxie 500
Auto = read.csv("C:/Users/miaca/OneDrive/Desktop/Auto.csv", header=T, na.strings="?")
View(Auto)
dim(Auto)
## [1] 397   9
Auto[1:4,]
##   mpg cylinders displacement horsepower weight acceleration year origin
## 1  18         8          307        130   3504         12.0   70      1
## 2  15         8          350        165   3693         11.5   70      1
## 3  18         8          318        150   3436         11.0   70      1
## 4  16         8          304        150   3433         12.0   70      1
##                        name
## 1 chevrolet chevelle malibu
## 2         buick skylark 320
## 3        plymouth satellite
## 4             amc rebel sst
Auto = na.omit(Auto)
dim(Auto)
## [1] 392   9
names(Auto)
## [1] "mpg"          "cylinders"    "displacement" "horsepower"   "weight"      
## [6] "acceleration" "year"         "origin"       "name"
plot(Auto$cylinders, Auto$mpg)

attach(Auto)
plot(cylinders, mpg)

cylinders <- as.factor(cylinders)
plot(cylinders, mpg)

plot(cylinders, mpg, col = "red")

plot(cylinders, mpg, col="red", varwidth=T)

plot(cylinders, mpg, col="red", varwidth = T, horizontal =T)

plot(cylinders, mpg, col="red", vardwidth =T, xlab="cylinders", ylab="MPG")

hist(mpg)

hist(mpg, col=2)

hist(mpg, col=2, breaks=15)

pairs(
  ~mpg + displacement+horsepower+weight+acceleration,
  data = Auto
)

plot(horsepower, mpg)
identify(horsepower, mpg, name)

## integer(0)
summary(Auto)
##       mpg          cylinders      displacement     horsepower        weight    
##  Min.   : 9.00   Min.   :3.000   Min.   : 68.0   Min.   : 46.0   Min.   :1613  
##  1st Qu.:17.00   1st Qu.:4.000   1st Qu.:105.0   1st Qu.: 75.0   1st Qu.:2225  
##  Median :22.75   Median :4.000   Median :151.0   Median : 93.5   Median :2804  
##  Mean   :23.45   Mean   :5.472   Mean   :194.4   Mean   :104.5   Mean   :2978  
##  3rd Qu.:29.00   3rd Qu.:8.000   3rd Qu.:275.8   3rd Qu.:126.0   3rd Qu.:3615  
##  Max.   :46.60   Max.   :8.000   Max.   :455.0   Max.   :230.0   Max.   :5140  
##   acceleration        year           origin          name          
##  Min.   : 8.00   Min.   :70.00   Min.   :1.000   Length:392        
##  1st Qu.:13.78   1st Qu.:73.00   1st Qu.:1.000   Class :character  
##  Median :15.50   Median :76.00   Median :1.000   Mode  :character  
##  Mean   :15.54   Mean   :75.98   Mean   :1.577                     
##  3rd Qu.:17.02   3rd Qu.:79.00   3rd Qu.:2.000                     
##  Max.   :24.80   Max.   :82.00   Max.   :3.000
summary(mpg)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    9.00   17.00   22.75   23.45   29.00   46.60