[R] help counting in data
Hi i have this data X [1]5.79 1579.52 2323.70 68.85 426.07 110.29 108.29 1067.60 17.05 22.66 [11] 21.02 175.88 139.07 144.12 20.46 43.40 194.90 47.307.74 0.40 [21] 82.859.88 89.29 215.101.750.79 15.933.910.27 0.69 [31] 100.58 27.80 13.95 53.240.964.150.190.788.01 31.75 [41]7.356.508.27 33.91 32.523.164.852.784.67 1.31 [51] 12.06 36.71 72.891.970.592.581.692.71 25.50 0.35 [61]0.993.993.672.070.965.352.90 13.770.47 0.73 [71]1.400.740.391.130.092.38 and i have an intervale I[j]- leftaj, rightajHERE I CAN T PROGRAMATE THIS INTERVAL SO i have leftaj [1] 0 1.179 3.729 9.418 18.010 29.746 58.662 131.566 rightaj [1]1.1793.7299.418 18.010 29.746 58.662 131.566 2323.700 i want to counting the number of Xhows in the intervale[leftaj, rightaj] thanks for helping hafida -- View this message in context: http://r.789695.n4.nabble.com/help-counting-in-data-tp4640033.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help to program my function
HI peter there is the function that i want to programm (joint in pdf folder). my data is dataexpv Ti1 265.792 26 1579.523 26 2323.704 28 68.855 28 426.076 28 110.297 28 108.298 28 1067.609 30 17.0510 30 22.6611 30 21.0212 30 175.8813 30 139.0714 30 144.1215 30 20.4616 30 43.4017 30 194.9018 30 47.3019 307.7420 320.4021 32 82.8522 32 9.8823 32 89.2924 32 215.1025 321.7526 320.7927 32 15.9328 32 3.9129 320.2730 320.6931 32 100.5832 32 27.8033 32 13.9534 32 53.2435 340.9636 344.1537 340.1938 340.7839 348.0140 34 31.7541 347.3542 346.5043 348.2744 34 33.9145 34 32.5246 34 3.1647 344.8548 342.7849 344.6750 341.3151 34 12.0652 34 36.7153 34 72.8954 361.9755 360.5956 362.5857 361.6958 36 2.7159 36 25.5060 360.3561 360.9962 363.9963 363.6764 36 2.0765 360.9666 365.3567 362.9068 36 13.7769 380.4770 38 0.7371 381.4072 380.7473 380.3974 38 ! 1.1375 380.0976 382.38 NB X-Ti thanks for helping mehafida Date: Wed, 8 Aug 2012 03:13:28 -0700 From: ml-node+s789695n463956...@n4.nabble.com To: hafida...@hotmail.fr Subject: Re: help to program my function Hi Maybe it is time for you to read some basic stuff like R intro. It seems to me that you expect R to behave like some other language you know but probably your expectation is wrong. See inline HI i have a problem please help me to solve it: http://r.789695.n4.nabble.com/file/n4639434/aj.pdf aj.pdf i want to calculate the vecteur a[j] where j: 1...8 this is the code in R: aj.fun - function(j, i, X, z, E, beta0, beta1){ + n - length(X) + iX - order(X) + iz - order(z) + e1 - -(beta)*z[ iz[1:(i - 1)] ] where do you get beta + numer - E[j] - sum( X[ iX[1:(i - 1)] ] * exp(e1) ) + e2 - -(beta)*z[ iz[i:n] ] + denom - sum( exp(e2) ) + numer/denom + } iX-order(X) iX [1] 75 37 29 60 73 20 69 55 30 70 72 38 26 35 65 61 74 50 71 57 25 54 64 76 56 [26] 58 48 67 46 63 28 62 36 49 47 66 1 42 41 19 39 43 22 51 68 33 27 9 15 11 [51] 10 59 32 40 45 44 52 16 18 34 4 53 21 23 31 7 6 13 14 12 17 24 5 8 2 [76] 3 iZ-order(Z) iZ [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 [26] 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 [51] 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 [76] 76 e1 - -(beta)*Z[ iZ[1:(i - 1)] ] Warning message: In 1:(i - 1) : numerical expression has 76 elements: only the first used As somebody already mentioned i is probably vector and in this case only first value is taken. i seems to have the firs value 3. e1 [1] -442 -1664 numer - E[j] - sum( X[ iX[1:(i - 1)] ] * exp(e1)) Warning message: In 1:(i - 1) : numerical expression has 76 elements: only the first used numer [1] 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 Here j is vector of 8 values therefore 8 values e2 - -(beta)*Z[ iZ[i:n] ] Warning message: In i:n : numerical expression has 76 elements: only the first used e2 [1] -442 -1664 -442 -1792 -476 -1792 -476 -1792 -510 -1920 -510 -1920 [13] -510 -1920 -510 -1920 -510 -1920 -510 -2048 -544 -2048 -544 -2048 [25] -544 -2048 -544 -2048 -544 -2048 -544 -2048 -544 -2048 -578 -2176 [37] -578 -2176 -578 -2176 -578 -2176 -578 -2176 -578 -2176 -578 -2176 [49] -578 -2176 -578 -2176 -578 -2304 -612 -2304 -612 -2304 -612 -2304 [61] -612 -2304 -612 -2304 -612 -2304 -612 -2304 -646 -2432 -646 -2432 [73] -646 -2432 -646 -2432 Strange, here first value of i seems to be 1 as n shall be 76 and final e2 length is 76. denom - sum( exp(e2) ) numer/denom [1] 4.313746e+192 4.313746e+192 4.313746e+192 4.313746e+192 4.313746e+192 [6] 4.313746e+192 4.313746e+192 4.313746e+192 my problem that the vecteur a[j] could not have the same number!!! I do not understand. Your numer is 9.5 repeted 8 times. If you divide it by one number you will get nine times the same number. You send us a code but no data so it is difficult to understand what is your goal. It would be better to send input data j, i, X, z, E, beta0, beta1 and assumed result in whole not in chunks scattered in several mails. Regards Petr thank you in advance hafida -- View this message in context: http://r.789695.n4.nabble.com/help-to- program-my-function-tp4639434.html Sent from the R help mailing list archive at Nabble.com. __ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code
Re: [R] help to program my function
hi peter the pdf folder is in http://r.789695.n4.nabble.com/file/n4639434/aj.pdf -- View this message in context: http://r.789695.n4.nabble.com/help-to-program-my-function-tp4639434p4639629.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Decimal number
HI i have a little problem please help me to solve it this is the code in R: beta0 [1] 64.90614 beta1 [1] 17.7025 beta [1] 17 64 her beta- c(beta0, beta1) thank you in advance hafida -- View this message in context: http://r.789695.n4.nabble.com/Decimal-number-tp4639428.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Decimal number
hello arun her beta can be considered simply as an object. when i wrote beta I want to get the number of beta and beta with the full part after the comma hafida -- View this message in context: http://r.789695.n4.nabble.com/Decimal-number-tp4639428p4639452.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Execution of a function
Hi i have aproblem withe execution of my function first, i wrote my function in the script of R nom_fonction - function(arg1[=expr1], arg2[=expr2], ...){ bloc d'instructions } when i want to have the result i mean the laste instruction in the bloc of instruction , i try to wrote the name of function source(aj.fun) Error in readLines(file, warn = FALSE) : 'con' is not a connection return(aj.fun) Error: no function to return from, jumping to top level thanks for helping hafida, univ of algeria -- View this message in context: http://r.789695.n4.nabble.com/Execution-of-a-function-tp4639424.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help to program my function
HI i have a problem please help me to solve it: http://r.789695.n4.nabble.com/file/n4639434/aj.pdf aj.pdf i want to calculate the vecteur a[j] where j: 1...8 this is the code in R: aj.fun - function(j, i, X, z, E, beta0, beta1){ + n - length(X) + iX - order(X) + iz - order(z) + e1 - -(beta)*z[ iz[1:(i - 1)] ] + numer - E[j] - sum( X[ iX[1:(i - 1)] ] * exp(e1) ) + e2 - -(beta)*z[ iz[i:n] ] + denom - sum( exp(e2) ) + numer/denom + } iX-order(X) iX [1] 75 37 29 60 73 20 69 55 30 70 72 38 26 35 65 61 74 50 71 57 25 54 64 76 56 [26] 58 48 67 46 63 28 62 36 49 47 66 1 42 41 19 39 43 22 51 68 33 27 9 15 11 [51] 10 59 32 40 45 44 52 16 18 34 4 53 21 23 31 7 6 13 14 12 17 24 5 8 2 [76] 3 iZ-order(Z) iZ [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 [26] 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 [51] 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 [76] 76 e1 - -(beta)*Z[ iZ[1:(i - 1)] ] Warning message: In 1:(i - 1) : numerical expression has 76 elements: only the first used e1 [1] -442 -1664 numer - E[j] - sum( X[ iX[1:(i - 1)] ] * exp(e1)) Warning message: In 1:(i - 1) : numerical expression has 76 elements: only the first used numer [1] 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 e2 - -(beta)*Z[ iZ[i:n] ] Warning message: In i:n : numerical expression has 76 elements: only the first used e2 [1] -442 -1664 -442 -1792 -476 -1792 -476 -1792 -510 -1920 -510 -1920 [13] -510 -1920 -510 -1920 -510 -1920 -510 -2048 -544 -2048 -544 -2048 [25] -544 -2048 -544 -2048 -544 -2048 -544 -2048 -544 -2048 -578 -2176 [37] -578 -2176 -578 -2176 -578 -2176 -578 -2176 -578 -2176 -578 -2176 [49] -578 -2176 -578 -2176 -578 -2304 -612 -2304 -612 -2304 -612 -2304 [61] -612 -2304 -612 -2304 -612 -2304 -612 -2304 -646 -2432 -646 -2432 [73] -646 -2432 -646 -2432 denom - sum( exp(e2) ) numer/denom [1] 4.313746e+192 4.313746e+192 4.313746e+192 4.313746e+192 4.313746e+192 [6] 4.313746e+192 4.313746e+192 4.313746e+192 my problem that the vecteur a[j] could not have the same number!!! thank you in advance hafida -- View this message in context: http://r.789695.n4.nabble.com/help-to-program-my-function-tp4639434.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Decimal number
HI THANK YOU ALL OF YOU THIS PROBLEM IS SOLVED THANK YOU hafida -- View this message in context: http://r.789695.n4.nabble.com/Decimal-number-tp4639428p4639467.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Execution of a function
HI Arun and all my function is: aj.fun - function(j, i, X, z, E, beta0, beta1){ + n - length(X) + iX - order(X) + iz - order(z) + e1 - -(beta)*z[ iz[1:(i - 1)] ] + numer - E[j] - sum( X[ iX[1:(i - 1)] ] * exp(e1) ) + e2 - -(beta)*z[ iz[i:n] ] + denom - sum( exp(e2) ) + numer/denom + } how excute this function thank you hafida -- View this message in context: http://r.789695.n4.nabble.com/Execution-of-a-function-tp4639424p4639469.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] program of matrix
Hi can ANY body help me to programme this formula: c[lj] and c[l'j] are matrix A[j]^-1 is an invertible diagonal matrix g[ll']=i[ll'] - sum *#from j=1 to k#* c[lj]c[l'j]A[j]^-1 WHERE i[ll']= 1/n sum from i=1 to n z[il] z[il'] n,k,m are given. j=1...k,l,l'=1...m, it s complicate for me ; hope you can help me thank you a lot -- View this message in context: http://r.789695.n4.nabble.com/program-of-matrix-tp4639288.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] program of matrix
A OK I MAKE A MISTAKE OK MR DAVID I WILL DO IT THANK YOU -- View this message in context: http://r.789695.n4.nabble.com/program-of-matrix-tp4639288p4639334.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] program of matrix
I CANT FIND ANY ANSWER MR DAVID -- View this message in context: http://r.789695.n4.nabble.com/program-of-matrix-tp4639288p4639332.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] AFT model time-dependent with weibull distribution
Dear R-community, I have tried to estimate an EXPONENTIEL accelerated failure time(AFT) power rule model with time-independent . For that purpose, I have used the eha package. Please, consider this example: vi Ti 1 265.79 2 26 1579.52 3 26 2323.70 4 28 68.85 5 28 426.07 6 28 110.29 7 28 108.29 8 28 1067.60 9 30 17.05 10 30 22.66 11 30 21.02 12 30 175.88 13 30 139.07 14 30 144.12 15 30 20.46 16 30 43.40 17 30 194.90 18 30 47.30 19 307.74 20 320.40 21 32 82.85 22 329.88 23 32 89.29 24 32 215.10 25 321.75 26 320.79 27 32 15.93 28 323.91 29 320.27 30 320.69 31 32 100.58 32 32 27.80 33 32 13.95 34 32 53.24 35 340.96 36 344.15 37 340.19 38 340.78 39 348.01 40 34 31.75 41 347.35 42 346.50 43 348.27 44 34 33.91 45 34 32.52 46 343.16 47 344.85 48 342.78 49 344.67 50 341.31 51 34 12.06 52 34 36.71 53 34 72.89 54 361.97 55 360.59 56 362.58 57 361.69 58 362.71 59 36 25.50 60 360.35 61 360.99 62 363.99 63 363.67 64 362.07 65 360.96 66 365.35 67 362.90 68 36 13.77 69 380.47 70 380.73 71 381.40 72 380.74 73 380.39 74 381.13 75 380.09 76 382.38 aftexp-aftreg(Surv(time,status) ~ vi, data=data.frame(dataexp), dist=exponentiel) Error in Surv(time, status) : Time variable is not numeric aftexp-aftreg(Surv(Ti,status) ~ vi, data=data.frame(dataexp), dist=exponentiel) Error in Surv(Ti, status) : object 'status' not found status- rep(1, 76) status [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [39] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 cbind(dataexp, status) vi Ti status 1 265.79 1 2 26 1579.52 1 3 26 2323.70 1 4 28 68.85 1 5 28 426.07 1 6 28 110.29 1 7 28 108.29 1 8 28 1067.60 1 9 30 17.05 1 10 30 22.66 1 11 30 21.02 1 12 30 175.88 1 13 30 139.07 1 14 30 144.12 1 15 30 20.46 1 16 30 43.40 1 17 30 194.90 1 18 30 47.30 1 19 307.74 1 20 320.40 1 21 32 82.85 1 22 329.88 1 23 32 89.29 1 24 32 215.10 1 25 321.75 1 26 320.79 1 27 32 15.93 1 28 323.91 1 29 320.27 1 30 320.69 1 31 32 100.58 1 32 32 27.80 1 33 32 13.95 1 34 32 53.24 1 35 340.96 1 36 344.15 1 37 340.19 1 38 340.78 1 39 348.01 1 40 34 31.75 1 41 347.35 1 42 346.50 1 43 348.27 1 44 34 33.91 1 45 34 32.52 1 46 343.16 1 47 344.85 1 48 342.78 1 49 344.67 1 50 341.31 1 51 34 12.06 1 52 34 36.71 1 53 34 72.89 1 54 361.97 1 55 360.59 1 56 362.58 1 57 361.69 1 58 362.71 1 59 36 25.50 1 60 360.35 1 61 360.99 1 62 363.99 1 63 363.67 1 64 362.07 1 65 360.96 1 66 365.35 1 67 362.90 1 68 36 13.77 1 69 380.47 1 70 380.73 1 71 381.40 1 72 380.74 1 73 380.39 1 74 381.13 1 75 380.09 1 76 382.38 1 aftexp-aftreg(Surv(Ti,status) ~ vi, data=data.frame(dataexp), dist=exponentiel) Error in aftreg.fit(X, Y, dist, strats, offset, init, shape, id, control, : exponentiel is not an implemented distribution aftexp-aftreg(Surv(time,status) ~ vi, data=data.frame(dataexp), dist=exponentiel) Error in Surv(time, status) : Time variable is not numeric pleas help me to find a solution to my problem -- View this message in context: http://r.789695.n4.nabble.com/AFT-model-time-dependent-with-weibull-distribution-tp3755079p4639174.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] AFT model time-dependent with weibull distribution
thanks a lot sorry for the mistake that i do in exponential, i am francophone and for the programme if we want to apply the power rule condition we use log(vi). it works thank yo -- View this message in context: http://r.789695.n4.nabble.com/AFT-model-time-dependent-with-weibull-distribution-tp3755079p4639184.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] evaluate sum of sum
Hi can any body please help me to programme this formula: a[j]= E[j]-sum from l=i to i-1 (exp{(B0 B1*row matrix*) (z[l]*column matrix*) } x[l]) / sum from l=i to n it s complicate for me ; hope you can help me thank you a lot -- View this message in context: http://r.789695.n4.nabble.com/evaluate-sum-of-sum-tp898262p4639191.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.