search for: cormat

Displaying 20 results from an estimated 25 matches for "cormat".

Did you mean: format
2011 Feb 09
2
Generate multivariate normal data with a random correlation matrix
...ower (or upper) triangle of the correlation matrix has n.tri=(d/2)(d+1)-d entries. Take a uniform sample of n.tri possible correlations (runi(n.tr,-.99,.99) Populate a triangle of the matrix with the sampled correlations Mirror the triangle to populate the other triangle forming a symmetric matrix, cormat Sample n observations from a multivariate normal distribution with mean vector=0 and varcov=cormat Problem: This approach violates the triangle inequality property of correlation matrices. ?So, the matrix I've constructed is certainly a valid matrix but it is not a valid correlation matrix an...
2002 Jan 15
1
acf conf intervals +speed
.../(sqrt(mb*mc)) # Grad wrt a @ g[2]<-(-0.5)*(cor/mb) # Grad wrt b @ g[3]<-(-0.5)*(cor/mc) # Grad wrt c @ vcor<-t(g)%*%vd%*%g secor<-sqrt(vcor) list(cor=cor,secor=secor) } acf2<-function(x,y=x,lagmax=(length(x)-10),m="ACF",mix=0){ L<-min(length(x),length(y)) cormat<-matrix(0,lagmax,1) secormat<-matrix(0,lagmax,1) x<-x[1:L] y<-y[1:L] c0<-initc(x,y) cx0<-c0$cx0 cy0<-c0$cy0 for (i in 1:lagmax){ x1<-x[1:(L-i)] y1<-y[(i+1):L] c<-corse(x1,y1,cx0,cy0) cormat[i]<-c$cor secormat[i]<-c$secor } stop...
2011 Jan 17
0
(no subject)
...pData <- data.frame(id = rep(paste("JohnDoe", 1:n, sep = "_"), each = t),time = rep(1981:1984, n)) rho <-0.95 alphai <- rnorm(n,mean=0,sd=1)#alphai simulation x<- as.matrix(rnorm(nt,1))#xi simulation akro <- kronecker(alphai ,matrix(1,t,1))#kronecker of alphai cormat<-matrix(c(1,rho,rho,1),nrow=2,ncol=2)#correlation matrix cormat.chold <- chol(cormat)#choleski transformation of correlation matrix akrox <- cbind(akro,x) ax <- akrox%*%cormat.chold ai <- as.matrix(ax[,1]) pData$alphai<-as.vector(ai) xcorr <- as.matrix(ax[,2:(1+ncol(x))]) pData...
2011 Jan 17
0
PANEL DATA SIMULATION(sorry for my previous email with no subject)
...pData <- data.frame(id = rep(paste("JohnDoe", 1:n, sep = "_"), each = t),time = rep(1981:1984, n)) rho <-0.95 alphai <- rnorm(n,mean=0,sd=1)#alphai simulation x<- as.matrix(rnorm(nt,1))#xi simulation akro <- kronecker(alphai ,matrix(1,t,1))#kronecker of alphai cormat<-matrix(c(1,rho,rho,1),nrow=2,ncol=2)#correlation matrix cormat.chold <- chol(cormat)#choleski transformation of correlation matrix akrox <- cbind(akro,x) ax <- akrox%*%cormat.chold ai <- as.matrix(ax[,1]) pData$alphai<-as.vector(ai) xcorr <- as.matrix(ax[,2:(1+ncol(x))]) pData...
2011 Jan 18
0
Need help in a simulation study
...*t pData <- data.frame(id = rep(paste("JohnDoe", 1:n, sep = "_"), each = t),time = rep(1981:1984, n)) rho <-0.95 alphai <- rnorm(n,mean=0,sd=1)#alphai simulation x<- as.matrix(rnorm(nt,1))#xi simulation akro <- kronecker(alphai ,matrix(1,t,1))#kronecker of alphai cormat<-matrix(c(1,rho,rho,1),nrow=2,ncol=2)#correlation matrix cormat.chold <- chol(cormat)#choleski transformation of correlation matrix akrox <- cbind(akro,x) ax <- akrox%*%cormat.chold ai <- as.matrix(ax[,1]) pData$alphai<-as.vector(ai) xcorr <- as.matrix(ax[,2:(1+ncol(x))]) pData...
2011 Jan 17
0
PANEL DATA SIMULATION
...frame(id = rep(paste("JohnDoe", 1:n, sep = "_"), each = t),time = rep(1981:1984, n)) rho <-0.95 alphai <- rnorm(n,mean=0,sd=1)#alphai simulation x<- as.matrix(rnorm(nt,1))#xi simulation akro <- kronecker(alphai ,matrix(1,t,1))#kronecker of alphai cormat<-matrix(c(1,rho,rho,1),nrow=2,ncol=2)#correlation matrix cormat.chold <- chol(cormat)#choleski transformation of correlation matrix akrox <- cbind(akro,x) ax <- akrox...
2009 May 15
2
Using column length in plot gives error
Hi I'm trying to write a generic script for processing some data which finishes off with some plots. Given Im never sure how many columns will be in my dataframe I wanted to using the following plot(spectra.wavelength, cormat, type = "l", ylim=c(-1,1), xlab="Wavelength (nm)", ylab="Correlation") however even if I specify as type="l" it appears plot as points (right hand plot). If I specify a range such as plot(650:700, cormat, type = "l", ylim=c(-1,1), xlab="Wave...
2010 Dec 02
2
Hmisc label function applied to data frame
...rks very nicely as shown here: library(Hmisc) library(corpcor) # Create example data x1 = runif(50) x2 = runif(50) x3 = runif(50) d = data.frame(x1=x1,x2=x2,x3=x3) label(d$x1) = "Variable x1" label(d$x2) = "Variable x2" label(d$x3) = "Variable x3" # Get correlations cormat = cor(d) # Get vector form of lower triangular elements cors = sm2vec(cormat,diag=F) inds = sm.index(cormat,diag=F) # Create a data frame var1 = dimnames(cormat)[[1]][inds[,1]] var2 = dimnames(cormat)[[2]][inds[,2]] lbl1 = label(d[,var1]) lbl2 = label(d[,var2]) cor_df = data.frame(Var1=lbl1,Var2=...
2013 Feb 20
1
Problem with levelplot() in a loop
...ot() line col.l <- colorRampPalette(c('blue', 'green', 'yellow', 'red'))(30) for (i in 1:10) { randmat <- cbind(rnorm(100),rnorm(100),rnorm(100),rnorm(100),rnorm(100)) colnames(randmat) <- c('A','B','C','D','E') cormat <- cor(randmat) levelplot(cormat,xlab=NULL,ylab=NULL,main='Correlation Heat Map',col.regions=col.l) # heatmap(cormat,col=col.l,Rowv=NA, Colv=NA,main=paste("Plot:",i,sep='')) Sys.sleep(1) } Thanks much in advance! [[alternative HTML version deleted]]
2005 Apr 15
5
Pearson corelation and p-value for matrix
Hi, I was trying to evaluate the pearson correlation and the p-values for an nxm matrix, where each row represents a vector. One way to do it would be to iterate through each row, and find its correlation value( and the p-value) with respect to the other rows. Is there some function by which I can use the matrix as input? Ideally, the output would be an nxn matrix, containing the p-values
2003 Jul 11
1
How to generate regression matrix with correlation matrix
Dear R community: I want to simulate a regression matrix which is generated from an orthonormal matrix X of dimension 30*10 with different between-column pairwise correlation coefficients generated from uniform distribution U(-1,1). Thanks in advance! Rui [[alternative HTML version deleted]]
2009 Oct 06
2
Viewing specific data from a dataframe
Dear R users, Simple question. Can anyone help with the code that would allow me to view only the variables who's correlation output is >0.8? This is the code I'm using to date >cor(data, method="spearman") Kind regards Krys -------------------------------------------- _________________________________________________________________ Save time by
2011 Jan 25
0
How to simulate a variable Xt=Wit+0.5Wit-1 with
...nDoe", 1:n, sep = "."), each = t),time = rep(1981:1985, n)) rho <-0.99#simulate alphai corelated with the xi print(rho) alphai <- rnorm(n,mean=0,sd=1)#alphai simulation x<- as.matrix(rnorm(nt,1))#xi simulation akro <- kronecker(alphai ,matrix(1,t,1))#kronecker of alphai cormat<-matrix(c(1,rho,rho,1),nrow=2,ncol=2)#correlation matrix cormat.chold <- chol(cormat)#choleski transformation of correlation matrix akrox <- cbind(akro,x) ax <- akrox%*%cormat.chold ai <- as.matrix(ax[,1]) pData$alphai<-as.vector(ai) xcorr <- as.matrix(ax[,2:(1+ncol(x))]) pData...
2008 May 17
1
Correlated Columns in data frame
...The code is ################# r2test <- function(df, cutoff=0.8) { if (cutoff > 1 || cutoff <= 0) { stop(" 0 <= cutoff < 1") } if (!is.matrix(d) && !is.data.frame(d)) { stop("Must supply a data.frame or matrix") } r2cut = sqrt(cutoff); cormat <- cor(d); bad.idx <- which(abs(cormat)>r2cut,arr.ind=T); bad.idx <- matrix( bad.idx[bad.idx[,1] > bad.idx[,2]], ncol=2); drop.idx <- ifelse(runif(nrow(bad.idx)) > .5, bad.idx[,1], bad.idx [,2]); if (length(drop.idx) == 0) { 1:ncol(d) } else { (1:ncol(d))[...
2013 Feb 02
1
Why replacement has length zero? And How can I fix it?
...gt; library (mvtnorm) > > options(digits=2) > > # Set variable name # > namelist1 <- c("Age", "Gender", "SES", "ISS", "IQTe", "PreTe") > > # Generate Data # > Sample.Size <- 10 # Variable Sample Size # > CorMat <- matrix(c(1.0 ,0.0 ,0.0 , 0.5, 0.2, 0.5, > 0.0, 1.0 ,0.0, 0.0, 0.0, 0.0, > 0.0 ,0.0 ,1.0, 0.5, 0.4, 0.5, > 0.5, 0.0, 0.5, 1.0, 0.4, 0.7, > 0.2, 0.0, 0.4, 0.4, 1.0, 0.9, > 0.5, 0.0, 0.5, 0.7, 0.9, 1.0),ncol=6) # Correlation Matrix # > > DataSet &lt...
2006 Jul 10
1
print color
B??dnie zakodowany tekst zosta? usuni?ty... Plik: nie znany Url: https://stat.ethz.ch/pipermail/r-help/attachments/20060710/8e0ea80d/attachment.pl
2006 Jun 28
1
Simulate dichotomous correlation matrix
Newsgroup members, Does anyone have a clever way to simulate a correlation matrix such that each column contains dichotomous variables (0,1) and where each column has different prevalence rates. For instance, I would like to simulate the following correlation matrix: > CORMAT[1:4,1:4] PUREPT PTCUT2 PHQCUT2T ALCCUTT2 PUREPT 1.0000000 0.5141552 0.1913139 0.1917923 PTCUT2 0.5141552 1.0000000 0.2913552 0.2204097 PHQCUT2T 0.1913139 0.2913552 1.0000000 0.1803987 ALCCUTT2 0.1917923 0.2204097 0.1803987 1.0000000 Where the prevalence for each variable is:...
2008 Aug 06
1
Correlation dichotomous factor, continous (numerical) and ordered factor
...I read also that it is possible to use a point-biserial correlation to calculate the correlation between dichotomous and continuous variables. Now I am confused what I should use to calculate the correlation using all my variables and how I could do that in R. Is it possible with cor(), rcorr(), cormat() or other R-functions using one of the available correlation-coefficients. I would be very happy if somebody could enlighten my darkness. Many thanks in advance. B. ----- The art of living is more like wrestling than dancing. (Marcus Aurelius) -- View this message in context: http://www.nabb...
2008 May 05
3
troubles with R CMD check and examples under Ubuntu gutsy
Dear listers, I was used to package pgirmess under Windows with everything OK, but, for the first time, I had a trial this afternoon on Ubuntu 7.10 gutsy (I have a double boot computer and work more and more under unix) and R 2.7.0. Everything went OK except this: sudo R CMD check pgirmess ..... * checking examples ... ERROR Running examples in 'pgirmess-Ex.R' failed. The error most
2004 Oct 17
2
Errors while compiling packages with namespace?
...se I can source them all without error). At this point, I am completelly lost. Any help would be welcome. This package contains several hundreds of lines of code, and NAMESPACE is quite complex: importFrom(svMisc, listCustoms, getTemp) importFrom(R2HTML, HTML, HTMLhr, HTMLInsertGraph, HTMLli, HTML.cormat) importFrom(utils, browseURL, methods) importFrom(lattice, lset) importFrom(MASS, lda) import(svIO, graphics, grDevices, stats) export(guiViewsCmd, guiViewsCSS, guiViewsCSSChange, guiViewsDir, guiViewsDisplay, guiViewsFile, report, reportGraph,...