# Monte Carlo simulation

#### Juliana

##### New Member
Hi I'm currently doing a third year university stats course. I need help with some questions.

The question gives Wind speed and Temperature data. It then asks to do linear regression to determine the relationship between them, which I've done. (explanatory variable is Wind speed)

It then asks to simulate Wind speed values according to a given distribution (which I've done) but then to use correlated simulation to predict the resultant temperatures.

After some google searches I used an the equation:
Temperature=c*Simulated Wind speed +sqrt(1-C squared)* given Wind Speed
where c is the correlation coeff.

but i also used another method, just using the regression equation:
Temp=-0.29Wind +35

I'm not sure which is right (if they are) or any other way to approach it.

Any help would be appreciated Thanks

#### Dragan

##### Super Moderator
Well, your close, but you are not there yet. You will need an error term (Error) that is independent of "Simulated Wind Speed" (X) to create Temperature on the right-hand side of the equation. For example, if you draw independent random samples from a Standard Normal Distribution (Mu=0, Var=1), then for sure the correlation between Temp and Wind Speed will be "c". However, you cannot use "given Wind Speed", you need to use an Error term (E) from the statistical distribution. In short, that variable needs to be the error term (independent of X) associated with the statistical distribution.

If need be, when you simulate the data, just conduct a linear transformation on the data and it will make no difference because the Pearson Correlation is invariant to linear transformations i.e., it will not change.

#### rogojel

##### TS Contributor
hi,
would using the regression equation work if I added a term containing a data point from the residuals? E.g. If the residials were normally distributed with mean 0 and sd of 1.5, say, then Temp=-0.29Wind +35+eps where eps is N(0,1.5)?

regards

#### Dragan

##### Super Moderator
hi,
would using the regression equation work if I added a term containing a data point from the residuals? E.g. If the residials were normally distributed with mean 0 and sd of 1.5, say, then Temp=-0.29Wind +35+eps where eps is N(0,1.5)?

regards
Well, yes. However, the OP has not identified the statistical distribution that the random deviates are being drawn from. Basically, the two of us are assuming that the random deviates are being drawn from a standard normal distribution, which implies that the sum of the two standard normal independent random variables are also normally distributed, which is correct.

However: Suppose X and E are both independent Standard Uniform RVs distributed as: X, E are iid U~[-Sqrt[3.0], Sqrt[3.0]]. The algorithm to obtain the correct correlation (between Y and X) still works i.e., Y = r*X + Sqrt[1-r**2]*E where X and E both have a mean of 0 and a Standard Deviation of 1.

The potential problem is that if the shape parameters (skew, kurtosis) of Y are of concern. If this is the case, then Y (in general) cannot be Uniformly distributed because of the Central Limit Theorem (CLT), albeit the correlation will still be r. For example, if X and E have some specified correlation of r then Y is distributed as somewhere between a Triangular and Uniform Distribution because of the CLT.

#### Juliana

##### New Member
Well, your close, but you are not there yet. You will need an error term (Error) that is independent of "Simulated Wind Speed" (X) to create Temperature on the right-hand side of the equation. For example, if you draw independent random samples from a Standard Normal Distribution (Mu=0, Var=1), then for sure the correlation between Temp and Wind Speed will be "c". However, you cannot use "given Wind Speed", you need to use an Error term (E) from the statistical distribution. In short, that variable needs to be the error term (independent of X) associated with the statistical distribution.

If need be, when you simulate the data, just conduct a linear transformation on the data and it will make no difference because the Pearson Correlation is invariant to linear transformations i.e., it will not change.
Thanks so much for your help 