# Maximizing combined log likelihood from different dataset using r

I have observed data $y$. And I have a function that gives me estimated $\hat{y} = f(x,\hat{P})$ where P is the parameter I want to estimate. I was able to optim() command in R to get maximized log-likelihood estimate $\hat{P}$ using the residuals, assuming a normal distribution.

My question is: If I have multiple dataset and all of them should have the same $P$ but x is on a different scale for each dataset. Now I want to maximize the overall log-likelihood to find the overall $\hat{P}$ and its standard error. Can I just simply compute all the residuals from each data and assume they all have the same distribution so that I can use optim() to maximize the log-likelihood of that?

If they have all the same $P$, and the scale of the error term is the same for each, and they're independent across data sets, then you could just combine (stack) them all into a single set of (x,y) data.
(Which will then mean, yes, if you're using an optimizer (like optim in R) on residuals you should be able to combine the residuals into a single big set of residuals.)