Reference no: EM132389192
Assignment - Problem Set
Please complete the following tasks regarding the data in R. Please generate a solution document in R markdown and upload the .Rmd document and a rendered .doc, .docx, or .pdf document. Your solution document should have your answers to the questions and should display the requested plots.
The questions have a strong sequential dependence, so please do ask for help if you're unsure of your solutions. These questions were rendered in R markdown through RStudio.
Question 1 - (Hypothetical) In analyzing a motel business, a consultant finds that the number of single rooms occupied on mid-week October days can be modeled as having a binomial distribution with size equal to the number of rooms s and probability of success equal to p. Suppose the profit on each occupied room is Normal(μ, σ2), independently, and on each unoccupied room is Normal(η, ρ2), independently. (Presumably η is negative number.)
1a. In terms of the Normal distribution, k, μ, σ2 and η and ρ2, what is the distribution of the profit if k rooms are occupied?
1b. Write an R function for the density function for the distribution of the profit, "profit<-function(x, s, p, mu, sigma, eta)" where "x" is the profit, "s" and "p" are as above and "mu"=μ, "sigma"=σ and "eta"=η. You may use "dbinom" and "dnorm".
Please run the integral and the plot commands below.
Note that in order for "integrate" and "stat_function" to perform correctly, the function "profit" must return a vector value given a vector for "x". Given a function that performs correctly on scalar "x", it can be applied to rows of "matrix(x,ncol=1)" to return the correct values for the entries in the vector "x".
1c. Please use the function "profit" and the function "integrate" to estimate the mean and variance of "profit" for s=10,p=.7,mu=200,sigma=35,eta=-25,rho=5.
1d. Please give a closed form formula (without use of integrals) for the mean of the distribution of profit in terms of s, p, μ, σ2 and η and ρ2 based on the density function for profit. Please check the formula by applying it to s=10, p=.7, μ=200, σ=35, η=-25, ρ=5.
1e. Please give a closed form formula (without use of integrals) for the variance of the distribution of profit in terms of s, p, μ, σ2 and η and ρ2 based on the density function for profit. Please check the formula by applying it to s=10, p=.7, μ=200, σ=35, η=-25, ρ=5.
The fact that E[X2]= Var[X2]+E[X]2 may be useful.
1f. Note that the density function for profit is equal to that produced by viewing profit as the sum of s independent variables based on the profit for an individual room as follows: model that each room is occupied with probability p, that the profit from an occupied room has the Normal(μ, σ2) distribution, and the profit from an unoccupied room has the Normal(η, ρ2) distribution. The total profit is the random variable equal to the sum of the s independent random variables modeling the profit from each room.
Based on this model and the theorems for the mean and variance of sums of independent random variables, give closed form formulas for the mean and variance of profit.
Please check the formulas by applying them to s=10, p=.7, μ=200, σ=35, η=-25, ρ=5.
Attachment:- Assignment Files.rar