Displaying 20 results from an estimated 30000 matches similar to: "Regress a matrix on another matrix column by column"
2011 Jul 29
4
finding a faster way to run lm on rows of predictor matrix
Hi, everyone.
I need to run lm with the same response vector but with varying predictor vectors. (i.e. 1 response vector on each individual 6,000 predictor vectors)
After looking through the R archive, I found roughly 3 methods that has been suggested.
Unfortunately, I need to run this task multiple times(~ 5,000 times) and would like to find a faster way than the existing methods.
All three
2011 Mar 13
1
using pre-calculated coefficients and LP in coxph()?
I need to force a coxph() function in R to use a pre-calculated set of beta
coefficients of a gene signature consisting of xx genes and the gene
expression is also provided of those xx genes.
If I try to use "coxph()" function in R using just the gene expression data
alone, the beta coefficients and coxph$linear.predictors will change and I
need to use the pre-calcuated linear predictor
2012 Feb 20
2
Column wise matrix multiplication
Hi all,
I am trying to multiply each column of a matrix such to have a unique resulting vector with length equal to the number of rows of the original matrix. In short I would like to do what prod(.) function in Matlab does, i.e.
A <-matrix(c(1:10),5,2)
V = A[,1]*A[,2]
Thank you
Graziano
[[alternative HTML version deleted]]
2009 Jul 31
5
Creating a column based on data in another column
hello all,
I have a data frame and I want to create a column which assigns a letter
based upon the value in another column. The data column has velocities
ranging from 0 to 1000. So for example, for velocities between 0 and 300
I'd like to assign the letter "A" in the new column, for 300-600, "B" and so
on and so forth. How would I do this?
Thank you very much!
Mehdi
2006 Nov 15
3
how to create this design matrix?
Hi all,
I have a multiple-linear regression problem.
There are 13 columns of data, the whole data matrix is: n x 13, where n is
the number of samples.
Now I want to regress EACH of the first 12 columns onto the 13th column,
with 2-parameter linear model y_i = b0 + b1 * x_i, where i goes from 1 to
n, and b0 is the intercept.
How do I create a design matrix to do the 12-column regression
2012 Apr 20
3
Matrix multiplication by multple constants
Dear R helpers
Suppose
x <- c(1:3)
y <- matrix(1:12, ncol = 3, nrow = 4)
> y
[,1] [,2] [,3]
[1,] 1 5 9
[2,] 2 6 10
[3,] 3 7 11
[4,] 4 8 12
I wish to multiply 1st column of y by first element of x i.e. 1, 2nd column of y by 2nd element of x i.e. 2 an so on. Thus the resultant matrix should be like
> z
[,1] [,2] [,3]
[1,] 1
2009 Feb 17
2
Efficient matrix computations
Hi,
I am looking for two ways to speed up my computations:
1. Is there a function that efficiently computes the 'sandwich product' of
three matrices, say, ZPZ'
2. Is there a function that efficiently computes the determinant of a
positive definite symmetric matrix?
Thanks,
S.A.
[[alternative HTML version deleted]]
2010 Mar 09
3
Removing Zeros from matrix
Hi Everybody,
I have a matrix of about 45 columns. Some of the rows contain zeros. Using
>data1<-data[complete.cases(data),], I can remove the "NA" rows. But I am
unable to tackle that of zeros.
Can anybody give me an idea of how to remove rows containing zeros in a
matrix.
Thanks so much
Best
Ogbos
[[alternative HTML version deleted]]
2012 Nov 07
2
simple coversion of matrix rows to matrix columns
Dear All
I would like to convert matrix rows to columns. I am thinking the t() function should help, but am having a hard time converting the matrix into the dimensions I would like them to. Example:
a <-matrix(c(1:30),ncol=3) gives me:[,1] [,2] [,3]
[1,] 1 11 21
[2,] 2 12 22
[3,] 3 13 23
[4,] 4 14 24
[5,] 5 15 25
[6,] 6 16 26
[7,] 7 17
2009 May 24
2
Deleting columns from a matrix
useR's,
I have a matrix given by the code:
mat <-
matrix(c(rep(NA,10),1,2,3,4,5,6,7,8,9,10,10,9,8,NA,6,5,4,NA,2,1,rep(NA,10),1,2,3,4,NA,6,7,8,9,10),10,5)
This is a 10x5 matrix containing missing values. All columns except the
second contain missing values. I want to delete all columns that contain
ALL missing values, and in this case, it would be the first and fourth
columns. Any column
2010 Sep 06
3
Aggregate certain rows in a matrix
Hi,
I have a matrix that looks like this
a <- c(1,1,1,1,2,2,3,3,3,3)
b <- c(2,2,2,3,4,4,4,5,5,6)
c <- c(1,2,3,4,5,6,7,8,9,10)
M <- matrix(nr=10,nc=3)
M[,1] <- a
M[,2] <- b
M[,3] <- c
> M
[,1] [,2] [,3]
[1,] 1 2 1
[2,] 1 2 2
[3,] 1 2 3
[4,] 1 3 4
[5,] 2 4 5
[6,] 2 4 6
[7,] 3 4 7
2011 Mar 09
4
Extracting only odd columns from a matrix
Hi,
This might seem like a simple question but at the moment I am stuck for ideas. The columns of my matrix in which some data is stored are of this form:
X1 Y1 X2 Y2 X3 Y3 ... Xn Yn
with n~100. I would like to look at just the X values (i.e. odd column numbers). Is there an easy way to loop round extracting only these columns?
Any help would be appreciated.
2012 Nov 01
3
convert list without same component length to matrix
Hi,
I have this lame question. I want to convert a list (each with varies in
length) to matrix with same row length by eliminating vectors outside the
needed range.
For example:
l<-list(NULL)
l[[1]]=1,2,3.7
l[[2]]=3,4,5,6,3
l[[3]]=4,2,5,7
l[[4]]=2,4,6,3,2
l[[5]]=3,5,7,2
#so say I want to only have 4 rows and 5 column in my matrix (or
data.frame) and eliminating the 5th index value in l[[2]]
2009 Feb 12
3
get top 50 correlated item from a correlation matrix for each item
Hi,
I have a correlation matrix of about 3000 items, i.e., a 3000*3000
matrix. For each of the 3000 items, I want to get the top 50 items that
have the highest correlation with it (excluding itself) and generate a
data frame with 3 columns like ("ID", "ID2", "cor"), where ID is those
3000 items each repeat 50 times, and ID2 is the top 50 correlated items
with ID,
2007 Nov 15
1
Why is model.matrix creating 2 columns for boolean?
I have a data frame "reading" that includes a logical variable "OLT"
along with response variable "Reading" and predictor "True" (BOTH are
numeric variables; it's "True" as in the true value).
When I suppress the intercept, model.matrix gives me OLTTRUE and
OLTFALSE columns. Why? Can I do anything to prevent it?
> r <-
2002 Aug 28
1
interested tru64 unix person - privsep patch against 3.4p1 + howto /regress
Hi-
Unfortunately, I just found out about the patch that was available for
tru64 privsep. I was entirely unaware that there was a lack of support.
Will the patch be considered for approval if it is applied to 3.4p1, or does
it have to be done against -current? The reason I'm asking is that I
have 3.4p1 working as is, so I know if I have a problem it is likely
related to the patch and not
2009 Nov 21
7
consecutive numbering of elements in a matrix
Within a very large matrix composed of a mix of values and NAs, e.g, matrix A:
[,1] [,2] [,3]
[1,] 1 NA NA
[2,] 3 NA NA
[3,] 3 10 17
[4,] 4 12 18
[5,] 6 16 19
[6,] 6 22 20
[7,] 5 11 NA
I need to be able to consecutively number, in new columns, the non-NA
values within each column (i.e. A[1,1] A[3,2] and A[3,3] would all be set
to one, and
2009 Jun 17
1
Coerce rectangular matrix to symmetrical square matrix
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I have a rectangular matrix of size 920 by 85. I'd like to coerce it into a
square matrix such that all row/col names are present in the new matrix and the
additional values are zero.
As an example:
A B C D
A 1 2 3 4
E 5 6 7 8
F 9 10 11 12
Would be coerced to:
A B C D E F
A 1 2 3 4 5 9
B 2 0 0 0 6 10
C 3 0 0
2008 Sep 21
2
Symmetric matrix
I have following matrix :
a = matrix(rnorm(36), 6)
Now I want to replace the lower-triangular elements with it's upper-triangular elements. That is I want to make a symmetric matrix from a. I have tried with lower.tri() and upper.tri() function, but got desired result. Can anyone please tell me how to do that?
2008 Oct 22
2
Creating list from matrix
Hello everyone,
I have a matrix like :
mat <- matrix(rnorm(12*3), 3)
Now I want to break that matrix in 4 parts each of them are matrix of (3x3) and put those 4 matrices in a "list" object of length 4
Can anyone please tell me how to do that?
Get your new Email address!
Grab the Email name you've always wanted before someone else does!
[[alternative HTML