search for: cov2cor

Displaying 20 results from an estimated 38 matches for "cov2cor".

2013 Sep 18
2
cov2cor exp
...ger(2) etc) Using integers (instead of "numeric" type) is more efficient as here they're used as indexes and would be converted to integer anyway. Compare > is(1) ... and > is(1L) 1L:p is the sequence 1, 2, 3, ..., p (just like 1:p) Just for curiosity, what is findFn('cov2cor') ? Regards, Kenn* I don't know what findFn('cov2cor') is, I'm a total newbie to R but I created a new, simpler to my opinion function for some descriptive statistics as matrix functions for a matrix called "x": one1=c(rep(1, nrow(x))) means <- t(one1)%*%x/3#row...
2009 Jul 13
0
Partial Correlation
...definite!\n") * * }* * * * * * # partial correlation* * Sxx.z <- Sxx - Sxz %*% solve(Szz) %*% t(Sxz)* * print("Sxx.z")* * print(qr(Sxx.z))* * rxx.z <- cov2cor(Sxx.z)[1,2]* * * * return(rxx.z)* *}* *Cov2cor function:-----------------------------------------* *cov2cor<-function (V) * *{* * print("inside cov2cor")* * * * * * p <- (d <- dim(V))[1]* * if (!is.numeric(V) || length(d) != 2L |...
2006 Feb 21
3
Compute a correlation matrix from an existing covariance matrix
Dear All, I am wondering if there is an R function to convert a covariance matrix to a correlation matrix. I have a covariance matrix sigma and I want to compute the corresponding correlation matrix R from sigma. Thank you very much, Bernard --------------------------------- [[alternative HTML version deleted]]
2009 Jun 25
2
Error: system is computationally singular: reciprocal condition number
...is Szz positive definite? zz.ev <- eigen(Szz)$values if(min(zz.ev)[1]<0){ stop("\'Szz\' is not positive definite!\n") } # partial correlation Sxx.z <- Sxx - Sxz %*% solve(Szz) %*% t(Sxz) print(Sxx.z) # this gets printed rxx.z <- cov2cor(Sxx.z)[1,2] #some problem in this function function (V) { print("cov2cor") p <- (d <- dim(V))[1] if (!is.numeric(V) || length(d) != 2L || p != d[2L]) stop("'V' is not a square numeric matrix") Is <- sqrt(1/diag(V))...
2011 Jun 02
4
generating random covariance matrices (with a uniform distribution of correlations)
...want. However, the following: > k<-6; kk<-(k*(k-1))/2; st.dev<-.5 > x<-matrix(0,5000,kk) > for(i in 1:5000){ > y1<-matrix(rnorm(k^2,mean=0,sd=st.dev),k) > y1<-t(y1)%*%y1 > y1<-y1/k #this keeps the variances similar across different k's > y1<-cov2cor(y1) > x[i,]<- y1[lower.tri(y1)] > } > hist(c(x)) demonstrates that the distribution of corresponding correlations is not uniformly distributed between -1 and 1 (of course there is no reason to suspect that it would be). I have tried using both rcorrmatrix and genPositiveDefMat in th...
2008 May 19
2
Converting variance covariance matrix to correlation matrix
Suppose I have a Variance-covariance matrix A. Is there any fast way to calculate correlation matrix from 'A' and vice-versa without emplying any 'for' loop? [[alternative HTML version deleted]]
2012 Apr 16
0
warning message: coxme with package multcomp
...t=Chisqtest()) General Linear Hypotheses Multiple Comparisons of Means: Tukey Contrasts Linear Hypotheses: Estimate tx - meta == 0 -22.1626 uv - meta == 0 -0.6932 uv - tx == 0 21.4694 Global Test: Chisq DF Pr(>Chisq) 1 71.94 1 2.217e-17 Warning message: In cov2cor(covm) : diag(.) had 0 or NA entries; non-finite result is doubtful and all pairwise comparisons between treatments are then not possible: summary(pp.coxme.glht,test=adjusted("Westfall")) Error in if (!chkcorr(corr)) stop(sQuote("corr"), " is not a correlation matrix&q...
2011 Jul 28
2
Help with modFit of FME package
...reason of the error and in fixing it. Thanks for your attention, Paola Lecca. Here the error: > summary(Fit) Parameters: Estimate Std. Error t value Pr(>|t|) pro1_strength 1 NA NA NA Residual standard error: 2.124 on 10 degrees of freedom Error in cov2cor(x$cov.unscaled) : 'V' is not a square numeric matrix In addition: Warning message: In summary.modFit(Fit) : Cannot estimate covariance; system is singular -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: wild_pp1_mrna.txt URL: <htt...
2009 Jun 28
1
ERROR: system is computationally singular: reciprocal condition number = 4.90109e-18
...method) # is Szz positive definite? zz.ev <- eigen(Szz)$values if(min(zz.ev)[1]<0){ stop("\'Szz\' is not positive definite!\n") } # partial correlation Sxx.z <- Sxx - Sxz %*% solve(Szz) %*% t(Sxz) # this gets printed rxx.z <- cov2cor(Sxx.z)[1,2] # probably error in this function cov2cor return(rxx.z) } for some other datasets this pcor.mat function works fine. The solve.default function is this:--------------- solve.default<-function(a, b, tol = ifelse(LINPACK, 1e-07, .Machine$double.eps),LINPACK = FALSE, ...) {...
2011 Aug 04
1
use of modMCMC
Dear all, I used modFit of the package FME to fit a set of ODE to a ste of eperiemntal data. The summary of this fit give me the following error > summary(Fit) Residual standard error: 984.1 on 452 degrees of freedom Error in cov2cor(x$cov.unscaled) : 'V' is not a square numeric matrix In addition: Warning message: In summary.modFit(Fit) : Cannot estimate covariance; system is singular This is due becasue the Hessian matrix has all the entries equal to 0. In these cases, on the help page of modFit, it is suggested to...
2004 Oct 22
1
cor, cov, method "pairwise.complete.obs"
Hi UseRs, I don't want to die beeing idiot... I dont understand the different results between: cor() and cov2cov(cov()). See this little example: > x=matrix(c(0.5,0.2,0.3,0.1,0.4,NA,0.7,0.2,0.6,0.1,0.4,0.9),ncol=3) > cov2cor(cov(x,use="pairwise.complete.obs")) [,1] [,2] [,3] [1,] 1.0000000 0.4653400 -0.1159542 [2,] 0.4653400 1.0000000 -0.7278728 [3,] -0.1159542 -0.7278728 1.0000000 > cor(x,use="pairwise.complete.obs") [,1] [,2] [,3] [1,] 1.00...
2012 Mar 15
6
Generation of correlated variables
Hi everyone. Based on a dependent variable (y), I'm trying to generate some independent variables with a specified correlation. For this there's no problems. However, I would like that have all my "regressors" to be orthogonal (i.e. no correlation among them. For example, y = x1 + x2 + x3 where the correlation between y x1 = 0.7, x2 = 0.4 and x3 = 0.8. However, x1, x2 and x3
2011 Mar 04
2
overleap an iteration within a for-loop when error message produced
Dear R-list member, I'm using the function pmnorm() (-->library(mnormt)) within a for-loop. Certain parameter values leads to an error message: "(In sqrt(diag(S)) : NaNs produced, In sqrt(1/diag(V)) : NaNs produced, In cov2cor(S) : diag(.) had 0 or NA entries; non-finite result is doubtful)" obviously because "NaNs" were produced. Is it possible to tell R that it should overleap the iteration which produce the error message? Here is an example code (does not lead to an error message): for (subject in 1...
2007 Jul 30
3
Constructing correlation matrices
Greetings, I have a seemingly simple task which I have not been able to solve today and I checked all of the help archives on this and have been unable to find anything useful. I want to construct a symmetric matrix of arbtriray size w/o using loops. The following I thought would do it: p <- 6 Rmat <- diag(p) dat.cor <- rnorm(p*(p-1)/2) Rmat[outer(1:p, 1:p, "<")] <-
2008 Jun 14
1
How to see data for a package built under Windows
...ding required package: lme4 Loading required package: Matrix Loading required package: lattice Attaching package: 'Matrix' The following object(s) are masked from package:stats : xtabs Warning in namespaceImportFrom(self, asNamespace(ns)) : replacing previous import: cov2cor Warning in namespaceImportFrom(self, asNamespace(ns)) : replacing previous import: update Warning in namespaceImportFrom(self, asNamespace(ns)) : replacing previous import: xtabs installing man source files installing indices not zipping data installing help >>> Building/Updat...
2024 Feb 29
1
R 4.3.3 is released
...ng vector x, fixing PR#18630, thanks to Ilia Kats. * list.files() on Windows now returns also files with names longer that 260 bytes (the Windows limit is 260 characters). Previously, some file names particularly with 'East Asian' characters were omitted. * cov2cor(<0 x 0>) now works, fixing PR#18423 thanks to Mikael Jagan and Elin Waring. * cov2cor(<negative diagonal>) and similar now give one warning instead of two, with better wording, fixing PR#18424 thanks to Mikael Jagan. * tools:: startDynamicHelp() now ensures p...
2024 Feb 29
1
R 4.3.3 is released
...ng vector x, fixing PR#18630, thanks to Ilia Kats. * list.files() on Windows now returns also files with names longer that 260 bytes (the Windows limit is 260 characters). Previously, some file names particularly with 'East Asian' characters were omitted. * cov2cor(<0 x 0>) now works, fixing PR#18423 thanks to Mikael Jagan and Elin Waring. * cov2cor(<negative diagonal>) and similar now give one warning instead of two, with better wording, fixing PR#18424 thanks to Mikael Jagan. * tools:: startDynamicHelp() now ensures p...
2024 Feb 29
1
R 4.3.3 is released
...ng vector x, fixing PR#18630, thanks to Ilia Kats. * list.files() on Windows now returns also files with names longer that 260 bytes (the Windows limit is 260 characters). Previously, some file names particularly with 'East Asian' characters were omitted. * cov2cor(<0 x 0>) now works, fixing PR#18423 thanks to Mikael Jagan and Elin Waring. * cov2cor(<negative diagonal>) and similar now give one warning instead of two, with better wording, fixing PR#18424 thanks to Mikael Jagan. * tools:: startDynamicHelp() now ensures p...
2008 May 28
2
Tukey HSD (or other post hoc tests) following repeated measures ANOVA
...MU3C)) > Cond.lmat <- c(0,1,-1) > Tukey <- glht.mmc(RT2.aov, focus = "Cond", focus.lmat = Cond.lmat) yielding Error in mvt(lower = carg$lower, upper = carg$upper, df = df, corr = carg$corr, : NA/NaN/Inf in foreign function call (arg 6) In addition: Warning message: In cov2cor(covm) : diagonal has non-finite entries > Tukey height Thank you very much for your help! Ullrich Dr Ullrich Ecker Postdoctoral Research Associate Cognitive Science Laboratories School of Psychology (Mailbag M304) Room 211 Sanders Building University of Western Australia 35 Stirli...
2009 Mar 09
2
path analysis (misspecification?)
hi, I have following data and code; cov <- c (1.670028 ,-1.197685 ,-2.931445,-1.197685,1.765646,3.883839,-2.931445,3.883839,12.050816) cov.matrix <- matrix(cov, 3, 3, dimnames=list(c("y1","x1","x2"), c("y1","x1","x2"))) path.model <- specify.model() x1 -> y1, x1-y1 x2 <-> x1, x2-x1 x2 <->