Displaying 20 results from an estimated 21 matches for "crossproduct".
2010 Oct 06
1
Does R have function/package works similar to SAS's 'PROC REG'?
Hello,
I am working on a variable selection problem and I wonder whether there is
some function or package in R works similar to the 'PROC REG' in SAS? Thank
you.
Some facts about 'PROC REG':
PROC REG in SAS first composes a crossproducts matrix. The matrix can be
calculated from input data, reformed from an input correlation matrix, or
read in from an SSCP data set. For each model, the procedure selects the
appropriate crossproducts from the main matrix. The normal equations formed
from the crossproducts are solved by using a swee...
2003 Jun 08
2
LDA: normalization of eigenvectors (see SPSS)
...the matrix with the eigenvectors
V
usually are not normalized to the length of 1, but in the way that the
following holds (SPSS does the same thing):
t(Vstar)%*%Derror%*%Vstar = I
where Vstar are the normalized eigenvectors. Derror is an "error" or
"within" squaresum- and crossproduct matrix (squaresum of the p
variables on the diagonale, and the non-diagonal elements are the sum of
the crossproducts). For Derror the following holds: Dtotal = Dtreat +
Derror.
Since I assume that many of you are familiar with this transformation:
can anybody of you tell me, how to conduct this t...
2007 Aug 23
1
.Call and to reclaim the memory by allocVector
...claimed by
allocVector. Even after applying gc() function and removing the R object
created by the .Call function, the memory was still not reclaimed back to
the operating system.
Here is an example. It was modified from the convolve2 example from the R
extension manual. Now I am computing the crossproduct of a and b, which
returns a vector of size length(a)*length(b).
The C code is at the end of this message with the modification commented.
The R code is here
----------------------------
dyn.load("crossprod2.so")
cp <- function(a, b) .Call("crossprod2", a, b)
gctorture()
a&l...
2007 Aug 23
1
.Call and to reclaim the memory by allocVector
...claimed by
allocVector. Even after applying gc() function and removing the R object
created by the .Call function, the memory was still not reclaimed back to
the operating system.
Here is an example. It was modified from the convolve2 example from the R
extension manual. Now I am computing the crossproduct of a and b, which
returns a vector of size length(a)*length(b).
The C code is at the end of this message with the modification commented.
The R code is here
----------------------------
dyn.load("crossprod2.so")
cp <- function(a, b) .Call("crossprod2", a, b)
gctorture()
a&l...
2006 May 03
1
Inverse X'WX matrix from weighted linear regression
Dear list,
how can I compute the inverse of the X'WX matrix ("inverse of the weighted sum of squares and crossproducts matrix") from an object of class "lm" from a weigthed linear regression?
Thanks, Sven
2010 May 24
2
Optimization
Hi all, I need to minimize following function :
dat <- matrix(rnorm(20000), ncol=2)
targetFn <- function(x) {
dat <- as.matrix(dat)
dat1 <- 1*dat[,1] - (x^2)*dat[,2]
return(sd(dat1)) }
i.e. I want ro find for which "x" the value of "targetFn" will be minimum,
depending on current dataset "dat". Is there any
2004 May 28
5
vector normal to a plane
Hi All,
(I have a degree in math, but I am too embarassed to ask my colleagues,
so here goes:)
I would like to get a vector normal (orthogonal) to a plane formed by
two other vectors. In matlab I do this:
v1 = [.4, .6, .8]; v2 = [.9, .7, .2]; nn = cross(v1,v2) (gives ~[-.48,
.65, -.24]
if I do R> cross(v1, v2), I get .94. Huh?
Thanks for all your help, again.
W
2005 Aug 05
5
How to set the floating point precision beyond e-22?
We have a problem inverting a matrix which has the following eigenvalues:
> eigen(tcross, only.values=TRUE)
$values
[1] 7.917775e+20 2.130980e+16 7.961620e+13 8.241041e+12 2.258325e+12
[6] 3.869428e+11 6.791041e+10 2.485352e+09 9.863098e+08 9.819373e+05
[11] 3.263408e+05 2.929853e+05 2.920419e+05 2.714355e+05 8.733435e+04
[16] 8.127136e+04 6.543883e+04 5.335074e+04
2002 Aug 09
2
Help with improving efficiency
Dear All,
I have a problem that I think could be solved much more efficiently, but
I don't have a clue how to accomplish this. I have a matrix W with
dimensions k*(p+1):
Let's say W is 5*4 and looks like this:
> W
[,1] [,2] [,3] [,4]
[1,] 1 -1 -1 1
[2,] 1 1 1 1
[3,] 1 2 -2 -1
[4,] 1 0 -1 -1
[5,] 1 -2 -1 0
I want to take
2009 May 14
1
"Fast" correlation algorithm
Hi,
Is in R any "fast" algorithm for correlation?
What I mean is:
I have very large dataset (microarray) with 55000 rows and 100 columns. I
want to count correlation (p-value and cor.coef) between each row of dataset
and some vector (of course length of this vector is equal to number of
columns of dataset).
In short words:
For t-test we have:
"normal" algorithm - t.test
2010 Mar 26
2
Is there a faster way to do this?
Hi guys, I am still learning R, and not well familiar with all the apply
functions.
I am trying to find faster alternatives to replace the for cycle.
Is there a faster way to do the example below?
nm <- 1000
b <- matrix (rnorm (5000, 0, 1), nrow = 500, ncol = nm)
a <- matrix (0, nm, nm)
for (i in 1 : nm) {
for (j in 1 : nm) {
if ( j == i) {
next }
a[i, j] <- t (b [, i]) %*% b[, j]
}
}
2008 Jan 09
1
pairwise cross tabulation tables
Hi,
I have a huge number of categorical variables, say at least 10000, and I put
them into a matrix, each column is one variable. The question is: how can I
make all of the pairwise cross tabulation tables efficiently? The
straightforward solution is to use for-loops by looping two indexes on the
table() function, but it was just too slow. Is there a more efficient way to
do that? Any guidance
2002 Dec 06
2
Fitting 2D vs. 2D data with nls()
Dear R-experts!
I have y(x) data, dim(y) == dim(x) == c(2000, 2)
I'd like to fit them with nls:
fit.result <- nls ( y ~ f(x, p1, p2, p3),
start = list(p1 = ... , p2 = .. , p3 = ..)
)
Actually I want to fit y[,1] ~ x[,1] and y[,2] ~ x[,2]
*simulaneously*, with the same parameters set {p1, p2, p3}.
I tried to feed R tha above formula, R errors with:
2006 May 17
1
Re : Large database help
...rged, so anyone
> considering further explorations with it may need training in
> Rchaeology.
A few hours ago I submitted to CRAN a package "biglm" that does large
linear regression models using a similar strategy (it uses incremental
QR decomposition rather than accumalating the crossproduct matrix). It
also computes the Huber/White sandwich variance estimate in the same
single pass over the data.
Assuming I haven't messed up the package checking it will appear in the
next couple of day on CRAN. The syntax looks like
a <- biglm(log(Volume) ~ log(Girth) + log(Height), chunk1)...
2005 Oct 06
3
Singular matrix
Dear All,
I have written the following programs to find a non-singular (10*10) covariance matrix.
Here is the program:
nitems <- 10
x <- array(rnorm(5*nitems,3,3), c(5,nitems))
sigma <- t(x)%*%x
inverse <- try(solve(sigma), TRUE)
while(inherits(inverse, "try-error"))
{
x <- array(rnorm(5*nitems,3,3), c(5,nitems))
sigma <- t(x)%*%x
inverse <-
2002 Jul 16
2
R 1.5.1 on AIX 5.1
I'm trying to get R running on AIX 5.1 with the native AIX compilers, VisualAge C++
5.0.2.0 and XL Fortran Compiler 7.1.0.0. R compiled fine, but in running the test
cases, the base-Ex.R tests fail in the Choleski decomposition with the following:
> x <- matrix(c(1:5, (1:5)^2), 5, 2)
> m <- crossprod(x)
> Q <- chol(m)
Error in chol(m) : NA/NaN/Inf in foreign function call
2009 Jan 07
2
Understanding dsyrk_ in C code
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I'm trying to understand some C code in an R package I'm using. I'm address this question here as
it's matrix algebra...and I'm no pro at that!
the C command reads:
double alpha = 1.0, beta = 0.0;
dsyrk_("L", "N", nGenes, nGenes, & alpha, mat1, nGenes,
& beta, mat2, nGenes);
- From google,
2011 Aug 24
3
Efficient way to Calculate the squared distances for a set of vectors to a fixed vector
I am pretty new to R. So this may be an easy question for most of you.
?
I would like to calculate the squared distances of a large set (let's say 20000) of vectors (let's say dimension of 5) to a fixed vector.
?
Say I have a data frame MY_VECTORS with 20000 rows and 5 columns, and one 5x1 vector y. I would like to efficiently calculate the squared distances?between each of the 20000
2004 May 06
5
Orthogonal Polynomial Regression Parameter Estimation
Dear all,
Can any one tell me how can i perform Orthogonal
Polynomial Regression parameter estimation in R?
--------------------------------------------
Here is an "Orthogonal Polynomial" Regression problem
collected from Draper, Smith(1981), page 269. Note
that only value of alpha0 (intercept term) and signs
of each estimate match with the result obtained from
coef(orth.fit). What
2006 Oct 20
1
Translating lme code into lmer was: Mixed effect model in R
This question comes up periodically, probably enough to give it a proper
thread and maybe point to this thread for reference (similar to the
'conservative anova' thread not too long ago).
Moving from lme syntax, which is the function found in the nlme package,
to lmer syntax (found in lme4) is not too difficult. It is probably
useful to first explain what the differences are between the