Predicting score in the presence of latent variables Given a dataset with the attributes (hour_of_day, day_of_week, performance) where performance is a function of hour_of_day and day_of_week and several other latent variables, how can a prediction model be built which can predict the performance given hour_of_day and day_of_week?
Background Information:
The problem is related to Facebook posts, hour_of_day and day_of_week are based on the publication time of the Facebook posts. performance is a measure of post engagement in Facebook, in the simplest case it can be assumed as the number of likes received by a post, in more complex scenarios it can be a variable derived from other variables like no_of_likes, no_of_shares, no_of_comments. If the area of study is limited to one person, over a limited period of time, we can assume that other latent variables (Social Networking Potential, Cultural and Geographical influences, etc.) remain more or less constant. The objective is to predict ideal time for posting so as to maximize engagement.
 A: For simplicty, denote the dependent variable as $Y$ (performance), the matrix of independent observed variables (hour_of_day, day_of_week) as $X$ and the matrix of latent variables (Social Networking Potential etc.) as $Z$. Now, as per my understanding, the key idea behind using latent variables is to combine information across users to add strength to the model. Also, you clearly want to have a model that predicts $Y$ based on $X$ only, since you don't observe $Z$. Here is how you can do it:  


*

*You need a model (probability distribution) for $Y|X,Z$. A simple model could just be a $Y|X,Z \sim N(\beta X+\gamma Z,\sigma^2I)$, where $\beta,\gamma$ are regression coefficient vectors, and $\sigma^2$ is noise variance.

*You need another model for the latent variable $Z|W$. Here $W$ is the matrix of additional observed variables that could help predict $Z$. For example, the Social Networking Potential of an individual ($Z$) might be influenced by location, age, number of friends and other individual-related factors. Lump all of these factors into $W$. A simple model here might be $Z|W \sim N(\alpha W, \delta^2I)$.  

*The model that predicts $Y$ only based on $X$ is $Y|X$. To obtain this, you need to integrate out $Z$ from the joint density of $Y,Z|X$. Use the fact:
$$
f(y|x)=\int f(y,z|x)dz = \int f(y|z,x)f(z|x)dz
$$
where the $f(\cdot)$'s generically denote respective probability density functions (slight abuse of notation here).   


Once you do this, you technically have a predictive model. Now, to make it good, you probably have to use something more sophisticated than the simple normal models I specified. Also, whether you take a Frequentist or Bayesian (read MCMC here) approach here depends on you. For the latter, you would put priors on $\beta,\gamma,\sigma,\delta$. Usually for predictive accuracy, ensemble models like Boosting and Random Forests are great, but I don't know how to cast them for latent variable use. I can suggest you take a look at Gaussian Processes.
A: I am afraid what you want is not going to happen via simple prediction models. But let me try to answer your question.
In order for you to choose between prediction models, you must have a loss function, i.e. the "cost" of predicting something other than the true value for performance. A common loss function is squared difference, but other forms are possible. Let's say the loss function is $L(\hat\theta, \theta_0)$ which is the price you pay for predicting $\hat\theta$ when the true performance is $\theta_0$. Prediction models are typically built to minimize the average value of this loss.
Now, given that there are latent variables, the best any prediction can hope to achieve is to predict so as to minimize the expected loss given the variables you know. Let those known variables be defined by the vector $x$. The best you can do is to choose $\hat\theta$ such that
$$\hat\theta(x) = \arg \min_\theta E_{\theta_0|X=x} L(\theta, \theta_0)$$
In other words, you are minimizing the loss for the distribution of the true performance $\theta_0$ conditional on what you know, which is $X=x$. Assuming this is what you want, how would you carry out this procedure? Regression is a standard way to do this but there are others.
Note that all of this is about conditional distributions and says nothing about cause. Causal Inference is its own rather involved field, going quite a bit beyond basic statistics (See "Causal Inference" by Imbens and Rubin). Basic prediction as I have described earlier will not give you what you want.
To see this, let's suppose you build a prediction system based on hour of week. And it turns out that Thursday 10pm is when the average performance of FB posts is greatest. But this just tells you the score of the average post at that hour. It doesn't say anything about the quality of the post. It seems you are assuming that post quality is uniformly distributed over the course of a week. This may not be the case. For instance, it might be that the best posts are from people who are too busy during the day to post on Facebook.
I hope that helps.
