Displaying 20 results from an estimated 40000 matches similar to: "Using "by" to create individual variance-covariance matrices"
2007 Sep 26
1
Accessing the fixed- and random-effects variance-covariance matrices of an nlme model
I would appreciate confirmation that the function vcov(model.nlme)
gives the var-cov matrix of the fixed effects in an nlme model.
Presumably the random-effects var-cov matrix is given by cov(ranef
(model.nlme)?
Rob Forsyth
2008 Aug 20
4
Looping over groups
Hello,
My R skills are somewhere between novice and intermediary, and I am hoping that some of you very helpful forum members, whom I've seen work your magic on other peoples' problems/questions, can help me here.
I have a matrix with the following format:
(i) individual plants comprising many different genotype groups (i.e., a plant is genotype 1 or genotype 2 or genotype 3, etc). The
2003 Apr 04
0
nlme and variance-covariance matrices.
--
Dear R users,
I have data on around 2000 birds from 3 generations for which I know
an individual's pedigree (i.e. the relationship it shares with other
individuals e.g brother, uncle, mother) and also a pedigree based on
foster-families, because half broods were removed from their nest of
origin and placed in a foster parent's nest.
From this I want to model two types of random
2010 Mar 27
3
Calculate variance/covariance with complex numbers
Anybody knows what functions can be used to calculate
variance/covariance with complex numbers? var and cov don't seem to
work:
> a
1
V1 0.00810014+0.00169366i
V2 0.00813054+0.00158251i
V3 0.00805489+0.00163295i
V4 0.00809141+0.00159533i
V5 0.00813976+0.00161850i
> var(a)
1
1 1.141556e-09
Warning message:
In var(a) : imaginary parts discarded in
2012 Mar 12
3
how to calculate a variance and covariance matrix for a vector
Hello,
I have a vector {a, b1, b2, b3, b4}. How can I calculate the following
matrix:
var(a) cov(a, b1) cov(a, b2) cov(a, b3) cov(a, b4)
cov(a, b1) var(b1) cov(a, b2) cov(a, b3) cov(a, b4)
...
...
cov(a, b1) cov(a, b2) cov(a, b3) cov(a, b4) var(b4)
I would very appreciate your inputs. Thank you very much.
Sincerely,
Jialin Huang
[[alternative HTML version deleted]]
2011 Sep 30
1
Covariance-Variance Matrix and For Loops
Hello,
I am very new to R (as my Subject probably indicates).
I want to do something that should, I think, be very simple. I have five
vectors in a list and I want to construct a covariance matrix out of them.
Given a 5X5 matrix cvm1, and the list of vectors, cvm1_list, I thought the
following would work (sorry cannot find code tags):
for(i in 1:5){
for(j in 1:5){
cvm1[i,j] <-
2009 Jun 02
2
variance does not equal serial covariance of lag zero?
Dear all,
Does this make any sense:
var() = cov() != acf(lag.max=0, type="covariance")?
I have daily data of IBM for May 2005, and I'm using the logarithmic return:
> ibm200505$LRAdj.Close
[1] NA 0.0203152 0.0005508 -0.0148397 -0.0025182 0.0092025
-0.0013889
[8] 0.0098196 -0.0103757 -0.0274917 0.0005716 -0.0159842 -0.0074306
0.0091710
[15] 0.0002898 0.0226306
2004 Jan 29
2
Calculating/understanding variance-covariance matrix of logistic regression (lrm $var)
Hallo!
I want to understand / recalculate what is done to get
the CI of the logistic regression evaluated with lrm.
As far as I came back, my problem is the
variance-covariance matrix fit$var of the fit
(fit<-lrm(...), fit$var). Here what I found and where
I stucked:
-----------------
library(Design)
# data
D<-c(rep("a", 20), rep("b", 20))
V<-0.25*(1:40)
V[1]<-25
2008 Jun 26
2
constructing arbitrary (positive definite) covariance matrix
Dear list,
I am trying to use the 'mvrnorm' function from the MASS package for
simulating multivariate Gaussian data with given covariance matrix.
The diagonal elements of my covariance matrix should be the same,
i.e., all variables have the same marginal variance. Also all
correlations between all pair of variables should be identical, but
could be any value in [-1,1]. The problem I am
2024 Oct 04
3
apply
OK. Thanks to all. Suppose I have two vectors, x and y. Is there a way
to do the covariance matrix with ?apply?. The matrix I need really
contains the deviation products divided by the degrees of freedom (n-1).
That is, the elements
(1,1), (1,2),...,(1,n)
(2,1), (2,2),...., (2,n)
....
(n,1),(n,2),...,(n,n).
> Hello,
>
> This doesn't make sense, if you have only one vector you
2004 Nov 05
1
Covariance bug in R-1.8.0
R-1.8.0 seems to calculate wrong covariances, when the argument of cov()
is a matrix or a data frame.
The following should produce a matrix of zeroes and NaNs:
x <- matrix(c(NA ,NA ,0.9068995 ,NA ,-0.3116229,
-0.06011117 ,0.7310134 ,NA ,1.738362 ,0.6276125,
0.6615581 ,NA ,NA ,-2.646011 ,-2.126105,
NA ,1.081825 ,NA ,1.253795 ,1.520708,
2010 Nov 15
1
Non-positive definite cross-covariance matrices
I am creating covariance matrices from sets of points, and I am having
frequent problems where I create matrices that are non-positive
definite. I've started using the corpcor package, which was
specifically designed to address these types of problems. It has
solved many of my problems, but I still have one left.
One of the matrices I need to calculate is a cross-covariance matrix.
In other
2004 Nov 05
1
covariance bug (PR#7342)
Full_Name: Christian Lederer
Version: 1.8.0
OS: Linux
Submission from: (NULL) (217.229.7.13)
R-1.8.0 seems to calculate wrong covariances, when the argument of cov()
is a matrix or a data frame.
The following should produce a matrix of zeroes and NaNs:
x <- matrix(c(NA ,NA ,0.9068995 ,NA ,-0.3116229,
-0.06011117 ,0.7310134 ,NA ,1.738362 ,0.6276125,
0.6615581 ,NA
2009 Apr 19
2
covariance
Does anyone know a way to calculate the covariances between two
arrays/matrices x and y, row by row. i.e. var(x[n,],y[n,]) for all n ?
Benjamin Chain
Division of Infection and Immunity
Windeyer Building
UCL, 46 Cleveland St.
London W1T 4JF
Fax 00 44 20 7679 9301
2024 Oct 04
1
apply
Hello,
This doesn't make sense, if you have only one vector you can estimate
its variance with
var(x)
but there is no covariance, the joint variance of two rv's. "co" or
joint with what if you have only x?
Note that the variance of x[1] or any other vector element is zero, it's
only one value therefore it does not vary. A similar reasonong can be
applied to cov(x[1],
2024 Oct 04
2
apply
Hello
I have a vector:
set.seed(123) > n<-3 > x<-rnorm(n); x [1] -0.56047565 -0.23017749
1.55870831 I like to create a matrix with elements containing variances
and covariances of x. That is var(x[1]) cov(x[1],x[2]) cov(x[1],x[3])
cov(x[2],x[1]) var(x[2]) cov(x[2],x[3]) cov(x[3],x[1]) cov(x[3],x[2])
var(x[3]) And I like to do it with "apply". Thanks.
On 10/4/2024 6:35
2009 Mar 22
3
variance/mean
At the risk of appearing ignorant why is the folowing true?
o <- cbind(rep(1,3),rep(2,3),rep(3,3))
var(o)
[,1] [,2] [,3]
[1,] 0 0 0
[2,] 0 0 0
[3,] 0 0 0
and
mean(o)
[1] 2
How do I get mean to return an array similar to var? I would expect in the above example a vector of length 3 {1,2,3}.
Thank you for your help.
Kevin
2009 Mar 22
3
variance/mean
At the risk of appearing ignorant why is the folowing true?
o <- cbind(rep(1,3),rep(2,3),rep(3,3))
var(o)
[,1] [,2] [,3]
[1,] 0 0 0
[2,] 0 0 0
[3,] 0 0 0
and
mean(o)
[1] 2
How do I get mean to return an array similar to var? I would expect in the above example a vector of length 3 {1,2,3}.
Thank you for your help.
Kevin
2006 Jun 02
3
lm() variance covariance matrix of coefficients.
Hi,
I am running a simple linear model with (say) 5 independent variables. Is
there a simple way of getting the variance-covariance matrix of the
coeffcient estimates? None of the values of the lm() seem to provide this.
Thanks in advance,
Ritwik Sinha
rsinha@darwin.cwru.edu
Grad Student
Case Western Reserve University
[[alternative HTML version deleted]]
2024 Oct 04
1
apply
It's still hard to figure out what you want. If you have two vectors
you can compute their (2x2) covariance matrix using cov(cbind(x,y)).
If you want to compute all pairwise squared differences between elements
of x and y you could use outer(x, y, "-")^2.
Can you explain a little bit more about (1) the context for your
question and (2) why you want/need to use apply() ?
On