Displaying 20 results from an estimated 5112 matches for "ncols".
Did you mean:
ncol
2011 May 19
3
problem with optim()
Dear R-users,
I would like to maximize the function g above which depends on 4 parameters (2 vectors, 1 real number, and 1 matrix) using optim() and BFGS method. Here is my code:
# fonction to maximize
g=function(x)
{
x1 = x[1:ncol(X)]
x2 = x[(ncol(X)+1)]
x3 = matrix(x[(ncol(X)+2):(ncol(X)+1+ncol(X)*ncol(Y))],nrow=ncol(X),ncol=ncol(Y))
x4 = x[(ncol(X)+1+ncol(X)*ncol(Y)+1):length(x)]
2010 Apr 09
0
step function
Hello I am using the step function in order to do backward selection for a
linear model of 52 variables with the following commands:
object<-lm(vars[,1] ~ (vars[,2:(ncol(predictors)+1)]-1))
BackS<-step(object,direction="backward")
but it isn't dropping any if the variables in the model, but there are lots
of not significant variables as you can see here
>
2012 Feb 17
2
(subscript) logical subscript too long in using apply
Dear ALL
I have this function in R:
func_LN <- function(data){
med_ge <- matrix(c(rep(NA,nrow(data)*ncol(data))), nrow = nrow(data),
ncol=ncol(data), byrow=TRUE)
T <- matrix(c(rep(NA,length(n)*ncol(data))), nrow = length(n),
ncol=ncol(data), byrow=TRUE)
Tdiff<- matrix(c(rep(NA,length(n)*ncol(data))), nrow = length(n),
ncol=ncol(data), byrow=TRUE)
T1<- c(rep(NA,ncol(data)))
2008 Apr 05
2
Adding a Matrix Exponentiation Operator
...by squaring. Is there a way to cut down on the number of
copies I am making here (I am assuming that the lhs and rhs of matprod()
must be different instances).
Any feedback appreciated !
Thanks
Rory
<snip>
/* Convenience function */
static void copyMatrixData(SEXP a, SEXP b, int nrows, int ncols, int mode) {
for (int i=0; i < ncols; ++i)
for (int j=0; j < nrows; ++j)
REAL(b)[i * nrows + j] = REAL(a)[i * nrows + j];
}
SEXP do_matexp(SEXP call, SEXP op, SEXP args, SEXP rho)
{
int nrows, ncols;
SEXP matrix, tmp, dims, dims2;
SEXP x, y, x_, x__;
int i,j,e...
2010 Nov 10
2
Parallel code runs slower!
My parallel code is running slower than my non-parallel code! Can someone
pls advise what am I doing wrong here?
t and tTA are simple matrices of equal dimensions.
#NON PARALLEL CODE
nCols=ncol(t)
nRows=nrow(t)
tTA = matrix(nrow=nRows,ncol=nCols)
require(TTR)
system.time(
for (i in 1:nCols) {
x = t[,i]
xROC = ROC(x)
tTA[,i]=xROC
}
)
user system elapsed
123.24 0.07 123.47
# PARALLEL CODE
nCols=ncol(t)
nRows=nrow(t)
tTA = matrix(nrow=nRows,ncol=nCols)
require(doS...
2013 Feb 07
1
Merging data in arrays
Dear All,
Here is a hypothetical sample (sorry for the clumsy code):
A1 <- matrix(1:5, nrow=5, ncol=1)
A2 <- matrix(6:10, nrow=5, ncol=1)
A3 <- matrix(11:15, nrow=5, ncol=1)
A4 <- matrix(16:20, nrow=5, ncol=1)
A5 <- matrix(21:25, nrow=5, ncol=1)
A6 <- matrix(26:30, nrow=5, ncol=1)
B1 <- matrix(c(A1, A2, A3), nrow=5, ncol=3)
B2 <- matrix(c(A2, A3, A4), nrow=5, ncol=3)
B3
2012 Dec 08
5
How to efficiently compare each row in a matrix with each row in another matrix?
Dear expeRts,
I have two matrices A and B. They have the same number of columns but possibly different number of rows. I would like to compare each row of A with each row of B and check whether all entries in a row of A are less than or equal to all entries in a row of B. Here is a minimal working example:
A <- rbind(matrix(1:4, ncol=2, byrow=TRUE), c(6, 2)) # (3, 2) matrix
B <-
2010 Oct 13
1
(no subject)
Dear all,
I have just sent an email with my problem, but I think no one can see the red part, beacuse it is black. So, i am writing again the codes:
rm(list=ls()) #remove almost everything in the memory
set.seed(180185)
nsim <- 10
mresultx <- matrix(-99, nrow=1000, ncol=nsim)
mresultb <- matrix(-99, nrow=1000, ncol=nsim)
N <- 200
I <- 5
taus <- c(0.480:0.520)
h <-
2009 Apr 05
2
loop problem for extract coefficients
Dear R users,
I have problem with extracting coefficients from a
object. Here, X (predictor)and Y (response) are two matrix , I am regressing
X ( dimensions 10 x 20) on each of columns of Y[,1] (10 x 1) and want to
store the coefficient values. I have performed a Elastic Net regression and
I want to store the coeffcients in each iteration. I got an error message .
I do not
2010 Mar 27
1
R runs in a usual way, but simulations are not performed
Dear addresses, I need perform a batch of 10 000 simulations for each of
4 options considered. (The idea is to obtain the parameter estimates in
a heteroskedastic linear regression model - with additive or mixed
heteroskedasticity - via the Kenward-Roger small-sample adjusted
covariance matrix of disturbances). For this purpose I wrote an R
program which would capture all possible options (true
2012 Feb 04
1
RFC: Proposal to make NROW() and NCOL() slightly more general
The help has
> Description:
> 'nrow' and 'ncol' return the number of rows or columns present in 'x'.
> 'NCOL' and 'NROW' do the same treating a vector as 1-column matrix.
and
> x: a vector, array or data frame
I'm proposing to extend these two convenience functions
to also work ``correctly'' for generalized versions of
2010 Oct 13
4
loop
Dear all,
I am trying to run a loop in my codes, but the software returns an error: "subscript out of bounds"
I dont understand exactly why this is happenning. My codes are the following:
rm(list=ls()) #remove almost everything in the memory
set.seed(180185)
nsim <- 10
mresultx <- matrix(-99, nrow=1000, ncol=nsim)
mresultb <- matrix(-99, nrow=1000, ncol=nsim)
N
2012 Aug 10
2
Zoo object problem: Find the column name of a univariate zoo object
Hi everyone and Achim,
Achim, I appreciate your help about the function "NCOL". When I use
"NCOL" instead of "ncol", I can find out the number of columns (number of
time series) in the presence of only one time series (one variable, one
column).
Now I want to know how I can find out the column names of the zoo
objects? In case of more than one time series, the
2011 Dec 26
4
Other ways to lm() regression? (non-loop?)
Hi, I'm quite new to R (1 month full time use so far). I have to run loop
regressions VERY often in my work, so I would appreciate some new
methodology that I'm not considering.
#---------------------------------------------------------------------------------------------
y<-matrix(rnorm(100),ncol=10,nrow=10)
x<-matrix(rnorm(50),ncol=5,nrow=10)
#Suppose I want to run the
2009 Apr 11
2
who happenly read these two paper Mohsen Pourahmadi (biometrika1999, 2000)
http://biomet.oxfordjournals.org/cgi/reprint/86/3/677 biometrika1999
http://biomet.oxfordjournals.org/cgi/reprint/94/4/1006 biometrika2000
Hi All:
I just want to try some luck.
I am currenly working on my project,one part of my project is to
reanalysis the kenward cattle data by using the method in Mohsen's paper,but
I found I really can get the same or close output as he did,so,any
2017 Jul 05
4
expand gridded matrix to higher resolution
Hi all,
(if me email goes out as html, than my email client don't do as told, and I apologies already.)
We need to downscale climate data and therefore first need to expand the climate from 0.5deg to the higher resolution 10min, before we can add high resolution deviations. We basically need to have the original data at each gridcell replicated into 3x3 gridcells.
A simple for loop can do
2009 Jan 07
0
How-To extract data from a matrix of lists subject to a set of given constraints
My goal is to store the DWT coefficients from a number of time series in such a way to be able to extract subsets satisfying giben conditions.
I have defined the following 11 matrices whose x-axis represent time intervals and y-axis represent the number of time series:
MS <- 11 d1.mat <- matrix (data=list(), nrow=TotNumCycles, ncol=2^(MS-1))
d2.mat <- matrix (data=list(),
2010 Oct 07
3
quantile regression
Dear all,
I am a new user in r and I am facing some problems with the quantile regression specification. I have two matrix (mresultb and mresultx) with nrow=1000 and ncol=nsim, where I specify (let's say) nsim=10. Hence, the columns in my matrix represents each simulation of a determined variable. I need to regress each column of mresultb on mresultx. My codes are the following:
2001 Jan 03
1
memory trouble
I don't know whether this belongs to r-devel or rather r-help.
Under RW1.11 --nsize=8M --vsize=512M I could
n <- 500000
m <- 20
x <- matrix(rnorm(n*m), ncol=m, nrow=n)
gc()
> n <- 500000
> m <- 20
> x <- matrix(rnorm(n*m), ncol=m, nrow=n)
> gc()
free total (Mb)
Ncells 8190509 8388608 160
Vcells 57033698 67108864 512
# under RW1.20 --vanilla
2012 Dec 11
1
converting manual command to loop command
Dear useRs,
i have certain commands for some operations in R. They are good if you have a small dataset but my dataset, apart from what i used in the recent past, is prety large. I want to convert these massive sets of commands into a simple loop.
Your help is required on it
thanks in advance
eliza
kindly note:
"e" is matrix whose each column has to be executed into a distance vector