Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
increase (or decrease) variability among correlated varaibles

Subject: increase (or decrease) variability among correlated varaibles

From: Kirk

Date: 2 Feb, 2009 17:54:02

Message: 1 of 7

I am looking for ideas on how to increase variability "noise" about 4 correlated variables. I am using 'mvnrnd' to generate stochastic values about the means, within the parameters of the variables covariance matrix.

Now I am looking for an approach to increase the relative noise about the variables without breaking all the autocorrelation assumptions that led me to use 'mvnrnd' in the first place.

Thanks in advance

Subject: increase (or decrease) variability among correlated varaibles

From: Roger Stafford

Date: 2 Feb, 2009 20:17:02

Message: 2 of 7

"Kirk" <kwythers.nospam@umn.edu> wrote in message <gm7bvp$ed9$1@fred.mathworks.com>...
> I am looking for ideas on how to increase variability "noise" about 4 correlated variables. I am using 'mvnrnd' to generate stochastic values about the means, within the parameters of the variables covariance matrix.
>
> Now I am looking for an approach to increase the relative noise about the variables without breaking all the autocorrelation assumptions that led me to use 'mvnrnd' in the first place.
>
> Thanks in advance

  If you increase by the same factor each of the elements in the covariance matrix you send to 'mvnrnd', this will not alter the correlation values between variables. If you check the definition of correlation, you will see that it is unaffected by such a change.

Roger Stafford

Subject: increase (or decrease) variability among correlated varaibles

From: Kirk

Date: 3 Feb, 2009 05:17:02

Message: 3 of 7


>
> If you increase by the same factor each of the elements in the covariance matrix you send to 'mvnrnd', this will not alter the correlation values between variables. If you check the definition of correlation, you will see that it is unaffected by such a change.
>

Would a 20% increase in the covariance matrix result in a 20% increase in variance about the mean?

Subject: increase (or decrease) variability among correlated varaibles

From: Roger Stafford

Date: 3 Feb, 2009 06:00:17

Message: 4 of 7

"Kirk" <kwythers.nospam@umn.edu> wrote in message <gm8k0d$jht$1@fred.mathworks.com>...
> Would a 20% increase in the covariance matrix result in a 20% increase in variance about the mean?

  Yes, that is correct. Multiplying each element in a covariance matrix by 1.2 would multiply the variances by 1.2, since they are the diagonal elements. However, as I have said, in the way they are defined, the correlation values would remain unchanged.

Roger Stafford

Subject: manipulate variability among correlated varaibles

From: Kirk

Date: 11 Feb, 2009 14:52:02

Message: 5 of 7

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gm8mhh$6bc$1@fred.mathworks.com>...
> "Kirk" <kwythers.nospam@umn.edu> wrote in message <gm8k0d$jht$1@fred.mathworks.com>...
> > Would a 20% increase in the covariance matrix result in a 20% increase in variance about the mean?
>
> Yes, that is correct. Multiplying each element in a covariance matrix by 1.2 would multiply the variances by 1.2, since they are the diagonal elements. However, as I have said, in the way they are defined, the correlation values would remain unchanged.
>
> Roger Stafford

Thanks Roger. Here is a twist on the above question. How would manipulating the means effect the correlations? If I were to reduce all means by 25%, would the correlations among the the variables remain consistent? However, what I would really like to do is to reduce only one of the 4 variables by 25%. As an example, I could write a little cat function that would allow me to treat each column in the matrix of means individually. Columns are in the order of tmax, tmin, par prec.

  mu=cat(2,climate_mu(:,1),climate_mu(:,2),climate_mu(:,3),climate_mu(:,4));

Therefore, I could multiply climate_mu(:,4) by 0.25, and let 'cat' reassemble the matrix. In this way all the precip means are being reduced, but temps and solar radiation is not. The question becomes... Have I just broken my correlation assumptions?

Subject: manipulate variability among correlated varaibles

From: Roger Stafford

Date: 11 Feb, 2009 21:16:02

Message: 6 of 7

"Kirk" <kwythers.nospam@umn.edu> wrote in message <gmuomi$g6h$1@fred.mathworks.com>...
> .... How would manipulating the means effect the correlations? .....

  The answer to your question is no. Changing the mean values has no effect on correlation. To calculate either correlations or covariances, it is necessary to first subtract all the mean values, so they play no role in the finding covariances and correlations.

  What would affect the correlation would be an alteration of the differences among the various data samples of a variable, but changing the means does not do that.

Roger Stafford

Subject: increase (or decrease) variability among correlated varaibles

From: Kirk

Date: 26 Nov, 2009 00:20:38

Message: 7 of 7

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gm8mhh$6bc$1@fred.mathworks.com>...
> "Kirk" <kwythers.nospam@umn.edu> wrote in message <gm8k0d$jht$1@fred.mathworks.com>...
> > Would a 20% increase in the covariance matrix result in a 20% increase in variance about the mean?
>
> Yes, that is correct. Multiplying each element in a covariance matrix by 1.2 would multiply the variances by 1.2, since they are the diagonal elements. However, as I have said, in the way they are defined, the correlation values would remain unchanged.
>
> Roger Stafford


Along similar lines of this old discussion, I am needing to "ramp" variability among the variables in the covariance matrix. Presently I have created two random matrices with repmat and mvnrnd, and then using cat to assemble them. The point is be able to apply a scaler (10x) to covariance matrix of the final 200 years of climate to increase the variability:

muPre=repmat(climate_mu,1000,1);
muPost=repmat(climate_mu,200,1);
sigmaPre=repmat(climate_sigma,[1 1 1000]);
sigmaPost=10*repmat(climate_sigma,[1 1 200]);

Then within a parfor loop, create the random matix with mvnrnd and assemble both pieces of the climate file:

climateDataPre=mvnrnd(muPre,sigmaPre);
climateDataPost=mvnrnd(muPost,sigmaPost);
climateData=cat(1,climateDataPre,climateDataPost);

However, as I said earlier, I need to increase variability slowly. Toward this end I wrote a function to do so. It works on the same line of code "sigmaPost":

function [scenario]=sRamp(woScenario)
% Will scale variability each year in order to reach an set maximum over
% the number of years defined in the ramp. Creates new covariance matrix
% (withScenario) from the input covariance (woScenario). sRamp askes for the
% increse in variavility (s) over the length of the ramp, and the length of the ramp
% as input

sInc = 10;
rampYrs = 200;

% Set first year of scenario equal to first year of the final 200 years of woScenario
scenario=woScenario(12001:14400);
% Loop through each year of the final 200 years (12 months per year)
for yr=1:rampYrs
    scenario((yr*12)-11:((yr-1)*12)+12)=woScenario((yr*12)-11:((yr-1)*12)+12)+(yr*(sInc/rampYrs));
end
woScenario(end-((12*rampYrs)-1):end) = scenario;
scenario = woScenario;

However, I am getting the error:

??? Error using ==> mvnrnd at 167
Each page of SIGMA must be a symmetric positive semi-definite matrix.

Error in ==> parallel_function at 475
            consume(base, limit, F(base, limit));

Error in ==> ncmc3 at 53
   parfor i = 1:1

It appears that I am breaking some rule concerning the structure of covariance matrix. Thoughts?

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us