##
## Attaching package: 'ggplot2'
##
## The following object is masked from 'package:psych':
##
## %+%
##
##
## Attaching package: 'dplyr'
##
## The following object is masked from 'package:stats':
##
## filter
##
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
Category <- c("Regulatory enforcement","Time cost to doctors","Convenience cost to patients","Total US costs","Avoided US resistance costs","better drug compliance","Total US benefits","Avoided non-US resistance costs","Fraction counted as US benefits","US benefits with fraction of non-US benefits","Total US net benefits")
Amount <- c(40,220,180,440,350,70,420,280,0,420,-20)
q1 <- data.frame(cbind(Category,Amount))
q1
## Category Amount
## 1 Regulatory enforcement 40
## 2 Time cost to doctors 220
## 3 Convenience cost to patients 180
## 4 Total US costs 440
## 5 Avoided US resistance costs 350
## 6 better drug compliance 70
## 7 Total US benefits 420
## 8 Avoided non-US resistance costs 280
## 9 Fraction counted as US benefits 0
## 10 US benefits with fraction of non-US benefits 420
## 11 Total US net benefits -20
No - net benefits are -$20 million
20/280
## [1] 0.07142857
.07142857
Taking this fraction of non-US benefits makes benefits and costs equal.
Category <- c("Regulatory enforcement","Time cost to doctors","Convenience cost to patients","Total US costs","Avoided US resistance costs","better drug compliance","Total US benefits","Avoided non-US resistance costs","Fraction counted as US benefits","US benefits with fraction of non-US benefits","Total US net benefits")
Amount <- c(40,220,180,440,350,70,420,280,.07142857,440,0)
q1 <- data.frame(cbind(Category,Amount))
q1
## Category Amount
## 1 Regulatory enforcement 40
## 2 Time cost to doctors 220
## 3 Convenience cost to patients 180
## 4 Total US costs 440
## 5 Avoided US resistance costs 350
## 6 better drug compliance 70
## 7 Total US benefits 420
## 8 Avoided non-US resistance costs 280
## 9 Fraction counted as US benefits 0.07142857
## 10 US benefits with fraction of non-US benefits 440
## 11 Total US net benefits 0
As a matter of policy, I would not generally recommend incorporating global net benefits into cost benefit analyses, although I can imagine there to be a limited number of cases where such analyses would be useful for context. In this case, we only need to take 7% of the global benefits to justify the cost domestically, so I would consider this fact not only contextually relevant but worthy of justifying the cost. We could probably draw up a scenario where the non-US benefits eventually accrue to the US. Consider how reduced antibiotic resistance might reduce the chances of some superbug entering the US, or consider how international migration also creates an interest among US policymakers in contributing to non-US benefits.
I would recommend that the policymaker enact this program based on the US and non-US benefits.
set.seed(1)
res <- round(data.frame(rnorm(100,11,3.9)),digits=2)
colnames(res) <- "ReservationPrice"
describe(res)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 100 11.42 3.5 11.45 11.46 3.4 2.36 20.37 18.01
## skew kurtosis se
## ReservationPrice -0.07 -0.05 0.35
res$Accept <- ifelse(res$ReservationPrice>12, 0,1)
res
## ReservationPrice Accept
## 1 8.56 1
## 2 11.72 1
## 3 7.74 1
## 4 17.22 0
## 5 12.29 0
## 6 7.80 1
## 7 12.90 0
## 8 13.88 0
## 9 13.25 0
## 10 9.81 1
## 11 16.90 0
## 12 12.52 0
## 13 8.58 1
## 14 2.36 1
## 15 15.39 0
## 16 10.82 1
## 17 10.94 1
## 18 14.68 0
## 19 14.20 0
## 20 13.32 0
## 21 14.58 0
## 22 14.05 0
## 23 11.29 1
## 24 3.24 1
## 25 13.42 0
## 26 10.78 1
## 27 10.39 1
## 28 5.26 1
## 29 9.14 1
## 30 12.63 0
## 31 16.30 0
## 32 10.60 1
## 33 12.51 0
## 34 10.79 1
## 35 5.63 1
## 36 9.38 1
## 37 9.46 1
## 38 10.77 1
## 39 15.29 0
## 40 13.98 0
## 41 10.36 1
## 42 10.01 1
## 43 13.72 0
## 44 13.17 0
## 45 8.31 1
## 46 8.24 1
## 47 12.42 0
## 48 14.00 0
## 49 10.56 1
## 50 14.44 0
## 51 12.55 0
## 52 8.61 1
## 53 12.33 0
## 54 6.60 1
## 55 16.59 0
## 56 18.72 0
## 57 9.57 1
## 58 6.93 1
## 59 13.22 0
## 60 10.47 1
## 61 20.37 0
## 62 10.85 1
## 63 13.69 0
## 64 11.11 1
## 65 8.10 1
## 66 11.74 1
## 67 3.96 1
## 68 16.72 0
## 69 11.60 1
## 70 19.47 0
## 71 12.85 0
## 72 8.23 1
## 73 13.38 0
## 74 7.36 1
## 75 6.11 1
## 76 12.14 0
## 77 9.27 1
## 78 11.00 1
## 79 11.29 1
## 80 8.70 1
## 81 8.78 1
## 82 10.47 1
## 83 15.59 0
## 84 5.06 1
## 85 13.32 0
## 86 12.30 0
## 87 15.15 0
## 88 9.81 1
## 89 12.44 0
## 90 12.04 0
## 91 8.88 1
## 92 15.71 0
## 93 15.53 0
## 94 13.73 0
## 95 17.19 0
## 96 13.18 0
## 97 6.02 1
## 98 8.76 1
## 99 6.22 1
## 100 9.15 1
## subset data to the job offers up to 20 accepts
subRes <- res[1:37,]
subRes
## ReservationPrice Accept
## 1 8.56 1
## 2 11.72 1
## 3 7.74 1
## 4 17.22 0
## 5 12.29 0
## 6 7.80 1
## 7 12.90 0
## 8 13.88 0
## 9 13.25 0
## 10 9.81 1
## 11 16.90 0
## 12 12.52 0
## 13 8.58 1
## 14 2.36 1
## 15 15.39 0
## 16 10.82 1
## 17 10.94 1
## 18 14.68 0
## 19 14.20 0
## 20 13.32 0
## 21 14.58 0
## 22 14.05 0
## 23 11.29 1
## 24 3.24 1
## 25 13.42 0
## 26 10.78 1
## 27 10.39 1
## 28 5.26 1
## 29 9.14 1
## 30 12.63 0
## 31 16.30 0
## 32 10.60 1
## 33 12.51 0
## 34 10.79 1
## 35 5.63 1
## 36 9.38 1
## 37 9.46 1
sum(subRes$ReservationPrice)
## [1] 414.33
414.33
(Not sure what the units would be here? Person dollars?)
resSort <- arrange(res, ReservationPrice)
resSort
## ReservationPrice Accept
## 1 2.36 1
## 2 3.24 1
## 3 3.96 1
## 4 5.06 1
## 5 5.26 1
## 6 5.63 1
## 7 6.02 1
## 8 6.11 1
## 9 6.22 1
## 10 6.60 1
## 11 6.93 1
## 12 7.36 1
## 13 7.74 1
## 14 7.80 1
## 15 8.10 1
## 16 8.23 1
## 17 8.24 1
## 18 8.31 1
## 19 8.56 1
## 20 8.58 1
## 21 8.61 1
## 22 8.70 1
## 23 8.76 1
## 24 8.78 1
## 25 8.88 1
## 26 9.14 1
## 27 9.15 1
## 28 9.27 1
## 29 9.38 1
## 30 9.46 1
## 31 9.57 1
## 32 9.81 1
## 33 9.81 1
## 34 10.01 1
## 35 10.36 1
## 36 10.39 1
## 37 10.47 1
## 38 10.47 1
## 39 10.56 1
## 40 10.60 1
## 41 10.77 1
## 42 10.78 1
## 43 10.79 1
## 44 10.82 1
## 45 10.85 1
## 46 10.94 1
## 47 11.00 1
## 48 11.11 1
## 49 11.29 1
## 50 11.29 1
## 51 11.60 1
## 52 11.72 1
## 53 11.74 1
## 54 12.04 0
## 55 12.14 0
## 56 12.29 0
## 57 12.30 0
## 58 12.33 0
## 59 12.42 0
## 60 12.44 0
## 61 12.51 0
## 62 12.52 0
## 63 12.55 0
## 64 12.63 0
## 65 12.85 0
## 66 12.90 0
## 67 13.17 0
## 68 13.18 0
## 69 13.22 0
## 70 13.25 0
## 71 13.32 0
## 72 13.32 0
## 73 13.38 0
## 74 13.42 0
## 75 13.69 0
## 76 13.72 0
## 77 13.73 0
## 78 13.88 0
## 79 13.98 0
## 80 14.00 0
## 81 14.05 0
## 82 14.20 0
## 83 14.44 0
## 84 14.58 0
## 85 14.68 0
## 86 15.15 0
## 87 15.29 0
## 88 15.39 0
## 89 15.53 0
## 90 15.59 0
## 91 15.71 0
## 92 16.30 0
## 93 16.59 0
## 94 16.72 0
## 95 16.90 0
## 96 17.19 0
## 97 17.22 0
## 98 18.72 0
## 99 19.47 0
## 100 20.37 0
resLow <- resSort[1:20,]
resLow
## ReservationPrice Accept
## 1 2.36 1
## 2 3.24 1
## 3 3.96 1
## 4 5.06 1
## 5 5.26 1
## 6 5.63 1
## 7 6.02 1
## 8 6.11 1
## 9 6.22 1
## 10 6.60 1
## 11 6.93 1
## 12 7.36 1
## 13 7.74 1
## 14 7.80 1
## 15 8.10 1
## 16 8.23 1
## 17 8.24 1
## 18 8.31 1
## 19 8.56 1
## 20 8.58 1
describe(resLow)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 20 6.52 1.83 6.76 6.72 2.08 2.36 8.58 6.22
## Accept 2 20 1.00 0.00 1.00 1.00 0.00 1.00 1.00 0.00
## skew kurtosis se
## ReservationPrice -0.72 -0.6 0.41
## Accept NaN NaN 0.00
sum(resLow$ReservationPrice)
## [1] 130.31
The opportunity cost for those who most want to work is 130.31
See Annex 1 for the simulations. The summary:
names <- c("seed","resRandom","resLow")
seed <- 1:15
resRandom <- c(414.33,436.38,237.74,484.68,331.33,387.89,459.54,318.25,311.97,269.07,244.94,276.84,375.7,501.58,464.06)
resLow <- c(130.31,95.93,128.8,133.13,125.34,115.53,131.87,92.8,122.17,105.35,118.98,125.33,111.62,128.75,122.52)
simul <- data.frame(cbind(seed,resRandom,resLow))
simul
## seed resRandom resLow
## 1 1 414.33 130.31
## 2 2 436.38 95.93
## 3 3 237.74 128.80
## 4 4 484.68 133.13
## 5 5 331.33 125.34
## 6 6 387.89 115.53
## 7 7 459.54 131.87
## 8 8 318.25 92.80
## 9 9 311.97 122.17
## 10 10 269.07 105.35
## 11 11 244.94 118.98
## 12 12 276.84 125.33
## 13 13 375.70 111.62
## 14 14 501.58 128.75
## 15 15 464.06 122.52
describe(simul)
## vars n mean sd median trimmed mad min max range
## seed 1 15 8.00 4.47 8.00 8.00 5.93 1.00 15.00 14.00
## resRandom 2 15 367.62 90.04 375.70 367.31 124.30 237.74 501.58 263.84
## resLow 3 15 119.23 12.70 122.52 120.19 10.36 92.80 133.13 40.33
## skew kurtosis se
## seed 0.00 -1.44 1.15
## resRandom 0.00 -1.59 23.25
## resLow -0.84 -0.64 3.28
For the random draw of reservation wages: mean 367.62 standard deviation 90.04
For those who most want to work: mean 119.23 standard deviation 12.7
Visually:
data <- melt(simul,id="seed")
ggplot(data,aes(x=value,fill=variable)) + geom_density(alpha=.25)
I’m not sure what to make of the distributions or whether I’ve constructed them correctly, but at face value I would say that the opportunity cost among those who most want to work is defined much more tightly around the mean, while the distribution for a random sample of reservation prices looks almost uniform. If it’s a correct characterization to say it approximates a uniform distribution, is that somehow a consequence of taking the random sample of reservation wages?
Given the difference in distributions, I find it reassuring to think that a government program to help the unemployed or underemployed can be tightly targeted to those who need/want it most.
A government data processing center has been plagued in recent years by complaints from employees of back pain. Consultants have estimated that upgrading office furniture at a net cost of $425,000 would reduce the incidence and severity of back injuries, allowing the center to avoid medical care that currently costs $68,000 each year. They estimate that the new furniture would also provide yearly benefits of avoided losses in work time and employee comfort worth $18,000. The furniture would have a useful life of five years, after which it would have a positive salvage value equal to 10 percent of its initial net cost. The consultants made their estimates of avoided costs assuming that they would be treated as occurring at the beginning of each year.
In its investment decisions, the center uses a nominal discount rate of 9.5 percent and an assumed general inflation rate of 3 percent. It expects the inflation rate for medical care will run between 3 percent and 5 percent but is uncertain as to the exact rate. In other words, it is uncertain as to whether the cost of medical care will inflate at the same rate as other prices or rise 2 percent faster. Should the center purchase the new furniture?
See Excel sheet for calculations. In summary:
At 3% inflation of medical costs, present value of net benefits is $133,600
At 5% inflation of medical costs, present value of net benefits is $154,895
The company should purchase the chairs.
As a personal aside, I feel like there is a missing benefit, which is the avoided reputational cost to the firm providing the chairs. A decision like this should not strictly be about avoided medical costs or increased comfort - it should be about projecting and executing a commitment to the well being of their workers in fundamental matters such as the things they use very day, and which accrue over many years to make a career.
exposure <- c("parasite","no_parasite")
program <- as.numeric(c(70000,76000))
no_program <- as.numeric(c(50000,80000))
prob <- as.numeric(c(.6,.4))
data <- data.frame(cbind(exposure,program,no_program,prob))
data[,2:4] <- lapply(data[,2:4],as.character)
data[,2:4] <- lapply(data[,2:4],as.numeric)
data$surplus <- data$program-data$no_program
data
## exposure program no_program prob surplus
## 1 parasite 70000 50000 0.6 20000
## 2 no_parasite 76000 80000 0.4 -4000
The surplus with exposure to the parasite is 20,000.
The surplus without exposure to the parasite is -4,000.
(20000*.6) + (-4000*.4)
## [1] 10400
The expected surplus is 10,400
var(data$program)
## [1] 1.8e+07
sd(data$program)
## [1] 4242.641
var(data$no_program)
## [1] 4.5e+08
sd(data$no_program)
## [1] 21213.2
Income variance is much lower with the program. The standard deviation in income is $21,213 without the program, and $4,243 with the program.
Expected utility without the program is:
log(50000)*.6 + log(80000)*.4
## [1] 11.00778
11
We set expected utility without the program equal to expected utility with the program minus the amount needed to equal expected utility without the program:
11 = .6U(70000-OP) + .4U(76000-OP)
I’m not sure how to solve algebraically when the unknown is inside the log operator. But Wolfram Alpha tells me the solution is 12,455 which seems about right.
At 50%:
11 = .5U(70000-OP) + .5U(76000-OP)
13,051
At 70%:
11 = .7U(70000-OP) + .3U(76000-OP)
11,864
I’m confused here. I thought OP was the conceptually correct measure of willingness to pay. Why would it go down when the risk of exposure goes up?
Using the expected surplus measure and a bit of trial and error:
(20000*.1675) + (-4000*.8325)
## [1] 20
Expected suprlus is around zero at a 16.7% risk of exposure.
year <- 0:7
costs <- c(2548000, 60000,60000,70000,70000,80000,80000,90000)
benefit1 <- c(0,400000,440000,440000,440000,440000,440000,440000)
benefit2 <- c(0,60000,175000,175000,175000,175000,175000,175000)
data <- data.frame(cbind(year,costs,benefit1,benefit2))
data
## year costs benefit1 benefit2
## 1 0 2548000 0 0
## 2 1 60000 400000 60000
## 3 2 60000 440000 175000
## 4 3 70000 440000 175000
## 5 4 70000 440000 175000
## 6 5 80000 440000 175000
## 7 6 80000 440000 175000
## 8 7 90000 440000 175000
The channel would be navigable for seven years, after which silting would render it un-navigable. Local economists estimate that 75 percent of the savings to shippers would be directly invested by the firms, or their shareholders, and the remaining 25 percent would be used by shareholders for consumption. They also estimate that all government expenditures come at the expense of private investment. The social marginal rate of time preference is assumed to be 3 percent, the marginal rate of return on private investment is assumed to be 7 percent, and the shadow price of capital is assumed to be 1.3. Assuming that the costs and benefits accrue at the end of each year, calculate the present value of net benefits of the project using each of the following methods:
data$TotalBenefit <- data$benefit1 + data$benefit2
data$PV_a <- data$TotalBenefit/1.07
data
## year costs benefit1 benefit2 TotalBenefit PV_a
## 1 0 2548000 0 0 0 0.0
## 2 1 60000 400000 60000 460000 429906.5
## 3 2 60000 440000 175000 615000 574766.4
## 4 3 70000 440000 175000 615000 574766.4
## 5 4 70000 440000 175000 615000 574766.4
## 6 5 80000 440000 175000 615000 574766.4
## 7 6 80000 440000 175000 615000 574766.4
## 8 7 90000 440000 175000 615000 574766.4
sum(data$PV_a)
## [1] 3878505
3,878,505
data$PV_b <- data$TotalBenefit/1.03
data
## year costs benefit1 benefit2 TotalBenefit PV_a PV_b
## 1 0 2548000 0 0 0 0.0 0.0
## 2 1 60000 400000 60000 460000 429906.5 446601.9
## 3 2 60000 440000 175000 615000 574766.4 597087.4
## 4 3 70000 440000 175000 615000 574766.4 597087.4
## 5 4 70000 440000 175000 615000 574766.4 597087.4
## 6 5 80000 440000 175000 615000 574766.4 597087.4
## 7 6 80000 440000 175000 615000 574766.4 597087.4
## 8 7 90000 440000 175000 615000 574766.4 597087.4
sum(data$PV_b)
## [1] 4029126
4,029,126
data$SPKCosts <- (1.3*data$costs*.75) + (.25*data$costs)
data$SPKBenefits <- (1.3*data$TotalBenefit*.75) + (.25*data$TotalBenefit)
data$PV_c <- data$SPKBenefits/1.03
data
## year costs benefit1 benefit2 TotalBenefit PV_a PV_b SPKCosts
## 1 0 2548000 0 0 0 0.0 0.0 3121300
## 2 1 60000 400000 60000 460000 429906.5 446601.9 73500
## 3 2 60000 440000 175000 615000 574766.4 597087.4 73500
## 4 3 70000 440000 175000 615000 574766.4 597087.4 85750
## 5 4 70000 440000 175000 615000 574766.4 597087.4 85750
## 6 5 80000 440000 175000 615000 574766.4 597087.4 98000
## 7 6 80000 440000 175000 615000 574766.4 597087.4 98000
## 8 7 90000 440000 175000 615000 574766.4 597087.4 110250
## SPKBenefits PV_c
## 1 0 0.0
## 2 563500 547087.4
## 3 753375 731432.0
## 4 753375 731432.0
## 5 753375 731432.0
## 6 753375 731432.0
## 7 753375 731432.0
## 8 753375 731432.0
sum(data$PV_c)
## [1] 4935680
4,935,680
data$SPKCosts2 <- (1.3*data$costs*.2) + (.8*data$costs)
data$SPKBenefits2 <- (1.3*data$TotalBenefit*.2) + (.8*data$TotalBenefit)
data$PV_d <- data$SPKBenefits2/1.03
data
## year costs benefit1 benefit2 TotalBenefit PV_a PV_b SPKCosts
## 1 0 2548000 0 0 0 0.0 0.0 3121300
## 2 1 60000 400000 60000 460000 429906.5 446601.9 73500
## 3 2 60000 440000 175000 615000 574766.4 597087.4 73500
## 4 3 70000 440000 175000 615000 574766.4 597087.4 85750
## 5 4 70000 440000 175000 615000 574766.4 597087.4 85750
## 6 5 80000 440000 175000 615000 574766.4 597087.4 98000
## 7 6 80000 440000 175000 615000 574766.4 597087.4 98000
## 8 7 90000 440000 175000 615000 574766.4 597087.4 110250
## SPKBenefits PV_c SPKCosts2 SPKBenefits2 PV_d
## 1 0 0.0 2700880 0 0.0
## 2 563500 547087.4 63600 487600 473398.1
## 3 753375 731432.0 63600 651900 632912.6
## 4 753375 731432.0 74200 651900 632912.6
## 5 753375 731432.0 74200 651900 632912.6
## 6 753375 731432.0 84800 651900 632912.6
## 7 753375 731432.0 84800 651900 632912.6
## 8 753375 731432.0 95400 651900 632912.6
sum(data$PV_d)
## [1] 4270874
4,270,874
About 650,000 less than if 75% were allocated to investment.
I don’t fully grasp the theoretical basis of using the shadow price of capital, but it has something to do with the value of investment vs. consumption, and whether the project expenditure is government or private sector financed. Investment generally provides a stream of benefits over time, while consumption provides benefit in only one time period. Therefore, investment flows need to be weighted in a way that makes them equal to consumption, so that costs or benefits of investment and consumption may be treated together as a single cost or benefit category. In this example, the benefits go down because more of the benefits are used for consumption rather than investment.
q6 <- read.xlsx("q6 data.xlsx",colNames=T, startRow=1)
q6
## town visits fee income pop
## 1 1 168590 0.00 20600 36879
## 2 2 179599 0.00 33400 64520
## 3 3 198595 0.00 39700 104123
## 4 4 206662 0.00 32600 103073
## 5 5 170259 0.00 24900 58386
## 6 6 209995 0.25 38000 116592
## 7 7 172018 0.25 26700 49945
## 8 8 190802 0.25 20800 79789
## 9 9 197019 0.25 26300 98234
## 10 10 186515 0.50 35600 71762
## 11 11 152679 0.50 38900 40178
## 12 12 137423 0.50 21700 22928
## 13 13 158056 0.50 37900 39031
## 14 14 157424 0.50 35100 44685
## 15 15 179490 0.50 35700 67882
## 16 16 164657 0.75 22900 69625
## 17 17 184428 0.75 38600 98408
## 18 18 183822 0.75 20500 93429
## 19 19 174510 1.00 39300 98077
## 20 20 187820 1.00 25800 104068
## 21 21 196318 1.25 23800 117940
## 22 22 166694 1.50 34000 59757
## 23 23 161716 1.50 29600 88305
## 24 24 167505 2.00 33800 84102
describe(q6)
## vars n mean sd median trimmed mad min
## town 1 24 12.50 7.07 12.5 12.50 8.90 1
## visits 2 24 177191.50 17876.56 177000.0 177291.85 17170.73 137423
## fee 3 24 0.60 0.54 0.5 0.55 0.37 0
## income 4 24 30675.00 6843.67 33000.0 30805.00 9043.86 20500
## pop 5 24 75488.25 27360.70 75775.5 75868.95 33425.96 22928
## max range skew kurtosis se
## town 24 23 0.00 -1.35 1.44
## visits 209995 72572 -0.08 -0.66 3649.04
## fee 2 2 0.86 -0.07 0.11
## income 39700 19200 -0.18 -1.61 1396.96
## pop 117940 95012 -0.19 -1.24 5584.98
visits <- lm(visits~fee+income+pop, data=q6)
summary(visits)
##
## Call:
## lm(formula = visits ~ fee + income + pop, data = q6)
##
## Residuals:
## Min 1Q Median 3Q Max
## -10499.6 -4707.5 551.1 5122.7 12106.6
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.405e+05 7.135e+03 19.698 1.44e-14 ***
## fee -1.464e+04 2.634e+03 -5.557 1.94e-05 ***
## income -1.127e-03 2.054e-01 -0.005 0.996
## pop 6.031e-01 5.242e-02 11.504 2.86e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 6686 on 20 degrees of freedom
## Multiple R-squared: 0.8784, Adjusted R-squared: 0.8601
## F-statistic: 48.14 on 3 and 20 DF, p-value: 2.474e-09
140546.7-(.001127*31500) + (.603*70230)
## [1] 182859.9
182,860
140546.7 - 14638.37 -(.001127*31500) + (.603*70230)
## [1] 168221.5
168,222
140546.7 - (1.25*14638.37) -(.001127*31500) + (.603*70230)
## [1] 164561.9
164,561.9
SEE EXCEL SHEET
Calculate CE ratios for each program without discounting.
Calculate CE ratios discounting cost but not effectiveness assuming a discount rate of 4 percent.
Calculate CE ratios discounting both costs and effectiveness at 4 percent.
Assume that the uncertainty range for each of the yearly effectiveness estimates is plus or minus 20 percent, and the uncertainty in each of the yearly cost estimates is 10 percent. Assuming uniform distributions of errors, produce Monte Carlo distributions of CE ratios for each program and compare them. Include the mean, standard deviation, minimum, and maximum for each alternative. (Note: See Appendix 7A in your textbook for doing Monte Carlo Sensitivity Analysis with a Simple Spreadsheet. The same techniques were used for the rural hiring question earlier in this problem set.)
A <- data.frame(rnorm(1000,1.9,.18))
costA <- data.frame(rnorm(1000,3.8,.35))
simA <- data.frame(cbind(A, costA))
colnames(simA) <- c("qaly","cost")
simA$ratio <- simA$cost / simA$qaly
describe(simA)
## vars n mean sd median trimmed mad min max range skew
## qaly 1 1000 1.90 0.19 1.89 1.90 0.19 1.36 2.59 1.23 -0.01
## cost 2 1000 3.79 0.37 3.78 3.79 0.37 2.66 5.07 2.41 0.03
## ratio 3 1000 2.02 0.28 2.00 2.01 0.28 1.20 2.98 1.78 0.45
## kurtosis se
## qaly -0.07 0.01
## cost -0.02 0.01
## ratio 0.28 0.01
ggplot(simA, aes(x=ratio)) + geom_density()
qalyB <- rnorm(1000,2,.19)
costB <- rnorm(1000,4,.38)
simB <- data.frame(cbind(qalyB,costB))
colnames(simB) <- c("qaly","cost")
simB$ratio <- simB$cost / simB$qaly
describe(simB)
## vars n mean sd median trimmed mad min max range skew
## qaly 1 1000 2.01 0.20 2.00 2.01 0.19 1.33 2.54 1.22 -0.10
## cost 2 1000 4.00 0.39 4.00 4.00 0.40 2.78 5.16 2.38 -0.05
## ratio 3 1000 2.01 0.28 1.99 2.00 0.27 1.19 3.26 2.07 0.48
## kurtosis se
## qaly -0.05 0.01
## cost -0.04 0.01
## ratio 0.89 0.01
ggplot(simB, aes(x=ratio)) + geom_density()
Annex 1: Simulations from question 2c
set.seed(2)
res <- round(data.frame(rnorm(100,11,3.9)),digits=2)
colnames(res) <- "ReservationPrice"
describe(res)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 100 10.88 4.52 10.46 10.85 4.48 1.44 19.15 17.71
## skew kurtosis se
## ReservationPrice 0.11 -0.8 0.45
res$Accept <- ifelse(res$ReservationPrice>12, 0,1)
res
## ReservationPrice Accept
## 1 7.50 1
## 2 11.72 1
## 3 17.19 0
## 4 6.59 1
## 5 10.69 1
## 6 11.52 1
## 7 13.76 0
## 8 10.07 1
## 9 18.74 0
## 10 10.46 1
## 11 12.63 0
## 12 14.83 0
## 13 9.47 1
## 14 6.95 1
## 15 17.95 0
## 16 1.99 1
## 17 14.43 0
## 18 11.14 1
## 19 14.95 0
## 20 12.69 0
## 21 19.15 0
## 22 6.32 1
## 23 17.20 0
## 24 18.62 0
## 25 11.02 1
## 26 1.44 1
## 27 12.86 0
## 28 8.67 1
## 29 14.09 0
## 30 12.13 0
## 31 13.88 0
## 32 12.24 0
## 33 15.20 0
## 34 9.89 1
## 35 7.97 1
## 36 8.68 1
## 37 4.27 1
## 38 7.48 1
## 39 8.82 1
## 40 10.04 1
## 41 9.50 1
## 42 3.36 1
## 43 7.72 1
## 44 18.42 0
## 45 13.43 0
## 46 18.76 0
## 47 9.81 1
## 48 10.65 1
## 49 10.28 1
## 50 6.32 1
## 51 7.73 1
## 52 19.06 0
## 53 8.81 1
## 54 15.98 0
## 55 6.91 1
## 56 3.33 1
## 57 9.74 1
## 58 14.65 0
## 59 15.44 0
## 60 17.52 0
## 61 4.03 1
## 62 18.92 0
## 63 8.26 1
## 64 11.62 1
## 65 12.97 0
## 66 7.80 1
## 67 3.20 1
## 68 9.13 1
## 69 11.33 1
## 70 7.51 1
## 71 7.41 1
## 72 12.29 0
## 73 10.45 1
## 74 12.70 0
## 75 10.79 1
## 76 7.46 1
## 77 16.08 0
## 78 14.01 0
## 79 15.10 0
## 80 5.50 1
## 81 14.88 0
## 82 4.39 1
## 83 8.92 1
## 84 5.65 1
## 85 2.39 1
## 86 18.11 0
## 87 8.45 1
## 88 9.89 1
## 89 9.49 1
## 90 12.51 0
## 91 17.24 0
## 92 17.56 0
## 93 6.38 1
## 94 5.70 1
## 95 5.10 1
## 96 6.11 1
## 97 18.64 0
## 98 11.03 1
## 99 7.71 1
## 100 8.66 1
## subset data to the job offers up to 12 accepts
subRes <- res[1:38,]
subRes
## ReservationPrice Accept
## 1 7.50 1
## 2 11.72 1
## 3 17.19 0
## 4 6.59 1
## 5 10.69 1
## 6 11.52 1
## 7 13.76 0
## 8 10.07 1
## 9 18.74 0
## 10 10.46 1
## 11 12.63 0
## 12 14.83 0
## 13 9.47 1
## 14 6.95 1
## 15 17.95 0
## 16 1.99 1
## 17 14.43 0
## 18 11.14 1
## 19 14.95 0
## 20 12.69 0
## 21 19.15 0
## 22 6.32 1
## 23 17.20 0
## 24 18.62 0
## 25 11.02 1
## 26 1.44 1
## 27 12.86 0
## 28 8.67 1
## 29 14.09 0
## 30 12.13 0
## 31 13.88 0
## 32 12.24 0
## 33 15.20 0
## 34 9.89 1
## 35 7.97 1
## 36 8.68 1
## 37 4.27 1
## 38 7.48 1
sum(subRes$ReservationPrice)
## [1] 436.38
436.38
resSort <- arrange(res, ReservationPrice)
resSort
## ReservationPrice Accept
## 1 1.44 1
## 2 1.99 1
## 3 2.39 1
## 4 3.20 1
## 5 3.33 1
## 6 3.36 1
## 7 4.03 1
## 8 4.27 1
## 9 4.39 1
## 10 5.10 1
## 11 5.50 1
## 12 5.65 1
## 13 5.70 1
## 14 6.11 1
## 15 6.32 1
## 16 6.32 1
## 17 6.38 1
## 18 6.59 1
## 19 6.91 1
## 20 6.95 1
## 21 7.41 1
## 22 7.46 1
## 23 7.48 1
## 24 7.50 1
## 25 7.51 1
## 26 7.71 1
## 27 7.72 1
## 28 7.73 1
## 29 7.80 1
## 30 7.97 1
## 31 8.26 1
## 32 8.45 1
## 33 8.66 1
## 34 8.67 1
## 35 8.68 1
## 36 8.81 1
## 37 8.82 1
## 38 8.92 1
## 39 9.13 1
## 40 9.47 1
## 41 9.49 1
## 42 9.50 1
## 43 9.74 1
## 44 9.81 1
## 45 9.89 1
## 46 9.89 1
## 47 10.04 1
## 48 10.07 1
## 49 10.28 1
## 50 10.45 1
## 51 10.46 1
## 52 10.65 1
## 53 10.69 1
## 54 10.79 1
## 55 11.02 1
## 56 11.03 1
## 57 11.14 1
## 58 11.33 1
## 59 11.52 1
## 60 11.62 1
## 61 11.72 1
## 62 12.13 0
## 63 12.24 0
## 64 12.29 0
## 65 12.51 0
## 66 12.63 0
## 67 12.69 0
## 68 12.70 0
## 69 12.86 0
## 70 12.97 0
## 71 13.43 0
## 72 13.76 0
## 73 13.88 0
## 74 14.01 0
## 75 14.09 0
## 76 14.43 0
## 77 14.65 0
## 78 14.83 0
## 79 14.88 0
## 80 14.95 0
## 81 15.10 0
## 82 15.20 0
## 83 15.44 0
## 84 15.98 0
## 85 16.08 0
## 86 17.19 0
## 87 17.20 0
## 88 17.24 0
## 89 17.52 0
## 90 17.56 0
## 91 17.95 0
## 92 18.11 0
## 93 18.42 0
## 94 18.62 0
## 95 18.64 0
## 96 18.74 0
## 97 18.76 0
## 98 18.92 0
## 99 19.06 0
## 100 19.15 0
resLow <- resSort[1:20,]
resLow
## ReservationPrice Accept
## 1 1.44 1
## 2 1.99 1
## 3 2.39 1
## 4 3.20 1
## 5 3.33 1
## 6 3.36 1
## 7 4.03 1
## 8 4.27 1
## 9 4.39 1
## 10 5.10 1
## 11 5.50 1
## 12 5.65 1
## 13 5.70 1
## 14 6.11 1
## 15 6.32 1
## 16 6.32 1
## 17 6.38 1
## 18 6.59 1
## 19 6.91 1
## 20 6.95 1
describe(resLow)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 20 4.8 1.72 5.3 4.92 1.74 1.44 6.95 5.51
## Accept 2 20 1.0 0.00 1.0 1.00 0.00 1.00 1.00 0.00
## skew kurtosis se
## ReservationPrice -0.44 -1.21 0.38
## Accept NaN NaN 0.00
sum(resLow$ReservationPrice)
## [1] 95.93
The opportunity cost for those who most want to work is 95.93
set.seed(3)
res <- round(data.frame(rnorm(100,11,3.9)),digits=2)
colnames(res) <- "ReservationPrice"
describe(res)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 100 11.04 3.34 11.13 11.09 4.23 2.16 17.77 15.61
## skew kurtosis se
## ReservationPrice -0.13 -0.77 0.33
res$Accept <- ifelse(res$ReservationPrice>12, 0,1)
res
## ReservationPrice Accept
## 1 7.25 1
## 2 9.86 1
## 3 12.01 0
## 4 6.51 1
## 5 11.76 1
## 6 11.12 1
## 7 11.33 1
## 8 15.35 0
## 9 6.25 1
## 10 15.94 0
## 11 8.10 1
## 12 6.59 1
## 13 8.21 1
## 14 11.99 1
## 15 11.59 1
## 16 9.80 1
## 17 7.28 1
## 18 8.47 1
## 19 15.77 0
## 20 11.78 1
## 21 8.74 1
## 22 7.33 1
## 23 10.21 1
## 24 4.50 1
## 25 9.11 1
## 26 8.11 1
## 27 15.53 0
## 28 14.95 0
## 29 10.72 1
## 30 6.57 1
## 31 14.51 0
## 32 14.32 0
## 33 13.84 0
## 34 13.87 0
## 35 9.63 1
## 36 13.75 0
## 37 16.07 0
## 38 11.15 1
## 39 7.18 1
## 40 14.10 0
## 41 14.07 0
## 42 9.79 1
## 43 17.63 0
## 44 7.90 1
## 45 12.36 0
## 46 2.16 1
## 47 10.37 1
## 48 15.41 0
## 49 9.22 1
## 50 7.49 1
## 51 13.83 0
## 52 7.84 1
## 53 12.04 0
## 54 4.22 1
## 55 5.50 1
## 56 9.23 1
## 57 6.96 1
## 58 16.31 0
## 59 14.58 0
## 60 7.94 1
## 61 13.24 0
## 62 14.58 0
## 63 12.00 1
## 64 12.37 0
## 65 15.58 0
## 66 9.12 1
## 67 9.37 1
## 68 14.72 0
## 69 5.97 1
## 70 11.73 1
## 71 10.88 1
## 72 12.82 0
## 73 14.99 0
## 74 12.04 0
## 75 11.90 1
## 76 13.92 0
## 77 15.75 0
## 78 12.50 0
## 79 7.15 1
## 80 10.39 1
## 81 17.77 0
## 82 9.63 1
## 83 13.69 0
## 84 15.78 0
## 85 14.10 0
## 86 10.98 1
## 87 11.85 1
## 88 7.54 1
## 89 12.72 0
## 90 7.54 1
## 91 7.67 1
## 92 7.14 1
## 93 8.46 1
## 94 15.11 0
## 95 9.48 1
## 96 10.72 1
## 97 9.20 1
## 98 13.11 0
## 99 14.63 0
## 100 10.18 1
## subset data to the job offers up to 12 accepts
subRes <- res[1:24,]
subRes
## ReservationPrice Accept
## 1 7.25 1
## 2 9.86 1
## 3 12.01 0
## 4 6.51 1
## 5 11.76 1
## 6 11.12 1
## 7 11.33 1
## 8 15.35 0
## 9 6.25 1
## 10 15.94 0
## 11 8.10 1
## 12 6.59 1
## 13 8.21 1
## 14 11.99 1
## 15 11.59 1
## 16 9.80 1
## 17 7.28 1
## 18 8.47 1
## 19 15.77 0
## 20 11.78 1
## 21 8.74 1
## 22 7.33 1
## 23 10.21 1
## 24 4.50 1
sum(subRes$ReservationPrice)
## [1] 237.74
237.74
resSort <- arrange(res, ReservationPrice)
resSort
## ReservationPrice Accept
## 1 2.16 1
## 2 4.22 1
## 3 4.50 1
## 4 5.50 1
## 5 5.97 1
## 6 6.25 1
## 7 6.51 1
## 8 6.57 1
## 9 6.59 1
## 10 6.96 1
## 11 7.14 1
## 12 7.15 1
## 13 7.18 1
## 14 7.25 1
## 15 7.28 1
## 16 7.33 1
## 17 7.49 1
## 18 7.54 1
## 19 7.54 1
## 20 7.67 1
## 21 7.84 1
## 22 7.90 1
## 23 7.94 1
## 24 8.10 1
## 25 8.11 1
## 26 8.21 1
## 27 8.46 1
## 28 8.47 1
## 29 8.74 1
## 30 9.11 1
## 31 9.12 1
## 32 9.20 1
## 33 9.22 1
## 34 9.23 1
## 35 9.37 1
## 36 9.48 1
## 37 9.63 1
## 38 9.63 1
## 39 9.79 1
## 40 9.80 1
## 41 9.86 1
## 42 10.18 1
## 43 10.21 1
## 44 10.37 1
## 45 10.39 1
## 46 10.72 1
## 47 10.72 1
## 48 10.88 1
## 49 10.98 1
## 50 11.12 1
## 51 11.15 1
## 52 11.33 1
## 53 11.59 1
## 54 11.73 1
## 55 11.76 1
## 56 11.78 1
## 57 11.85 1
## 58 11.90 1
## 59 11.99 1
## 60 12.00 1
## 61 12.01 0
## 62 12.04 0
## 63 12.04 0
## 64 12.36 0
## 65 12.37 0
## 66 12.50 0
## 67 12.72 0
## 68 12.82 0
## 69 13.11 0
## 70 13.24 0
## 71 13.69 0
## 72 13.75 0
## 73 13.83 0
## 74 13.84 0
## 75 13.87 0
## 76 13.92 0
## 77 14.07 0
## 78 14.10 0
## 79 14.10 0
## 80 14.32 0
## 81 14.51 0
## 82 14.58 0
## 83 14.58 0
## 84 14.63 0
## 85 14.72 0
## 86 14.95 0
## 87 14.99 0
## 88 15.11 0
## 89 15.35 0
## 90 15.41 0
## 91 15.53 0
## 92 15.58 0
## 93 15.75 0
## 94 15.77 0
## 95 15.78 0
## 96 15.94 0
## 97 16.07 0
## 98 16.31 0
## 99 17.63 0
## 100 17.77 0
resLow <- resSort[1:20,]
resLow
## ReservationPrice Accept
## 1 2.16 1
## 2 4.22 1
## 3 4.50 1
## 4 5.50 1
## 5 5.97 1
## 6 6.25 1
## 7 6.51 1
## 8 6.57 1
## 9 6.59 1
## 10 6.96 1
## 11 7.14 1
## 12 7.15 1
## 13 7.18 1
## 14 7.25 1
## 15 7.28 1
## 16 7.33 1
## 17 7.49 1
## 18 7.54 1
## 19 7.54 1
## 20 7.67 1
describe(resLow)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 20 6.44 1.4 7.05 6.7 0.72 2.16 7.67 5.51
## Accept 2 20 1.00 0.0 1.00 1.0 0.00 1.00 1.00 0.00
## skew kurtosis se
## ReservationPrice -1.62 2.01 0.31
## Accept NaN NaN 0.00
sum(resLow$ReservationPrice)
## [1] 128.8
The opportunity cost for those who most want to work is 128.8
set.seed(4)
res <- round(data.frame(rnorm(100,11,3.9)),digits=2)
colnames(res) <- "ReservationPrice"
describe(res)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 100 11.38 3.56 10.95 11.3 3.7 3.99 20.09 16.1
## skew kurtosis se
## ReservationPrice 0.23 -0.57 0.36
res$Accept <- ifelse(res$ReservationPrice>12, 0,1)
res
## ReservationPrice Accept
## 1 11.85 1
## 2 8.88 1
## 3 14.48 0
## 4 13.32 0
## 5 17.38 0
## 6 13.69 0
## 7 6.00 1
## 8 10.17 1
## 9 18.40 0
## 10 17.93 0
## 11 13.21 0
## 12 11.06 1
## 13 12.49 0
## 14 10.82 1
## 15 11.13 1
## 16 11.66 1
## 17 15.54 0
## 18 10.83 1
## 19 10.61 1
## 20 9.89 1
## 21 17.01 0
## 22 11.64 1
## 23 16.10 0
## 24 16.02 0
## 25 13.31 0
## 26 9.90 1
## 27 15.90 0
## 28 14.55 0
## 29 7.38 1
## 30 15.84 0
## 31 11.60 1
## 32 15.10 0
## 33 8.06 1
## 34 5.22 1
## 35 14.36 0
## 36 9.42 1
## 37 10.11 1
## 38 14.64 0
## 39 9.18 1
## 40 8.51 1
## 41 16.24 0
## 42 11.71 1
## 43 16.04 0
## 44 4.42 1
## 45 7.80 1
## 46 7.64 1
## 47 11.39 1
## 48 9.53 1
## 49 13.82 0
## 50 3.99 1
## 51 8.41 1
## 52 8.57 1
## 53 10.69 1
## 54 12.70 0
## 55 18.69 0
## 56 8.67 1
## 57 8.85 1
## 58 13.71 0
## 59 10.39 1
## 60 16.26 0
## 61 6.83 1
## 62 15.15 0
## 63 5.88 1
## 64 19.05 0
## 65 11.51 1
## 66 10.10 1
## 67 9.45 1
## 68 14.47 0
## 69 13.05 0
## 70 10.33 1
## 71 11.62 1
## 72 9.11 1
## 73 7.26 1
## 74 11.70 1
## 75 13.81 0
## 76 9.56 1
## 77 11.93 1
## 78 8.40 1
## 79 7.89 1
## 80 10.80 1
## 81 16.02 0
## 82 10.16 1
## 83 8.76 1
## 84 5.26 1
## 85 6.97 1
## 86 5.90 1
## 87 7.73 1
## 88 6.59 1
## 89 12.44 0
## 90 10.21 1
## 91 6.02 1
## 92 7.89 1
## 93 11.62 1
## 94 13.40 0
## 95 13.68 0
## 96 10.82 1
## 97 20.09 0
## 98 8.75 1
## 99 14.78 0
## 100 9.92 1
## subset data to the job offers up to 12 accepts
subRes <- res[1:39,]
subRes
## ReservationPrice Accept
## 1 11.85 1
## 2 8.88 1
## 3 14.48 0
## 4 13.32 0
## 5 17.38 0
## 6 13.69 0
## 7 6.00 1
## 8 10.17 1
## 9 18.40 0
## 10 17.93 0
## 11 13.21 0
## 12 11.06 1
## 13 12.49 0
## 14 10.82 1
## 15 11.13 1
## 16 11.66 1
## 17 15.54 0
## 18 10.83 1
## 19 10.61 1
## 20 9.89 1
## 21 17.01 0
## 22 11.64 1
## 23 16.10 0
## 24 16.02 0
## 25 13.31 0
## 26 9.90 1
## 27 15.90 0
## 28 14.55 0
## 29 7.38 1
## 30 15.84 0
## 31 11.60 1
## 32 15.10 0
## 33 8.06 1
## 34 5.22 1
## 35 14.36 0
## 36 9.42 1
## 37 10.11 1
## 38 14.64 0
## 39 9.18 1
sum(subRes$ReservationPrice)
## [1] 484.68
484.68
resSort <- arrange(res, ReservationPrice)
resSort
## ReservationPrice Accept
## 1 3.99 1
## 2 4.42 1
## 3 5.22 1
## 4 5.26 1
## 5 5.88 1
## 6 5.90 1
## 7 6.00 1
## 8 6.02 1
## 9 6.59 1
## 10 6.83 1
## 11 6.97 1
## 12 7.26 1
## 13 7.38 1
## 14 7.64 1
## 15 7.73 1
## 16 7.80 1
## 17 7.89 1
## 18 7.89 1
## 19 8.06 1
## 20 8.40 1
## 21 8.41 1
## 22 8.51 1
## 23 8.57 1
## 24 8.67 1
## 25 8.75 1
## 26 8.76 1
## 27 8.85 1
## 28 8.88 1
## 29 9.11 1
## 30 9.18 1
## 31 9.42 1
## 32 9.45 1
## 33 9.53 1
## 34 9.56 1
## 35 9.89 1
## 36 9.90 1
## 37 9.92 1
## 38 10.10 1
## 39 10.11 1
## 40 10.16 1
## 41 10.17 1
## 42 10.21 1
## 43 10.33 1
## 44 10.39 1
## 45 10.61 1
## 46 10.69 1
## 47 10.80 1
## 48 10.82 1
## 49 10.82 1
## 50 10.83 1
## 51 11.06 1
## 52 11.13 1
## 53 11.39 1
## 54 11.51 1
## 55 11.60 1
## 56 11.62 1
## 57 11.62 1
## 58 11.64 1
## 59 11.66 1
## 60 11.70 1
## 61 11.71 1
## 62 11.85 1
## 63 11.93 1
## 64 12.44 0
## 65 12.49 0
## 66 12.70 0
## 67 13.05 0
## 68 13.21 0
## 69 13.31 0
## 70 13.32 0
## 71 13.40 0
## 72 13.68 0
## 73 13.69 0
## 74 13.71 0
## 75 13.81 0
## 76 13.82 0
## 77 14.36 0
## 78 14.47 0
## 79 14.48 0
## 80 14.55 0
## 81 14.64 0
## 82 14.78 0
## 83 15.10 0
## 84 15.15 0
## 85 15.54 0
## 86 15.84 0
## 87 15.90 0
## 88 16.02 0
## 89 16.02 0
## 90 16.04 0
## 91 16.10 0
## 92 16.24 0
## 93 16.26 0
## 94 17.01 0
## 95 17.38 0
## 96 17.93 0
## 97 18.40 0
## 98 18.69 0
## 99 19.05 0
## 100 20.09 0
resLow <- resSort[1:20,]
resLow
## ReservationPrice Accept
## 1 3.99 1
## 2 4.42 1
## 3 5.22 1
## 4 5.26 1
## 5 5.88 1
## 6 5.90 1
## 7 6.00 1
## 8 6.02 1
## 9 6.59 1
## 10 6.83 1
## 11 6.97 1
## 12 7.26 1
## 13 7.38 1
## 14 7.64 1
## 15 7.73 1
## 16 7.80 1
## 17 7.89 1
## 18 7.89 1
## 19 8.06 1
## 20 8.40 1
describe(resLow)
## vars n mean sd median trimmed mad min max range skew
## ReservationPrice 1 20 6.66 1.27 6.9 6.77 1.4 3.99 8.4 4.41 -0.52
## Accept 2 20 1.00 0.00 1.0 1.00 0.0 1.00 1.0 0.00 NaN
## kurtosis se
## ReservationPrice -0.95 0.28
## Accept NaN 0.00
sum(resLow$ReservationPrice)
## [1] 133.13
The opportunity cost for those who most want to work is 133.13
set.seed(5)
res <- round(data.frame(rnorm(100,11,3.9)),digits=2)
colnames(res) <- "ReservationPrice"
describe(res)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 100 11.12 3.69 10.63 11.08 3.6 2.48 20.31 17.83
## skew kurtosis se
## ReservationPrice 0.12 -0.26 0.37
res$Accept <- ifelse(res$ReservationPrice>12, 0,1)
res
## ReservationPrice Accept
## 1 7.72 1
## 2 16.40 0
## 3 6.10 1
## 4 11.27 1
## 5 17.67 0
## 6 8.65 1
## 7 9.16 1
## 8 8.52 1
## 9 9.89 1
## 10 11.54 1
## 11 15.79 0
## 12 7.87 1
## 13 6.79 1
## 14 10.39 1
## 15 6.82 1
## 16 10.46 1
## 17 8.67 1
## 18 2.48 1
## 19 11.94 1
## 20 9.99 1
## 21 14.51 0
## 22 14.67 0
## 23 16.73 0
## 24 13.76 0
## 25 14.19 0
## 26 9.86 1
## 27 16.53 0
## 28 16.85 0
## 29 8.44 1
## 30 7.67 1
## 31 12.23 0
## 32 15.33 0
## 33 19.64 0
## 34 15.75 0
## 35 16.77 0
## 36 14.71 0
## 37 7.06 1
## 38 3.20 1
## 39 4.13 1
## 40 10.44 1
## 41 17.05 0
## 42 7.87 1
## 43 10.71 1
## 44 18.39 0
## 45 9.22 1
## 46 13.19 0
## 47 7.54 1
## 48 9.21 1
## 49 8.18 1
## 50 10.73 1
## 51 16.71 0
## 52 11.73 1
## 53 14.99 0
## 54 8.69 1
## 55 10.56 1
## 56 7.39 1
## 57 13.94 0
## 58 10.56 1
## 59 10.75 1
## 60 11.91 1
## 61 6.57 1
## 62 14.33 0
## 63 8.74 1
## 64 12.94 0
## 65 8.04 1
## 66 9.67 1
## 67 2.80 1
## 68 9.82 1
## 69 6.04 1
## 70 9.91 1
## 71 10.20 1
## 72 10.12 1
## 73 12.35 0
## 74 11.13 1
## 75 12.61 0
## 76 10.39 1
## 77 14.80 0
## 78 11.47 1
## 79 11.74 1
## 80 8.80 1
## 81 12.94 0
## 82 4.21 1
## 83 14.80 0
## 84 10.91 1
## 85 13.64 0
## 86 8.23 1
## 87 20.31 0
## 88 9.15 1
## 89 10.70 1
## 90 8.96 1
## 91 14.61 0
## 92 6.86 1
## 93 13.17 0
## 94 14.51 0
## 95 14.86 0
## 96 12.50 0
## 97 9.65 1
## 98 8.89 1
## 99 10.29 1
## 100 10.77 1
## subset data to the job offers up to 12 accepts
subRes <- res[1:30,]
subRes
## ReservationPrice Accept
## 1 7.72 1
## 2 16.40 0
## 3 6.10 1
## 4 11.27 1
## 5 17.67 0
## 6 8.65 1
## 7 9.16 1
## 8 8.52 1
## 9 9.89 1
## 10 11.54 1
## 11 15.79 0
## 12 7.87 1
## 13 6.79 1
## 14 10.39 1
## 15 6.82 1
## 16 10.46 1
## 17 8.67 1
## 18 2.48 1
## 19 11.94 1
## 20 9.99 1
## 21 14.51 0
## 22 14.67 0
## 23 16.73 0
## 24 13.76 0
## 25 14.19 0
## 26 9.86 1
## 27 16.53 0
## 28 16.85 0
## 29 8.44 1
## 30 7.67 1
sum(subRes$ReservationPrice)
## [1] 331.33
331.33
resSort <- arrange(res, ReservationPrice)
resSort
## ReservationPrice Accept
## 1 2.48 1
## 2 2.80 1
## 3 3.20 1
## 4 4.13 1
## 5 4.21 1
## 6 6.04 1
## 7 6.10 1
## 8 6.57 1
## 9 6.79 1
## 10 6.82 1
## 11 6.86 1
## 12 7.06 1
## 13 7.39 1
## 14 7.54 1
## 15 7.67 1
## 16 7.72 1
## 17 7.87 1
## 18 7.87 1
## 19 8.04 1
## 20 8.18 1
## 21 8.23 1
## 22 8.44 1
## 23 8.52 1
## 24 8.65 1
## 25 8.67 1
## 26 8.69 1
## 27 8.74 1
## 28 8.80 1
## 29 8.89 1
## 30 8.96 1
## 31 9.15 1
## 32 9.16 1
## 33 9.21 1
## 34 9.22 1
## 35 9.65 1
## 36 9.67 1
## 37 9.82 1
## 38 9.86 1
## 39 9.89 1
## 40 9.91 1
## 41 9.99 1
## 42 10.12 1
## 43 10.20 1
## 44 10.29 1
## 45 10.39 1
## 46 10.39 1
## 47 10.44 1
## 48 10.46 1
## 49 10.56 1
## 50 10.56 1
## 51 10.70 1
## 52 10.71 1
## 53 10.73 1
## 54 10.75 1
## 55 10.77 1
## 56 10.91 1
## 57 11.13 1
## 58 11.27 1
## 59 11.47 1
## 60 11.54 1
## 61 11.73 1
## 62 11.74 1
## 63 11.91 1
## 64 11.94 1
## 65 12.23 0
## 66 12.35 0
## 67 12.50 0
## 68 12.61 0
## 69 12.94 0
## 70 12.94 0
## 71 13.17 0
## 72 13.19 0
## 73 13.64 0
## 74 13.76 0
## 75 13.94 0
## 76 14.19 0
## 77 14.33 0
## 78 14.51 0
## 79 14.51 0
## 80 14.61 0
## 81 14.67 0
## 82 14.71 0
## 83 14.80 0
## 84 14.80 0
## 85 14.86 0
## 86 14.99 0
## 87 15.33 0
## 88 15.75 0
## 89 15.79 0
## 90 16.40 0
## 91 16.53 0
## 92 16.71 0
## 93 16.73 0
## 94 16.77 0
## 95 16.85 0
## 96 17.05 0
## 97 17.67 0
## 98 18.39 0
## 99 19.64 0
## 100 20.31 0
resLow <- resSort[1:20,]
resLow
## ReservationPrice Accept
## 1 2.48 1
## 2 2.80 1
## 3 3.20 1
## 4 4.13 1
## 5 4.21 1
## 6 6.04 1
## 7 6.10 1
## 8 6.57 1
## 9 6.79 1
## 10 6.82 1
## 11 6.86 1
## 12 7.06 1
## 13 7.39 1
## 14 7.54 1
## 15 7.67 1
## 16 7.72 1
## 17 7.87 1
## 18 7.87 1
## 19 8.04 1
## 20 8.18 1
describe(resLow)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 20 6.27 1.85 6.84 6.49 1.27 2.48 8.18 5.7
## Accept 2 20 1.00 0.00 1.00 1.00 0.00 1.00 1.00 0.0
## skew kurtosis se
## ReservationPrice -0.88 -0.76 0.41
## Accept NaN NaN 0.00
sum(resLow$ReservationPrice)
## [1] 125.34
The opportunity cost for those who most want to work is 125.34
set.seed(6)
res <- round(data.frame(rnorm(100,11,3.9)),digits=2)
colnames(res) <- "ReservationPrice"
describe(res)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 100 10.96 4.03 10.46 10.73 3.83 3.39 21.17 17.78
## skew kurtosis se
## ReservationPrice 0.46 -0.41 0.4
res$Accept <- ifelse(res$ReservationPrice>12, 0,1)
res
## ReservationPrice Accept
## 1 12.05 0
## 2 8.54 1
## 3 14.39 0
## 4 17.74 0
## 5 11.09 1
## 6 12.44 0
## 7 5.89 1
## 8 13.88 0
## 9 11.18 1
## 10 6.91 1
## 11 17.74 0
## 12 6.40 1
## 13 13.55 0
## 14 9.56 1
## 15 8.66 1
## 16 11.21 1
## 17 17.66 0
## 18 6.73 1
## 19 9.87 1
## 20 19.61 0
## 21 13.02 0
## 22 5.52 1
## 23 18.86 0
## 24 6.37 1
## 25 11.74 1
## 26 6.44 1
## 27 10.85 1
## 28 20.18 0
## 29 16.43 0
## 30 8.81 1
## 31 8.38 1
## 32 12.92 0
## 33 6.40 1
## 34 6.87 1
## 35 15.44 0
## 36 10.37 1
## 37 13.46 0
## 38 17.31 0
## 39 10.25 1
## 40 4.73 1
## 41 7.55 1
## 42 9.31 1
## 43 9.36 1
## 44 10.34 1
## 45 11.96 1
## 46 8.09 1
## 47 9.93 1
## 48 18.12 0
## 49 11.06 1
## 50 11.73 1
## 51 10.79 1
## 52 12.80 0
## 53 8.67 1
## 54 15.93 0
## 55 6.53 1
## 56 15.23 0
## 57 5.04 1
## 58 4.86 1
## 59 10.56 1
## 60 11.43 1
## 61 11.84 1
## 62 13.16 0
## 63 6.87 1
## 64 4.72 1
## 65 9.68 1
## 66 11.80 1
## 67 10.13 1
## 68 7.45 1
## 69 7.85 1
## 70 13.16 0
## 71 9.48 1
## 72 9.26 1
## 73 10.92 1
## 74 8.66 1
## 75 9.79 1
## 76 8.34 1
## 77 10.21 1
## 78 15.36 0
## 79 14.22 0
## 80 15.88 0
## 81 21.17 0
## 82 10.80 1
## 83 19.69 0
## 84 10.95 1
## 85 4.97 1
## 86 5.62 1
## 87 16.77 0
## 88 10.01 1
## 89 9.73 1
## 90 8.17 1
## 91 3.39 1
## 92 12.65 0
## 93 15.61 0
## 94 14.58 0
## 95 11.37 1
## 96 4.43 1
## 97 14.86 0
## 98 8.24 1
## 99 8.68 1
## 100 6.84 1
## subset data to the job offers up to 12 accepts
subRes <- res[1:34,]
subRes
## ReservationPrice Accept
## 1 12.05 0
## 2 8.54 1
## 3 14.39 0
## 4 17.74 0
## 5 11.09 1
## 6 12.44 0
## 7 5.89 1
## 8 13.88 0
## 9 11.18 1
## 10 6.91 1
## 11 17.74 0
## 12 6.40 1
## 13 13.55 0
## 14 9.56 1
## 15 8.66 1
## 16 11.21 1
## 17 17.66 0
## 18 6.73 1
## 19 9.87 1
## 20 19.61 0
## 21 13.02 0
## 22 5.52 1
## 23 18.86 0
## 24 6.37 1
## 25 11.74 1
## 26 6.44 1
## 27 10.85 1
## 28 20.18 0
## 29 16.43 0
## 30 8.81 1
## 31 8.38 1
## 32 12.92 0
## 33 6.40 1
## 34 6.87 1
sum(subRes$ReservationPrice)
## [1] 387.89
387.89
resSort <- arrange(res, ReservationPrice)
resSort
## ReservationPrice Accept
## 1 3.39 1
## 2 4.43 1
## 3 4.72 1
## 4 4.73 1
## 5 4.86 1
## 6 4.97 1
## 7 5.04 1
## 8 5.52 1
## 9 5.62 1
## 10 5.89 1
## 11 6.37 1
## 12 6.40 1
## 13 6.40 1
## 14 6.44 1
## 15 6.53 1
## 16 6.73 1
## 17 6.84 1
## 18 6.87 1
## 19 6.87 1
## 20 6.91 1
## 21 7.45 1
## 22 7.55 1
## 23 7.85 1
## 24 8.09 1
## 25 8.17 1
## 26 8.24 1
## 27 8.34 1
## 28 8.38 1
## 29 8.54 1
## 30 8.66 1
## 31 8.66 1
## 32 8.67 1
## 33 8.68 1
## 34 8.81 1
## 35 9.26 1
## 36 9.31 1
## 37 9.36 1
## 38 9.48 1
## 39 9.56 1
## 40 9.68 1
## 41 9.73 1
## 42 9.79 1
## 43 9.87 1
## 44 9.93 1
## 45 10.01 1
## 46 10.13 1
## 47 10.21 1
## 48 10.25 1
## 49 10.34 1
## 50 10.37 1
## 51 10.56 1
## 52 10.79 1
## 53 10.80 1
## 54 10.85 1
## 55 10.92 1
## 56 10.95 1
## 57 11.06 1
## 58 11.09 1
## 59 11.18 1
## 60 11.21 1
## 61 11.37 1
## 62 11.43 1
## 63 11.73 1
## 64 11.74 1
## 65 11.80 1
## 66 11.84 1
## 67 11.96 1
## 68 12.05 0
## 69 12.44 0
## 70 12.65 0
## 71 12.80 0
## 72 12.92 0
## 73 13.02 0
## 74 13.16 0
## 75 13.16 0
## 76 13.46 0
## 77 13.55 0
## 78 13.88 0
## 79 14.22 0
## 80 14.39 0
## 81 14.58 0
## 82 14.86 0
## 83 15.23 0
## 84 15.36 0
## 85 15.44 0
## 86 15.61 0
## 87 15.88 0
## 88 15.93 0
## 89 16.43 0
## 90 16.77 0
## 91 17.31 0
## 92 17.66 0
## 93 17.74 0
## 94 17.74 0
## 95 18.12 0
## 96 18.86 0
## 97 19.61 0
## 98 19.69 0
## 99 20.18 0
## 100 21.17 0
resLow <- resSort[1:20,]
resLow
## ReservationPrice Accept
## 1 3.39 1
## 2 4.43 1
## 3 4.72 1
## 4 4.73 1
## 5 4.86 1
## 6 4.97 1
## 7 5.04 1
## 8 5.52 1
## 9 5.62 1
## 10 5.89 1
## 11 6.37 1
## 12 6.40 1
## 13 6.40 1
## 14 6.44 1
## 15 6.53 1
## 16 6.73 1
## 17 6.84 1
## 18 6.87 1
## 19 6.87 1
## 20 6.91 1
describe(resLow)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 20 5.78 1.02 6.13 5.87 1.07 3.39 6.91 3.52
## Accept 2 20 1.00 0.00 1.00 1.00 0.00 1.00 1.00 0.00
## skew kurtosis se
## ReservationPrice -0.59 -0.81 0.23
## Accept NaN NaN 0.00
sum(resLow$ReservationPrice)
## [1] 115.53
The opportunity cost for those who most want to work is 115.53
set.seed(7)
res <- round(data.frame(rnorm(100,11,3.9)),digits=2)
colnames(res) <- "ReservationPrice"
describe(res)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 100 11.54 3.74 11.41 11.39 3.65 4.04 21.6 17.56
## skew kurtosis se
## ReservationPrice 0.37 -0.13 0.37
res$Accept <- ifelse(res$ReservationPrice>12, 0,1)
res
## ReservationPrice Accept
## 1 19.92 0
## 2 6.33 1
## 3 8.29 1
## 4 9.39 1
## 5 7.21 1
## 6 7.31 1
## 7 13.92 0
## 8 10.54 1
## 9 11.60 1
## 10 19.54 0
## 11 12.39 0
## 12 21.60 0
## 13 19.90 0
## 14 12.26 0
## 15 18.39 0
## 16 12.82 0
## 17 7.51 1
## 18 9.80 1
## 19 10.98 1
## 20 14.85 0
## 21 14.28 0
## 22 13.75 0
## 23 16.09 0
## 24 5.59 1
## 25 15.96 0
## 26 11.72 1
## 27 13.93 0
## 28 13.31 0
## 29 7.17 1
## 30 9.92 1
## 31 7.60 1
## 32 13.80 0
## 33 11.43 1
## 34 10.69 1
## 35 9.36 1
## 36 8.81 1
## 37 14.89 0
## 38 6.69 1
## 39 10.45 1
## 40 12.23 0
## 41 15.75 0
## 42 8.27 1
## 43 9.89 1
## 44 5.88 1
## 45 9.48 1
## 46 9.43 1
## 47 16.27 0
## 48 13.31 0
## 49 11.39 1
## 50 14.63 0
## 51 9.98 1
## 52 10.97 1
## 53 12.43 0
## 54 17.66 0
## 55 13.82 0
## 56 12.88 0
## 57 4.89 1
## 58 12.24 0
## 59 11.65 1
## 60 7.49 1
## 61 11.30 1
## 62 11.62 1
## 63 13.12 0
## 64 13.75 0
## 65 12.24 0
## 66 15.33 0
## 67 14.00 0
## 68 15.50 0
## 69 15.92 0
## 70 13.73 0
## 71 12.69 0
## 72 7.40 1
## 73 8.60 1
## 74 7.62 1
## 75 4.61 1
## 76 5.83 1
## 77 7.53 1
## 78 8.83 1
## 79 10.76 1
## 80 20.45 0
## 81 12.34 0
## 82 11.02 1
## 83 11.11 1
## 84 9.47 1
## 85 7.91 1
## 86 9.78 1
## 87 9.65 1
## 88 9.81 1
## 89 4.04 1
## 90 13.29 0
## 91 17.38 0
## 92 8.48 1
## 93 13.41 0
## 94 11.92 1
## 95 14.30 0
## 96 8.76 1
## 97 15.36 0
## 98 4.99 1
## 99 9.29 1
## 100 10.41 1
## subset data to the job offers up to 12 accepts
subRes <- res[1:38,]
subRes
## ReservationPrice Accept
## 1 19.92 0
## 2 6.33 1
## 3 8.29 1
## 4 9.39 1
## 5 7.21 1
## 6 7.31 1
## 7 13.92 0
## 8 10.54 1
## 9 11.60 1
## 10 19.54 0
## 11 12.39 0
## 12 21.60 0
## 13 19.90 0
## 14 12.26 0
## 15 18.39 0
## 16 12.82 0
## 17 7.51 1
## 18 9.80 1
## 19 10.98 1
## 20 14.85 0
## 21 14.28 0
## 22 13.75 0
## 23 16.09 0
## 24 5.59 1
## 25 15.96 0
## 26 11.72 1
## 27 13.93 0
## 28 13.31 0
## 29 7.17 1
## 30 9.92 1
## 31 7.60 1
## 32 13.80 0
## 33 11.43 1
## 34 10.69 1
## 35 9.36 1
## 36 8.81 1
## 37 14.89 0
## 38 6.69 1
sum(subRes$ReservationPrice)
## [1] 459.54
459.54
resSort <- arrange(res, ReservationPrice)
resSort
## ReservationPrice Accept
## 1 4.04 1
## 2 4.61 1
## 3 4.89 1
## 4 4.99 1
## 5 5.59 1
## 6 5.83 1
## 7 5.88 1
## 8 6.33 1
## 9 6.69 1
## 10 7.17 1
## 11 7.21 1
## 12 7.31 1
## 13 7.40 1
## 14 7.49 1
## 15 7.51 1
## 16 7.53 1
## 17 7.60 1
## 18 7.62 1
## 19 7.91 1
## 20 8.27 1
## 21 8.29 1
## 22 8.48 1
## 23 8.60 1
## 24 8.76 1
## 25 8.81 1
## 26 8.83 1
## 27 9.29 1
## 28 9.36 1
## 29 9.39 1
## 30 9.43 1
## 31 9.47 1
## 32 9.48 1
## 33 9.65 1
## 34 9.78 1
## 35 9.80 1
## 36 9.81 1
## 37 9.89 1
## 38 9.92 1
## 39 9.98 1
## 40 10.41 1
## 41 10.45 1
## 42 10.54 1
## 43 10.69 1
## 44 10.76 1
## 45 10.97 1
## 46 10.98 1
## 47 11.02 1
## 48 11.11 1
## 49 11.30 1
## 50 11.39 1
## 51 11.43 1
## 52 11.60 1
## 53 11.62 1
## 54 11.65 1
## 55 11.72 1
## 56 11.92 1
## 57 12.23 0
## 58 12.24 0
## 59 12.24 0
## 60 12.26 0
## 61 12.34 0
## 62 12.39 0
## 63 12.43 0
## 64 12.69 0
## 65 12.82 0
## 66 12.88 0
## 67 13.12 0
## 68 13.29 0
## 69 13.31 0
## 70 13.31 0
## 71 13.41 0
## 72 13.73 0
## 73 13.75 0
## 74 13.75 0
## 75 13.80 0
## 76 13.82 0
## 77 13.92 0
## 78 13.93 0
## 79 14.00 0
## 80 14.28 0
## 81 14.30 0
## 82 14.63 0
## 83 14.85 0
## 84 14.89 0
## 85 15.33 0
## 86 15.36 0
## 87 15.50 0
## 88 15.75 0
## 89 15.92 0
## 90 15.96 0
## 91 16.09 0
## 92 16.27 0
## 93 17.38 0
## 94 17.66 0
## 95 18.39 0
## 96 19.54 0
## 97 19.90 0
## 98 19.92 0
## 99 20.45 0
## 100 21.60 0
resLow <- resSort[1:20,]
resLow
## ReservationPrice Accept
## 1 4.04 1
## 2 4.61 1
## 3 4.89 1
## 4 4.99 1
## 5 5.59 1
## 6 5.83 1
## 7 5.88 1
## 8 6.33 1
## 9 6.69 1
## 10 7.17 1
## 11 7.21 1
## 12 7.31 1
## 13 7.40 1
## 14 7.49 1
## 15 7.51 1
## 16 7.53 1
## 17 7.60 1
## 18 7.62 1
## 19 7.91 1
## 20 8.27 1
describe(resLow)
## vars n mean sd median trimmed mad min max range skew
## ReservationPrice 1 20 6.59 1.24 7.19 6.69 0.9 4.04 8.27 4.23 -0.6
## Accept 2 20 1.00 0.00 1.00 1.00 0.0 1.00 1.00 0.00 NaN
## kurtosis se
## ReservationPrice -1.07 0.28
## Accept NaN 0.00
sum(resLow$ReservationPrice)
## [1] 131.87
The opportunity cost for those who most want to work is 131.87
set.seed(8)
res <- round(data.frame(rnorm(100,11,3.9)),digits=2)
colnames(res) <- "ReservationPrice"
describe(res)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 100 10.64 4.21 10.7 10.73 3.92 -0.76 20.27 21.03
## skew kurtosis se
## ReservationPrice -0.29 0.13 0.42
res$Accept <- ifelse(res$ReservationPrice>12, 0,1)
res
## ReservationPrice Accept
## 1 10.67 1
## 2 14.28 0
## 3 9.19 1
## 4 8.85 1
## 5 13.87 0
## 6 10.58 1
## 7 10.34 1
## 8 6.76 1
## 9 -0.74 1
## 10 8.69 1
## 11 8.04 1
## 12 12.14 0
## 13 12.64 0
## 14 5.95 1
## 15 11.27 1
## 16 7.83 1
## 17 16.89 0
## 18 9.94 1
## 19 17.08 0
## 20 10.07 1
## 21 16.00 0
## 22 10.96 1
## 23 9.44 1
## 24 11.09 1
## 25 17.80 0
## 26 6.68 1
## 27 6.86 1
## 28 18.61 0
## 29 13.35 0
## 30 3.12 1
## 31 16.88 0
## 32 14.76 0
## 33 4.94 1
## 34 7.98 1
## 35 15.92 0
## 36 12.67 0
## 37 14.29 0
## 38 8.27 1
## 39 10.75 1
## 40 12.84 0
## 41 12.42 0
## 42 8.60 1
## 43 11.89 1
## 44 9.98 1
## 45 13.39 0
## 46 3.37 1
## 47 8.41 1
## 48 12.11 0
## 49 12.05 0
## 50 8.50 1
## 51 15.21 0
## 52 9.58 1
## 53 13.30 0
## 54 10.63 1
## 55 14.79 0
## 56 13.26 0
## 57 7.97 1
## 58 8.66 1
## 59 5.15 1
## 60 13.94 0
## 61 13.17 0
## 62 11.37 1
## 63 4.05 1
## 64 6.68 1
## 65 9.96 1
## 66 6.80 1
## 67 9.08 1
## 68 17.39 0
## 69 12.55 0
## 70 4.77 1
## 71 5.28 1
## 72 15.06 0
## 73 14.05 0
## 74 9.14 1
## 75 11.37 1
## 76 13.34 0
## 77 -0.30 1
## 78 13.28 0
## 79 20.27 0
## 80 8.48 1
## 81 11.95 1
## 82 7.92 1
## 83 6.73 1
## 84 18.97 0
## 85 4.44 1
## 86 15.74 0
## 87 10.63 1
## 88 7.29 1
## 89 13.34 0
## 90 -0.76 1
## 91 14.00 0
## 92 17.12 0
## 93 9.04 1
## 94 8.59 1
## 95 5.73 1
## 96 14.00 0
## 97 12.28 0
## 98 10.83 1
## 99 8.51 1
## 100 10.73 1
## subset data to the job offers up to 12 accepts
subRes <- res[1:30,]
subRes
## ReservationPrice Accept
## 1 10.67 1
## 2 14.28 0
## 3 9.19 1
## 4 8.85 1
## 5 13.87 0
## 6 10.58 1
## 7 10.34 1
## 8 6.76 1
## 9 -0.74 1
## 10 8.69 1
## 11 8.04 1
## 12 12.14 0
## 13 12.64 0
## 14 5.95 1
## 15 11.27 1
## 16 7.83 1
## 17 16.89 0
## 18 9.94 1
## 19 17.08 0
## 20 10.07 1
## 21 16.00 0
## 22 10.96 1
## 23 9.44 1
## 24 11.09 1
## 25 17.80 0
## 26 6.68 1
## 27 6.86 1
## 28 18.61 0
## 29 13.35 0
## 30 3.12 1
sum(subRes$ReservationPrice)
## [1] 318.25
318.25
resSort <- arrange(res, ReservationPrice)
resSort
## ReservationPrice Accept
## 1 -0.76 1
## 2 -0.74 1
## 3 -0.30 1
## 4 3.12 1
## 5 3.37 1
## 6 4.05 1
## 7 4.44 1
## 8 4.77 1
## 9 4.94 1
## 10 5.15 1
## 11 5.28 1
## 12 5.73 1
## 13 5.95 1
## 14 6.68 1
## 15 6.68 1
## 16 6.73 1
## 17 6.76 1
## 18 6.80 1
## 19 6.86 1
## 20 7.29 1
## 21 7.83 1
## 22 7.92 1
## 23 7.97 1
## 24 7.98 1
## 25 8.04 1
## 26 8.27 1
## 27 8.41 1
## 28 8.48 1
## 29 8.50 1
## 30 8.51 1
## 31 8.59 1
## 32 8.60 1
## 33 8.66 1
## 34 8.69 1
## 35 8.85 1
## 36 9.04 1
## 37 9.08 1
## 38 9.14 1
## 39 9.19 1
## 40 9.44 1
## 41 9.58 1
## 42 9.94 1
## 43 9.96 1
## 44 9.98 1
## 45 10.07 1
## 46 10.34 1
## 47 10.58 1
## 48 10.63 1
## 49 10.63 1
## 50 10.67 1
## 51 10.73 1
## 52 10.75 1
## 53 10.83 1
## 54 10.96 1
## 55 11.09 1
## 56 11.27 1
## 57 11.37 1
## 58 11.37 1
## 59 11.89 1
## 60 11.95 1
## 61 12.05 0
## 62 12.11 0
## 63 12.14 0
## 64 12.28 0
## 65 12.42 0
## 66 12.55 0
## 67 12.64 0
## 68 12.67 0
## 69 12.84 0
## 70 13.17 0
## 71 13.26 0
## 72 13.28 0
## 73 13.30 0
## 74 13.34 0
## 75 13.34 0
## 76 13.35 0
## 77 13.39 0
## 78 13.87 0
## 79 13.94 0
## 80 14.00 0
## 81 14.00 0
## 82 14.05 0
## 83 14.28 0
## 84 14.29 0
## 85 14.76 0
## 86 14.79 0
## 87 15.06 0
## 88 15.21 0
## 89 15.74 0
## 90 15.92 0
## 91 16.00 0
## 92 16.88 0
## 93 16.89 0
## 94 17.08 0
## 95 17.12 0
## 96 17.39 0
## 97 17.80 0
## 98 18.61 0
## 99 18.97 0
## 100 20.27 0
resLow <- resSort[1:20,]
resLow
## ReservationPrice Accept
## 1 -0.76 1
## 2 -0.74 1
## 3 -0.30 1
## 4 3.12 1
## 5 3.37 1
## 6 4.05 1
## 7 4.44 1
## 8 4.77 1
## 9 4.94 1
## 10 5.15 1
## 11 5.28 1
## 12 5.73 1
## 13 5.95 1
## 14 6.68 1
## 15 6.68 1
## 16 6.73 1
## 17 6.76 1
## 18 6.80 1
## 19 6.86 1
## 20 7.29 1
describe(resLow)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 20 4.64 2.56 5.21 5.01 2.21 -0.76 7.29 8.05
## Accept 2 20 1.00 0.00 1.00 1.00 0.00 1.00 1.00 0.00
## skew kurtosis se
## ReservationPrice -1.08 -0.12 0.57
## Accept NaN NaN 0.00
sum(resLow$ReservationPrice)
## [1] 92.8
The opportunity cost for those who most want to work is 92.8
set.seed(9)
res <- round(data.frame(rnorm(100,11,3.9)),digits=2)
colnames(res) <- "ReservationPrice"
describe(res)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 100 10.79 3.74 10.34 10.63 3.42 0.79 21.46 20.67
## skew kurtosis se
## ReservationPrice 0.31 0.13 0.37
res$Accept <- ifelse(res$ReservationPrice>12, 0,1)
res
## ReservationPrice Accept
## 1 8.01 1
## 2 7.82 1
## 3 10.45 1
## 4 9.92 1
## 5 12.70 0
## 6 6.37 1
## 7 15.65 0
## 8 10.93 1
## 9 10.03 1
## 10 9.58 1
## 11 15.98 0
## 12 9.17 1
## 13 11.28 1
## 14 9.96 1
## 15 18.20 0
## 16 7.73 1
## 17 10.70 1
## 18 0.79 1
## 19 14.46 0
## 20 8.24 1
## 21 17.85 0
## 22 11.71 1
## 23 9.96 1
## 24 14.61 0
## 25 8.30 1
## 26 21.46 0
## 27 11.87 1
## 28 8.24 1
## 29 12.63 0
## 30 12.44 0
## 31 7.44 1
## 32 9.76 1
## 33 15.09 0
## 34 11.66 1
## 35 11.12 1
## 36 7.06 1
## 37 12.49 0
## 38 7.80 1
## 39 12.41 0
## 40 11.36 1
## 41 7.85 1
## 42 3.12 1
## 43 8.12 1
## 44 12.49 0
## 45 17.75 0
## 46 10.21 1
## 47 7.11 1
## 48 5.90 1
## 49 7.11 1
## 50 8.80 1
## 51 17.83 0
## 52 8.86 1
## 53 7.65 1
## 54 11.19 1
## 55 10.22 1
## 56 6.69 1
## 57 11.94 1
## 58 12.49 0
## 59 19.70 0
## 60 15.68 0
## 61 12.10 0
## 62 6.31 1
## 63 12.81 0
## 64 12.37 0
## 65 8.70 1
## 66 7.67 1
## 67 10.04 1
## 68 17.00 0
## 69 13.13 0
## 70 17.10 0
## 71 11.97 1
## 72 3.35 1
## 73 7.84 1
## 74 9.06 1
## 75 12.19 0
## 76 9.87 1
## 77 16.69 0
## 78 14.41 0
## 79 7.28 1
## 80 10.88 1
## 81 11.44 1
## 82 6.89 1
## 83 11.61 1
## 84 16.07 0
## 85 6.49 1
## 86 11.84 1
## 87 14.14 0
## 88 8.14 1
## 89 4.69 1
## 90 14.27 0
## 91 9.63 1
## 92 8.21 1
## 93 7.33 1
## 94 13.85 0
## 95 9.29 1
## 96 10.03 1
## 97 8.38 1
## 98 14.12 0
## 99 5.19 1
## 100 12.77 0
## subset data to the job offers up to 12 accepts
subRes <- res[1:28,]
subRes
## ReservationPrice Accept
## 1 8.01 1
## 2 7.82 1
## 3 10.45 1
## 4 9.92 1
## 5 12.70 0
## 6 6.37 1
## 7 15.65 0
## 8 10.93 1
## 9 10.03 1
## 10 9.58 1
## 11 15.98 0
## 12 9.17 1
## 13 11.28 1
## 14 9.96 1
## 15 18.20 0
## 16 7.73 1
## 17 10.70 1
## 18 0.79 1
## 19 14.46 0
## 20 8.24 1
## 21 17.85 0
## 22 11.71 1
## 23 9.96 1
## 24 14.61 0
## 25 8.30 1
## 26 21.46 0
## 27 11.87 1
## 28 8.24 1
sum(subRes$ReservationPrice)
## [1] 311.97
311.97
resSort <- arrange(res, ReservationPrice)
resSort
## ReservationPrice Accept
## 1 0.79 1
## 2 3.12 1
## 3 3.35 1
## 4 4.69 1
## 5 5.19 1
## 6 5.90 1
## 7 6.31 1
## 8 6.37 1
## 9 6.49 1
## 10 6.69 1
## 11 6.89 1
## 12 7.06 1
## 13 7.11 1
## 14 7.11 1
## 15 7.28 1
## 16 7.33 1
## 17 7.44 1
## 18 7.65 1
## 19 7.67 1
## 20 7.73 1
## 21 7.80 1
## 22 7.82 1
## 23 7.84 1
## 24 7.85 1
## 25 8.01 1
## 26 8.12 1
## 27 8.14 1
## 28 8.21 1
## 29 8.24 1
## 30 8.24 1
## 31 8.30 1
## 32 8.38 1
## 33 8.70 1
## 34 8.80 1
## 35 8.86 1
## 36 9.06 1
## 37 9.17 1
## 38 9.29 1
## 39 9.58 1
## 40 9.63 1
## 41 9.76 1
## 42 9.87 1
## 43 9.92 1
## 44 9.96 1
## 45 9.96 1
## 46 10.03 1
## 47 10.03 1
## 48 10.04 1
## 49 10.21 1
## 50 10.22 1
## 51 10.45 1
## 52 10.70 1
## 53 10.88 1
## 54 10.93 1
## 55 11.12 1
## 56 11.19 1
## 57 11.28 1
## 58 11.36 1
## 59 11.44 1
## 60 11.61 1
## 61 11.66 1
## 62 11.71 1
## 63 11.84 1
## 64 11.87 1
## 65 11.94 1
## 66 11.97 1
## 67 12.10 0
## 68 12.19 0
## 69 12.37 0
## 70 12.41 0
## 71 12.44 0
## 72 12.49 0
## 73 12.49 0
## 74 12.49 0
## 75 12.63 0
## 76 12.70 0
## 77 12.77 0
## 78 12.81 0
## 79 13.13 0
## 80 13.85 0
## 81 14.12 0
## 82 14.14 0
## 83 14.27 0
## 84 14.41 0
## 85 14.46 0
## 86 14.61 0
## 87 15.09 0
## 88 15.65 0
## 89 15.68 0
## 90 15.98 0
## 91 16.07 0
## 92 16.69 0
## 93 17.00 0
## 94 17.10 0
## 95 17.75 0
## 96 17.83 0
## 97 17.85 0
## 98 18.20 0
## 99 19.70 0
## 100 21.46 0
resLow <- resSort[1:20,]
resLow
## ReservationPrice Accept
## 1 0.79 1
## 2 3.12 1
## 3 3.35 1
## 4 4.69 1
## 5 5.19 1
## 6 5.90 1
## 7 6.31 1
## 8 6.37 1
## 9 6.49 1
## 10 6.69 1
## 11 6.89 1
## 12 7.06 1
## 13 7.11 1
## 14 7.11 1
## 15 7.28 1
## 16 7.33 1
## 17 7.44 1
## 18 7.65 1
## 19 7.67 1
## 20 7.73 1
describe(resLow)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 20 6.11 1.83 6.79 6.43 0.88 0.79 7.73 6.94
## Accept 2 20 1.00 0.00 1.00 1.00 0.00 1.00 1.00 0.00
## skew kurtosis se
## ReservationPrice -1.46 1.29 0.41
## Accept NaN NaN 0.00
sum(resLow$ReservationPrice)
## [1] 122.17
The opportunity cost for those who most want to work is 122.17
set.seed(10)
res <- round(data.frame(rnorm(100,11,3.9)),digits=2)
colnames(res) <- "ReservationPrice"
describe(res)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 100 10.47 3.67 10.25 10.47 4.15 2.48 19.66 17.18
## skew kurtosis se
## ReservationPrice 0.03 -0.56 0.37
res$Accept <- ifelse(res$ReservationPrice>12, 0,1)
res
## ReservationPrice Accept
## 1 11.07 1
## 2 10.28 1
## 3 5.65 1
## 4 8.66 1
## 5 12.15 0
## 6 12.52 0
## 7 6.29 1
## 8 9.58 1
## 9 4.66 1
## 10 10.00 1
## 11 15.30 0
## 12 13.95 0
## 13 10.07 1
## 14 14.85 0
## 15 13.89 0
## 16 11.35 1
## 17 7.28 1
## 18 10.24 1
## 19 14.61 0
## 20 12.88 0
## 21 8.67 1
## 22 2.48 1
## 23 8.37 1
## 24 2.74 1
## 25 6.07 1
## 26 9.54 1
## 27 8.32 1
## 28 7.60 1
## 29 10.60 1
## 30 10.01 1
## 31 3.77 1
## 32 10.70 1
## 33 14.78 0
## 34 11.72 1
## 35 5.62 1
## 36 5.40 1
## 37 12.41 0
## 38 4.14 1
## 39 9.73 1
## 40 8.46 1
## 41 15.24 0
## 42 8.03 1
## 43 7.77 1
## 44 14.25 0
## 45 7.23 1
## 46 10.89 1
## 47 11.91 1
## 48 9.83 1
## 49 8.36 1
## 50 13.56 0
## 51 9.44 1
## 52 9.70 1
## 53 16.34 0
## 54 19.34 0
## 55 12.97 0
## 56 14.07 0
## 57 7.48 1
## 58 13.08 0
## 59 8.48 1
## 60 12.13 0
## 61 6.17 1
## 62 9.22 1
## 63 7.76 1
## 64 12.33 0
## 65 15.16 0
## 66 15.74 0
## 67 13.87 0
## 68 9.12 1
## 69 13.19 0
## 70 6.14 1
## 71 12.49 0
## 72 5.42 1
## 73 6.91 1
## 74 10.15 1
## 75 5.19 1
## 76 15.57 0
## 77 5.23 1
## 78 9.32 1
## 79 6.90 1
## 80 16.94 0
## 81 13.31 0
## 82 10.13 1
## 83 13.78 0
## 84 13.79 0
## 85 12.72 0
## 86 11.62 1
## 87 13.57 0
## 88 19.66 0
## 89 6.38 1
## 90 10.71 1
## 91 9.38 1
## 92 10.25 1
## 93 11.27 1
## 94 15.51 0
## 95 13.32 0
## 96 5.46 1
## 97 4.73 1
## 98 14.48 0
## 99 11.58 1
## 100 15.79 0
## subset data to the job offers up to 12 accepts
subRes <- res[1:28,]
subRes
## ReservationPrice Accept
## 1 11.07 1
## 2 10.28 1
## 3 5.65 1
## 4 8.66 1
## 5 12.15 0
## 6 12.52 0
## 7 6.29 1
## 8 9.58 1
## 9 4.66 1
## 10 10.00 1
## 11 15.30 0
## 12 13.95 0
## 13 10.07 1
## 14 14.85 0
## 15 13.89 0
## 16 11.35 1
## 17 7.28 1
## 18 10.24 1
## 19 14.61 0
## 20 12.88 0
## 21 8.67 1
## 22 2.48 1
## 23 8.37 1
## 24 2.74 1
## 25 6.07 1
## 26 9.54 1
## 27 8.32 1
## 28 7.60 1
sum(subRes$ReservationPrice)
## [1] 269.07
269.07
resSort <- arrange(res, ReservationPrice)
resSort
## ReservationPrice Accept
## 1 2.48 1
## 2 2.74 1
## 3 3.77 1
## 4 4.14 1
## 5 4.66 1
## 6 4.73 1
## 7 5.19 1
## 8 5.23 1
## 9 5.40 1
## 10 5.42 1
## 11 5.46 1
## 12 5.62 1
## 13 5.65 1
## 14 6.07 1
## 15 6.14 1
## 16 6.17 1
## 17 6.29 1
## 18 6.38 1
## 19 6.90 1
## 20 6.91 1
## 21 7.23 1
## 22 7.28 1
## 23 7.48 1
## 24 7.60 1
## 25 7.76 1
## 26 7.77 1
## 27 8.03 1
## 28 8.32 1
## 29 8.36 1
## 30 8.37 1
## 31 8.46 1
## 32 8.48 1
## 33 8.66 1
## 34 8.67 1
## 35 9.12 1
## 36 9.22 1
## 37 9.32 1
## 38 9.38 1
## 39 9.44 1
## 40 9.54 1
## 41 9.58 1
## 42 9.70 1
## 43 9.73 1
## 44 9.83 1
## 45 10.00 1
## 46 10.01 1
## 47 10.07 1
## 48 10.13 1
## 49 10.15 1
## 50 10.24 1
## 51 10.25 1
## 52 10.28 1
## 53 10.60 1
## 54 10.70 1
## 55 10.71 1
## 56 10.89 1
## 57 11.07 1
## 58 11.27 1
## 59 11.35 1
## 60 11.58 1
## 61 11.62 1
## 62 11.72 1
## 63 11.91 1
## 64 12.13 0
## 65 12.15 0
## 66 12.33 0
## 67 12.41 0
## 68 12.49 0
## 69 12.52 0
## 70 12.72 0
## 71 12.88 0
## 72 12.97 0
## 73 13.08 0
## 74 13.19 0
## 75 13.31 0
## 76 13.32 0
## 77 13.56 0
## 78 13.57 0
## 79 13.78 0
## 80 13.79 0
## 81 13.87 0
## 82 13.89 0
## 83 13.95 0
## 84 14.07 0
## 85 14.25 0
## 86 14.48 0
## 87 14.61 0
## 88 14.78 0
## 89 14.85 0
## 90 15.16 0
## 91 15.24 0
## 92 15.30 0
## 93 15.51 0
## 94 15.57 0
## 95 15.74 0
## 96 15.79 0
## 97 16.34 0
## 98 16.94 0
## 99 19.34 0
## 100 19.66 0
resLow <- resSort[1:20,]
resLow
## ReservationPrice Accept
## 1 2.48 1
## 2 2.74 1
## 3 3.77 1
## 4 4.14 1
## 5 4.66 1
## 6 4.73 1
## 7 5.19 1
## 8 5.23 1
## 9 5.40 1
## 10 5.42 1
## 11 5.46 1
## 12 5.62 1
## 13 5.65 1
## 14 6.07 1
## 15 6.14 1
## 16 6.17 1
## 17 6.29 1
## 18 6.38 1
## 19 6.90 1
## 20 6.91 1
describe(resLow)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 20 5.27 1.23 5.44 5.4 1.07 2.48 6.91 4.43
## Accept 2 20 1.00 0.00 1.00 1.0 0.00 1.00 1.00 0.00
## skew kurtosis se
## ReservationPrice -0.81 -0.19 0.27
## Accept NaN NaN 0.00
sum(resLow$ReservationPrice)
## [1] 105.35
The opportunity cost for those who most want to work is 105.35
set.seed(11)
res <- round(data.frame(rnorm(100,11,3.9)),digits=2)
colnames(res) <- "ReservationPrice"
describe(res)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 100 10.52 3.57 10.27 10.4 3.84 2.47 20.12 17.65
## skew kurtosis se
## ReservationPrice 0.32 -0.25 0.36
res$Accept <- ifelse(res$ReservationPrice>12, 0,1)
res
## ReservationPrice Accept
## 1 8.69 1
## 2 11.10 1
## 3 5.09 1
## 4 5.69 1
## 5 15.60 0
## 6 7.36 1
## 7 16.16 0
## 8 13.44 0
## 9 10.82 1
## 10 7.08 1
## 11 7.77 1
## 12 9.64 1
## 13 5.00 1
## 14 10.00 1
## 15 6.52 1
## 16 11.05 1
## 17 10.13 1
## 18 14.46 0
## 19 8.69 1
## 20 8.44 1
## 21 8.34 1
## 22 10.94 1
## 23 9.27 1
## 24 12.37 0
## 25 11.29 1
## 26 11.03 1
## 27 10.27 1
## 28 8.01 1
## 29 10.14 1
## 30 7.16 1
## 31 6.69 1
## 32 7.34 1
## 33 13.65 0
## 34 4.85 1
## 35 7.61 1
## 36 12.89 0
## 37 10.27 1
## 38 17.03 0
## 39 8.62 1
## 40 9.64 1
## 41 4.62 1
## 42 11.08 1
## 43 14.48 0
## 44 7.60 1
## 45 14.47 0
## 46 9.66 1
## 47 2.47 1
## 48 14.43 0
## 49 13.82 0
## 50 11.86 1
## 51 14.08 0
## 52 10.10 1
## 53 7.81 1
## 54 12.95 0
## 55 11.62 1
## 56 13.12 0
## 57 10.39 1
## 58 12.71 0
## 59 16.80 0
## 60 11.23 1
## 61 7.69 1
## 62 20.12 0
## 63 10.53 1
## 64 3.39 1
## 65 13.10 0
## 66 17.60 0
## 67 7.92 1
## 68 6.81 1
## 69 8.63 1
## 70 13.94 0
## 71 12.77 0
## 72 10.52 1
## 73 8.02 1
## 74 11.89 1
## 75 15.37 0
## 76 11.61 1
## 77 8.31 1
## 78 12.77 0
## 79 6.84 1
## 80 12.57 0
## 81 10.75 1
## 82 12.23 0
## 83 8.64 1
## 84 7.46 1
## 85 19.82 0
## 86 8.65 1
## 87 5.94 1
## 88 12.98 0
## 89 7.67 1
## 90 5.13 1
## 91 15.69 0
## 92 6.99 1
## 93 14.66 0
## 94 8.88 1
## 95 13.00 0
## 96 9.62 1
## 97 16.17 0
## 98 6.55 1
## 99 16.51 0
## 100 8.65 1
## subset data to the job offers up to 12 accepts
subRes <- res[1:25,]
subRes
## ReservationPrice Accept
## 1 8.69 1
## 2 11.10 1
## 3 5.09 1
## 4 5.69 1
## 5 15.60 0
## 6 7.36 1
## 7 16.16 0
## 8 13.44 0
## 9 10.82 1
## 10 7.08 1
## 11 7.77 1
## 12 9.64 1
## 13 5.00 1
## 14 10.00 1
## 15 6.52 1
## 16 11.05 1
## 17 10.13 1
## 18 14.46 0
## 19 8.69 1
## 20 8.44 1
## 21 8.34 1
## 22 10.94 1
## 23 9.27 1
## 24 12.37 0
## 25 11.29 1
sum(subRes$ReservationPrice)
## [1] 244.94
244.94
resSort <- arrange(res, ReservationPrice)
resSort
## ReservationPrice Accept
## 1 2.47 1
## 2 3.39 1
## 3 4.62 1
## 4 4.85 1
## 5 5.00 1
## 6 5.09 1
## 7 5.13 1
## 8 5.69 1
## 9 5.94 1
## 10 6.52 1
## 11 6.55 1
## 12 6.69 1
## 13 6.81 1
## 14 6.84 1
## 15 6.99 1
## 16 7.08 1
## 17 7.16 1
## 18 7.34 1
## 19 7.36 1
## 20 7.46 1
## 21 7.60 1
## 22 7.61 1
## 23 7.67 1
## 24 7.69 1
## 25 7.77 1
## 26 7.81 1
## 27 7.92 1
## 28 8.01 1
## 29 8.02 1
## 30 8.31 1
## 31 8.34 1
## 32 8.44 1
## 33 8.62 1
## 34 8.63 1
## 35 8.64 1
## 36 8.65 1
## 37 8.65 1
## 38 8.69 1
## 39 8.69 1
## 40 8.88 1
## 41 9.27 1
## 42 9.62 1
## 43 9.64 1
## 44 9.64 1
## 45 9.66 1
## 46 10.00 1
## 47 10.10 1
## 48 10.13 1
## 49 10.14 1
## 50 10.27 1
## 51 10.27 1
## 52 10.39 1
## 53 10.52 1
## 54 10.53 1
## 55 10.75 1
## 56 10.82 1
## 57 10.94 1
## 58 11.03 1
## 59 11.05 1
## 60 11.08 1
## 61 11.10 1
## 62 11.23 1
## 63 11.29 1
## 64 11.61 1
## 65 11.62 1
## 66 11.86 1
## 67 11.89 1
## 68 12.23 0
## 69 12.37 0
## 70 12.57 0
## 71 12.71 0
## 72 12.77 0
## 73 12.77 0
## 74 12.89 0
## 75 12.95 0
## 76 12.98 0
## 77 13.00 0
## 78 13.10 0
## 79 13.12 0
## 80 13.44 0
## 81 13.65 0
## 82 13.82 0
## 83 13.94 0
## 84 14.08 0
## 85 14.43 0
## 86 14.46 0
## 87 14.47 0
## 88 14.48 0
## 89 14.66 0
## 90 15.37 0
## 91 15.60 0
## 92 15.69 0
## 93 16.16 0
## 94 16.17 0
## 95 16.51 0
## 96 16.80 0
## 97 17.03 0
## 98 17.60 0
## 99 19.82 0
## 100 20.12 0
resLow <- resSort[1:20,]
resLow
## ReservationPrice Accept
## 1 2.47 1
## 2 3.39 1
## 3 4.62 1
## 4 4.85 1
## 5 5.00 1
## 6 5.09 1
## 7 5.13 1
## 8 5.69 1
## 9 5.94 1
## 10 6.52 1
## 11 6.55 1
## 12 6.69 1
## 13 6.81 1
## 14 6.84 1
## 15 6.99 1
## 16 7.08 1
## 17 7.16 1
## 18 7.34 1
## 19 7.36 1
## 20 7.46 1
describe(resLow)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 20 5.95 1.39 6.54 6.14 1.21 2.47 7.46 4.99
## Accept 2 20 1.00 0.00 1.00 1.00 0.00 1.00 1.00 0.00
## skew kurtosis se
## ReservationPrice -0.91 -0.13 0.31
## Accept NaN NaN 0.00
sum(resLow$ReservationPrice)
## [1] 118.98
The opportunity cost for those who most want to work is 118.98
set.seed(12)
res <- round(data.frame(rnorm(100,11,3.9)),digits=2)
colnames(res) <- "ReservationPrice"
describe(res)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 100 10.88 3.37 10.57 10.82 3.26 2.62 19.08 16.46
## skew kurtosis se
## ReservationPrice 0.17 -0.1 0.34
res$Accept <- ifelse(res$ReservationPrice>12, 0,1)
res
## ReservationPrice Accept
## 1 5.23 1
## 2 17.15 0
## 3 7.27 1
## 4 7.41 1
## 5 3.21 1
## 6 9.94 1
## 7 9.77 1
## 8 8.55 1
## 9 10.58 1
## 10 12.67 0
## 11 7.97 1
## 12 5.95 1
## 13 7.96 1
## 14 11.05 1
## 15 10.41 1
## 16 8.26 1
## 17 15.64 0
## 18 12.33 0
## 19 12.98 0
## 20 9.86 1
## 21 11.87 1
## 22 18.83 0
## 23 14.95 0
## 24 9.82 1
## 25 7.00 1
## 26 9.96 1
## 27 10.22 1
## 28 11.51 1
## 29 11.57 1
## 30 12.41 0
## 31 13.63 0
## 32 19.08 0
## 33 8.89 1
## 34 6.83 1
## 35 9.55 1
## 36 9.11 1
## 37 12.07 0
## 38 9.13 1
## 39 14.11 0
## 40 7.08 1
## 41 11.41 1
## 42 6.49 1
## 43 13.25 0
## 44 4.78 1
## 45 9.80 1
## 46 12.75 0
## 47 7.19 1
## 48 11.74 1
## 49 13.85 0
## 50 9.08 1
## 51 10.83 1
## 52 10.56 1
## 53 12.78 0
## 54 18.88 0
## 55 6.90 1
## 56 13.87 0
## 57 13.10 0
## 58 5.87 1
## 59 10.02 1
## 60 12.23 0
## 61 12.59 0
## 62 14.88 0
## 63 14.34 0
## 64 11.77 1
## 65 14.25 0
## 66 14.30 0
## 67 18.62 0
## 68 2.62 1
## 69 14.79 0
## 70 15.47 0
## 71 8.95 1
## 72 11.98 1
## 73 9.33 1
## 74 10.29 1
## 75 10.60 1
## 76 8.53 1
## 77 6.04 1
## 78 9.50 1
## 79 13.02 0
## 80 10.31 1
## 81 11.02 1
## 82 6.03 1
## 83 10.21 1
## 84 15.54 0
## 85 10.91 1
## 86 14.50 0
## 87 10.31 1
## 88 15.34 0
## 89 8.89 1
## 90 7.24 1
## 91 12.47 0
## 92 7.16 1
## 93 14.50 0
## 94 11.50 1
## 95 15.03 0
## 96 9.67 1
## 97 12.76 0
## 98 8.29 1
## 99 10.07 1
## 100 7.07 1
## subset data to the job offers up to 12 accepts
subRes <- res[1:27,]
subRes
## ReservationPrice Accept
## 1 5.23 1
## 2 17.15 0
## 3 7.27 1
## 4 7.41 1
## 5 3.21 1
## 6 9.94 1
## 7 9.77 1
## 8 8.55 1
## 9 10.58 1
## 10 12.67 0
## 11 7.97 1
## 12 5.95 1
## 13 7.96 1
## 14 11.05 1
## 15 10.41 1
## 16 8.26 1
## 17 15.64 0
## 18 12.33 0
## 19 12.98 0
## 20 9.86 1
## 21 11.87 1
## 22 18.83 0
## 23 14.95 0
## 24 9.82 1
## 25 7.00 1
## 26 9.96 1
## 27 10.22 1
sum(subRes$ReservationPrice)
## [1] 276.84
276.84
resSort <- arrange(res, ReservationPrice)
resSort
## ReservationPrice Accept
## 1 2.62 1
## 2 3.21 1
## 3 4.78 1
## 4 5.23 1
## 5 5.87 1
## 6 5.95 1
## 7 6.03 1
## 8 6.04 1
## 9 6.49 1
## 10 6.83 1
## 11 6.90 1
## 12 7.00 1
## 13 7.07 1
## 14 7.08 1
## 15 7.16 1
## 16 7.19 1
## 17 7.24 1
## 18 7.27 1
## 19 7.41 1
## 20 7.96 1
## 21 7.97 1
## 22 8.26 1
## 23 8.29 1
## 24 8.53 1
## 25 8.55 1
## 26 8.89 1
## 27 8.89 1
## 28 8.95 1
## 29 9.08 1
## 30 9.11 1
## 31 9.13 1
## 32 9.33 1
## 33 9.50 1
## 34 9.55 1
## 35 9.67 1
## 36 9.77 1
## 37 9.80 1
## 38 9.82 1
## 39 9.86 1
## 40 9.94 1
## 41 9.96 1
## 42 10.02 1
## 43 10.07 1
## 44 10.21 1
## 45 10.22 1
## 46 10.29 1
## 47 10.31 1
## 48 10.31 1
## 49 10.41 1
## 50 10.56 1
## 51 10.58 1
## 52 10.60 1
## 53 10.83 1
## 54 10.91 1
## 55 11.02 1
## 56 11.05 1
## 57 11.41 1
## 58 11.50 1
## 59 11.51 1
## 60 11.57 1
## 61 11.74 1
## 62 11.77 1
## 63 11.87 1
## 64 11.98 1
## 65 12.07 0
## 66 12.23 0
## 67 12.33 0
## 68 12.41 0
## 69 12.47 0
## 70 12.59 0
## 71 12.67 0
## 72 12.75 0
## 73 12.76 0
## 74 12.78 0
## 75 12.98 0
## 76 13.02 0
## 77 13.10 0
## 78 13.25 0
## 79 13.63 0
## 80 13.85 0
## 81 13.87 0
## 82 14.11 0
## 83 14.25 0
## 84 14.30 0
## 85 14.34 0
## 86 14.50 0
## 87 14.50 0
## 88 14.79 0
## 89 14.88 0
## 90 14.95 0
## 91 15.03 0
## 92 15.34 0
## 93 15.47 0
## 94 15.54 0
## 95 15.64 0
## 96 17.15 0
## 97 18.62 0
## 98 18.83 0
## 99 18.88 0
## 100 19.08 0
resLow <- resSort[1:20,]
resLow
## ReservationPrice Accept
## 1 2.62 1
## 2 3.21 1
## 3 4.78 1
## 4 5.23 1
## 5 5.87 1
## 6 5.95 1
## 7 6.03 1
## 8 6.04 1
## 9 6.49 1
## 10 6.83 1
## 11 6.90 1
## 12 7.00 1
## 13 7.07 1
## 14 7.08 1
## 15 7.16 1
## 16 7.19 1
## 17 7.24 1
## 18 7.27 1
## 19 7.41 1
## 20 7.96 1
describe(resLow)
## vars n mean sd median trimmed mad min max range skew
## ReservationPrice 1 20 6.27 1.39 6.87 6.51 0.7 2.62 7.96 5.34 -1.3
## Accept 2 20 1.00 0.00 1.00 1.00 0.0 1.00 1.00 0.00 NaN
## kurtosis se
## ReservationPrice 0.82 0.31
## Accept NaN 0.00
sum(resLow$ReservationPrice)
## [1] 125.33
The opportunity cost for those who most want to work is 125.33
set.seed(13)
res <- round(data.frame(rnorm(100,11,3.9)),digits=2)
colnames(res) <- "ReservationPrice"
describe(res)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 100 10.76 3.71 10.69 10.73 3.74 3.09 18.16 15.07
## skew kurtosis se
## ReservationPrice 0.02 -0.68 0.37
res$Accept <- ifelse(res$ReservationPrice>12, 0,1)
res
## ReservationPrice Accept
## 1 13.16 0
## 2 9.91 1
## 3 17.92 0
## 4 11.73 1
## 5 15.46 0
## 6 12.62 0
## 7 15.80 0
## 8 11.92 1
## 9 9.58 1
## 10 15.31 0
## 11 6.73 1
## 12 12.80 0
## 13 5.69 1
## 14 3.76 1
## 15 9.28 1
## 16 10.24 1
## 17 16.45 0
## 18 11.39 1
## 19 10.55 1
## 20 13.74 0
## 21 12.02 0
## 22 18.16 0
## 23 12.39 0
## 24 6.92 1
## 25 13.42 0
## 26 11.58 1
## 27 5.31 1
## 28 3.09 1
## 29 6.88 1
## 30 8.16 1
## 31 10.97 1
## 32 14.31 0
## 33 9.50 1
## 34 8.95 1
## 35 9.93 1
## 36 8.64 1
## 37 9.70 1
## 38 10.06 1
## 39 7.64 1
## 40 7.70 1
## 41 11.39 1
## 42 17.20 0
## 43 13.21 0
## 44 17.30 0
## 45 9.17 1
## 46 8.17 1
## 47 7.01 1
## 48 3.44 1
## 49 12.08 0
## 50 16.49 0
## 51 12.07 0
## 52 13.95 0
## 53 9.64 1
## 54 8.87 1
## 55 11.91 1
## 56 9.84 1
## 57 7.72 1
## 58 14.22 0
## 59 16.79 0
## 60 13.73 0
## 61 6.08 1
## 62 12.16 0
## 63 10.42 1
## 64 7.53 1
## 65 14.95 0
## 66 7.41 1
## 67 8.76 1
## 68 15.49 0
## 69 15.46 0
## 70 10.07 1
## 71 6.76 1
## 72 10.76 1
## 73 8.98 1
## 74 3.56 1
## 75 11.42 1
## 76 6.41 1
## 77 17.81 0
## 78 9.45 1
## 79 12.73 0
## 80 12.76 0
## 81 10.70 1
## 82 12.16 0
## 83 6.34 1
## 84 3.21 1
## 85 16.42 0
## 86 10.68 1
## 87 12.53 0
## 88 6.78 1
## 89 17.25 0
## 90 14.92 0
## 91 12.48 0
## 92 8.79 1
## 93 6.27 1
## 94 5.68 1
## 95 5.48 1
## 96 10.00 1
## 97 6.22 1
## 98 11.83 1
## 99 11.26 1
## 100 14.34 0
## subset data to the job offers up to 12 accepts
subRes <- res[1:34,]
subRes
## ReservationPrice Accept
## 1 13.16 0
## 2 9.91 1
## 3 17.92 0
## 4 11.73 1
## 5 15.46 0
## 6 12.62 0
## 7 15.80 0
## 8 11.92 1
## 9 9.58 1
## 10 15.31 0
## 11 6.73 1
## 12 12.80 0
## 13 5.69 1
## 14 3.76 1
## 15 9.28 1
## 16 10.24 1
## 17 16.45 0
## 18 11.39 1
## 19 10.55 1
## 20 13.74 0
## 21 12.02 0
## 22 18.16 0
## 23 12.39 0
## 24 6.92 1
## 25 13.42 0
## 26 11.58 1
## 27 5.31 1
## 28 3.09 1
## 29 6.88 1
## 30 8.16 1
## 31 10.97 1
## 32 14.31 0
## 33 9.50 1
## 34 8.95 1
sum(subRes$ReservationPrice)
## [1] 375.7
375.70
resSort <- arrange(res, ReservationPrice)
resSort
## ReservationPrice Accept
## 1 3.09 1
## 2 3.21 1
## 3 3.44 1
## 4 3.56 1
## 5 3.76 1
## 6 5.31 1
## 7 5.48 1
## 8 5.68 1
## 9 5.69 1
## 10 6.08 1
## 11 6.22 1
## 12 6.27 1
## 13 6.34 1
## 14 6.41 1
## 15 6.73 1
## 16 6.76 1
## 17 6.78 1
## 18 6.88 1
## 19 6.92 1
## 20 7.01 1
## 21 7.41 1
## 22 7.53 1
## 23 7.64 1
## 24 7.70 1
## 25 7.72 1
## 26 8.16 1
## 27 8.17 1
## 28 8.64 1
## 29 8.76 1
## 30 8.79 1
## 31 8.87 1
## 32 8.95 1
## 33 8.98 1
## 34 9.17 1
## 35 9.28 1
## 36 9.45 1
## 37 9.50 1
## 38 9.58 1
## 39 9.64 1
## 40 9.70 1
## 41 9.84 1
## 42 9.91 1
## 43 9.93 1
## 44 10.00 1
## 45 10.06 1
## 46 10.07 1
## 47 10.24 1
## 48 10.42 1
## 49 10.55 1
## 50 10.68 1
## 51 10.70 1
## 52 10.76 1
## 53 10.97 1
## 54 11.26 1
## 55 11.39 1
## 56 11.39 1
## 57 11.42 1
## 58 11.58 1
## 59 11.73 1
## 60 11.83 1
## 61 11.91 1
## 62 11.92 1
## 63 12.02 0
## 64 12.07 0
## 65 12.08 0
## 66 12.16 0
## 67 12.16 0
## 68 12.39 0
## 69 12.48 0
## 70 12.53 0
## 71 12.62 0
## 72 12.73 0
## 73 12.76 0
## 74 12.80 0
## 75 13.16 0
## 76 13.21 0
## 77 13.42 0
## 78 13.73 0
## 79 13.74 0
## 80 13.95 0
## 81 14.22 0
## 82 14.31 0
## 83 14.34 0
## 84 14.92 0
## 85 14.95 0
## 86 15.31 0
## 87 15.46 0
## 88 15.46 0
## 89 15.49 0
## 90 15.80 0
## 91 16.42 0
## 92 16.45 0
## 93 16.49 0
## 94 16.79 0
## 95 17.20 0
## 96 17.25 0
## 97 17.30 0
## 98 17.81 0
## 99 17.92 0
## 100 18.16 0
resLow <- resSort[1:20,]
resLow
## ReservationPrice Accept
## 1 3.09 1
## 2 3.21 1
## 3 3.44 1
## 4 3.56 1
## 5 3.76 1
## 6 5.31 1
## 7 5.48 1
## 8 5.68 1
## 9 5.69 1
## 10 6.08 1
## 11 6.22 1
## 12 6.27 1
## 13 6.34 1
## 14 6.41 1
## 15 6.73 1
## 16 6.76 1
## 17 6.78 1
## 18 6.88 1
## 19 6.92 1
## 20 7.01 1
describe(resLow)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 20 5.58 1.38 6.15 5.71 0.96 3.09 7.01 3.92
## Accept 2 20 1.00 0.00 1.00 1.00 0.00 1.00 1.00 0.00
## skew kurtosis se
## ReservationPrice -0.74 -1.1 0.31
## Accept NaN NaN 0.00
sum(resLow$ReservationPrice)
## [1] 111.62
The opportunity cost for those who most want to work is 111.62
set.seed(14)
res <- round(data.frame(rnorm(100,11,3.9)),digits=2)
colnames(res) <- "ReservationPrice"
describe(res)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 100 11.17 3.53 10.95 11.11 3.6 2.67 19.27 16.6
## skew kurtosis se
## ReservationPrice 0.13 -0.44 0.35
res$Accept <- ifelse(res$ReservationPrice>12, 0,1)
res
## ReservationPrice Accept
## 1 8.42 1
## 2 17.70 0
## 3 19.27 0
## 4 16.84 0
## 5 10.86 1
## 6 15.80 0
## 7 10.75 1
## 8 15.17 0
## 9 9.53 1
## 10 15.07 0
## 11 9.51 1
## 12 12.17 0
## 13 13.63 0
## 14 9.86 1
## 15 12.90 0
## 16 14.44 0
## 17 18.26 0
## 18 17.29 0
## 19 11.53 1
## 20 15.24 0
## 21 6.06 1
## 22 10.23 1
## 23 11.54 1
## 24 9.91 1
## 25 13.76 0
## 26 8.01 1
## 27 16.63 0
## 28 14.30 0
## 29 9.44 1
## 30 5.43 1
## 31 5.45 1
## 32 9.72 1
## 33 12.11 0
## 34 13.81 0
## 35 12.69 0
## 36 9.63 1
## 37 12.16 0
## 38 9.98 1
## 39 16.10 0
## 40 11.06 1
## 41 9.32 1
## 42 12.49 0
## 43 11.16 1
## 44 10.77 1
## 45 5.94 1
## 46 2.67 1
## 47 7.51 1
## 48 13.39 0
## 49 13.27 0
## 50 10.98 1
## 51 3.72 1
## 52 18.14 0
## 53 7.13 1
## 54 5.34 1
## 55 10.94 1
## 56 13.09 0
## 57 7.84 1
## 58 9.76 1
## 59 15.33 0
## 60 10.45 1
## 61 10.20 1
## 62 8.34 1
## 63 10.83 1
## 64 6.47 1
## 65 7.99 1
## 66 7.42 1
## 67 11.35 1
## 68 8.05 1
## 69 17.82 0
## 70 11.66 1
## 71 14.22 0
## 72 10.93 1
## 73 12.92 0
## 74 12.39 0
## 75 11.44 1
## 76 15.43 0
## 77 8.79 1
## 78 13.16 0
## 79 10.95 1
## 80 8.77 1
## 81 8.33 1
## 82 15.56 0
## 83 12.44 0
## 84 9.01 1
## 85 8.54 1
## 86 17.68 0
## 87 10.13 1
## 88 7.26 1
## 89 11.15 1
## 90 4.60 1
## 91 14.08 0
## 92 6.88 1
## 93 6.99 1
## 94 15.29 0
## 95 8.61 1
## 96 9.65 1
## 97 11.34 1
## 98 8.47 1
## 99 12.19 0
## 100 7.99 1
## subset data to the job offers up to 12 accepts
subRes <- res[1:41,]
subRes
## ReservationPrice Accept
## 1 8.42 1
## 2 17.70 0
## 3 19.27 0
## 4 16.84 0
## 5 10.86 1
## 6 15.80 0
## 7 10.75 1
## 8 15.17 0
## 9 9.53 1
## 10 15.07 0
## 11 9.51 1
## 12 12.17 0
## 13 13.63 0
## 14 9.86 1
## 15 12.90 0
## 16 14.44 0
## 17 18.26 0
## 18 17.29 0
## 19 11.53 1
## 20 15.24 0
## 21 6.06 1
## 22 10.23 1
## 23 11.54 1
## 24 9.91 1
## 25 13.76 0
## 26 8.01 1
## 27 16.63 0
## 28 14.30 0
## 29 9.44 1
## 30 5.43 1
## 31 5.45 1
## 32 9.72 1
## 33 12.11 0
## 34 13.81 0
## 35 12.69 0
## 36 9.63 1
## 37 12.16 0
## 38 9.98 1
## 39 16.10 0
## 40 11.06 1
## 41 9.32 1
sum(subRes$ReservationPrice)
## [1] 501.58
501.58
resSort <- arrange(res, ReservationPrice)
resSort
## ReservationPrice Accept
## 1 2.67 1
## 2 3.72 1
## 3 4.60 1
## 4 5.34 1
## 5 5.43 1
## 6 5.45 1
## 7 5.94 1
## 8 6.06 1
## 9 6.47 1
## 10 6.88 1
## 11 6.99 1
## 12 7.13 1
## 13 7.26 1
## 14 7.42 1
## 15 7.51 1
## 16 7.84 1
## 17 7.99 1
## 18 7.99 1
## 19 8.01 1
## 20 8.05 1
## 21 8.33 1
## 22 8.34 1
## 23 8.42 1
## 24 8.47 1
## 25 8.54 1
## 26 8.61 1
## 27 8.77 1
## 28 8.79 1
## 29 9.01 1
## 30 9.32 1
## 31 9.44 1
## 32 9.51 1
## 33 9.53 1
## 34 9.63 1
## 35 9.65 1
## 36 9.72 1
## 37 9.76 1
## 38 9.86 1
## 39 9.91 1
## 40 9.98 1
## 41 10.13 1
## 42 10.20 1
## 43 10.23 1
## 44 10.45 1
## 45 10.75 1
## 46 10.77 1
## 47 10.83 1
## 48 10.86 1
## 49 10.93 1
## 50 10.94 1
## 51 10.95 1
## 52 10.98 1
## 53 11.06 1
## 54 11.15 1
## 55 11.16 1
## 56 11.34 1
## 57 11.35 1
## 58 11.44 1
## 59 11.53 1
## 60 11.54 1
## 61 11.66 1
## 62 12.11 0
## 63 12.16 0
## 64 12.17 0
## 65 12.19 0
## 66 12.39 0
## 67 12.44 0
## 68 12.49 0
## 69 12.69 0
## 70 12.90 0
## 71 12.92 0
## 72 13.09 0
## 73 13.16 0
## 74 13.27 0
## 75 13.39 0
## 76 13.63 0
## 77 13.76 0
## 78 13.81 0
## 79 14.08 0
## 80 14.22 0
## 81 14.30 0
## 82 14.44 0
## 83 15.07 0
## 84 15.17 0
## 85 15.24 0
## 86 15.29 0
## 87 15.33 0
## 88 15.43 0
## 89 15.56 0
## 90 15.80 0
## 91 16.10 0
## 92 16.63 0
## 93 16.84 0
## 94 17.29 0
## 95 17.68 0
## 96 17.70 0
## 97 17.82 0
## 98 18.14 0
## 99 18.26 0
## 100 19.27 0
resLow <- resSort[1:20,]
resLow
## ReservationPrice Accept
## 1 2.67 1
## 2 3.72 1
## 3 4.60 1
## 4 5.34 1
## 5 5.43 1
## 6 5.45 1
## 7 5.94 1
## 8 6.06 1
## 9 6.47 1
## 10 6.88 1
## 11 6.99 1
## 12 7.13 1
## 13 7.26 1
## 14 7.42 1
## 15 7.51 1
## 16 7.84 1
## 17 7.99 1
## 18 7.99 1
## 19 8.01 1
## 20 8.05 1
describe(resLow)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 20 6.44 1.52 6.94 6.64 1.52 2.67 8.05 5.38
## Accept 2 20 1.00 0.00 1.00 1.00 0.00 1.00 1.00 0.00
## skew kurtosis se
## ReservationPrice -0.87 -0.2 0.34
## Accept NaN NaN 0.00
sum(resLow$ReservationPrice)
## [1] 128.75
The opportunity cost for those who most want to work is 128.75
set.seed(15)
res <- round(data.frame(rnorm(100,11,3.9)),digits=2)
colnames(res) <- "ReservationPrice"
describe(res)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 100 11.4 3.88 11.05 11.33 4.05 1.49 20.69 19.2
## skew kurtosis se
## ReservationPrice 0.12 -0.45 0.39
res$Accept <- ifelse(res$ReservationPrice>12, 0,1)
res
## ReservationPrice Accept
## 1 12.01 0
## 2 18.14 0
## 3 9.68 1
## 4 14.50 0
## 5 12.90 0
## 6 6.10 1
## 7 11.09 1
## 8 15.25 0
## 9 10.48 1
## 10 6.81 1
## 11 14.33 0
## 12 9.58 1
## 13 11.65 1
## 14 6.15 1
## 15 16.69 0
## 16 10.99 1
## 17 10.92 1
## 18 11.13 1
## 19 6.45 1
## 20 8.97 1
## 21 16.36 0
## 22 16.51 0
## 23 9.43 1
## 24 9.29 1
## 25 14.94 0
## 26 12.68 0
## 27 13.86 0
## 28 8.35 1
## 29 12.27 0
## 30 14.54 0
## 31 9.20 1
## 32 11.02 1
## 33 16.66 0
## 34 13.94 0
## 35 14.77 0
## 36 12.83 0
## 37 10.06 1
## 38 15.03 0
## 39 8.50 1
## 40 5.87 1
## 41 12.41 0
## 42 13.81 0
## 43 20.69 0
## 44 7.16 1
## 45 9.68 1
## 46 15.89 0
## 47 6.60 1
## 48 17.08 0
## 49 13.76 0
## 50 14.64 0
## 51 13.67 0
## 52 14.97 0
## 53 10.06 1
## 54 17.54 0
## 55 12.60 0
## 56 7.53 1
## 57 8.27 1
## 58 13.03 0
## 59 15.51 0
## 60 10.57 1
## 61 12.16 0
## 62 9.33 1
## 63 8.70 1
## 64 5.94 1
## 65 5.20 1
## 66 6.47 1
## 67 9.70 1
## 68 13.11 0
## 69 8.11 1
## 70 15.84 0
## 71 5.05 1
## 72 3.68 1
## 73 5.82 1
## 74 9.06 1
## 75 11.16 1
## 76 8.88 1
## 77 12.40 0
## 78 14.91 0
## 79 7.17 1
## 80 18.96 0
## 81 11.01 1
## 82 20.11 0
## 83 11.60 1
## 84 9.18 1
## 85 9.17 1
## 86 9.06 1
## 87 9.74 1
## 88 13.40 0
## 89 11.50 1
## 90 10.41 1
## 91 7.97 1
## 92 5.86 1
## 93 19.21 0
## 94 12.48 0
## 95 10.13 1
## 96 17.05 0
## 97 10.34 1
## 98 16.01 0
## 99 7.09 1
## 100 1.49 1
## subset data to the job offers up to 12 accepts
subRes <- res[1:39,]
subRes
## ReservationPrice Accept
## 1 12.01 0
## 2 18.14 0
## 3 9.68 1
## 4 14.50 0
## 5 12.90 0
## 6 6.10 1
## 7 11.09 1
## 8 15.25 0
## 9 10.48 1
## 10 6.81 1
## 11 14.33 0
## 12 9.58 1
## 13 11.65 1
## 14 6.15 1
## 15 16.69 0
## 16 10.99 1
## 17 10.92 1
## 18 11.13 1
## 19 6.45 1
## 20 8.97 1
## 21 16.36 0
## 22 16.51 0
## 23 9.43 1
## 24 9.29 1
## 25 14.94 0
## 26 12.68 0
## 27 13.86 0
## 28 8.35 1
## 29 12.27 0
## 30 14.54 0
## 31 9.20 1
## 32 11.02 1
## 33 16.66 0
## 34 13.94 0
## 35 14.77 0
## 36 12.83 0
## 37 10.06 1
## 38 15.03 0
## 39 8.50 1
sum(subRes$ReservationPrice)
## [1] 464.06
464.06
resSort <- arrange(res, ReservationPrice)
resSort
## ReservationPrice Accept
## 1 1.49 1
## 2 3.68 1
## 3 5.05 1
## 4 5.20 1
## 5 5.82 1
## 6 5.86 1
## 7 5.87 1
## 8 5.94 1
## 9 6.10 1
## 10 6.15 1
## 11 6.45 1
## 12 6.47 1
## 13 6.60 1
## 14 6.81 1
## 15 7.09 1
## 16 7.16 1
## 17 7.17 1
## 18 7.53 1
## 19 7.97 1
## 20 8.11 1
## 21 8.27 1
## 22 8.35 1
## 23 8.50 1
## 24 8.70 1
## 25 8.88 1
## 26 8.97 1
## 27 9.06 1
## 28 9.06 1
## 29 9.17 1
## 30 9.18 1
## 31 9.20 1
## 32 9.29 1
## 33 9.33 1
## 34 9.43 1
## 35 9.58 1
## 36 9.68 1
## 37 9.68 1
## 38 9.70 1
## 39 9.74 1
## 40 10.06 1
## 41 10.06 1
## 42 10.13 1
## 43 10.34 1
## 44 10.41 1
## 45 10.48 1
## 46 10.57 1
## 47 10.92 1
## 48 10.99 1
## 49 11.01 1
## 50 11.02 1
## 51 11.09 1
## 52 11.13 1
## 53 11.16 1
## 54 11.50 1
## 55 11.60 1
## 56 11.65 1
## 57 12.01 0
## 58 12.16 0
## 59 12.27 0
## 60 12.40 0
## 61 12.41 0
## 62 12.48 0
## 63 12.60 0
## 64 12.68 0
## 65 12.83 0
## 66 12.90 0
## 67 13.03 0
## 68 13.11 0
## 69 13.40 0
## 70 13.67 0
## 71 13.76 0
## 72 13.81 0
## 73 13.86 0
## 74 13.94 0
## 75 14.33 0
## 76 14.50 0
## 77 14.54 0
## 78 14.64 0
## 79 14.77 0
## 80 14.91 0
## 81 14.94 0
## 82 14.97 0
## 83 15.03 0
## 84 15.25 0
## 85 15.51 0
## 86 15.84 0
## 87 15.89 0
## 88 16.01 0
## 89 16.36 0
## 90 16.51 0
## 91 16.66 0
## 92 16.69 0
## 93 17.05 0
## 94 17.08 0
## 95 17.54 0
## 96 18.14 0
## 97 18.96 0
## 98 19.21 0
## 99 20.11 0
## 100 20.69 0
resLow <- resSort[1:20,]
resLow
## ReservationPrice Accept
## 1 1.49 1
## 2 3.68 1
## 3 5.05 1
## 4 5.20 1
## 5 5.82 1
## 6 5.86 1
## 7 5.87 1
## 8 5.94 1
## 9 6.10 1
## 10 6.15 1
## 11 6.45 1
## 12 6.47 1
## 13 6.60 1
## 14 6.81 1
## 15 7.09 1
## 16 7.16 1
## 17 7.17 1
## 18 7.53 1
## 19 7.97 1
## 20 8.11 1
describe(resLow)
## vars n mean sd median trimmed mad min max range
## ReservationPrice 1 20 6.13 1.51 6.3 6.33 0.96 1.49 8.11 6.62
## Accept 2 20 1.00 0.00 1.0 1.00 0.00 1.00 1.00 0.00
## skew kurtosis se
## ReservationPrice -1.4 2.2 0.34
## Accept NaN NaN 0.00
sum(resLow$ReservationPrice)
## [1] 122.52
The opportunity cost for those who most want to work is 122.52