Questions tagged [covariance-matrix]
113 questions
2
votes
1 answer
How can I get a subcovariance from a covariance matrix in python
I have a covariance matrix (as a pandas DataFrame) in python as follows:
a b c
a 1 2 3
b 2 10 4
c 3 4 100
And I want dynamically to select only a subset of the covariance of matrix. For example a subset of A and…

Mugurel
- 198
- 10
2
votes
1 answer
How to check the equality of two covariance matrices?
I need to check two conditions:
$E[X]\stackrel{?}{=}\mu$,
$E[(X-\mu)(X-\mu)^{\top}]\stackrel{?}{=}\Sigma$.
Here $X$ is generated (output) data, $\mu$ is the mean vector, $\Sigma$ is the covariance matrix. $\mu$, $\Sigma$ are input data.
For the…

Nick
- 1,086
- 7
- 21
1
vote
1 answer
block diagonal covariance matrix by group of variable
If this is my dataset, 3 subjects, measured at two time points t1,t2 , at each time point each subject is measured twice
ID Time Observation Y
1 t1 1 3.1
1 t1 2 …

Ahir Bhairav Orai
- 611
- 1
- 7
1
vote
1 answer
ValueError: The truth value of a Index is ambiguous. Use a.empty, a.bool(), a.item(), a.any()
I am writing this code for streamlit deployment:
if show_covariance_matrix:
if not cov_matrix.columns.empty:
fig = ff.create_annotated_heatmap(z=cov_matrix.values, x=cov_matrix.columns.tolist(), y=cov_matrix.index, colorscale='Viridis')
…

automorp15m
- 13
- 3
1
vote
1 answer
scipy.optimize.leastsq in Python not returning covariance matrix when fitting data
I am using optimize.leastsq to fit the data I have collected from a Mossbauer Spectroscopy experiment. The data was successfully fit, and the best fit parameters returned are good. But the second output cov_x, as called in the documentation, is…

William Han
- 13
- 3
1
vote
0 answers
Error list' object cannot be coerced to type 'double'
I'm trying to get the "EvolvabilityMeans" (evolvability package) of covariance matrices from 14 species. First, I'm getting the list of covariance matrices and list of means (17 cranial distances). To test evolvability, I need to adjust the matrices…

Carolline Raidan
- 11
- 1
1
vote
0 answers
Using Eigen's SelfAdjointEigenSolver to get get the EigenVectors of a covariance matrix doesn't output expected values
I'm having trouble getting the proper eigenvectors from a covariance matrix. Every other tool I've tried (Hipparchus, numpy, and Wolfram Alpha) all have the same results. Note that the bolded values in the two tables below are the ones that don't…

J'e
- 3,014
- 4
- 31
- 55
1
vote
2 answers
Using the correlation matrix after a fit in Gnuplot
Say I need to fit some data to a parabola, and then perform some calculations involving the correlation matrix elements of the fit parameters: is there a way to use these parameters directly in gnuplot after the fit converges? Are they stored in…

Rogert
- 31
- 5
1
vote
1 answer
How to plot a covariance matrix on a 2D plot in MATLAB?
In MATLAB there is a function called cov. If I insert a matrix X into cov like this cov(X), then cov will return a square matrix of covariance.
My question is very simple:
How can I, with MATLAB, plot that matrix cov(X) onto a 2D plot like this.
I…

euraad
- 2,467
- 5
- 30
- 51
1
vote
1 answer
Variance-covariance matrix : difference between cov(X) and t(X)X(1/n-1)
First, let's get this straight: I'm not a mathematician or statistician.
To the problem.
I want to compute a variance-covariance matrix for a set of values. The values are stored in a matrix such as:
M <- matrix(c(1,2,3,4,
2,4,6,8,
…

Patrik Ulvdal
- 13
- 5
1
vote
1 answer
Variance-covariance matrix of repeated measurements from data in a long format?
I have repeated measurements data on 66 patients with either endogenous or exogenous depression (endo) and depression scores measured weekly for 0-5 weeks (hdrs, so six measurements per patients including baseline). The data is in a long…

tcvdb1992
- 413
- 3
- 12
1
vote
2 answers
How is the result of the vcov() function in R computed?
I wanted to know how I can manually compute what is returned when I call the vcov() function in R on a lm object, i.e. the variance-covariance matrix.
The diagonal entries are very straightforward, one just needs to take the st. error of every…

ZAVIM
- 23
- 1
- 4
1
vote
1 answer
Stan Covariance Matrix
I am experimenting with stan and Gaussian Processes. After some errors I found out the root of everything is a strange behavior of the function cov_exp_quad.
In particular I do not understand why it returns a matrix that is not symmetrical.
Here the…

Marco De Virgilis
- 982
- 1
- 9
- 29
1
vote
1 answer
Multiply a pandas MultiIndex (k x n x n) by a DataFrame (k x n x 1)
I have a time series of covariance matrices stored as a MultiIndex (let's called it "A") and a time series of scalars stored as a DataFrame (let's call it "b").
"A" is of shape "k" x "n" x "n" and "b" is of shape "k" x "n", so I have a MultiIndex of…

The User
- 55
- 3
- 11
1
vote
0 answers
Fitting a negative binomial model and covariance structure syntax in glmmTMB
I read the glmmTMB package vignettes (https://cran.r-project.org/web/packages/glmmTMB/vignettes/covstruct.html) and have the following questions:
In the vignetts, they fit the model using
glmmTMB(y~ar1(times+0|group),data=dat0)
and mentioned that…

user2829551
- 11
- 1