Displaying 20 results from an estimated 1000 matches similar to: "bug in crossprod? (PR#4092)"
2012 Feb 13
2
Error in apply(x2, 1, diff) : dim(X) must have a positive length
Anyone knows hat might be the cause of this error? Thanks for any help!
>library(MASS)
> dif.mns = function(x2,tr1=.2,tr2=.3){
+ #generates four different 'means' using
+ #difference scores from x2, an n x 2 matrix
+ #for use w/ bootstrap comparisons
+ diffs = apply(x2,1,diff)
+ mn1=mean(diffs)
+ mn2=mean(diffs,tr=.2)
+ mn3=mean(diffs,tr=.3)
+
2006 Nov 21
1
crossprod(x) vs crossprod(x,x)
I found out the other day that crossprod() will take a single matrix
argument;
crossprod(x) notionally returns crossprod(x,x).
The two forms do not return identical matrices:
x <- matrix(rnorm(3000000),ncol=3)
M1 <- crossprod(x)
M2 <- crossprod(x,x)
R> max(abs(M1-M2))
[1] 1.932494e-08
But what really surprised me is that crossprod(x) is slower than
crossprod(x,x):
R>
2002 Mar 15
1
Thought on crossprod
Hi everyone,
I do a lot of work with large variance matrices, and I like to use
"crossprod" for speed and to keep everything symmetric, i.e. I often
compute "crossprod(Q %*% t(A))" for "A %*% Sigma %*% t(A)", where
"Sigma" decomposes as "t(Q) %*% Q". I notice in the code that
"crossprod", current definition
> crossprod
function (x,
2005 Oct 05
2
eliminate t() and %*% using crossprod() and solve(A,b)
Hi
I have a square matrix Ainv of size N-by-N where N ~ 1000
I have a rectangular matrix H of size N by n where n ~ 4.
I have a vector d of length N.
I need X = solve(t(H) %*% Ainv %*% H) %*% t(H) %*% Ainv %*% d
and
H %*% X.
It is possible to rewrite X in the recommended crossprod way:
X <- solve(quad.form(Ainv, H), crossprod(crossprod(Ainv, H), d))
where quad.form() is a little
2003 Oct 17
2
Problems with crossprod
Dear R-users,
I found a strange problem
working with products of two matrices, say:
a <- A[i, ] ; crossprod(a)
where i is a set of integers selecting rows. When i is empty
the result is in a sense random.
After some trials the right answer
(a matrix of zeros) appears.
--------------- Illustration --------------------
R : Copyright 2003, The R Development Core Team
Version 1.8.0
2008 Mar 10
1
crossprod is slower than t(AA)%*BB
Dear Rdevelopers
The background for this email is that I was helping a PhD student to
improve the speed of her R code. I suggested to replace calls like
t(AA)%*% BB by crossprod(AA,BB) since I expected this to be faster. The
surprising result to me was that this change actually made her code
slower.
> ## Examples :
>
> AA <- matrix(rnorm(3000*1000),3000,1000)
> BB <-
2005 Jan 27
3
the incredible lightness of crossprod
The following is at least as much out of intellectual curiosity
as for practical reasons.
On reviewing some code written by novices to R, I came
across:
crossprod(x, y)[1,1]
I thought, "That isn't a very S way of saying that, I wonder
what the penalty is for using 'crossprod'." To my surprise the
penalty was substantially negative. Handily the client had S-PLUS
as
2004 Oct 06
3
crossprod vs %*% timing
Hi
the manpage says that crossprod(x,y) is formally equivalent to, but
faster than, the call 't(x) %*% y'.
I have a vector 'a' and a matrix 'A', and need to evaluate 't(a) %*% A
%*% a' many many times, and performance is becoming crucial. With
f1 <- function(a,X){ ignore <- t(a) %*% X %*% a }
f2 <- function(a,X){ ignore <-
2002 Jul 14
1
crossprod and X %*% t(X)
hi,
the help page for crossprod states that crossprod(A,B) is faster than
t(A) %*% B; experimentation certainly bears this out. more alarming
is the evidence that crossprod(t(A), B) is faster than A %*% B:
on a PII laptop, 128MB memory, win98, R-1.5.0.-patched precompiled
(no ATLAS):
> A <- matrix(rnorm(250000),500,500)
> B <- matrix(rnorm(250000),500,500)
> for (i in 1:5) {
2018 Apr 27
5
predict.glm returns different results for the same model
Hi all,
Very surprising (to me!) and mystifying result from predict.glm(): the
predictions vary depending on whether or not I use ns() or
splines::ns(). Reprex follows:
library(splines)
set.seed(12345)
dat <- data.frame(claim = rbinom(1000, 1, 0.5))
mns <- c(3.4, 3.6)
sds <- c(0.24, 0.35)
dat$wind <- exp(rnorm(nrow(dat), mean = mns[dat$claim + 1], sd =
sds[dat$claim + 1]))
dat <-
2003 May 23
2
predict.smooth.spline
I'm using R 1.7.0 on linux. With this version of R the package modreg is
automatically loaded at start of session. However attempting to use
predict.smooth.spline() produces Error: couldn't find function
predict.smooth.spline.
The function smooth.spline() is OK. What am I missing?
======================================
I.White
ICAPB, University of Edinburgh
Ashworth Laboratories, West
2013 Mar 05
1
crossprod(): g77 versus gfortran
Hi
I've got two builds of R, one using g77 (version 3.4.6) and the other
using gfortran (version 4.1.2). The two builds are otherwise identical
as far as I can tell. The one which used g77 performs crossprod()s
roughly twice as fast as the gfortran one. I'm wondering if this rings a
bell with anyone, and if so, are you aware of any configure settings
which will improve the performance
2005 Feb 10
1
Failure of update.packages()
Can anyone explain why with latest version of R (2.0.1) on FC3, installed
from R-2.0.1-0.fdr.2.fc3.i386.rpm, update.packages() produces the message
/usr/lib/R/bin/Rcmd exec: INSTALL: not found.
Indeed /usr/lib/R/bin seems to lack various shell scripts (INSTALL,
REMOVE, etc).
======================================
I.White
University of Edinburgh
Ashworth Laboratories, West Mains Road
Edinburgh
2005 Oct 18
3
CAPI - displaying individual MSN
Hi,
I'm currently using chan_capi-cm-0.6, with the following capi.conf:
[general]
nationalprefix=0
internationalprefix=00
rxgain=0.8
txgain=0.8
language=de
[ISDN1]
msn=8304490
incomingmsn=8304490
isdnmode=msn
group=1
controller=1
softdtmf=1
context=demo
echosquelch=1
echocancel=yes
echotail=64
callgroup=1
devices=2
Each user has a different numer, e.g. 83044910, 83044911, 83044912 and
so
2004 Sep 20
4
Multiple operations on list
Hello,
suppose I have a list with matrices:
a=list(x1=matrix(rnorm(10),5,2),x2=matrix(rnorm(10),5,2),x3=matrix(rnorm(10),5,2))
I want to compute for all combination of xi and xj (x1,x2 x1,x3 and x2,x3)
a value.
This value is given for the pair x1,x2 by trace(x1%*%t(x1)%*%x2%*%t(x2)) /
trace(x1%*%t(x1))*trace(x2%*%t(x2))
I know that product matrices t(xi)%*%xi can be obtained by:
2003 May 08
2
natural splines
Apologies if this is this too obscure for R-help.
In package splines, ns(x,,knots,intercept=TRUE) produces an n by K+2
matrix N, the values of K+2 basis functions for the natural splines with K
(internal) knots, evaluated at x. It does this by first generating an
n by K+4 matrix B of unconstrained splines, then postmultiplying B by
H, a K+4 by K+2 representation of the nullspace of C (2 by K+4),
2002 Aug 22
1
aov bug? (PR#1930)
R : Copyright 2001, The R Development Core Team
Version 1.4.0 (2001-12-19)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type `license()' or `licence()' for distribution details.
R is a collaborative project with many contributors.
Type `contributors()' for more information.
Type `demo()' for some demos,
2015 Mar 19
6
RFC: Matrix package: Matrix products (%*%, crossprod, tcrossprod) involving "nsparseMatrix" aka sparse pattern matrices
This is a Request For Comment, also BCCed to 390 package maintainers
of reverse dependencies of the Matrix package.
Most users and package authors working with our 'Matrix' package will
be using it for numerical computations, and so will be using
"dMatrix" (d : double precision) matrix objects M, and indirectly, e.g., for
M >= c will also use "lMatrix" (l:
2010 Apr 08
1
Placing the ≥ symbol in the Trellis custom strip
Hello,
I am trying to use ≥ symbol in the Trellis custom strip. The ascii ALT Key
for this symbol is 242. However, when I try "\242 90 kg" I get the ¢ symbol
in the trellis custom strip. Can some one kindly help me?
Thanking you in advance,
MNS
[[alternative HTML version deleted]]
2010 Jul 16
1
Toggle between the various pages for multi-page figures
Hello,
I am a new R user having transitioned over from S-plus recently. I have a
question that is probably very trivial but I am having trouble finding a
solution. In S-plus, graphic pages are created as tabs when multi-page
figures are created. I have shown the R code for xpose.VPC (a function
within library xpose4 for R) where I want the figure from each Strata (STRT)
to displayed on a