Displaying 20 results from an estimated 10000 matches similar to: "how to calculate a variance and covariance matrix for a vector"
2003 May 20
1
How to use pakcage SEM
Hi.
I have tried to use Package "SEM".
As a learning, I try to convert a program running well of EQS
which is as follows to SEM:
### EQS ###
/SPECIFICATION
CAS=100; VAR=5 MAT=COR; ANA=COR;
/EQUATIONS
V1=*F1+E1; V2=*F1+E2; V3=*F1+*F2+E3; V4=**F1+*F2*E4;
V5=*F2+E5;
/VAR
E1 TO E5=*; F1*1.0; F2=1.0;
/COV
E1,E2=*; F1,F2=*:
/PRINT
FIT ALL;
/MATRIX ......
/END
This is the converted SEM
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 05
1
How to identify a matrix which causes memory limit?
Hello,
I am running a simulation on an old computer with memory of 512M. I
constantly received a warning of "cannot allocate a vector of ...". How can
I identify the matrix causing the problem? Is there any way to fix this
issue?
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] <-
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
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
2008 Sep 27
1
Using "by" to create individual variance-covariance matrices
Hello R list subscribers,
I am trying to use the "by" command to create line-specific variance covariance matrices (where "x" is the original data matrix):
by(x, x$line, function(d) {
d.clean <- d[,-1]})
write.table(d.clean$line[1,1], sep = ",", file = "covariances.csv", col.names = FALSE, row.names = FALSE, append = TRUE)
write.table("", sep
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
2006 Jan 13
1
Variance-covariance by factor
Dear all,
I have a data frame with one factor and four numeric variables and
wish to obtain the var-cor matrix separately by factor. I tried by() and
sapply() but getting nowhere. I understand this can be done by subsetting
the dataframe, but there should have some sleek ways of doing it.
Here is a simulated dataframe;
s <- rep(c("A","B","C"), c(25,22,18))
d
2009 Dec 04
1
how to calculate covariance matrix in R? why cov doesn't work
Hello,
Sorry. It may be a stupid question.
I have two vectors
a<-c(9,3,5)
b<-c(3,4,1)
How can I get the variance-covariance matrix of these two vectors?
I tried cov(a,b), I got a number not a matrix.
I tried to transpose vector a and b as t(a) and t(b), it still cannot work.
Any suggestions? Thank a lot!
--
View this message in context:
2005 Oct 07
3
Converting PROC NLMIXED code to NLME
Hi,
I am trying to convert the following NLMIXED code to NLME, but am
running into problems concerning 'Singularity in backsolve'. As I am new
to R/S-Plus, I thought I may be missing something in the NLME code.
NLMIXED
***********
proc nlmixed data=kidney.kidney;
parms delta=0.03 gamma=1.1 b1=-0.003 b2=-1.2 b3=0.09 b4=0.35 b5=-1.43
varu=0.5;
eta=b1*age+b2*sex+b3*gn+b4*an+b5*pkn+u;
2012 Oct 18
7
summation coding
I would like to code the following in R: a1(b1+b2+b3) + a2(b1+b3+b4) +
a3(b1+b2+b4) + a4(b1+b2+b3)
or in summation notation: sum_{i=1, j\neq i}^{4} a_i * b_i
I realise this is the same as: sum_{i=1, j=1}^{4} a_i * b_i - sum_{i=j} a_i
* b_i
would appreciate some help.
Thank you.
--
View this message in context: http://r.789695.n4.nabble.com/summation-coding-tp4646678.html
Sent from the R
2010 Jul 19
1
Calculation of Covariance Matrix Calculation
Hi,
Excuse me for asking this silly question. But I really couldn't understand
why cov() and ccov() don't work for my calculation of covariance matrix.
a <- matrix(1:8, 2, 4)
a
[,1] [,2] [,3] [,4]
[1,] 1 3 5 7
[2,] 2 4 6 8
> ccov(a)
Error in solve.default(cov, ...) :
Lapack routine dgesv: system is exactly singular
I also tried colume bind, but it
2009 Oct 29
3
Removing & generating data by category
Dear R users,
Basically, from the following arbitrary data set:
a <-
data.frame(id=c(c("A1","A2","A3","A4","A5"),c("A3","A2","A3","A4","A5")),loc=c("B1","B2","B3","B4","B5"),clm=c(rep(("General"),6),rep("Life",4)))
> a
2013 Apr 25
2
Selecting and then joining data blocks
Hi all,
I have 4 matrices, each having 5 columns and 4 rows .....denoted by
B1,B2,B3,B4.
I have generated a vector of 7 indices, say (1,2,4,3,2,3,1} which refers to
the index of the matrices to be chosen and then appended one on the top of
the next: like, in this case, I wish to have the following mega matrix:
B1over B2 over B4 over B3 over B2 over B3 over B1.
1> How can I achieve this?
2010 Aug 03
2
How to name matrices from a list with lapply ?
Dear list,
I have a list of matrices :
i1 <- matrix(1:10, nrow = 2, ncol = 5)
i2 <- matrix(11:20, nrow = 2, ncol = 5)
j <- list(i1 = i1, i2 = i2)
I would like to attribute names to each dimension, for each matrix,
as follows :
$i1
B1 B2 B3 B4 B5
A1 1 3 5 7 9
A2 2 4 6 8 10
$i2
B1 B2 B3 B4 B5
A1 11 13 15 17 19
A2 12 14 16 18 20
However, I have to use lapply function and attribute
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
2017 Oct 17
3
gfid entries in volume heal info that do not heal
Hi Matt,
Run these commands on all the bricks of the replica pair to get the attrs
set on the backend.
On the bricks of first replica set:
getfattr -d -e hex -m . <brick path>/.glusterfs/10/86/
108694db-c039-4b7c-bd3d-ad6a15d811a2
On the fourth replica set:
getfattr -d -e hex -m . <brick path>/.glusterfs/
e0/c5/e0c56bf7-8bfe-46ca-bde1-e46b92d33df3
Also run the "gluster volume
2009 Jul 30
4
edit.row.names taking row names from the edited dataframe
Hi all,
I am struggling to work out how to use the rownames from an edited dataframe
rather than the row names from the original dataframe. In my data set i'm
trying to extract several rows of data on particular individuals, i don't
doubt i'm using the long way round but what i have in the way of a script is
this:
##selecting the IDs from the dataframe individually
2001 Jan 18
1
Question on the nature of b3/b4 changes
I have a number of .ogg files encoded with b2, and some with b3. Is the
psychoacoustic model in the forthcoming b4 significantly improved over these
builds, such that re-encoding these files would give me either noticeably
better sound, or smaller files? Also, just out of curiousity, will
b4-encoded files be playable with older WinAmp plugins?
Incidentally, I did some tests with b2 a while back