search for: z2

Displaying 20 results from an estimated 467 matches for "z2".

Did you mean: bz2
2006 Jul 08
2
String mathematical function to R-function
...nto function ( R function ). thanks for any tips. cleber #e.g. fun_String = "-100*x1 + 0*x2 + 100*x3" fun <- function(x1,x2,x3){ return( ############ evaluation( fun_String ) ############ ) True String mathematical function :-( :-( > nomes [1] "8.49*x1*z1 + 6.13*x1*z2 + 6.4*x1*z3 + 6.9*x2*z1 + 4.54*x2*z2 + 3.99*x2*z3 + 19.31*x3*z1 + 12.49*x3*z2 + 3.86*x3*z3 + 5.25*x1*z1*z2 + -6.2*x1*z1*z3 + 9.07*x1*z2*z3 + 10.87*x2*z1*z2 + 9.78*x2*z1*z3 + 49.05*x2*z2*z3 + 4.56*x1*x2*z1 + -4.9*x1*x2*z2 + 4.01*x1*x2*z3 + -0.39*x3*z1*z2 + 14.34*x3*z1*z3 + 0.7*x3*z2*z3 + -2.84*x1*x3...
2009 Nov 09
3
How to transform the Matrix into the way I want it ???
Hi, R users, I'm trying to transform a matrix A into B (see below). Anyone knows how to do it in R? Thanks. Matrix A (zone to zone travel time) zone z1 z2 z3 z1 0 2.9 4.3 z2 2.9 0 2.5 z3 4.3 2.5 0 B: from to time z1 z1 0 z1 z2 2.9 z1 z3 4.3 z2 z1 2.9 z2 z2 0 z2 z3 2.5 z3 z1 4.3 z3 z2 2.5 z3 z3 0 The real matrix I have is much larger, with more than 2000 zones. But I think it should be the same thing if I can transform A into B. Thanks. Garry...
2012 Aug 08
3
help, please! matrix operations inside 3 nested loops
....matrix(daten) #2) create empty matrix: indxind<-matrix(nrow=617, ncol=617) indxind[1:20,1:19] #3) compare cells to each other, score: for (s in 3:34) { #walks though the matrix colum by colum, starting at colum 3 for (z1 in 1:617) { #for each current colum, take one row (z1)... for (z2 in 1:617) { #...and compare it to another row (z2) of the current colum if (z1!=z2) {topf<-indxind[z1,z2] if (daten[2*z1-1,s]==daten[2*z2-1,s]) topf<-topf+1 #actually, 2 rows make up 1 individual, if (daten[2*z1-1,s]==daten[2*z2,s]) topf<-topf...
2011 Mar 29
5
Integration with variable bounds
If this is posted elsewhere I cannot find it. I need to perform multiple integration where some of the variables are in the bounds of the other variables. I was trying to use R2Cuba function but cannot set the upper and lower bounds. My code so far is : int <- function(y){ u2 = y[1] z2 = y[2] u1 =y[3] z1 = y[4] ff <- u1*(z1-u1)*u2*(z2-u2)*exp(-0.027*(12-z2)) return(ff) } cuhre(4,1,int,rel.tol=1e-3,lower=c(y[4],y[4],4,4),upper=c(12,y[4],12,y[2]),abs.tol= 1e-12,flags= list(verbose=2, final=0)) I know that code is wrong but it shows that variables are in both the upper and l...
2002 Mar 27
2
Error with nls
...- exp(p50) k56 <- exp(p56) k60 <- exp(p60) k65 <- exp(p65) c <- exp(pc) h <- exp(ph) d <- exp(pd) b50 <- exp(pb50) b60 <- exp(pb60) a <- (k50+k56) b <- k65 e <- k56 f <- (k60+k65) z1 <- (-(a+f)/2 - sqrt((a+f)^2/4 - a*f + b*e)) z2 <- (-(a+f)/2 + sqrt((a+f)^2/4 - a*f + b*e)) K <- ((z1+a)/(z2-z1)) B1 <- (b/(z2-z1)*b60 - K*b50) A1 <- (b50-B1) X1 <- (b*d/(z2-z1)-K*(c*b4i+h)) X2 <- (K*c*(b4i-b40)) X3 <- (c*b4i + h - X1) X4 <- (c*(b40-b4i)- X2) C1E <- (X3/(-z1)*(1-exp(z1*t)) + X4/(-(k4+...
2008 Oct 04
3
How to plot countours with fixted densities?
...structure with unit Frechet margins. Sigma <- matrix(c(1,.5*sqrt(1),.5*sqrt(1),1),2,2) # generate y <- mvrnorm(Nsam, c(0,0), Sigma) # random v <- cbind(pnorm(y[,1],mean = 0, sd = 1), pnorm(y[,2],mean = 0, sd = 1)) z <- cbind(-1/log(v[,1]),-1/log(v[,2])) z1 <- z[,1] z2 <- z[,2] And to get the scatter plot by: plot(z1,z2) How can I get the contour densities plots for (z1,z2) at 10^(-j/2) for j=2,...,9? Waiting for your reply!Many thanks! Xiao [[alternative HTML version deleted]]
2009 Dec 01
1
Multiple grouping on the X axis.
...of the kind of data I am working with and the desired output. We have a jmp script that can do the same thing, but at ~$200 a year the licensing is counterproductive. Thanks for any help. Data input: Loaded from a CSV file. Physical_1 Logical_1 Logical_2 Data_1 Data_2 x Y Z2 54 56 x Y2 Z2 53 55 x Y3 Z2 52 54 x2 Y Z 60 58 x2 Y2 Z 59 57 x2 Y3 Z 58 56 x3 Y...
2017 Jul 28
3
problem with "unique" function
I have the joint distribution of three discrete random variables z1, z2 and z3 which is captured by "z" and "prob" as described below. For example, the probability for z1=0.46667, z2=-1 and z3=-1 is 2.752e-13. Also, the probability adds up to 1. > head(z) z1 z2 z3 [1,] -0.46667 -1.0000 -1.0000 [2,] -0.33333 -0.9333 -0.9333 [...
2013 Oct 18
1
crr question‏ in library(cmprsk)
Hi all I do not understand why I am getting the following error message. Can anybody help me with this? Thanks in advance. install.packages("cmprsk") library(cmprsk) result1 <-crr(ftime, fstatus, cov1, failcode=1, cencode=0 ) one.pout1 = predict(result1,cov1,X=cbind(1,one.z1,one.z2)) predict.crr(result1,cov1,X=cbind(1,one.z1,one.z2)) Error: could not find function "predict.crr" [[alternative HTML version deleted]]
2006 Jun 15
3
matrix selection return types
Dear Rusers, I would like some comments about the following results (under R-2.2.0) > m = matrix(1:6 , 2 , 3) > m [,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 6 > z1 = m[(m[,1]==2),] > z1 [1] 2 4 6 > is.matrix(z1) [1] FALSE > z2 = m[(m[,1]==0),] > z2 [,1] [,2] [,3] > is.matrix(z2) [1] TRUE Considered together, I'm a bit surprised about the returned types from z1 and z2. I would not have been surprised if z1 would still have been a matrix, or z2=NULL. There is certainly a logic behind this choice but it&...
2006 Jan 27
1
about lm restrictions...
...defined because of singularities) Estimate Std. Error t value Pr(>|t|) (Intercept) 15.5000 0.5270 29.409 2.97e-10 *** z1:x1 -5.0000 0.7454 -6.708 8.77e-05 *** z1:x2 0.5000 0.7454 0.671 0.519177 z1:x3 -3.0000 0.7454 -4.025 0.002996 ** z2:x1 -6.0000 0.7454 -8.050 2.11e-05 *** z2:x2 -5.0000 0.7454 -6.708 8.77e-05 *** z2:x3 -4.5000 0.7454 -6.037 0.000193 *** z3:x1 1.0000 0.7454 1.342 0.212580 z3:x2 1.5000 0.7454 2.012 0.075029 . z3:x3 NA NA NA...
2006 Jun 14
3
A question about stepwise procedures: step function
...at I don't understand is that data as data.frame worked well for my other programs, how come I cannot make it run this time. Could you please tell me how I can fix it? *************************************************************************************************** >all<-data.frame(z1,z2,z3) >fit.model.all<- coxph(Surv(t,cen) ~z1+z2+z3,data=all) > reg.model.all<-step(fit.model.all) Start: AIC= 689.1 Surv(t, cen) ~ z1 + z2 + z3 Error in as.data.frame.default(data) : cannot coerce class "function" into a data.frame *****************************************...
2004 Aug 13
2
lapply problem
R-help, I wish to replace NULL elements(or missing) in the following list : > z2 $cod mean sd 62.56190 12.65452 $haddock mean sd 36.61490 11.50365 $ling mean sd 86.17949 20.43587 $saithe mean sd 50.275847 5.453606 $whiting NULL $"norway pout" mean sd 13.739623 1.393104 $"great silver smelt&qu...
2008 Jul 11
1
Comparing complex numbers
Is there an easy way to compare complex numbers? Here is a small example: > (z1=polyroot(c(1,-.4,-.45))) [1] 1.111111-0i -2.000000+0i > (z2=polyroot(c(1,1,.25))) [1] -2+0i -2+0i > x=0 > if(any(identical(z1,z2))) x=99 > x [1] 0 # real and imaginary parts: > Re(z1); Im(z1) [1] 1.111111 -2.000000 [1] -8.4968e-21 8.4968e-21 > Re(z2); Im(z2) [1] -2 -2 [1] 0 0 Both z1 and z2 have a root of -2, but I...
2011 Jul 06
1
question about getting things out of an lapply
...a quite stupid question about using lapply. I have the following function: create.gradient <- function(i){ colorgrad01<-color.scale(seq(0,1,by=0.01), extremes=c("red","blue")) tree1$edge[i,1] -> x tree1$edge[i,2] -> y print(x) print(y) all2[x] -> z all2[y] -> z2 round(z, digits = 2) -> z round(z2, digits = 2) -> z2 z*100 -> z z2*100 -> z2 print(z) print(z2) colorgrad<-colorgrad01[z:z2] colorgrad } Basically, I want to pick a partial gradient out of a bigger gradient (colorgrad01) for values that are on row i, from a matrix called tree1. w...
2007 Apr 29
1
probl with optimization
...(theta){ theta <- rbind(beta,lambda) fun <- sum(exp(h(beta)%*%lambda)) fun } where h(beta) is h <- function(beta,...){ g1 <- matrix(0,b,M) g2 <- matrix(0,b,M) h1 <- matrix(0,b,1) h2 <- matrix(0,b,1) for(f in 1:M){ for(F in 1:b){ g1[F,f] <- exp(mu-beta*(z1[F,f]+z2[F,f])+3*z2[F,f])-1 g2[F,f] <- z2[F,f]*(exp(mu-beta*(z1[F,f]+z2[F,f])+3*z2[F,f])-1) } } for(q in 1:b){ h1[q] <- (1/M)*sum(g1[q,]) h2[q] <- (1/M)*sum(g2[q,]) } h <- matrix(0, b,2) h[,1] <- h1 h[,2] <- h2 h } i tried to optimize fun with optim and nlminb but i get an...
2010 Jan 29
1
use zoo package with multiple column data sets
...1: hh:mm:ss 1 hh:mm:ss 2 hh:mm:ss 3 hh:mm:ss 4 file2: hh:mm:ss 11 55 hh:mm:ss 22 66 hh:mm:ss 33 77 hh:mm:ss 44 88 I wanted to merge these data set so I tried the following commands: library(chron) library(zoo) z1<-read.zoo("path/to/file1.csv",header=TRUE,sep=",",FUN=times) z2<-read.zoo("path/to/file2.csv",header=TRUE,sep=",",FUN=times) z3<-(na.approx(merge(z1,z2),time(z1))) plot(z3$z1,z3$z2[3]) Warning message: some methods for ?zoo? objects do not work if the index entries in ?order.by? are not unique in: zoo(rval, ix) > z3<-(na.approx(...
2004 Mar 10
1
Shorewall2 - Action commands
...but I still have not understood how, in what context and where to use the action commands enumerated in /usr/share/shorewall/actions.std. Illustrating with SMB traffic for instance, how can one use AllowSMB, DropSMB and RejectSMB to control SMB traffic instead of the classic ACCEPT z1 z2 udp 135,445 ACCEPT z1 z2 udp 137:139 ACCEPT z1 z2 udp 1024: 137 ACCEPT z1 z2 tcp 135,139,445 I have copied action.AllowSMB from /usr/share/shorewall to /etc/shorewall and modified the SRC, DST as...
2009 Jul 02
1
lpSolve: how to allow variables to become negative
Dear all, I am interested in solving a MIP problem with binary outcomes and continuous variables, which ARE NOT RESTRICTED TO BE NEGATIVE. In particular, Max {z1,z2,z3,b1} z1 + z2 + z3 (s.t.) # 7 z1 + 0 z2 + 0 z3 + b1 <= 5 # 0 z1 + 8 z2 + 0 z3 - b1 <= 5 # 0 z1 + 0 z2 + 6 z3 + b1 <= 7 # z1, z2, z3 BINARY {0,1} # -5<= b1 <=5 (i.e. b1 <= 5; -b1 <= 5 ) Using the lpSolve package of R, I wrote: library (lpSolve) f.obj <- c(1,...
2009 Mar 19
1
two plots side-by-side with persp3d(rgl)
...final idea would be to animate both surfaces using play3d(rgl). Thanks in advance for any help. Best, Carlo Giovanni Camarda # simple datasets x <- seq(-10, 10, length= 30) y <- x f <- function(x,y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r } z1 <- outer(x, y, f) z1[is.na(z1)] <- 1 z2 <- matrix(outer(1:30, 1:30)/200, 30, 30) # simple persp par(mfrow=c(1,2)) persp(x, y, z1) persp(x, y, z2) # wireframe library(lattice) grid. <- expand.grid(list(x=x,y=y,name=c("Z1", "Z2"))) grid.$Z <- c(c(z1), c(z2)) wireframe(Z ~ x * y | name, data = grid.) # single...