Task
Your goal is to produce a function that computes E[q ∗ j |q˜jt, Njt], the expected quality of a GP given observed rounded rating ˜qjt and number of reviews Njt. The function obviously needs to take ˜qjt, Njt as variable inputs. Some fixed inputs (i.e. inputs that won’t ever change) that you also need are:
• A vector of random draws from the prior P(q ∗ j ). This is so that computing R f(q ∗ j )dP(q ∗ j ) is as simple as taking an average of f(·) over the vector of random draws.
• A vector of 4 cutpoints for the ordered probit.
Some hints:
• Start by building the simplest functions. For example, P(qrt|q ∗ j ) is really easy.
• Think carefully through the combinatorics when computing R(˜qjt, Njt).
– This is one of the hardest (if not the hardest) parts, especially if you’re trying to do so efficiently.
– I suggest using recursion. This shows how to do so for an equivalent problem: https: //www.techiedelight.com/total-ways-sum-with-n-throws-dice-having-k-faces/. Memoization can also really help.
• An excellent “checkpoint” is computing p(˜qjt|Njt, q∗ j ). If you can compute p(˜qjt|Njt, q∗ j ), you’re basically done with the hard part. Let me know when you can compute p(˜qjt|Njt, q∗ j ). I may tell you that the code gives me enough information and you don’t need to finish the exercise.
• Test your functions along the way. For example: do the probabilities sum to 1 when you
integrate your probability over the whole state space?
Students succeed in their courses by connecting and communicating with an expert until they receive help on their questions
Consult our trusted tutors.