Question

In: Statistics and Probability

***Please only reply with answers using R. Please leave for other experts if not able to...

***Please only reply with answers using R. Please leave for other experts if not able to help with R programming.

I need help trying to figure out how to set up a simulation to the below question using R.

The annual demand for Prizdol, a prescription drug manufactured and marketed by the NuFeel Company, is normally distributed with mean 50,000 and standard deviation 12,000. We assume that demand during each of the next 10 years is an independent random draw from this distribution. NuFeel needs to determine how large they should build the Prizdol plant to maximize its expected profit over the next 10 years. If the company builds a plant that can produce x units of Prizdol per year, it will incur a one-time cost of $16 for each of these x units. NuFeel will produce only the amount demanded each year, and each unit of Prizdol produced will sell for $3.70. Each unit of Prizdol produced incurs a variable production cost of $0.20. It costs $0.40 per year to operate a unit of capacity.
1. Among the capacity levels of 30K, 35K, 40K, 45K, 50K, 55K, and 60K units per year, which level maximizes expected profit? Use simulation to answer the question.

2. Using the capacity from your answer to the previous question, NuFeel can be 95% certain that expected profit for the 10-year period will be between what two values?

Solutions

Expert Solution

1) R code with comments

----

#function to calculate the Net profit
#x is the capacity of plant
NProfit<-function(x){
   #set the number of simulations
   R<-10000
   #get R simulations of 10 annual demands
   d<-rnorm(R*10,mean=50000,sd=12000)
   #convert this into a matrix of 10xR
   d<-matrix(d,nrow=10)
   #get the amount sold (cannot sell more than the capacity)
   qs<-pmin(d,x)  
   #revenue from selling s
   r<-qs*3.70
   #get the annual cost of producing qs using capacity x
   #cannot produce more than the capacity x and hence produced=sold
   ac<-qs*0.20+x*0.40
   #get the annual profit (without the fixed cost)
   ap<-r-ac
   #get the fixed cost for capacity x
   fc<-x*16
   #get R number of net profit for 10 years
   netp<-apply(ap,2,sum)-fc
   return(netp)
}

#set the random seed for repetability
set.seed(123)
#initialize the max profit
MaxP<-0;
for (x in seq(30000,60000,by=5000)) {
   #get R net profits
   NP<-NProfit(x)
   #get the expected Profit
   MeanP<-mean(NP)  
   #get the maximum expected profit
   if (MaxP<MeanP){
       MaxP<-MeanP
       MaxX<-x
   }
}
sprintf('The capcacity which maximizes the expected profit is %g units/year',MaxX)
sprintf('The maximum expected profit is $%.2f',MaxP)

----

#get this

2) get 95% interval using x=50000

R code

---

#part 2)
#get the net profits for x=50000
NP<-NProfit(50000)
#get 2.5 and 97.5 percentiles
ci<-quantile(NP,c(0.25,0.975))
sprintf('NuFeel can be 95%% certain that expected profit for the 10-year period will be between $%.2f and $%.2f',ci[1],ci[2])

----

#get this

All code together

--------

#function to calculate the Net profit
#x is the capacity of plant
NProfit<-function(x){
   #set the number of simulations
   R<-10000
   #get R simulations of 10 annual demands
   d<-rnorm(R*10,mean=50000,sd=12000)
   #convert this into a matrix of 10xR
   d<-matrix(d,nrow=10)
   #get the amount sold (cannot sell more than the capacity)
   qs<-pmin(d,x)  
   #revenue from selling s
   r<-qs*3.70
   #get the annual cost of producing qs using capacity x
   #cannot produce more than the capacity x and hence produced=sold
   ac<-qs*0.20+x*0.40
   #get the annual profit (without the fixed cost)
   ap<-r-ac
   #get the fixed cost for capacity x
   fc<-x*16
   #get R number of net profit for 10 years
   netp<-apply(ap,2,sum)-fc
   return(netp)
}

#set the random seed for repetability
set.seed(123)
#initialize the max profit
MaxP<-0;
for (x in seq(30000,60000,by=5000)) {
   #get R net profits
   NP<-NProfit(x)
   #get the expected Profit
   MeanP<-mean(NP)  
   #get the maximum expected profit
   if (MaxP<MeanP){
       MaxP<-MeanP
       MaxX<-x
   }
}
sprintf('The capcacity which maximizes the expected profit is %g units/year',MaxX)
sprintf('The maximum expected profit is $%.2f',MaxP)

#part 2)
#get the net profits for x=50000
NP<-NProfit(50000)
#get 2.5 and 97.5 percentiles
ci<-quantile(NP,c(0.25,0.975))
sprintf('NuFeel can be 95%% certain that expected profit for the 10-year period will be between $%.2f and $%.2f',ci[1],ci[2])

--------


Related Solutions

