search for: vect

Displaying 20 results from an estimated 121 matches for "vect".

Did you mean: vec
2018 May 03
4
adding overall constraint in optim()
...This is giving me a headache. I?m trying to do a relatively simple optimization ? actually trying to approximate the output from the Excel Solver function but at roughly 1000x the speed. ? The optimization parameters look like this. The only trouble is that I want to add a constraint that sum(wgt.vect)=1, and I can?t figure out how to do that in optim. Mo.vect <- as.vector(tail(head(mo,i),1)) wgt.vect <- as.vector(tail(head(moWeightsMax,i),1)) cov.mat <- cov(tail(head(morets,i+12),12)) opt.fun <- function(wgt.vect) -sum(Mo.vect %*% wgt.vect) / (t(wgt.vect) %*% (c...
2006 Sep 04
3
Subsetting vectors based on condition
Hello, I have a question regarding subsetting of vectors. Here's an example of what I'm trying to do: vect.1 <- c(76,195, 290, 380) vect.2 <- c(63, 95, 133, 170, 215, 253, 285, 299, 325, 375) I would like to subset vect.2 so that it has the same length as vect.1, and its numbers are the first corresponging higher value compared to v...
2009 Aug 23
0
[LLVMdev] x86_64 darwin multilib gfortran testresults
...ps execution test FAIL: gfortran.dg/g77/intrinsic-unix-bessel.f -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions execution test FAIL: gfortran.dg/g77/intrinsic-unix-bessel.f -O3 -g execution test FAIL: gfortran.dg/g77/intrinsic-unix-bessel.f -Os execution test FAIL: gfortran.dg/vect/pr19049.f90 -O (test for excess errors) ERROR: gfortran.dg/vect/pr19049.f90 -O : error executing dg-final: no files matched glob pattern "pr19049.f90.[0-9][0-9][0-9][ti].vect" UNRESOLVED: gfortran.dg/vect/pr19049.f90 -O : error executing dg-final: no files matched glob pattern "p...
2003 Nov 14
7
Vector indices and minus sign
Hi, I got caught out by this behaviour in 1.8.0 and I wondered why this happens: I have a list of vectors and was using lapply and grep to remove matched elements that occur in only a subset of the elements of the list: locs <- lapply(locs, function(x){x[- grep("^x", x)]}) The problem is that where the grep finds no matches and hence returns a vector of length 0, all the elements o...
2008 Jun 09
1
Cross-validation in R
...onfused if the cv.glm generates new glm models for each simulation of if it uses the one provided? (3) is the cv.glm sampling using replacement = TRUE or not? Thanks in advance. LOT ***** cv.glm method glm0.dmi<-glm(DMI_kg~Sex+DOF+Avg_Nem+In_Wt) # Simulation for 50 re-samplings... perr1.vect<-vector() for (j in 1:50) { print(j) cv.dmi<-cv.glm(data.dmi, glm0.dmi, K = 10) perr1<-cv.dmi$delta[2] perr1.vect<-c(perr1.vect,perr1) } x11() hist(perr1.vect) mean(perr1.vect) sd(perr1.vect) ***** homemade method # Brute-force cross-validation. This should be simi...
2018 May 03
2
adding overall constraint in optim()
...a headache. I?m trying to do a relatively simple optimization ? actually trying to approximate the output from the Excel Solver function but at roughly 1000x the speed. ? >> >> The optimization parameters look like this. The only trouble is that I want to add a constraint that sum(wgt.vect)=1, and I can?t figure out how to do that in optim. >> >> Mo.vect <- as.vector(tail(head(mo,i),1)) >> wgt.vect <- as.vector(tail(head(moWeightsMax,i),1)) >> cov.mat <- cov(tail(head(morets,i+12),12)) >> opt.fun <- function(wgt.vect) -sum(Mo...
2012 Dec 11
1
Rprof causing R to crash
...6 seconds the second part causes RGui to immediately close with no error or warning. Any advice on how to get Rprof to work or how to speed up this code would be greatly appreciated. I'm using Windows 7 (which might be my problem) and R version 2.15.0. CalcMESS<-function(tiff.entry,pred.vect){ f<-sum(pred.vect<tiff.entry)/length(pred.vect)*100 if(is.na(f)) return(NA) if(f==0) return((tiff.entry-min(pred.vect))/(max(pred.vect)-min(pred.vect))*100) if(0<f & f<=50) return(2*f) if(50<=f & f<100)...
2018 May 06
1
adding overall constraint in optim()
Hi Michael, A few comments 1. To add the constraint sum(wgt.vect=1) you would use the method of Lagrange multipliers. What this means is that in addition to the w_i (the components of the weight variables) you would add an additional variable, call it lambda. Then you would modify your optim.fun() function to add the term lambda * (sum(wgt.vect - 1) 2....
2018 May 03
0
adding overall constraint in optim()
...giving me a headache. I?m trying to do a relatively simple optimization ? actually trying to approximate the output from the Excel Solver function but at roughly 1000x the speed. ? > > The optimization parameters look like this. The only trouble is that I want to add a constraint that sum(wgt.vect)=1, and I can?t figure out how to do that in optim. > > Mo.vect <- as.vector(tail(head(mo,i),1)) > wgt.vect <- as.vector(tail(head(moWeightsMax,i),1)) > cov.mat <- cov(tail(head(morets,i+12),12)) > opt.fun <- function(wgt.vect) -sum(Mo.vect %*% wgt.vec...
1999 Sep 02
1
count of factors
Hello, I was used to count how many times every factor is found the following way : (assuming 'vect' is a vector of factors) tapply(vect,vect,length) but recently I experienced weird results with this In fact, my command line was tapply(ORGMORE[[1]][vect],ORGMORE[[1]][vect],length) where - 'vect' is a vector of indices - 'ORGMORE[[1]]' is a slightly long vector of factors I...
2018 May 04
0
adding overall constraint in optim()
...ache. I?m trying to do a relatively simple optimization ? actually trying to approximate the output from the Excel Solver function but at roughly 1000x the speed. ? >>> >>> The optimization parameters look like this. The only trouble is that I want to add a constraint that sum(wgt.vect)=1, and I can?t figure out how to do that in optim. >>> >>> Mo.vect <- as.vector(tail(head(mo,i),1)) >>> wgt.vect <- as.vector(tail(head(moWeightsMax,i),1)) >>> cov.mat <- cov(tail(head(morets,i+12),12)) >>> opt.fun <- functio...
2009 Jan 19
2
[LLVMdev] llvm-gfortran test results
...ps execution test FAIL: gfortran.dg/g77/intrinsic-unix-bessel.f -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions execution test FAIL: gfortran.dg/g77/intrinsic-unix-bessel.f -O3 -g execution test FAIL: gfortran.dg/g77/intrinsic-unix-bessel.f -Os execution test FAIL: gfortran.dg/vect/pr19049.f90 -O (test for excess errors) ERROR: gfortran.dg/vect/pr19049.f90 -O : error executing dg-final: no files matched glob pattern "pr19049.f90.[0-9][0-9][0-9][ti].vect" UNRESOLVED: gfortran.dg/vect/pr19049.f90 -O : error executing dg-final: no files matched glob pattern "p...
2009 Apr 16
2
error bars in matplot
Hi, I was trying to get error bars in my matplot. I looked at an earlier thread, and the sample code that I made is: #------------------ library(plotrix) mat1 <- matrix(sample(1:30,10),nrow=5,ncol=2) ses <- matrix(sample(1:3,10,replace=T),nrow=5,ncol=2) vect <- seq(20,100,20) rownames(mat1) <- rownames(ses) <- vect colnames(mat1) <- colnames(ses) <- letters[1:2] matplot(mat1,pch=c('x','o'),type = "b",lwd = 2,lty = c(1,2), col = c("green","black"),cex.main = 1.8,cex=2,cex.lab=1.5, mai...
2011 Feb 13
6
From numeric vector to string vector
Hi there, I have a numeric vector let say: Vect <- c(12.234, 234.5675, 1.5) Now I want a string vector like: changedVec <- c("012.234", "234.568", "001.500") Would be grateful if somebody help me how can I do that. Thanks and regards, [[alternative HTML version deleted]]
2008 Nov 02
1
[LLVMdev] llvm-2.4 prerelease gfortran results
...ps execution test FAIL: gfortran.dg/g77/intrinsic-unix-bessel.f -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions execution test FAIL: gfortran.dg/g77/intrinsic-unix-bessel.f -O3 -g execution test FAIL: gfortran.dg/g77/intrinsic-unix-bessel.f -Os execution test FAIL: gfortran.dg/vect/pr19049.f90 -O (test for excess errors) ERROR: gfortran.dg/vect/pr19049.f90 -O : error executing dg-final: no files matched glob pattern "pr19049.f90.[0-9][0-9][0-9][ti].vect" UNRESOLVED: gfortran.dg/vect/pr19049.f90 -O : error executing dg-final: no files matched glob pattern "p...
2009 Aug 04
2
can a key of a list be a variable
...on to record data in dynamic structures in R. I have an algorithm that will be executed each step and whose output is an array of doubles with unknown size. The solution I found is to use lists 1) I initialise my list l <- list() 2) and at a step numbered i I conacatain the new tab to the list vect <- algorithm() l <<--c( l , list(stepi=vect)) The problem is that the key "stepi" is here a constant, I'd like to use a variable like this x = paste("step",index,sep="") where index is the last index (i) l <<--c( l , list(x=vect)) --> this doesn&...
2013 May 27
0
choose the lines
...na(dat1$evnmt_brutal),] fun1<- function(dat){??? ? ??? lst1<- split(dat,dat$patient_id) ??? lst2<- lapply(lst1,function(x) x[cumsum(x$evnmt_brutal==0)>0,]) ??? lst3<- lapply(lst2,function(x) x[!(all(x$evnmt_brutal==1)|all(x$evnmt_brutal==0)),]) ??? lst4<-lapply(lst3,function(x) {vect.brutal=c() ??? ??? ??? ??? for(line in which(x$evnmt_brutal==1)){ ??? ??? ??? ??? ?? if(x$evnmt_brutal[line-1]==0){ ??? ??? ??? ??? ? vect.brutal=c(vect.brutal,line) ??? ??? ??? ??? ??? } ??? ??? ??? ??? ??? ?? } ??? ??? ??? ????? vect.brutal1<- sort(c(vect.brutal,vect.brutal-1)) ??? ??? ??? ???...
2007 Aug 10
2
need help to manipulate function and time interval
...L <- L+10 and W <- 10^((L+10)/10) else L=L and W = W Could someone help me to realize this function please? You will find my following proposal code, but my main problem is to handle the time interval. Best regard ########################### myfunc <- function(mytab, Time, Level) { vect <- rep(0, length(mytab)) for(i in 1:length(vect)) { for(j in 1:length(Time)) if(time[j] is between 18:00:00 and 23:59:59) L[i] <- L[j]+5 vect[i] <- 10^((L[i])/10 if (time[j] is between 22:00:00 and 05:59:59) L[i] &...
2012 Mar 17
3
rtriang using ifelse statement
Hi All, I want to draw samples (n=4) from one of 2 triangular distributions for each value in a matrix. I am using an ifelse statement to try to define which distribution to draw from. >From the output, I can see that the ifelse statement is choosing the correct distribution, however, my n=4 simulations aren't occurring. Is there a way to adjust the ifelse statement to fix this, or must
2008 Jun 10
1
[LLVMdev] llvm-gcc4.2-2.3 gfortran failures
...s execution test FAIL: gfortran.dg/g77/intrinsic-unix-bessel.f -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions execution test FAIL: gfortran.dg/g77/intrinsic-unix-bessel.f -O3 -g execution test FAIL: gfortran.dg/g77/intrinsic-unix-bessel.f -Os execution test ERROR: gfortran.dg/vect/pr19049.f90 -O : error executing dg-final: no files matched glob pattern "pr19049.f90.[0-9][0-9][0-9]t.vect" UNRESOLVED: gfortran.dg/vect/pr19049.f90 -O : error executing dg-final: no files matched glob pattern "pr19049.f90.[0-9][0-9][0-9]t.vect" ERROR: gfortran.dg/vect/vect-1...