similar to: How to build a large identity matrix faster?

Displaying 20 results from an estimated 9000 matches similar to: "How to build a large identity matrix faster?"

2011 Mar 31
1
rank of Matrix
Dear list, Can anyone tell me how to obtain the rank of a sparse Matrix, for example from package Matrix (class dgCMatrix)? Here is an example of QR decomposition of a sparse matrix (from the sparseQR class help). library(Matrix) data(KNex) mm <- KNex$mm str(mmQR <- qr(mm)) Similarly, using the functions/classes from the relatively new MatrixModels package: library(MatrixModels)
2011 Sep 26
2
Triangular matrix upper to down
Hi, suppose that we have a triangular upper matrix A test <- matrix(ncol = 4, nrow = 4) test[1, ] <- c(NA,1,1,1) test[2, ] <- c(NA,NA,1,1) test[3, ] <- c(NA,NA,NA,1) test[4, ] <- c(NA,NA,NA,NA) I know how quickly set diagonal value diag(test) <- 1. But how quickly set down value i.e. matrix is symmetrical? Is there in r project any quickly function? Thanks, Best Marcin
2012 May 16
3
triangular matrices input/output
Hi, Is there any package that deals with triangular matrices? Say ways of inputting an upper (lower) triangular matrix? Or convert a vector of length 6 to an upper (lower) triangular matrix (by row/column)? Thanks! ----- ###################### PhD candidate in Statistics Big R Fan Big LEGO Fan Big sTaTs Fan ###################### -- View this message in context:
2010 Jan 07
1
faster GLS code
Dear helpers, I wrote a code which estimates a multi-equation model with generalized least squares (GLS). I can use GLS because I know the covariance matrix of the residuals a priori. However, it is a bit slow and I wonder if anybody would be able to point out a way to make it faster (it is part of a bigger code and needs to run several times). Any suggestion would be greatly appreciated. Carlo
2006 Oct 26
1
A faster way to calculate Trace?
I want to know how to get trace of product of matrices **faster** when the matrices are really big. Unfortunately the matrices are not symmetric. If anybody know how to get the trace of it, please help me. An example is as below. n <- 2500 a <- matrix(rnorm(n*n),n,n) b <- matrix(rnorm(n*n),n,n) tr1 <- sum(diag(a %*% b)) tr2 <- sum(diag(a %*% b %*% a %*% b)) Thanks, Yongwan Chun
2011 Dec 15
2
Data Manipulation - make diagonal matrix of each element of a matrix
Dear R list, I have the following data: set.seed(1) n <- 5 # number of subjects tt <- 3 # number of repeated observation per subject numco <- 2 # number of covariates x <- matrix(round(rnorm(n*numco),2), ncol=numco) # the actual covariates x > x [,1] [,2] [1,] -0.63 -0.82 [2,] 0.18 0.49 [3,] -0.84 0.74 [4,] 1.60 0.58 [5,] 0.33 -0.31 I need to form a matrix
2011 Aug 04
1
Running a column loop through the Moran.I function.
Dear R users, I have two data frames that consist of statistical information for most countries around the world. One dataframe consists of the latitude and longitude ("coord.csv") of each country, while the other consists of 100's of different attributes ("countryattri.csv") for each country (like, GDP, Population, etc.). The data is organized with a header and then
2011 Sep 03
1
Bootstrapping a covariance matrix
Dear all I am a bit new to R so please keep your swords sheathed! I would simply like to bootstrap a covariance matrix from a multivariate gaussian density. At face value that seemed like a very straightforward problem to solve but I somehow could not get the boot package to work and did not really understand the documentation so I tried to do the bootstrap manually. Hence: x<-rmvnorm(n = 5,
2011 Jan 22
1
faster mvrnorm alternative
Hello, does anybody know another faster function for random multivariate normal variable simulation? I'm using mvrnorm, but as profiling shows, my algorithm spends approximately 50 % in executing mvrnorm function. Maybe some of you knows much faster function for multivariate normal simulation? I would be very gratefull for advices. -- View this message in context:
2010 Jul 21
1
Question about allocMatrix error message
Dear R family, I faced a technical problem in r coding. #s=t(dev)%*%dev/(nr-1) # dev (100,000 by 2) stands for deviation from the mean #sinv=solve(s) #t2=diag(dev%*%sinv%*%t(dev)) I got an error message at t2 statement: Error in diag(dev %*% si %*% t(dev)) : allocMatrix: too many elements specified Please let me know if there is a way to overcome this problem. best moohwan
2012 Aug 14
2
Communative Matrix Multiplcation
Friends I'm not seeing why the following occurs: > T1 <- (A1 - A2) %*% D > T2 <- (A1 %*% D) - (A2 %*% D) > identical(T1, T2) [1] FALSE Harold > dput(A1) new("dsCMatrix" , i = c(0L, 1L, 2L, 3L, 0L, 1L, 4L, 2L, 3L, 5L) , p = c(0L, 1L, 2L, 3L, 4L, 7L, 10L) , Dim = c(6L, 6L) , Dimnames = list(NULL, NULL) , x = c(5, 5, 5, 5, 5, 5, 10, 5, 5, 10)
2004 May 12
6
Design matrix not identity
Hello again, I was too quick before. What I was looking for was a function that constructs the design (or incidence) matrix (X in a linear model) from a factor. Uwe Ligges suggested using model.matrix and this does almost what I want, but it is first necessary to construct a data variable. It also asigns ones to all rows of the first column (because this is set to be the contrast, not really what
2003 May 14
1
Multiple comparison and lme (again, sorry)
Dear list, As a reply to my recent mail: > simint and TukeyHSD work for aov objects. > Can someone point me to similar functions for lme objects? Douglas Bates wrote There aren't multiple comparison methods for lme objects because it is not clear how to do multiple comparisons for these. I don't think the theory of multiple comparisons extends easily to lme models. One could
2012 Apr 25
2
On the Design of the R Language
http://www.cs.purdue.edu/homes/jv/pubs/ecoop12.pdf A new paper out on R the language -- I'm not all the way through it but it's been an interesting read so far. Thought it might be of interest to the list. Michael Weylandt [[alternative HTML version deleted]]
2005 Nov 10
2
error in rowSums:'x' must be numeric
Dear All, It's Eszter again from Hungary. I could not solve my problem form yesterday, so I still have to ask your help. I have a binary dataset of vegetation samples and species as a comma separated file. I would like to calculate the Jaccard distance of the dataset. I have the following error message: Error in rowSums(x, prod(dn), p, na.rm) : 'x' must be numeric In addition:
2011 Oct 03
4
distance coefficient for amatrix with ngative valus
Hi, I need to run a PCoA (PCO) for a data set wich has both positive and negative values for variables. I  could not find any distancecoefficient other than euclidean distace running for the data set. Are there any other coefficient works with negtive values.Also I cannot get summary out put (the eigen values) for PCO as for PCA.   Thanks. Dilshan [[alternative HTML version deleted]]
2024 Jan 30
1
linear programming in R | limits to what it can do, or my mistake?
Apart from the fact that the statement "such that t1+t2+t3+t4=2970 (as it must)" is not correct, the LP can be implemented as follows: library(lpSolve) LHS <- rbind( c(0,0,0,0, 1, 0, 0,0), c(1,0,0,0,-1, 1, 0,0), c(0,1,0,0, 0,-1, 1,0), c(0,0,1,0, 0, 0,-1,1), cbind(-diag(4),diag(4)), c(0,0,0,0,0,1,0,0), c(0,0,0,0,0,0,1,0), c(0,0,0,0,0,0,0,1) ) RHS <-
2011 Aug 25
3
Segment out of the Graph
Hello everyone, I have a graph and a segment parallel to the x axis at y=-10, x=0, and bars on it. Now the question is, Is there a way to leave the segment there but let the graph axis start from the origin? In this way the segment will be out of the graph Thanks [[alternative HTML version deleted]]
2011 Sep 25
4
selecting first row of a variable with long-format data
Hi, I am trying to select the first row of a variable with data in long-format, e.g., # sample data id <- c(1,1,1,2,2) value <- c(5,6,7,4,5) dat <- data.frame(id, value) dat How can I select/subset the first 'value' for each unique 'id'? Thanks, AC [[alternative HTML version deleted]]
2011 Nov 21
6
Scatter plot - using colour to group points?
Dear All, I am very new to R - trying to teach myself it for some MSc coursework. I am plotting temperature data for two different sites over the same time period which I have downloaded from a university weather station data archive. I am using the following code to create the plot plot ( x = TEMP3[,"TIME"], y = TEMP3[,"TEMP"], type = "p", col =