Please solve all of the question using R and do clarify the answers. Using the (SATGPA)...
Please solve all of the question using R and do clarify the answers. Using the (SATGPA) data set in (Stat2Data) package. Test by using ?= .01. 1) Create the following three variables and then print out all the six variables. A) Create new variable "SAT", which is the sum of (MathSAT) and (VerbalSAT). B) Create second new variable ("SATLevel"), and assign the value of( "SATLevel") as 1 when SAT<=1100, 2 when 1100<SAT<=1200, 3 when 1200<SAT<=1300, and 4 when SAT>1300. C)Create...
PLEASE DO ONLY THE "JOURNAL" SECTION. I ALREADY HAVE ANSWERS TO ALL THE OTHER ONES!!! Beacon...
PLEASE DO ONLY THE "JOURNAL" SECTION. I ALREADY HAVE ANSWERS TO ALL THE OTHER ONES!!! Beacon Signals Company maintains and repairs warning lights, such as those found on radio towers and lighthouses. Beacon Signals Company prepared the following end-ofperiod spreadsheet at December 31, 2019, fiscal year: Beacon Signals Company End-of-Period Spreadsheet For the Year Ended December 31, 2019 Unadjusted Trial Balance Adjustments Adjusted Trial Balance Account Title Dr. Cr. Dr. Cr. Dr. Cr. Cash 13,000.00 13,000.00 Accounts Receivable 40,500.00 (a)...
For the case study section only: Please only provide short answers for the case study No...
For the case study section only: Please only provide short answers for the case study No more than 2 sentence response. Answer all the questions in all case study scenarios. Case Study # 1 Jordan is a 9-year-old boy who is a direct admit for observation. He has had a history of vomiting and diarrhea for 48 hours. Subjective Data Has a history of nausea and vomiting for 24 hours. Has not voided today. Is unable to tolerate oral fluids....
For the case study section only: Please only provide short answers for the case study No...
For the case study section only: Please only provide short answers for the case study No more than 2 sentence response. Answer all the questions in all case study scenarios. Case Study: Childhood Obesity Mason is a 7-year-old boy who is at his primary care physician for a routine physical examination. Mason’s mother expresses concern about childhood obesity and is worried that he sleeps too much. Subjective Data: Mason has been eating more than usual. Mason sleeps between 11 and...
For the case study section only: Please only provide short answers for the case study No...
For the case study section only: Please only provide short answers for the case study No more than 2 sentence response. Answer all the questions in all case study scenarios. Case Study: Childhood Obesity Mason is a 7-year-old boy who is at his primary care physician for a routine physical examination. Mason’s mother expresses concern about childhood obesity and is worried that he sleeps too much. Subjective Data: Mason has been eating more than usual. Mason sleeps between 11 and...
Show the R inputs and the answers to the questions if asked please # Q1. Generate...
Show the R inputs and the answers to the questions if asked please # Q1. Generate 10 random numbers from a uniform distribution on [0,10]. Use R to find the maximum and minimum values. # Q2. Generate 10 random normal numbers with mean 5 and standard deviation 5 (normal(5,5)). How many are less than 0 (Use R)? # Q3. Generate 100 random normal numbers with mean 100 and standard deviation 10. How many are 2 standard deviations from the mean...
Case Study: For the case study section only: Please only provide short answers for the case...
Case Study: For the case study section only: Please only provide short answers for the case study No more than 2 sentence response. Answer all the questions in all case study scenarios. Case Study # 1 Jordan is a 9-year-old boy who is a direct admit for observation. He has had a history of vomiting and diarrhea for 48 hours. Subjective Data Has a history of nausea and vomiting for 24 hours. Has not voided today. Is unable to tolerate...
[USING R & dataset “Boston”] Using the leave-one-out cross-validation and 5-fold cross-validation techniques to compare the...
[USING R & dataset “Boston”] Using the leave-one-out cross-validation and 5-fold cross-validation techniques to compare the performance of models in (a) and (b) with: (a) SalesPredict <- lm(Sales ~ Price + Urban + US, data = Carseats) (b) SalesRevise <- lm(Sales ~ Price + US, data = Carseats) Hint: Functions update (with option subset) and predict.
Please answer the following marketing question- please answer all parts. other answers are wrong !!! will...
Please answer the following marketing question- please answer all parts. other answers are wrong !!! will rate. thank you Ethics: The Internet of Things refers to the increased proliferation of devices that are connected to the Internet and that in turn can be connected to each other. Although there are a number of benefits to this level of connectivity for both society and businesses, there are also a number of risks and ethical issues. What are some of the risks...
The Book of R (Question 20.2) Please answer using R code. Continue using the survey data...
The Book of R (Question 20.2) Please answer using R code. Continue using the survey data frame from the package MASS for the next few exercises. The survey data set has a variable named Exer , a factor with k = 3 levels describing the amount of physical exercise time each student gets: none, some, or frequent. Obtain a count of the number of students in each category and produce side-by-side boxplots of student height split by exercise. Assuming independence...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT