[R] rank of Matrix
Carson Farmer
carson.farmer at gmail.com
Fri Apr 1 02:23:03 CEST 2011
Hmm, looks like I'm 'answering' my own question here...
library(Matrix)
data(KNex)
mm <- KNex$mm
str(mmQR <- qr(mm))
# new stuff:
R <- mmQR at R
Rdiag <- diag(R)
rank <- sum(Rdiag > max(dim(mm))*.Machine$double.eps*abs(R[1,1])) #
this is the matlab default I think?
# 712
for comparison, rankMatrix from package Matrix gives the same answer,
but takes considerably more time and memory!
rankMatrix(mm)
# 712
Does the above make sense to others? Alternatively, is it possible to
derive rank from the model itself (I can't see how)?
library(MatrixModels)
trial <- data.frame(counts=c(18,17,15,20,10,20,25,13,12),
outcome=gl(3,1,9,labels=LETTERS[1:3]),
treatment=gl(3,3,labels=letters[1:3]))
glmS <- glm4(counts ~ 0+outcome + treatment, family=poisson, data=trial,
verbose = TRUE, sparse = TRUE)
str(glmS)
--
Carson J. Q. Farmer
ISSP Doctoral Fellow
National Centre for Geocomputation
National University of Ireland, Maynooth,
http://www.carsonfarmer.com/
More information about the R-help
mailing list