similar to: Multiplying a list of matrices with a vector

Displaying 20 results from an estimated 4000 matches similar to: "Multiplying a list of matrices with a vector"

2011 May 30
2
Group by multiple variables
Hello, I would like to create a group variable that is based on the values of three variables: For example, > dat <- data.frame(A=c(1,1,1,1,1,2,2,2,2,2), B=c(1,1,1,5,5,5,9,9,9,9), C=c(1,1,1,1,1,2,2,7,7,7)) > dat A B C 1 1 1 1 2 1 1 1 3 1 1 1 4 1 5 1 5 1 5 1 6 2 5 2 7 2 9 2 8 2 9 7 9 2 9 7 10 2 9 7 All rows that that are
2010 Aug 11
4
Arbitrary number of covariates in a formula
Hello! I have something like this: test1 <- data.frame(intx=c(4,3,1,1,2,2,3), status=c(1,1,1,0,1,1,0), x1=c(0,2,1,1,1,0,0), x2=c(1,1,0,0,2,2,0), sex=c(0,0,0,0,1,1,1)) and I can easily fit a cox model: library(survival) coxph(Surv(intx,status) ~ x1 + x2 + strata(sex),test1) However, I want to
2006 Oct 19
5
write data to pdf
Hello! Is there a possibility in R to save data in pdf-format? I do not want to save a plot but some lines of simple text. Regards, Franco Mendolia
2006 Aug 02
2
tcl/tk bind destroy event
Hello! I want to create a messagebox whenever the user wants to destroy the window (e.g. <Alt-F4> or the 'x' in the right top corner) and ask if a modified file should be saved or not. If 'cancel' is chosen then nothing should happen and the windows still should be existing. This doesn't work. When I press cancel the window will be destroyed although. I also
2010 Aug 31
1
Q about package Icens: change the color of the shading in plot function
Hello! I want to use the Icens package for analyzing interval-censored data. This code from the manual gives me what I want. library(Icens) data(cosmesis) csub1 <- subset(cosmesis, subset=Trt==0, select=c(L,R)) e1 <- VEM(csub1) plot(e1) However, I would like to change the color of the shading from green to something less green, say gray. Any ideas how I could do that? I looked at par, but
2005 Jun 15
2
need help on computing double summation
Dear helpers in this forum, This is a clarified version of my previous questions in this forum. I really need your generous help on this issue. > Suppose I have the following data set: > > id x y > 023 1 2 > 023 2 5 > 023 4 6 > 023 5 7 > 412 2 5 > 412 3 4 > 412 4 6 > 412 7 9 > 220 5 7 > 220 4 8 > 220 9 8 > ...... > Now I want to compute the
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
2003 Jul 18
2
create a vector looping over a frame
Hello, I have a data.frame > names(popA) [1] "Year" "Series" "Age" "WM" "WF" "HM" "HF" "BM" [9] "BF" "IM" "IF" "AM" "AF" "Yr" how do i loop over a subset of variables in this frame to create a vector of
2007 Mar 30
1
Using split() several times in a row?
Hi, fellow R users. I have a question about sapply and split combination. I have a big dataframe (40000 observations, 21 variables). First variable (factor) is "date" and it is in format "8.29.97", that is, I have monthly data. Second variable (also factor) has levels 1 to 6 (fractiles 1 to 5 and missing value with code 6). The other 19 variables are numeric. For each month I
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
2003 Feb 27
2
PRESS again
Sorry for the repeat. The PRESS statistic is defined as sum(y-yhat(i))^2, where yhat(i) denotes the ith predicted value using all the data except the ith case (as used typically in linear models). Thanks again Jacob Jacob L van Wyk Department of Mathematics and Statistics Rand Afrikaans University P O Box 524 Auckland Park 2006 South Africa Tel: +27-11-489-3080 Fax: +27-11-489-2832
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
2008 Sep 16
1
Car.proper C[] matrix
I am hoping someone can help translate some WinBUGS code into R code. I would like to use R to create the C[] matrix required for a car.proper model in WinBUGS, but I am having a difficult time negotiating the coding. The C matrix provides normalized weights for each pair of spatial areas. So the WinBUGS example is as follows: # of the weight matrix with elements Cij. The first J1 elements
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 *
2002 Sep 03
1
matrices and arrays loose dimension after multiplying with scalar (PR#1979)
A matrix or array with one of its dimensions having zero elements looses its dimension after multiplying with scalar. Admittedly this is an extreme case, however it DOES make sense to retain an objects formal structure after multiplying with a scalar, as e.g. a matrix with zero rows IS a legal object in S. BTW, the prototype does retain the dimension. Best Jens Oehlschlägel # replication code
2010 Jan 17
6
More than on loop??
hello every one, How to function more than one loop in R? I have the following problem to be solved with the a method of three loops, can you help me please? The data is attached with this message. The data is composed of two parts, cleaved (denoted by ?cleaved?) and non cleaved (denoted by ?noncleaved?). ? to access to the ith peptide, you can use X$Peptide[i] ? to access to the ith label,
2012 Aug 29
1
Help on not matching object lengths
Dear All   I have the following code set up: Code #1 a <-matrix(seq(0,8, by = sign(8-0)*0.25)) b <-matrix(seq(8,16, by = sign(16-8)*0.25)) c <-runif(1000,50,60) d <-exp(-c*a)+exp(-c*b)   This will give me the obvious error message of lengths not matching. What I am trying to do here is to have 33 rows x 1000 columns d values calculated in total. As an eaxmple for visual, this is what
2012 Dec 15
3
How to speed up the for loop by releasing memeory
Dear list; How can I speed up the run of following code (illustrative) #======================================================================== con<-vector("numeric") for (i in 1:limit) { if(matched data for the ith item found) { if(i==1) {con<-RowOfMatchedData } else {con<-rbind(con,matchedData)} } }
2010 Nov 14
2
replace a row in a matrix
Dear all, I created a n*2 matrix and I want to replace the ith row with a vector. Can anyone suggest me what is the simple way to do it? Sorry for bothering you with such simple question. I appreciate any hints or advice. Thanks in advance. Cassie [[alternative HTML version deleted]]
2017 Jul 23
4
matching element of a vector to i-2nd element
I have a df with a vector v. For each element of the vector, I want to know whether the i-2nd element is the same as the ith element. For example: given v=c(A,C,D,C) the result should be: FALSE,FALSE,FALSE,TRUE. I attempted something using indexing in a for loop such as (bad, incorrect example): for (i in v){ if [i]==[i-2] print T else print F } However, this is obviously wrong. Can someone