R: Recreate a 3D mesh plot
<p>How would I recreate the following plot in R? </p>

<p><a href="https://i.stack.imgur.com/x9Gmq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x9Gmq.jpg" alt="enter image description here"></a></p>

<p>I'm struggling with generating data, given that the Z-coordinate is determined with the following equation:</p>

<p><a href="https://i.stack.imgur.com/EqI0U.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EqI0U.gif" alt="enter image description here"></a></p>

<p>where</p>

<p><a href="https://i.stack.imgur.com/msbYm.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/msbYm.gif" alt="enter image description here"></a></p>

<p>A vectorized solution would be good, and a 3D, interactive plot would be even better.</p>

<p>I have the following:</p>

<pre><code>## generate the data points from a multivariate normal
library(MASS)
library(ggplot2)
Sigma &lt;- matrix(c(10,3,3,2),2,2)
set.seed(1)
df &lt;- data.frame(mvrnorm(n=100,mu=c(10,10),Sigma=Sigma)) # X1=x, X2=y

theta0 = theta0 &lt;- seq(-5,5,by=0.5)
theta1 &lt;- seq(-5,5,by=0.5)
z = NULL
m &lt;- theta1
</code></pre>