Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 4 . Let x be a random variable whose density is given by f ( x ) = { e - x , x
Question
Let be a random variable whose density is given by where is a fixed parameter.
Part a
Create function likely thet which, for a given value of parameter theta and a given vector which represents a sample from the
population returns the corresponding value of the likelihood function of parameter of population based on the sample
Note that since for we can assume that all the entries of the sample are positive. So think of variable as a vector
dots, with for all iindots,
In other words, you don't need to worry about how to handle situation in which for some iindots,although in that case the likelihood
equals so it's trivial
Your function likely should be flexible allowing vector to be of any length.
Hint: After figuring out the mathematical formula for the likelihood function ;vec your function likely should have one or two lines of code. No
loops, nor ifelse statments, please! Loops are okay only when you cannot vectorize.
Make sure that your R code passes ALL of the test provided by the following code:
## check the output of likely for some combinations of and theta
theta;
theta;
if testthatdesc
expectequal abslikelytheta xe TRUE
TRUE stopSorry wrong answer."
if testthatdesc code
expectequal abslikelytheta xe TRUE
TRUE stopSorry wrong answer."
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started