search for: byrow

Displaying 20 results from an estimated 1248 matches for "byrow".

2004 Oct 29
1
[rmetasim] Need help deciphering this error msg... targeted to those who use rmetasim...
...<- new.landscape.empty() penguinland <- new.intparam.land(penguinland,h=2,s=3) penguinland <- new.floatparam.land(penguinland,s=0) penguinland <- new.switchparam.land(penguinland,mp=0) ## local matrices are 3x3 (or greater than 2x2) matrixR <- matrix( c(rep(0.2, 3*3)), ncol=3,nrow=3,byrow=TRUE ) matrixS <- matrix( c(rep(0.1, 3*3)), ncol=3,nrow=3,byrow=TRUE ) matrixM <- matrix( c(1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0), ncol=3,nrow=3,byrow=TRUE ) penguinland <- new.local.demo(penguinland,matrixR,matrixS,matrixM) matrixRR <- matrix( c(rep(0,6*6)), ncol=6,nrow=6,byrow...
2010 Jan 19
0
Macualay Duration code in a Functional Form - Please Help
...I have added following code after the function is defined i.e. after #return(data.frame(macaulay_duration, modified_duration)) #} # Added code ONS  = read.csv('instrument details.csv') n      = length(ONS$par_value) par_value      =  matrix(data = ONS$par_value, nrow = n, ncol = 1, byrow = TRUE) coupon_rate    =  matrix(data = ONS$coupon_rate, nrow = n, ncol = 1, byrow = TRUE) freq_coupon  =  matrix(data = ONS$frequency_copoun, nrow = n, ncol = 1, byrow = TRUE) tenure          =  matrix(data = ONS$tenure, nrow = n, ncol = 1, byrow = TRUE) ytm             =   matrix(data = ONS$ytm,...
2017 Sep 28
3
building random matrices from vectors of random parameters
Suppose I have interest in a matrix with the following symbolic structure (specified by 3 parameters: sa, so, m): matrix(c(0,sa*m,so,sa),2,2,byrow=T) What I can't figure out is how to construct a series of matrices, where the elements/parameters are rnorm values. I'd like to construct separate matrices, with each matrix in the series using the 'next random parameter value'. While the following works (for generating, say, 5...
2011 Oct 01
2
Entering data into a multi-way array?
Hello: I am a novice R user, but I have been working my way through the manuals / tutorials, ... I have R / Deducer up and running, and know the basics. I want to analyze a microarray (gene expression) dataset. I need to input the data into R as a multidimensional (multi-way) array, something on the order of 15,000 x 3 x 8 x 2 [genes x replicates x time points x treatments] I've
2017 Sep 20
1
How to use depmix for HMM with intial parameters
Hello, I have initial parameters for HMM model and I want to use depmixS4 package. The parameters are in the form intial_prob_matrix=matrix(c(0.07614213, 0.45177665, 0.47208122), nrow=1, ncol=3, byrow = TRUE) transition_matrix=matrix(c(0.46666667,0.46666667,0.06666667, 0.06741573,0.5617978,0.37078652, 0.02173913,0.3478261,0.63043478), nrow = 3, ncol = 3, byrow = TRUE) meanval_matrix=matrix(c(545.1737,545.1737,803.5235, 565.7763,...
2002 Feb 07
2
FW: layout and piechart diameter problem (PR#1300)
...representing the same information.) > > When I plot pie charts in a column, the piechart at the top of a column is > always smaller than the others: > > For example: > > layout( matrix(c(1,1,2, > 1,1,3, > 1,1,4), ncol=3, byrow=T)) > for(i in 1:4) piechart( 1:3 ) > > In column 3, the first piechart has a radius something like 2/3 of the > others. > > This also happens for: > > layout( matrix(c(1,2, > 1,3, > 1,4), ncol=2, byrow=T)) > for(i...
2010 May 22
2
Fast Matrix Computation
...and (p,n) respectively. I'd like to see if the is a fast way to compute a new matrix C with dimension (m*p,n) in which each row in C is found by applying some function f to each pair of rows (x,y) where x is a row in A and y is a row in B. For example, if A <- matrix(c(1, 2, 3, 4, 5, 6), byrow=TRUE, ncol=3) B <- matrix(c(7, 8, 9), byrow=TRUE, ncol=3) and f <- function(x,y) abs(y-x) then C <- matrix(c(6, 6, 6, 3, 3, 3), byrow=TRUE, ncol=3) Many thanks! Cheers, David
2012 Sep 26
1
Creating x*y different contigency tables
Dear all, I am trying to construct 25x31 different matrices of 2x2 dimension. Here is the problem: we have the following matrix matrix(c(54+s0, 43+s1, 56-s0, 67-s1), nrow=2, ncol=2, byrow=T) the values for s0 and s1 are c(0:24) and c(0:31), respectively. I wrote the following code without the desired results x<-0:24 y<-0:30 results<-array(matrix(0,nrow=2,ncol=2,byrow=T),dim=c(2,2,2...
2012 Aug 06
2
Splitting Data Into Different Series
...2-04-01","2012-05-01","2012-06-01", 0.56,0.45,0.21,0.64,0.36,0.08,152136,153081,155872,158356,162157,166226, 33.47,34.48,35.24,38.42,35.33,34.43,433,433,433,433,433,433,2005,2005,2005, 2005,2005,2005,3939,3939,3939,3939,3939,3939), nrow=18, ncol=3, byrow=FALSE, dimnames=list(c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18), c("date", "value", "code"))) dados433 <- matrix(data = NA, nrow = 6, ncol = 3, byrow= FALSE) dados2005 <- matrix(data = NA, nrow = 6, ncol = 3, byrow= FALSE) dados3939...
2017 Jul 05
4
expand gridded matrix to higher resolution
...re package than can do what we need already? I tried matrix with rep, but I am missing some magic there, since it doesn't do what we need. replicate might be promising, but then still need to rearrange the output into the column and row format we need. A simple example: mm=matrix(1:15,nrow=3,byrow = T) xmm=matrix(NA,nrow=nrow(mm)*3,ncol=ncol(mm)*3) for(icol in 1:ncol(mm)) { for(irow in 1:nrow(mm)) { xicol=(icol-1)*3 +c(1:3) xirow=(irow-1)*3 +c(1:3) xmm[xirow,xicol]=mm[irow,icol] } } mm > > mm > [,1] [,2] [,3] [,4] [,5] > [1,] 1 2 3 4 5 > [2,...
2011 Mar 01
2
Entering table with multiple columns & rows
...at I've typed in and errors that I am getting. Thank you. Laura Table trying to enter: Diet: Binger-yes: Binger-No: Total: None 24 134 158 Healthy 9 52 61 Unhealthy 23 72 95 Dangerous 12 15 27 > diet=matrix(c(24,134,9,52,23,72,12,15),ncol=4,byrow=TRUE) > rownames(diet)=c("none", "healthy", "unhealthy", "dangerous") Error in dimnames(x) <- dn : length of 'dimnames' [1] not equal to array extent > diet=matrix(c(24,134,9,52,23,72,12,15), ncol=4, byrow=4) > rownanes(diet)=c("non...
2005 Oct 07
1
Matrix calculations in R--erroneous?
Does anyone know how -log(x) can equal 743 but -log(x+0)=Inf? That's what the following stream of calculations suggest: Browse[2]> -log ( 1e-323+yMat2 - yMat1 * logitShape(matrix(parsList$Xs, nrow = numXs, ncol=numOfCurves), matrix(means, nrow = numXs, ncol=numOfCurves, byrow=TRUE), matrix(sigmas, nrow = numXs, ncol=numOfCurves, byrow=TRUE)) )[5,9] [1] Inf Yet: Browse[2]> logitShape(matrix(parsList$Xs, nrow = numXs, ncol=numOfCurves), matrix(means, nrow = numXs, ncol=numOfCurves, byrow=TRUE), matrix(sigmas, nrow = numXs, ncol=numOfCurves, byrow=TRUE))[5,9] [1] 1...
2011 Nov 27
1
generating a vector of y_t = \sum_{i = 1}^t (alpha^i * x_{t - i + 1})
...double(n) for(i in 1:n){ y[i] <- sum(cumprod(rep(alpha, i)) * rev(x[1:i])) } y } loopRec(c(1, 2, 3), 0.5) ## This is a crazy solution, but worth giving it a try. charRec <- function(x, alpha){ n <- length(x) exp.mat <- matrix(rep(x, each = n), nc = n, byrow = TRUE) up.mat <- matrix(eval(parse(text = paste("c(", paste(paste(paste("rep(0, ", 0:(n - 1), ")", sep = ""), paste("cumprod(rep(", alpha, ",", n:1, "))"...
2008 Jun 21
2
Generating groupings of ordered observations
...rship. We then cbind these matrices with the trivial partitions into 1 and 6 groups: mat2g <- matrix(c(1,1,1,1,1, 2,1,1,1,1, 2,2,1,1,1, 2,2,2,1,1, 2,2,2,2,1, 2,2,2,2,2), nrow = 6, ncol = 5, byrow = TRUE) mat3g <- matrix(c(1,1,1,1,1,1,1,1,1,1, 2,2,2,2,1,1,1,1,1,1, 3,2,2,2,2,2,2,1,1,1, 3,3,2,2,3,2,2,2,2,1, 3,3,3,2,3,3,2,3,2,2, 3,3,3,3,3,3,3,3,3,3), nrow = 6, ncol = 10, byrow = TRUE)...
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))) T0<- c(rep(NA,ncol(data))) cov_rank<-matrix(c(rep(NA,ncol(data)*...
2002 Apr 26
1
optim or nlm with matrices
...s but I kept receive the following massage: Error in A%*%x1 : non-conformable arguments. The massage appears even the -det() can be calculated and the dimensions are checked. here is my example although there might be no solution for the optimization problem. A=A myfn=function(A){ x=matrix(c(1.8,0),byrow=T) x1=matrix(c(.8,1.8),byrow=T) -det((t(x)-t(x1)%*%A)%*%(x-A%*%x1)) } A=matrix(c(1,.3,2,-1.2),byrow=T,nrow=2) optim(A,myfn) Another question regarding optimization: is there any chance that I can find a function or package that can do a constrained optimization such as: -det(x-A*x1-B*x2)' (x-A*...
2012 Dec 19
2
probability of binary data
Hi, how are you? I am trying to replicate the binary data f(2) function in the attached document by starting with the simple example found below: observed <- matrix(c(0, 1, 0, 0, 1, 1, 1, 0, 0),3,3,byrow=TRUE) data <- matrix(c(1, 1, 0, 0, 1, 0, 0, 0, 1),3,3,byrow=TRUE) f2 = sum(probability of the matrix element where the matrix element is present in both the observed and the data)/[sum(probability of the matrix element where the matrix element is present in both the observed and the data) + sum...
2004 Sep 30
2
pointsize in png graphics
...ot) and the other one consisting of 4 image plots and a color table. I'd like the color table to be exactly the same. The way I proceded is the following: for one plot and the color-table png(file = png.file, width = 650, height = 800, pointsize = 16) layout(matrix(c(1, 2), ncol = 2, nrow = 1, byrow = T), widths = c(6, 1), heights = 1) par(mar = c(0.2, 0.2, 0.2, 0.2), mgp = c(2, 1, 0), las = 0) ... dev.off() for 4 plots and the color-table png(file = png.file, width = 650, height = 800, pointsize = 16) layout(matrix(c(1, 2, 5, 3, 4, 5), ncol = 3, nrow = 2, byrow = T), widths = c...
2007 Sep 04
3
variable format
...c(1, "New England", 2, "Middle Atlantic", 3, "East North Central", 4, "West North Central", 5, "South Atlantic"), ncol=2, byrow=T) a$divisionNew[match(a$divisionOld, divisionTable[,1])] <- divisionTable[,2] But how do I handle the case where... a$divisionOld <- c(0,1,2,3,4,5) #no format available for 0, this throws an error. OR divisionTable <- matrix(c(1, "New England", 2, &...
2013 Mar 18
2
Loop or some other way to parse by data generated values when it is not linear
...example, though in reality I am looking at about 10 different variables that I am crossing so the values of X1 and X2 change. X1 and X2 are place holders. Here's the dataset (though using this first part does not happen in reality): X1 <- matrix(c(0, 1, 2, 3, 4, 99), nrow=18, ncol=1, byrow=T) X2 <- sort(matrix(c(0, 2, 4), nrow=18, ncol=1, byrow=T), decreasing=F) Y <- matrix(c(83, 107, 47, 27, 38, 1, 12 ,25, 14, 4, 9, 0, 14, 27, 28, 13, 18, 0), nrow=18, ncol=1, byrow=T) tmp.n <- data.frame(X1, X2, Y) The final data frame is what I actually get: X1 X2 Y 1 0 0 83...