Changing diagonal elements of a matrix

In summary: You have to be more specific. In what way do you want to modify the variances of your original variables?In summary, the conversation discusses the possibility of scaling a variance-covariance matrix W with a vector of weights v in order to change the variances of the variables but not the covariances. One suggestion is to create a diagonal matrix V from v and multiply it with W, but this would also change the off-diagonal elements. The conversation also explores the implications and limitations of only multiplying the diagonal elements of W with v and suggests using a convex combination of W and a diagonal matrix of diag(W) to achieve the desired result. However, the exact method of modifying the variances of the variables using
  • #1
adelaide_user_1009
3
0
TL;DR Summary
Can I transform only diagonal elements of a variance-covariance matrix?
I have a variance-covariance matrix W with diagonal elements diag(W). I have a vector of weights v. I want to scale W with these weights but only to change the variances and not the covariances. One way would be to make v into a diagonal matrix and (say V) and obtain VW or WV, which changes both diagonal and off-diagonal elements of W. Does it make sense to only multiply diag(W) with v and leave the off-diagonal elements of W untouched?

I have searched for any intuition around it but found nothing that supports it or otherwise. Any help would be appreciated on references, texts, etc that would involve such a situation.
 
Physics news on Phys.org
  • #2
Why?

The variance is only a specific case of covariance. Hence changing it means changing a covariance automatically.

Assume for a moment that you were successful. What would the new matrix represent? Definitely no covariances anymore.

Assume a very simple case: ##X_k \longmapsto X'_k:=\alpha_kX_k.## Then ##\operatorname{cov}(X'_m,X'_n)=\alpha_m\alpha_n \operatorname{cov}(X_m,X_n).## Since all covariances should remain unchanged, we get ##\alpha_m\alpha_n = 1## for all ##m\neq n##. If we have enough indices, then we will be left with ##\alpha_k=1## for all ##k.##

You are asking the wrong question.
What do you intend to do, in the sense that your result will still have a meaning?​
 
  • Like
Likes adelaide_user_1009
  • #3
A matrix is a covariance matrix if and only if it is symmetric and positive semi definite. So you can change the diagonal as long as you don't make it too small, and it should continue to satisfy these properties. It will be the covariance matrix for a totally different set of random variables though as fresh points out.

As long as you want to increase the diagonal entries, you can just add some new random variable that is uncorrelated with all your existing random variables whose variance is equal to the increase. Making them smaller requires something more clever (and isn't anyways possible)
 
  • Like
Likes adelaide_user_1009, WWGD and FactChecker
  • #4
Office_Shredder said:
A matrix is a covariance matrix if and only if it is symmetric and positive semi definite. So you can change the diagonal as long as you don't make it too small, and it should continue to satisfy these properties. It will be the covariance matrix for a totally different set of random variables though as fresh points out.

As long as you want to increase the diagonal entries, you can just add some new random variable that is uncorrelated with all your existing random variables whose variance is equal to the increase. Making them smaller requires something more clever (and isn't anyways possible)
You are right — changing only the diagonal of the covariance matrix would not transform the matrix and it would not be the covariance matrix of the variables anymore. I will try to explore the possibility of a convex combination of the full matrix W and matrix with only diag(W). Something like (1-a)diag(W) + aW
 
  • #5
That is the covariance matrix of ##\sqrt{a}## multiplied by your original variables, plus new uncorrelated random variables added to each of them with variance ##(1-a)## times the variance of the variable it is being added to.
 
  • Like
Likes adelaide_user_1009
  • #6
Office_Shredder said:
That is the covariance matrix of ##\sqrt{a}## multiplied by your original variables, plus new uncorrelated random variables added to each of them with variance ##(1-a)## times the variance of the variable it is being added to.
Right. So assuming no restriction is imposed on their correlation, ##a = 1## and W is true and assuming variables are totally uncorrelated, ##a = 0## diagonal matrix of diag(W) is true. I need to figure out how to specify ##a## in my case.
 
  • #7
I think I don't fully understand when you say you have a vector of weights, how those are supposed to modify the variances
 

FAQ: Changing diagonal elements of a matrix

How do I change the diagonal elements of a matrix?

To change the diagonal elements of a matrix, you can use a for loop to iterate through the rows and columns of the matrix and use conditional statements to identify the diagonal elements. Then, you can use the indexing notation to change the values of the diagonal elements.

Can I change the diagonal elements of a matrix to a specific value?

Yes, you can change the diagonal elements of a matrix to a specific value by using the indexing notation to assign the desired value to the diagonal elements.

Is it possible to change only a part of the diagonal elements in a matrix?

Yes, you can change only a part of the diagonal elements in a matrix by specifying the range of indices for the diagonal elements that you want to change. This can be done using the slicing notation in Python.

How do I change the diagonal elements of a matrix in MATLAB?

To change the diagonal elements of a matrix in MATLAB, you can use the built-in function "diag" which allows you to specify the values of the diagonal elements. You can also use the indexing notation to directly change the values of the diagonal elements.

Can I change the diagonal elements of a matrix using a mathematical operation?

Yes, you can change the diagonal elements of a matrix using a mathematical operation by first accessing the diagonal elements using the indexing notation and then performing the desired mathematical operation on them.

Back
Top