Questions tagged [covariance-matrix]
113 questions
1
vote
1 answer
Applying 'clustering functions' to a series of linear models
I want to iterate over a list of linear models and apply "clustered" standard errors to each model using the vcovCL function. My goal is to do this as efficiently as possible (I am running a linear model across many columns of a dataframe). My…

Thomas Bilach
- 591
- 2
- 16
1
vote
1 answer
Application of a multi-way cluster-robust function in R
Hello (first timer here),
I would like to estimate a "two-way" cluster-robust variance-covariance matrix in R. I am using a particular canned routine from the "multiwayvcov" library. My question relates solely to the set-up of the cluster.vcov…

Thomas Bilach
- 591
- 2
- 16
1
vote
2 answers
DataFrame to breeze DenseMatrix in spark using scala
I'm trying to convert a dataframe to a breeze dense matrix using scala. I couldn't find any built-in functions to do this, so here's what I'm doing.
import scala.util.Random
import breeze.linalg.DenseMatrix
val featuresDF = (1 to 10)
.map(_ =>…

rasthiya
- 650
- 1
- 6
- 20
1
vote
1 answer
Non-conformable arrays | Error calculating T squared | R
I am trying to calculate T squared. I have the following parameters:
> invS #inverse variance covariance matrix
x1 x2
x1 0.005536320 -0.001167908
x2 -0.001167908 0.002635186
> n # number of rows
[1] 11
> d_mean
x1 …

Feyzi Bagirov
- 1,292
- 4
- 28
- 46
1
vote
1 answer
Reducing calculation time and requirements for large covariance matrix
I currently am trying to calculate a covariance matrix for a ~30k row matrix (all values are in range of [0,1]), and its taking a very long time (I have let it run for over and hour and it still hasn't completed).
One thing i noticed on smaller…

DrTchocky
- 515
- 1
- 5
- 14
0
votes
1 answer
Horizontal legend for a covariance matrix plot
I am trying to construct a 2D perspective plot of a covariance matrix in R. A reprex code is below
nrows <- 10
ncols <- 10
p <- nrows * ncols
Qvariance <- 1
Qrho <- 0.8
alpha <- matrix(rep(1:p, p), nrow = p, ncol = p)
JJ <- (alpha - 1) %% nrows +…

Ash
- 85
- 5
0
votes
0 answers
Why the result of Qt estimate of fitSSM function in KFAS package is negative?
I have this following model, I want to estimate the matrix of Ht and Qt using 200 random initialization using multivariate uniform distribution, then choosing the maximum likelihood. I try this following code, and got Qt as negative value…
0
votes
0 answers
Error message in R after conducting ANOVA
I want to conduct a mixed ANOVA in R with three factors (factor group and age_group are between subjects, factor test_interval is within subject) and used the aov-function of the "car" package. So the Model I generated is:
Model <-…

Lin29
- 1
- 1
0
votes
1 answer
Lagged Covariance functions in R are extremely slow
I am trying to estimate the lagged covariance between two vector. I have used gsignal::xcov, forecast::Ccf and stats::ccf. My code has several nested loops so computing time is pilling up, with gsignal::xcov being the fastest but still extremely…

Orestis
- 53
- 5
0
votes
1 answer
Find Covariance and Correlation of Joint Probability Distribution in Python
If I'm given a joint distribution of 2 random variables say A and B, how would I find the covariance of A,B?
(I have known to calculate E_X, E_Y, E_XY and apply formula, what I want to find library that calculate directly Cov(X,Y) without…

NamNguyen
- 21
- 6
0
votes
0 answers
Problem with Matlab multivariate normal distribution (mvncdf)
I want to create a normal distribution with a MU = 0 and SIGMA = cov(A); A is a 4000*5460 matrix.
I get this error: SIGMA must be a square, symmetric, positive definite matrix.
Since the error is related to the Cholesky transformation and negative…

Fatemeh
- 1
- 1
0
votes
1 answer
Wrong VCOV matrix from sandwich::vcovHC with observation counts in R
I am trying to estimate a weighted LM with repeated observations. Naturally, one can exploit this redundancy information to save space and memory. I am working on an application with 400k observations, many of which are duplicated, and said LMs (and…

Andreï V. Kostyrka
- 352
- 1
- 12
0
votes
0 answers
Why does a RBF kernel fail to produce a positive-definite covariance matrix?
I am currently trying to use Gaussian Process Regression to build a model for a prediction task. The training set contains 100 data points (each data point has 11 features and 1 response value), which can be written as [X y], where
the…

Donke_F
- 1
0
votes
0 answers
Understanding variance calculations in scipy.optimise.curve_fit
I'm trying to use Scipy's scipy.optimise.curve_fit to calculate the parameters for a non-linear least squares fit of my data to a function. I have 2-3 response values for each value of my explanatory variable. Each of these individual response…
0
votes
0 answers
How to a create a covariance matrix starting from 30 separate data frames?
I need to do a research on defining the efficient frontier of a portfolio containing all the stocks of the mib30 index (highest by market share stocks in the Italian stock exchange FTSE MIB). I have started by downloading all the closing prices (30…

kimnara
- 1