Displaying 20 results from an estimated 9000 matches similar to: "variance/mean"
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 Dec 21
3
R code for var-cov matrix given variances and correlations
Dear list members,
Where can I find code for computing the p*p variance-covariance
matrix given a vector of p variances (ordered varA, varB, ...,
varp) and a vector of all possible correlations (ordered corAB,
corAC, ..., corp-1,p)?
I know that the covariance between 2 variables is equal to the
product of their correlation and their standard deviations:
corAB * varA^.5 * varB^.5
and so:
2011 Nov 05
1
acf?
I started to check what I thought I knew with autocovariance and it doesn’t
jive with the the calculations given by ‘R’. I was wondering if there is
some scaling or something that I am not aware of.
Take the example
Ø d <- 1:10
Ø (a <- acf(d, type="covariance", demean=FALSE, plot=FALSE))
Autocovariances of series ‘d’, by lag
0 1 2 3 4 5 6
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]]
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
2011 Oct 22
7
"Plotting" text?
I noticed that the text() command adds text to a plot. Is there a way to
either make the plot blank or add text to a "blank sheet". I would like
to "plot" a page that contains just text, no plot lines, labels, etc.
Suggestions?
Kevin
[[alternative HTML version deleted]]
1999 Feb 09
1
Robust estimate of variance
Has anybody written or located a robust verion of Var(X)?
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in
2008 Oct 10
2
Leap year?
Given a Date object or simply a year is there an R function to tell me if the it is a leap year or not? I was hoping for something like 'is.leapyear'. I probably can build my own function (year divisible by 4 etc.) but I would rather use an existing function if it is available.
Thank you.
Kevin
2002 Feb 22
1
Avoiding the mean
Dear list,
what is the fastest way to compute a multivariate mean and cov-matrix? I
presume that the mean is computed in cov, so it may be a waste of time to
compute the mean first and then a second time inside of cov. Is it faster
to use cov.wt, which gives cov-matrix and center?
And: If mean and cov should be computed on a part of the data, is it faster
to use cov.wt with some weights zero, or
2008 Aug 28
6
Function not returning a vector?
Why does:
(shape/scale) * (1:365/scale)^(shape - 1)
return a vector of numbers but calling a function
hasard(1:365,shape,scale)
defined like:
hazard <- function(x,shape,scale)
{
return (shape/scale) * (x/scale)^(shape - 1)
}
Only return a single value? It is like x becomes a single value passed as an argument.
Thank you.
Kevin
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] <-
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
2010 Mar 22
2
Factors attribute?
I noticed that when I fit a linear model using 'lm' there is an attribute called "factors" that is added to the "term". It doesn't seem to appear for 'model.matrix', just 'lm'. I have been unable to find where it gets constructed or what it means? It looks like a two dimensional array that I may be able to use so I would just like to get some
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 Jan 03
5
Power functions?
I had a question about the basic power functions in R.
For example from the R console I enter:
-1 ^ 2
[1] -1
but also
-1^3
[1] -1
-0.1^2
[1] -0.01
Normally pow(-1, 2) return either -Infinity or NaN. Has R taken over the math functions? If so I would think that -1^2 is 1 not -1 and -0.1^2 is 0.01 not -0.01.
Thank you.
Kevin
2011 Mar 17
2
Incorrect degrees of freedom in SEM model using lavaan
I have been trying to use lavaan (version 0.4-7) for a simple path model,
but the program seems to be computing far less degrees of freedom for my
model then it should have. I have 7 variables, which should give (7)(8)/2 =
28 covariances, and hence 28 DF. The model seems to only think I have 13
DF. The code to reproduce the problem is below. Have I done something
wrong, or is this something I
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
2011 Nov 07
3
Upgrade R?
I am trying to upgrade to R 2.14 from R 2.13.1 I have compied all the
libraries from the 'library' directory in my existing installation (2.13.1)
to the installed R 2.14. Now I want to uninstall the old installation (R
2.13.1) and I get the error:
Internal Error: Cannot find utCompiledCode record for this version of the
uninstaller.
Any ideas?
Kevin
[[alternative HTML
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
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]]