Create a random matrix with full rank [closed] - r

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
For one of my projects I would like to create several random matrices, which have full rank. Does anybody know a quick way to do this in R or has an idea how to proceed?

You are overwhelmingly likely to get a full-rank matrix if you generate a matrix with iid elements, with no additional constraints:
library(Matrix)
set.seed(101)
r <- replicate(1000,rankMatrix(matrix(rnorm(10000),100)))
table(r) ## all values are equal to 100
(Someone who spent more time on the math might be able to prove that the set of reduced-rank matrices within this space of matrices actually has measure 0 ...)

Related

multiplication R without float [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
is there a way to do the multiplication with a float in a serie sof two multiplications with integers. I would need to write a function which accepts as input values such as
3.4556546e-8
1.3
0.134435
Instead of doing 100*0.134435 it would do
100/1000000
and then multiply with
134435
the function should as output just give 1000000 and 134435 - it is just needed because i need to work with some very large numbers in big integers and mutipliying with anythign except for intgers doent work
Apparently you want to do arbitrary precision arithmetics. You don't need to reinvent the wheel.
library(gmp)
x <- as.bigq(0.134435)
100 * x
#Big Rational ('bigq') :
# [1] 121088283181110525/9007199254740992

how to select all but certain rows in matrix in r? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Is there an easy way to do this in r with a matrix, similar to negative indexing for data.frames?
for example, I can remove the n-th row of the matrix mat as follows:
mat = rbind(mat[1:(n-1),],mat[(n+1):nrow(mat)])
but are there faster and/or simpler ways to do this?
-Paul
Negative indexing works for matrices, i.e. mat[-n,]

R Text Mining and Random Forest [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am working on a data set that has a bunch of raw text that I am vectorizing and using in my matrix for a random forest regression. My question is, should I be treating each word as a .factor or a .numeric if it is a sparse matrix? Which one speed up the computation time?
My understanding is that R matrices coerce factors to characters, so you're better off using numeric.
I'm not terribly familiar with RandomForest -- I have a general idea of what it does, but I'm not sure about the guts of its R implementation. If you need to give it a design matrix (for instance, how ANOVAs or GLMs work when you implement them by hand), you can try using the model.matrix function.

When Teaching R, how to avoid the possible confusion with the term ''variable''? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
In the R official docs, the term ''variable'' is used to describe two distinct things:
The name we give to any type of object with the <-operator or with assign
For instance, we could say that in a <- data.frame(0), a is a variable, i.e. a symbol that links that particular dataframe to it.
A vector or a factor, belonging or not to a structure like a matrix or a dataframe, and containing units of data which, we assume, can take any of several or many values.
In this case it's akin to the statistical version of the term, such as in ''random variable''.
So my question is the following:
How do I help students understand the difference between programmatic and statistical usage of the term variable when teaching R?
(thanks and credits to #Gregor who formulated it in a better way than I would.)

How do I normalize and denormalize data in R? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have data that contains 14 columns of predictors and 1 column of solution variable(y).
I wanted to know if there are any inbuilt functions to normalize and denormalize data in R.
Thank you.
normDataWithin of package {Rmisc} can be used: http://www.inside-r.org/packages/cran/Rmisc/docs/normDataWithin
Else following methods can be used:
(variable-mean)/sd . Following code can be used for a data.frame:
mydata$myNormalizedVar<-(mydata$myvar-mean(mydata$myvar))/sd(myvar)
log (log10), log2, and square root (sqrt)
Normal quantile normalization or normal quantile transformation. Try:
quantNorm = function(x){qnorm(rank(x,ties.method = "average")/(length(x)+1))}
hist(quantNorm(1:10000),100)

Resources