similar to: Multiply each column of array by vector component

Displaying 20 results from an estimated 7000 matches similar to: "Multiply each column of array by vector component"

2007 Oct 16
2
How to speed up multiple for loop over list of data frames
Hi there, I have a multiple for loop over a list of data frames for ( i in 1:(N-1) ) { for ( j in (i+1):N ) { for ( p in 1:M ) { v_i[p] = alist[[p]][i,"v"] v_j[p] = alist[[p]][j,"v"] } rho_s = cor(v_i, v_j, method = "spearman") rho_p = cor(v_i, v_j, method = "pearson"
2007 Nov 20
2
Plotting Non Numeric Data
Hi, Is there a way to plot non numerical data in R? Specifically, I have an array, say with 1000 entries, where each entry is a string of 4 characters (in any order, 24 possibilities in my case). I would like on the y-axis all the strings that are in the array as labels. The x-axis I would like labeled 0 to 1000. The line is to show how the strings change as we move through the array.
2006 Oct 03
1
Summation in R
Hello! Maybe this is a trivial question as I'm still a new baby in R but I wish that u will help me. I want to calculate the following U= sum (t_j*v_j) where t_j is a vector and v_j is the matrix Thanks Dina
2003 Apr 02
2
lme parameterization question
Hi, I am trying to parameterize the following mixed model (following Piepho and Ogutu 2002), to test for a trend over time, using multiple sites: y[ij]=mu+b[j]+a[i]+w[j]*(beta +t[i])+c[ij] where: y[ij]= a response variable at site i and year j mu = fixed intercept Beta=fixed slope w[j]=constant representing the jth year (covariate) b[j]=random effect of jth year, iid N(0,sigma2[b]) a[i]=random
2001 May 19
2
calculations on diagonals of a matrix
Given an nxm matrix A I want to compute the nxm matrix B whose ij-th element is the sum of the elements of A lying on the diagonal that ends with element ij, i.e., b_ij = a_ij + a_(i-1)(j-1) + a_(i-2)(j-2) + ... In APL (which I no longer use), I would use the 'rotate' operator to derive an array whose columns are diagonals of the given array and then cumulate down columns. Is
2002 Sep 12
1
Problem with indexing
Dear List I am having a bit of a problem getting a program to work. For each of i=1 to n persons I have a matrix (different for each person) with m rows. What I want to do, is create m new data sets such that the first is made up of the first row for each person from the original matrices, the second contains the second row for each person from the original matrices etc etc up to the mth
2011 Apr 19
2
Data frame with 3 columns to matrix
Dear R Users, Lets assume I have this data frame: x y z 1 1.00 5 0.5 2 1.02 5 0.7 3 1.04 7 0.1 4 1.06 9 0.4 x and y columns are sorted and the values not necessarily integers. z values are not sorted. Now I would like to create a matrix out of this with x as first column values and y as first row values. Matrix element a_11 shall be left NA. The a_ij should have the z value for the
2010 Feb 23
1
function on all pairs of vector entries
Hello all, Is there a way in R to compute the multivariate normal density of every pair of entries in a vector efficiently instead of using for loop? For example Suppose I have a vector a=c(v_1,...,v_p)=c(0.5343909, -0.7784353, -0.0568370, 1.8772838, -1.3183407, 0.8227418,...) I want to compute density(v_i, v_j) for every pair of entries (i,j) (i!=j) in a. The joint bivariate distribution
2010 Sep 21
1
Creating table from data frame
Hey, I have a dataset where two columns are factors and another column consists of values. Each combination of factors can only have a single value assigned to it. I'd like to represent this as a matrix or table where the rows are the first column factors and the columns the second column factors. So that each cell a_ij in the matrix represents the associated value for the factor combination
2010 Mar 04
2
smbclient queue and cancel commands not working
Hi, I'm trying to manage printer queues on a XP box in the lan. Other client commands work well, even echo "test" | smbclient //XPBOX/PRINTER -c "print -" works as expected and starts a print job. But either queue and cancel don't work, without debug flags with no errors. Cancel even says job is deleted. With -d4 I see # smbclient -d3 //volker/HPDJ1120C -U admin
2010 Aug 05
2
Multiply each depth level of an array with another vector element
Suppose x <- array(c(1,1,1,1,2,2,2,2), dim = c(2,2,2)) y <- c(5, 10) Now I would like to multiply x[, , 1] with y[1] and x[, , 2] with y[2]. Possible solution is a for-loop: for (i in 1:2) { x[, , i] * y[i] } Another possible solution is this construction: as.vector(t(replicate(nrow(x) * ncol(x), y))) * x I find that these two solutions have a relatively large computation
2008 Mar 15
2
Please find the error in my code
hello everybody I use the following code for my programming & it runs with the error as specified below.Any help that would disolve the error will be highly appreciated. Thanks in advance my code looks like this #### R programme for simulating the power of the two sample t test vs various #### non-parametric alternatives sim.size <- 200 sample.size <- 10 set.seed(231) mu1 <- 0 delta
2004 Nov 16
1
Pairwise Distances -- How to vectorize the loop
R-List, I'm trying to compute pairwise distances among pairs of observations, which each pair containing data from 2 groups. There are more than 100000 unique pairs. I have programmed a distance function that has three parameters, a vector of covariates from the ith observation in Group 1, a vector of covarites from the jth observation in Group 2, and a weighting matrix. I have used
2006 Oct 02
1
multilevel factor model in lmer
Hello -- I am curious if lmer can be used to fit a multilevel factor model such as a two-parameter item response model. The one parameter model is straightforward. A two-factor model requires a set of factor loadings multiplying a single random effect. For example, a logit model for the ith subject responding correctly to the jth item (j=1,..,J) is logit[p(ij)] = a1*item1(i) + ... + aJ *
2007 Oct 29
1
How to test combined effects?
Suppose I have a mixed-effects model where yij is the jth sample for the ith subject: yij= beta0 + beta1(age) + beta2(age^2) + beta3(age^3) + beta4(IQ) + beta5(IQ^2) + beta6(age*IQ) + beta7(age^2*IQ) + beta8(age^3 *IQ) +random intercepti + eij In R how can I get an F test against the null hypothesis of beta6=beta7=beta8=0? In SAS I can run something like contrast age*IQ 1,
2012 Dec 06
1
Vectorizing integrate()
I have written a program to solve a particular logistic regression problem using IRLS. In one step, I need to integrate something out of the linear predictor. The way I'm doing it now is within a loop and it is as you would expect slow to process, especially inside an iterative algorithm. I'm hoping there is a way this can be vectorized, but I have not found it so far. The portion of code
2007 Feb 28
1
Efficient way to repeat rows (or columns) of a matrix?
Hi. If I have a vector, v_1, and another vector of positive integers, i_1, the same length as v_1, then rep(v_1,i_1) will repeat v_i[j] exactly i_1[j] times, like so: >rep(c(1,2,3),c(3,2,1)) [1] 1 1 1 2 2 3 > I'd like to do the same sort of thing where I replace v_1 with a matrix, and the jth row of the matrix is repeated i_1 times. Obviously, I could do this with for loops, like
2003 Dec 17
1
Accessing row and col names of SEXP objects
Can someone lend me a hand with extracting the dimnames from a SEXP? I've looked through R-exts, but I couldn't find an example. Here is the code I'm using to grab the jth column name and print it, but the colnames I'm getting are garbage. None of the following are working. void printInfo(SEXP ts) { int j; for (j=0; j<col; j++) {
2010 May 04
1
All possible paths between two nodes in a flowgraph using igraphs?
Hi all Is there any systematic way to compute all possible paths, first-order loops and j-th order loops between two given nodes in a flowgraph (directed graph with cycles) - preferably using the igraph library in R? I have checked the igraph documentation but I can't figure out any direct and systematic way to do so. Any ideas? I use the following definitions from Butler, R. and A.
2013 Apr 01
1
Parameter Estimation in R with Sums and Lagged Variables
Hi guys, I am afraid I am stuck with an estimation problem. I have two variables, X and Y. Y is explained by the weighted sum of n lagged values of X. My aim is to estimate the two parameters c(alpha0,alpha1) in: Yt = Sum from j=1 to n of ( ( alpha0 + alpha1 * j ) * Xt-j ) Where Xt-j denotes the jth lag of X. I came up with this approach because I thought it would be a good idea to estimate