Re: [R] possible bug in image() ??
Gareth Davies a écrit : Hi everyone. The function image() seems not to be correctly plotting some matrices that I give it. (I’m using R 2.1.1) ..where the first column in x (vector ccc) is depicted horizontally along the bottom of the image. Hello, here's a way to have an image according the usual view. timage = function(M) { M1 = M; for (i in 1:nrow(M)) M1[i,] = M[nrow(M)-i+1,]; image(t(M1)); } hih __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] (no subject)
Hello, Can anybody tell me, please, how to get a matrix of SE of differences (or any SE) from a GLM object? Both model.tables and se.contrast work only for ANOVA objects. I remember there was a disp s directive in GLIM package. I would need something like that. Many thanks. Wishes, Stano Pekar __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] details about lm()
Dear all, I'd like to get a linear regression of some data, and impose that the line goes through a given point P. I've tried to use the lm() method in the package stats, but I wasn't able to specify the coordinates of the point P. Maybe I should use another method? I also have another question: How does lm() choose the point through which the output straight line goes in order to compute the values of its slope and intercept? I would be very grateful if anyone could help me. Domenico * Domenico Cozzetto Biocomputing group Department of Biochemical Sciences A. Rossi Fanelli University of Rome La Sapienza P.le Aldo Moro, 5 - 00185 Rome Tel: +39 06 49690276 Fax: +39 06 4400062 URL: http://cassandra.bio.uniroma1.it/~cozzetto/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] interpretation output glmmPQL
Hi ! We study the effect of several variables on fruit set for 44 individuals (plants). For each individual, we have the number of fruits, the number of flowers and a value for each variable. Here is our first model in R : y - cbind(indnbfruits,indnbflowers); model1 -glm(y~red*yellow+I(red^2)+I(yellow^2)+densite8+I(densite8^2)+freq8_4+I (freq8_4^2), quasibinomial); -We have used a quasibinomial error because there is overdispersion. How to know if it is OK? -Glm does not take account of the correlation between the flowers of a unique individual. So we would like to add a random effect individual but the model2 (here after) gives an output similar to the one of model1 for estimated coefficients and p-values. model2 - glmmPQL(y~red*yellow+I(red^2)+I(yellow^2)+densite8+I(densite8^2)+freq8_4 +I(freq8_4^2), random=~1|num, quasibinomial); Does it mean that there is no individual effect or is my model not good (number of groups (individuals)=number of observations, is it possible?). Thank you by advance for your help Emmanuelle TASTARD Output model1 : Call: glm(formula = y ~ red * yellow + I(red^2) + I(yellow^2) + densite8 + I(densite8^2) + freq8_4 + I(freq8_4^2), family = quasibinomial) Deviance Residuals: Min 1Q Median 3Q Max -3.4978 -1.5396 -0.1700 0.5210 4.5302 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 2.8076 2.4489 1.146 0.262042 red-1.9290 0.8498 -2.270 0.031738 * yellow -0.3415 1.5189 -0.225 0.823848 I(red^2)0.3250 0.1229 2.644 0.013700 * I(yellow^2)-0.1776 0.4129 -0.430 0.670573 densite8 -8.2691 4.6140 -1.792 0.084750 . I(densite8^2) 6.0005 3.4666 1.731 0.095318 . freq8_4 9.0044 2.5358 3.551 0.001490 ** I(freq8_4^2) -14.3066 3.8049 -3.760 0.000871 *** red:yellow 0.2320 0.1893 1.226 0.231315 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for quasibinomial family taken to be 5.374839) Null deviance: 404.64 on 35 degrees of freedom Residual deviance: 137.20 on 26 degrees of freedom AIC: NA Number of Fisher Scoring iterations: 4 Output model2 : Linear mixed-effects model fit by maximum likelihood Data: NULL AIC BIClogLik 112.5895 131.5917 -44.29476 Random effects: Formula: ~1 | num (Intercept) Residual StdDev: 0.02253235 1.968849 Variance function: Structure: fixed weights Formula: ~invwt Fixed effects: y ~ red * yellow + I(red^2) + I(yellow^2) + densite8 + I(densite8^2) + freq8_4 + I(freq8_4^2) Value Std.Error DF t-value p-value (Intercept) 2.805933 2.449548 26 1.145490 0.2624 red-1.927214 0.850055 26 -2.267164 0.0319 yellow -0.343353 1.519357 26 -0.225986 0.8230 I(red^2)0.324676 0.122961 26 2.640481 0.0138 I(yellow^2)-0.177084 0.412955 26 -0.428820 0.6716 densite8 -8.265473 4.615384 26 -1.790853 0.0850 I(densite8^2) 5.997720 3.467743 26 1.729574 0.0956 freq8_4 9.006669 2.535929 26 3.551625 0.0015 I(freq8_4^2) -14.309852 3.804955 26 -3.760847 0.0009 red:yellow 0.231987 0.189296 26 1.225523 0.2314 Correlation: (Intr) redyellow I(r^2) I(y^2) denst8 I(8^2) frq8_4 I(8_4^ red -0.562 yellow-0.581 -0.179 I(red^2) 0.467 -0.934 0.248 I(yellow^2)0.240 0.481 -0.896 -0.451 densite8 -0.764 0.369 0.196 -0.338 0.075 I(densite8^2) 0.743 -0.326 -0.208 0.327 -0.038 -0.987 freq8_4 -0.100 -0.112 0.171 -0.041 -0.254 -0.016 -0.086 I(freq8_4^2) 0.141 0.001 -0.061 0.140 0.095 -0.150 0.240 -0.938 red:yellow 0.585 -0.634 -0.113 0.355 -0.308 -0.468 0.383 0.375 -0.237 Standardized Within-Group Residuals: Min Q1 Med Q3 Max -1.66511749 -0.59215881 -0.08635717 0.26740423 2.75720770 Number of Observations: 36 Number of Groups: 36 Emmanuelle TASTARD UMR 5174 'Evolution et Diversité Biologique' Université Paul Sabatier Bat 4R3 31062 TOULOUSE CEDEX 9 France tel : 05 61 55 67 59 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R version 2.01.1, Crimson Editor and the one from nowhere
Thanks a lot, really, Philippe, for this explanation... and sorry for taking some of your time. Of course your guess is right : I turned to French (and forgot to tell...). So I'll use your second suggestion (turn to english in MDI). Once again this list works amazingly well ! Olivier Philippe Grosjean a écrit: ... OK, I have spot the problem: TpR.exe expects RGui running in English. Shortcut for the Windows menu is Alt-w, which is what it sends to R. Then, it sends 1, meaning, activate first window (the console). You have probably RGui running in French, or in another language. In French the menu is called Fenêtres, with the corresponding shortcut being Alt-n. Consequently, the menu is not triggered and the 1 is send to the command line. Two solutions to continue using TpR.exe with R 2.1.1 or more: 1) Switch R in SDI mode, 2) Use RGui in MDI mode, but in English. The third solution is to patch TpR.exe, which I will not do, because I need to program a separate command for each different language of R! Best, Philippe Grosjean ..°})) ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Pentagone (3D08) ( ( ( ( (Academie Universitaire Wallonie-Bruxelles ) ) ) ) ) 8, av du Champ de Mars, 7000 Mons, Belgium ( ( ( ( ( ) ) ) ) ) phone: + 32.65.37.34.97, fax: + 32.65.37.30.54 ( ( ( ( (email: [EMAIL PROTECTED] ) ) ) ) ) ( ( ( ( (web: http://www.umh.ac.be/~econum ) ) ) ) ) http://www.sciviews.org ( ( ( ( ( .. Olivier ETERRADOSSI wrote: Dear List sorry to bother you R-gurus with such an unstatistical question... but I face a problem using Crimson Editor with R 2.01.1 that I never had using R 2.00.1. I already posted on the Crimson Editor forum but it seems to be VERY few R-users there I successfully used R v2.00.1until now (under Windows XP professionnal, version 2002, Service Pack 2, P4 processor CPU 1.8 GHz), together with Crimson Editor. This editor is linked to R using three files (TpR.exe, R.SPC and R.KEYS). I recently upgraded to R 2.01.1. I kept using my old TpR.exe, R.SPC and R.KEYS, because I did not find any new files on the Crimson Editor Release web page. When I now launch a script, instead of getting my old, well known prompt : source(C:/Program Files/R/fooscript.txt) I get : 1source(C:/Program Files/R/fooscript.txt) with a 1 in front of the line and of course R greets me with a syntax error message. Then I have to remove the 1 by hand (pretty prehistoric, ...and does not work if my script is meant to launch other scripts during the night) I cannot figure where this 1 comes from !! Did some of you already encountered this problem, and how did you get rid of it ? Thanks a lot, have a nice week-end. Olivier -- Olivier ETERRADOSSI Maître-Assistant CMGD / Equipe Propriétés Psycho-Sensorielles des Matériaux Ecole des Mines d'Alès Hélioparc, 2 av. P. Angot, F-64053 PAU CEDEX 9 tel: +33 (0)5.59.30.54.25 fax: +33 (0)5.59.30.63.68 http://www.ema.fr __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] sqlFetch on MySQL-DB
On Mon, 10 Oct 2005, Bernd Weiss wrote: I successfully set up a local MySQL-database. Connecting via RODBC is not problem, the same in fetching 3 of 4 tables. But trying to connect to table 4 fails. author-sqlFetch(test,author) Error in fromchar(unclass(x)) : character string is not in a standard unambiguous format Try traceback() after an error that is lacking context: it would have helped. In principle I understand that error message, but I don't know any solution. You have a date or datetime or timestamp column that is not in a format R recognizes. Use argument 'as.is' to bring it across as character. See ?sqlGetResults (referenced from ?sqlFetch). -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] possible bug in image() ??
I guess what you see is the limited resolution of your screen rather than a bug in R. Try to produce a reliably image, e.g. some pdf file: pdf(test.pdf) cc=runif(n=1500,min=0.1,max=1.2) ccc=ceiling(cc-1) dd=runif(n=1500,min=0.1,max=1.2) ddd=ceiling(dd-1) ee=runif(n=1500,min=0.1,max=1.2) eee=ceiling(ee-1) x=matrix(data=c(ccc,ddd,eee),nrow=1500) image(x) points(seq(0,1,1/(1500-1)),(ccc)^-1*0, pch=.) points(seq(0,1,1/(1500-1)),(ddd)^-1*0.5, pch=.) points(seq(0,1,1/(1500-1)),(eee)^-1*1, pch=.) dev.off() and zoom in now Uwe Ligges Gareth Davies wrote: Hi everyone. The function image() seems not to be correctly plotting some matrices that I give it. (I’m using R 2.1.1) The following code creates a matrix (denoted x) with 1500 rows and 3 columns, with all entries 0 or 1, and then plots the image of this matrix. cc=runif(n=1500,min=0.1,max=1.2) ccc=ceiling(cc-1) dd=runif(n=1500,min=0.1,max=1.2) ddd=ceiling(dd-1) ee=runif(n=1500,min=0.1,max=1.2) eee=ceiling(ee-1) x=matrix(data=c(ccc,ddd,eee),nrow=1500) image(x) ..where the first column in x (vector ccc) is depicted horizontally along the bottom of the image. However, when I overplot the non-zero elements of the vectors ccc, ddd and eee onto their respective horizontal positions on the image,.. points(seq(0,1,1/(1500-1)),(ccc)^-1*0) points(seq(0,1,1/(1500-1)),(ddd)^-1*0.5) points(seq(0,1,1/(1500-1)),(eee)^-1*1) …the locations of the 1’s in image do not always match the locations of the 1’s in ccc,ddd, and eee (although they are mostly correct). Do other people find this problem?? I've tried with other matrices, and the results only seem in error when the matrix is large, say with more than 1000 rows. Cheers, Gareth Davies __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] ATLAS version for Rblas.dll under Windows; was: (no subject)
Bing Ho wrote: Hello, I noticed that the README found in /bin/windows/contrib/ATLAS indicates that the ATLAS version is 3.4.1. According to the ATLAS sourceforge site, 3.6.0 the latest stable version. Does anybody know if the ATLAS Rblas.dll are 3.4.1 or 3.6.0, and if they are not the latest version, is there a technical reason why they have not been updated? Version is as indicated 3.4.1. The reason is that nobody had a reason to build updated versions. If you are volunteering to build Rblas.dll files based on new ATLAS versions for various platforms such as P2, P3, P4, Xeon, AthlonXP, Athlon64 (32-bit), you are welocme to contribute, of course. Uwe Ligges Thank you, Bing Ho __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] R: integration problem
hi all an integration problem. i would like an exact or good approximation for the following, but i do not want to use a computer. any suggestions: integral of exp(b*x)/sqrt(1-x^2) where b is a constant greater than or equal to 0 and the integral runs from 0 to 1 any help would be apreciated / allan__ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] details about lm()
Domenico Cozzetto a écrit : Dear all, I'd like to get a linear regression of some data, and impose that the line goes through a given point P. I've tried to use the lm() method in the package stats, but I wasn't able to specify the coordinates of the point P. Maybe I should use another method? add directly P in your data is also a way __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] interpretation output glmmPQL
We study the effect of several variables on fruit set for 44 individuals (plants). For each individual, we have the number of fruits, the number of flowers and a value for each variable. ... - Glm does not take account of the correlation between the flowers of a unique individual. So we would like to add a random effect 'individual' but the model2 (here after) gives an output similar to the one of model1 for estimated coefficients and p-values. ... Does it mean that there is no individual effect or is my model not good (number of groups (individuals)=number of observations, is it possible?). If you have only one observation per indiviudal plant, how could there be dependence within the plant? This would only make sense if your observations were the individual flowers. Data on those could be correlated within plant and then a random term for the plant is meaningful. Cheers, Lorenz - Lorenz Gygax Centre for proper housing of ruminants and pigs Swiss Federal Veterinary Office agroscope FAT Tänikon, CH-8356 Ettenhausen / Switzerland __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] details about lm()
[EMAIL PROTECTED] wrote: Domenico Cozzetto a écrit : Dear all, I'd like to get a linear regression of some data, and impose that the line goes through a given point P. I've tried to use the lm() method in the package stats, but I wasn't able to specify the coordinates of the point P. Maybe I should use another method? add directly P in your data is also a way No! Please, both of you, consult a basic textbook on linear regression. You can transform the data (linear) so that P becomes (0,0), after that you can estimate the slope without intercept by specifying lm(y ~ x - 1) The slope estimate is still valid while your intercept can be calculated afterwards. Uwe Ligges __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Show Progress in loop
Hi I have a loop which is doing time consuming calculations and I would like to be able to have some feedback on where it is in it's calculations. I tried to simply show the counter variable in the loop, but id doesn't work as all display seems to be delayed until the loop is completed. Is there any way of displaying the progress of a loop? Rainer The loop: for (i in 2:Result$NoSims) { ppp - runifpoint(Result$NoPlants) K - Kest(ppp) Result$LSim[i,] - sqrt(K$iso / pi) - K$r CM - (Result$LSim[i,] * Result$LSim[i,]) / abs(K$r[2] - K$r[1]) Result$SigCM[i] - sum(CM, na.rm=TRUE) i #Doesn't display in the loop } -- Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology University of Stellenbosch Matieland 7602 South Africa __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Show Progress in loop
Rainer M. Krug [EMAIL PROTECTED] writes: Hi I have a loop which is doing time consuming calculations and I would like to be able to have some feedback on where it is in it's calculations. I tried to simply show the counter variable in the loop, but id doesn't work as all display seems to be delayed until the loop is completed. Is there any way of displaying the progress of a loop? Rainer The loop: for (i in 2:Result$NoSims) { ppp - runifpoint(Result$NoPlants) K - Kest(ppp) Result$LSim[i,] - sqrt(K$iso / pi) - K$r CM - (Result$LSim[i,] * Result$LSim[i,]) / abs(K$r[2] - K$r[1]) Result$SigCM[i] - sum(CM, na.rm=TRUE) i #Doesn't display in the loop } Just print(i) and if on Windows, remember to unset output buffering. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] question about ways to solve nonlinear system
Leite,Walter wrote: Dear R users I am trying to write an R function to solve for a,b,c in the following system of equations, given any value of x1, x2 and x3: b^2 + 6*b*a + 2*c^2 + 15*a^2 = x1 2*c*(b^2 + 24*b*a + 105*a^2 + 2) = x2 24*(b*a + c^2*(1 + b^2 + 28*b*a) + a*(12 + 48 *b*a + 141*c^2 + 225*a^2)) =x3 Could you give me suggestions about which R function(s) I can use to solve this problem and how I should use these functions? Thank you very much for your assistance, Walter Leite __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html R itself cannot calculate symbolically (which is what you want to do it in this case, I guess), just numerically. Uwe Ligges __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Show Progress in loop
Rainer M. Krug wrote: Hi I have a loop which is doing time consuming calculations and I would like to be able to have some feedback on where it is in it's calculations. I tried to simply show the counter variable in the loop, but id doesn't work as all display seems to be delayed until the loop is completed. Is there any way of displaying the progress of a loop? Rainer The loop: for (i in 2:Result$NoSims) { ppp - runifpoint(Result$NoPlants) K - Kest(ppp) Result$LSim[i,] - sqrt(K$iso / pi) - K$r CM - (Result$LSim[i,] * Result$LSim[i,]) / abs(K$r[2] - K$r[1]) Result$SigCM[i] - sum(CM, na.rm=TRUE) i #Doesn't display in the loop } - Update your console (I guess you are on Windows?) by using flush.console(). - You might want to measure time consumption, hence see ?Rprof. - Save some more time by moving as much as possible out of your loop by doing it in a vectorized way (I don't know all the functions you are using, hence cannot make any further recommendations). Uwe Ligges __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Show Progress in loop
I put print(i) in the loop instead of i, but it still only prints (in the Windows R GUI) i after it finished the calculations. I guess it might be due to the output buffering you mentioned - but how do I unset it? Rainer Peter Dalgaard wrote: Rainer M. Krug [EMAIL PROTECTED] writes: Hi I have a loop which is doing time consuming calculations and I would like to be able to have some feedback on where it is in it's calculations. I tried to simply show the counter variable in the loop, but id doesn't work as all display seems to be delayed until the loop is completed. Is there any way of displaying the progress of a loop? Rainer The loop: for (i in 2:Result$NoSims) { ppp - runifpoint(Result$NoPlants) K - Kest(ppp) Result$LSim[i,] - sqrt(K$iso / pi) - K$r CM - (Result$LSim[i,] * Result$LSim[i,]) / abs(K$r[2] - K$r[1]) Result$SigCM[i] - sum(CM, na.rm=TRUE) i #Doesn't display in the loop } Just print(i) and if on Windows, remember to unset output buffering. -- NEW TELEPHONE NUMBER Tel:+27 - (0)72 808 2975 (w) Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology University of Stellenbosch Matieland 7602 South Africa Tel:+27 - (0)72 808 2975 (w) Fax:+27 - (0)21 808 3304 Cell: +27 - (0)83 9479 042 email: [EMAIL PROTECTED] [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R: integration problem
Clark Allan wrote: hi all an integration problem. i would like an exact or good approximation for the following, but i do not want to use a computer. any suggestions: integral of exp(b*x)/sqrt(1-x^2) Sounds like the problem of integrating the Gaussian density... Uwe Ligges where b is a constant greater than or equal to 0 and the integral runs from 0 to 1 any help would be apreciated / allan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Show Progress in loop
Thanks - flush.console() did the trick. As you might guess, I am quite new to R. I like the idea of vectorizing the calculation, but I guess it is not possible in this case - I will ask in a new thread. Thanks, Rainer Uwe Ligges wrote: Rainer M. Krug wrote: Hi I have a loop which is doing time consuming calculations and I would like to be able to have some feedback on where it is in it's calculations. I tried to simply show the counter variable in the loop, but id doesn't work as all display seems to be delayed until the loop is completed. Is there any way of displaying the progress of a loop? Rainer The loop: for (i in 2:Result$NoSims) { ppp - runifpoint(Result$NoPlants) K - Kest(ppp) Result$LSim[i,] - sqrt(K$iso / pi) - K$r CM - (Result$LSim[i,] * Result$LSim[i,]) / abs(K$r[2] - K$r[1]) Result$SigCM[i] - sum(CM, na.rm=TRUE) i #Doesn't display in the loop } - Update your console (I guess you are on Windows?) by using flush.console(). - You might want to measure time consumption, hence see ?Rprof. - Save some more time by moving as much as possible out of your loop by doing it in a vectorized way (I don't know all the functions you are using, hence cannot make any further recommendations). Uwe Ligges -- NEW TELEPHONE NUMBER Tel:+27 - (0)72 808 2975 (w) Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology University of Stellenbosch Matieland 7602 South Africa Tel:+27 - (0)72 808 2975 (w) Fax:+27 - (0)21 808 3304 Cell: +27 - (0)83 9479 042 email: [EMAIL PROTECTED] [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Vectorizing loop
Hi I have the following loop and would like to vectorize it. Any ideas if it is possible? Thanks, Rainer Tha Loop: for (i in 2:Result$NoSims) { ppp - runifpoint(Result$NoPlants) K - Kest(ppp) Result$LSim[i,] - sqrt(K$iso / pi) - K$r CM - (Result$LSim[i,] * Result$LSim[i,]) / abs(K$r[2] - K$r[1]) Result$SigCM[i] - sum(CM, na.rm=TRUE) print(i) flush.console() } -- NEW TELEPHONE NUMBER Tel:+27 - (0)72 808 2975 (w) Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology University of Stellenbosch Matieland 7602 South Africa Tel:+27 - (0)72 808 2975 (w) Fax:+27 - (0)21 808 3304 Cell: +27 - (0)83 9479 042 email: [EMAIL PROTECTED] [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Show Progress in loop
Hello, You must explicitly use print(), show() on an object -here, use print(i)- in a loop or alternatively, use cat() to display string like: cat(loop, i, \n) With RGui under Windows, there is another subtility: if you have turn on 'Misc - Buffered output' (it is ON by default), all output are delayed until the end of the command processing. You need to use flush.console() to tell to print i immediatelly within a loop. The best synthax is (since the command is only usable under Windows): for (i in 1:10) { print(i)# You must use print explicitly within a loop # or, better, use: cat(loop, i, \n) # Next command is to overcome buffered output in RGui if (.Platform$OS.type == windows) flush.console() # Next command simulates a long process (taking 1 sec) Sys.sleep(1) # ... your loop code here... } Alternatively, you can use the progress() function in svMisc package (SciViews bundle). Load svMisc and look at its online help... you have several examples of use. library(svMisc) ?progress Best, Philippe Grosjean ..°})) ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Pentagone (3D08) ( ( ( ( (Academie Universitaire Wallonie-Bruxelles ) ) ) ) ) 8, av du Champ de Mars, 7000 Mons, Belgium ( ( ( ( ( ) ) ) ) ) phone: + 32.65.37.34.97, fax: + 32.65.37.30.54 ( ( ( ( (email: [EMAIL PROTECTED] ) ) ) ) ) ( ( ( ( (web: http://www.umh.ac.be/~econum ) ) ) ) ) http://www.sciviews.org ( ( ( ( ( .. Rainer M. Krug wrote: Hi I have a loop which is doing time consuming calculations and I would like to be able to have some feedback on where it is in it's calculations. I tried to simply show the counter variable in the loop, but id doesn't work as all display seems to be delayed until the loop is completed. Is there any way of displaying the progress of a loop? Rainer The loop: for (i in 2:Result$NoSims) { ppp - runifpoint(Result$NoPlants) K - Kest(ppp) Result$LSim[i,] - sqrt(K$iso / pi) - K$r CM - (Result$LSim[i,] * Result$LSim[i,]) / abs(K$r[2] - K$r[1]) Result$SigCM[i] - sum(CM, na.rm=TRUE) i #Doesn't display in the loop } __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Show Progress in loop
Rainer M. Krug [EMAIL PROTECTED] writes: I put print(i) in the loop instead of i, but it still only prints (in the Windows R GUI) i after it finished the calculations. I guess it might be due to the output buffering you mentioned - but how do I unset it? Using the user friendly interface... (it's on one of the top menus), or, as Uwe suggested, stick in flush.console() after the print(i). -p Rainer Peter Dalgaard wrote: Rainer M. Krug [EMAIL PROTECTED] writes: Hi I have a loop which is doing time consuming calculations and I would like to be able to have some feedback on where it is in it's calculations. I tried to simply show the counter variable in the loop, but id doesn't work as all display seems to be delayed until the loop is completed. Is there any way of displaying the progress of a loop? Rainer The loop: for (i in 2:Result$NoSims) { ppp - runifpoint(Result$NoPlants) K - Kest(ppp) Result$LSim[i,] - sqrt(K$iso / pi) - K$r CM - (Result$LSim[i,] * Result$LSim[i,]) / abs(K$r[2] - K$r[1]) Result$SigCM[i] - sum(CM, na.rm=TRUE) i #Doesn't display in the loop } Just print(i) and if on Windows, remember to unset output buffering. -- NEW TELEPHONE NUMBER Tel: +27 - (0)72 808 2975 (w) Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology University of Stellenbosch Matieland 7602 South Africa Tel: +27 - (0)72 808 2975 (w) Fax: +27 - (0)21 808 3304 Cell: +27 - (0)83 9479 042 email:[EMAIL PROTECTED] [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Show Progress in loop
Rainer M. Krug a écrit : Hi I have a loop which is doing time consuming calculations and I would like to be able to have some feedback on where it is in it's calculations. I tried to simply show the counter variable in the loop, but id doesn't work as all display seems to be delayed until the loop is completed. Is there any way of displaying the progress of a loop? for (i in 2:Result$NoSims) { ... i #Doesn't display in the loop } Hi, for your last line, use : print(i); flush.console(); #== now displays in the loop hih __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Show Progress in loop
Rainer M. Krug wrote: Hi I have a loop which is doing time consuming calculations and I would like to be able to have some feedback on where it is in it's calculations. I tried to simply show the counter variable in the loop, but id doesn't work as all display seems to be delayed until the loop is completed. Is there any way of displaying the progress of a loop? Rainer The loop: for (i in 2:Result$NoSims) { ppp - runifpoint(Result$NoPlants) K - Kest(ppp) Result$LSim[i,] - sqrt(K$iso / pi) - K$r CM - (Result$LSim[i,] * Result$LSim[i,]) / abs(K$r[2] - K$r[1]) Result$SigCM[i] - sum(CM, na.rm=TRUE) i #Doesn't display in the loop } Hi, You can simply include a command like cat(loop: , i, \n) inside your loop. EJ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Show Progress in loop
On Mon, 10 Oct 2005, Philippe Grosjean wrote: Hello, You must explicitly use print(), show() on an object -here, use print(i)- in a loop or alternatively, use cat() to display string like: cat(loop, i, \n) With RGui under Windows, there is another subtility: if you have turn on 'Misc - Buffered output' (it is ON by default), all output are delayed until the end of the command processing. You need to use flush.console() to tell to print i immediatelly within a loop. The best synthax is (since the command is only usable under Windows): Not so: all systems have it. It is also useful on MacOS X. All this is on the help page. This is in the rw-FAQ: it seems we have lost the convention of not answering FAQs but referring people to the appropriate FAQ. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] plot - no main title and missing abscissa value
Hi all. I have defined a plot thus: par(mar=c(5,5,4,5),las=1, xpd=NA) plot(Day, Ym1Imp, ylim=c(0,100), type=b, bty=l, main=Ym1 Expression, cex=1.3, xaxt=n, yaxt=n) #plot implant data axis(side=1, at=c(0,1,3,5,7,10,14,21), labels=c(0,1,3,5,7,10,14,21)) # label x axis mtext(Day, side =1, at=10, line=3, cex=1.2) # title x axis The problem with this graph is that the main title is missing and so is the digit 1 at the abscissa position 1 - although the other abscissa labels are all there as defined in the axis call. Can anyone shed anylight on why this is? I'm using R 2.1 on OS X. Thanks Iain -- Iain Gallagher Institute for Infection Immunology Research Ashworth Laboratories Kings Buildings University of Edinburgh Edinburgh EH9 3JT UK (+44) 0131 651 3630 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] text(x,y,greek character)
Dear list, I would like to plot points with two types of labels, one at the data point (the name of the point) and another offset a bit with another factor which is either of the two greek characters alpha or beta. I have tried to get the routine to plot a greek character with expression() or with substitute() and have not yet had any success. The following only plots the word in english in plain text. Here is my subroutine and data: --- vmat-as.matrix(read.table(vmat)) Xm-vmat[1:22,1:20] hemd-read.table(threehem,header=T) Ym-as.matrix(hemd[,2]) gvdw.pls-plsr(Ym ~ Xm,6,method=kernelpls) rsltv-predict(gvdw.pls,comps=6) plot(Ym,rsltv,type=n,xlab=Actividad + Biológica,xlim=c(4.6,6),ylim=c(4.8,6),ylab= Act. + Biol.(Pred.),main=QSAR Ligación de Derivados de la Artemisina con + Hemina,sub=Descriptores de Coeficientes VdW) text(Ym,rsltv,labels=threehem$cpd) text(Ym,rsltv,labels=hemd$type,adj=c(0,-1)) - threehem: cpd ba deox ox hemin type 1 1 4.89 -5.32 -5.11 -5.18 alpha 2 2 4.89 -5.12 -4.92 -5.12 beta 3 3 5.41 -5.62 -5.41 -5.56 alpha 4 4 5.47 -5.34 -5.09 -5.3 beta 5 5 5.21 -5.41 -5.12 -5.36 beta 6 6 5.28 -5.44 -5.14 -5.39 beta 7 7 5.16 -5.47 -5.17 -5.39 beta 8 8 4.8 -5.43 -5.03 -5.41 beta 9 9 4.92 -5.17 -4.9 -5.12 beta 10 10 5.02 -5.29 -4.94 -5.35 beta 11 11 5.18 -5.72 -5.38 -5.68 alpha 12 12 5.44 -5.53 -5.39 -5.66 alpha 13 13 5.71 -5.93 -5.64 -5.86 alpha 14 14 5.74 -6.01 -5.78 -5.91 alpha 15 15 5.75 -5.79 -5.61 -5.71 alpha 16 16 5.87 -5.97 -5.67 -5.94 alpha 17 17 5.37 NA NA -6.49 alpha 18 18 5.75 NA NA -6.5 alpha 19 19 5.04 -5.26 NA -5.17 beta 20 20 4.89 -5.04 -4.75 -4.98 beta 21 21 5.81 -5.71 NA -5.87 alpha 22 22 5.62 -6.11 NA -6.23 alpha -- I have included the Xm matrix of predictors as an attachment. Thank you very much for your help. Roy Little Dept. Chem. Facultad de Ciencias Universidad de los Andes Mérida, Venezuela -0.12 -0.18 -0.41 0.14 -0.21 0.15 -0.25 -0.41 -0.41 -0.29 -0.28 -0.27 -0.43 -0.39 -0.43 -0.5 -0.3 -0.25 -0.4 0.06 4.89 -0.2 -0.16 -0.38 0.15 -0.2 0.15 -0.24 -0.42 -0.43 -0.3 -0.3 -0.29 -0.44 -0.39 -0.43 -0.51 -0.27 -0.26 -0.41 0.19 4.89 -0.11 -0.19 -0.41 0.14 -0.21 0.14 -0.27 -0.4 -0.4 -0.29 -0.28 -0.26 -0.42 -0.38 -0.44 -0.5 -0.3 -0.24 -0.4 0.03 5.41 -0.18 -0.16 -0.38 0.15 -0.2 0.15 -0.24 -0.42 -0.42 -0.31 -0.3 -0.29 -0.44 -0.39 -0.43 -0.51 -0.27 -0.26 -0.41 0.19 5.47 -0.2 -0.16 -0.38 0.15 -0.2 0.15 -0.24 -0.42 -0.42 -0.31 -0.3 -0.29 -0.44 -0.39 -0.43 -0.5 -0.27 -0.26 -0.4 0.19 5.21 -0.18 -0.16 -0.38 0.15 -0.2 0.15 -0.24 -0.42 -0.42 -0.31 -0.3 -0.29 -0.44 -0.39 -0.43 -0.51 -0.27 -0.26 -0.4 0.19 5.28 -0.18 -0.16 -0.38 0.15 -0.2 0.15 -0.24 -0.42 -0.42 -0.31 -0.3 -0.29 -0.44 -0.39 -0.43 -0.51 -0.27 -0.26 -0.41 0.19 5.16 -0.18 -0.16 -0.38 0.15 -0.21 0.15 -0.25 -0.42 -0.42 -0.31 -0.3 -0.29 -0.44 -0.39 -0.43 -0.51 -0.27 -0.26 -0.4 0.19 4.8 -0.18 -0.16 -0.38 0.15 -0.2 0.15 -0.24 -0.42 -0.42 -0.31 -0.3 -0.29 -0.44 -0.39 -0.43 -0.51 -0.27 -0.26 -0.4 0.19 4.92 -0.23 -0.14 -0.35 0.15 -0.2 0.15 -0.25 -0.4 -0.43 -0.33 -0.32 -0.3 -0.44 -0.39 -0.41 -0.51 -0.24 -0.26 -0.39 0.18 5.02 -0.15 -0.22 -0.44 0.14 -0.21 0.13 -0.29 -0.39 -0.41 -0.26 -0.24 -0.22 -0.39 -0.35 -0.44 -0.48 -0.33 -0.19 -0.39 -0.02 5.18 -0.12 -0.2 -0.42 0.14 -0.21 0.14 -0.28 -0.4 -0.41 -0.29 -0.27 -0.25 -0.41 -0.37 -0.44 -0.49 -0.31 -0.22 -0.39 0 5.44 -0.14 -0.19 -0.42 0.14 -0.21 0.14 -0.26 -0.41 -0.41 -0.28 -0.26 -0.25 -0.42 -0.39 -0.46 -0.49 -0.31 -0.23 -0.37 0.01 5.71 -0.16 -0.23 -0.44 0.14 -0.21 0.13 -0.29 -0.4 -0.4 -0.26 -0.23 -0.22 -0.4 -0.36 -0.45 -0.48 -0.33 -0.19 -0.38 -0.02 5.74 -0.14 -0.23 -0.43 0.14 -0.21 0.14 -0.28 -0.39 -0.4 -0.28 -0.26 -0.24 -0.38 -0.35 -0.42 -0.49 -0.32 -0.21 -0.39 -0.01 5.75 -0.14 -0.23 -0.43 0.14 -0.21 0.14 -0.28 -0.4 -0.4 -0.27 -0.25 -0.23 -0.37 -0.34 -0.4 -0.48 -0.32 -0.2 -0.39 -0.01 5.87 -0.22 -0.15 -0.36 0.15 -0.2 0.16 -0.24 -0.44 -0.43 -0.26 -0.26 -0.27 -0.38 -0.35 -0.32 -0.49 -0.27 -0.25 -0.34 0.05 5.37 -0.2 -0.27 -0.42 0.14 -0.2 0.15 -0.23 -0.34 -0.41 -0.28 -0.29 -0.28 -0.39 -0.34 -0.28 -0.46 -0.32 -0.26 -0.26 0.05 5.75 -0.18 -0.16 -0.38 0.15 -0.21 0.15 -0.25 -0.41 -0.42 -0.31 -0.3 -0.29 -0.44 -0.39 -0.43 -0.51 -0.27 -0.26 -0.4 0.19 5.04 -0.23 -0.13 -0.35 0.15 -0.2 0.16 -0.24 -0.41 -0.44 -0.32 -0.31 -0.3 -0.44 -0.39 -0.41 -0.51 -0.25 -0.26 -0.41 0.19 4.89 -0.22 -0.09 -0.35 0.15 -0.2 0.15 -0.26 -0.45 -0.45 -0.28 -0.26 -0.25 -0.41 -0.34 -0.36 -0.5 -0.27 -0.23 -0.34 0.01 5.81 -0.23 -0.13 -0.37 0.15 -0.2 0.14 -0.28 -0.43 -0.44 -0.26 -0.23 -0.22 -0.4 -0.33 -0.39 -0.49 -0.28 -0.2 -0.34 -0.01 5.62 -0.12 -0.18 -0.41 0.14 -0.21 0.15 -0.25 -0.42 -0.41 -0.3 -0.29 -0.28 -0.43 -0.43 -0.39 -0.51 -0.3 -0.26 -0.4 0.14 NA __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] plot - no main title and missing abscissa value
Iain Gallagher wrote: Hi all. I have defined a plot thus: par(mar=c(5,5,4,5),las=1, xpd=NA) plot(Day, Ym1Imp, ylim=c(0,100), type=b, bty=l, main=Ym1 Expression, cex=1.3, xaxt=n, yaxt=n) #plot implant data axis(side=1, at=c(0,1,3,5,7,10,14,21), labels=c(0,1,3,5,7,10,14,21)) # label x axis mtext(Day, side =1, at=10, line=3, cex=1.2) # title x axis The problem with this graph is that the main title is missing and so is the digit 1 at the abscissa position 1 - although the other abscissa labels are all there as defined in the axis call. Can anyone shed anylight on why this is? I'm using R 2.1 on OS X. We cannot reproduce your example due to lack of the data, hence cannot help very much. I can only guess that the number at the x-axis is left out for space reasons, but don't know what happens with your title. Please read the posting guide which suggests to specify a minimal toy example that shows your problem. Uwe Ligges Thanks Iain __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] matrix operation
There a re a few ways to do it without loop. Here is one: dat = matrix(runif(100), 50,2) dat[,1] = dat[,1] = dat[,2] Jarek \ Jarek Tuszynski, PhD. o / \ Science Applications International Corporation \__,| (703) 676-4192 \ [EMAIL PROTECTED] ` \ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, October 07, 2005 6:02 PM To: r-help@stat.math.ethz.ch Subject: [R] matrix operation Hello: I have a matrix 'dat' with 2 columns. I have the following code: for (i in 1:nrows(dat)) { if (dat[i,1] dat[i,2]) { dat[i,2]-0 } else { dat[i,2]-1 } Is there a way to accomplish this without the for loop? Thank you. -Dhiren __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] plot - no main title and missing abscissa value
Hi. Sorry (esp to Uwe for the repeated messages!) Here is the data and my code in full. Thanks for the help. Data. Day Ym1Imp Ym1sham Semimp Semsham 0 5.785.781.221.36 1 44.36 42.116.26 18.83 3 38.39 14.66 18.02 2.86 5 57.76 1.0315.28 0.29 7 72.93 2.7118.61.06 10 48.57 4.6111.26 5.21 14 74.08 1.539.660.11 21 73.86 0.147.2 0.02 Code ym- read.table(ym1expression.csv, header=T, sep=\t, quote=\) #read in ym data attach(ym)# make data visible to R par(mar=c(5,5,4,5),las=1, xpd=NA) x- c(0,1,3,5,7,10,14,21) plot(Day, Ym1Imp, ylim=c(0,100), type=b, bty=l, main=Ym1 Expression, cex=1.3, xaxt=n, yaxt=n) #plot implant data axis(side=1, at=c(0,1,3,5,7,10,14,21), labels=c(0,1,3,5,7,10,14,21)) # label x axis mtext(Day, side =1, at=10, line=3, cex=1.2) # title x axis mtext(AU, side=2, at=50, line=3, cex=1.2)# y axis title axis(side=2, at=c(0, 25, 50, 75, 100), labels=expression(0, 25, 50, 75, 100)) # label y axis arrows(x, Ym1Imp-Semimp, x, Ym1Imp+Semimp, code=3, angle=90, length=0.1)# place error bars points(Day, Ym1sham, type=b, pch=16, cex=1.3)# plot sham data arrows(x, Ym1sham-Semsham, x, Ym1sham+Semsham, code=3, angle=90, length=0.1)# plot sham error bars legend(20, 60, legend=Implant, pch=1, lty=1, bty=n)# implant legend legend(20, 50, legend=Sham, pch=16, lty=1, bty=n)# sham legend Iain -- Iain Gallagher Institute for Infection Immunology Research Ashworth Laboratories Kings Buildings University of Edinburgh Edinburgh EH9 3JT UK (+44) 0131 651 3630 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] glm contrasts (was: no subject)
pekar at sci.muni.cz writes: Can anybody tell me, please, how to get a matrix of SE of differences (or any SE) from a GLM object? Both model.tables and se.contrast work only for ANOVA objects. I remember there was a disp s directive in GLIM package. I would need something like that. estimable in bundle gregmisc (package gmodels) should do this. (Kiebitzers: Hope I got the bundle/package/library definition correct) Please use a meaningful subject line next time. Dieter __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Vectorizing loop
Not unless we know what runifpoint() and Kest() are. AFAIK these are not part of base R. If you use functions from add-on packages, please state them so as not to leave others guessing. (This is in the Posting Guide, which you were asked to read.) Andy From: Rainer M. Krug Hi I have the following loop and would like to vectorize it. Any ideas if it is possible? Thanks, Rainer Tha Loop: for (i in 2:Result$NoSims) { ppp - runifpoint(Result$NoPlants) K - Kest(ppp) Result$LSim[i,] - sqrt(K$iso / pi) - K$r CM - (Result$LSim[i,] * Result$LSim[i,]) / abs(K$r[2] - K$r[1]) Result$SigCM[i] - sum(CM, na.rm=TRUE) print(i) flush.console() } -- NEW TELEPHONE NUMBER Tel: +27 - (0)72 808 2975 (w) Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology University of Stellenbosch Matieland 7602 South Africa Tel: +27 - (0)72 808 2975 (w) Fax: +27 - (0)21 808 3304 Cell: +27 - (0)83 9479 042 email:[EMAIL PROTECTED] [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Vectorizing loop
Sorry runifpoint() and Kest are from the package spatstat Rainer Liaw, Andy wrote: Not unless we know what runifpoint() and Kest() are. AFAIK these are not part of base R. If you use functions from add-on packages, please state them so as not to leave others guessing. (This is in the Posting Guide, which you were asked to read.) Andy From: Rainer M. Krug Hi I have the following loop and would like to vectorize it. Any ideas if it is possible? Thanks, Rainer Tha Loop: for (i in 2:Result$NoSims) { ppp - runifpoint(Result$NoPlants) K - Kest(ppp) Result$LSim[i,] - sqrt(K$iso / pi) - K$r CM - (Result$LSim[i,] * Result$LSim[i,]) / abs(K$r[2] - K$r[1]) Result$SigCM[i] - sum(CM, na.rm=TRUE) print(i) flush.console() } __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] text(x,y,greek character)
On Mon, 2005-10-10 at 07:59 -0400, Roy Little wrote: Dear list, I would like to plot points with two types of labels, one at the data point (the name of the point) and another offset a bit with another factor which is either of the two greek characters alpha or beta. I have tried to get the routine to plot a greek character with expression() or with substitute() and have not yet had any success. The following only plots the word in english in plain text. Here is my subroutine and data: --- vmat-as.matrix(read.table(vmat)) Xm-vmat[1:22,1:20] hemd-read.table(threehem,header=T) Ym-as.matrix(hemd[,2]) gvdw.pls-plsr(Ym ~ Xm,6,method=kernelpls) rsltv-predict(gvdw.pls,comps=6) plot(Ym,rsltv,type=n,xlab=Actividad + Biológica,xlim=c(4.6,6),ylim=c(4.8,6),ylab= Act. + Biol.(Pred.),main=QSAR Ligación de Derivados de la Artemisina con + Hemina,sub=Descriptores de Coeficientes VdW) text(Ym,rsltv,labels=threehem$cpd) text(Ym,rsltv,labels=hemd$type,adj=c(0,-1)) - snip of data I believe I have a solution for you, but you may want to consider the presentation, as it gets a bit busy. Perhaps consider using two colors for the numeric text, where each color represents either alpha or beta and then indicate this in a legend. This could be done using: cols - ifelse(hemd$type == alpha, red, blue) text(Ym,rsltv,labels=hemd$cpd, col = cols) legend(topleft, legend = c(expression(alpha), expression(beta)), fill = c(red, blue)) Also, two notes: 1. If you are going to use a function that is not in the base R distribution, please indicate this so that folks can help without having to search. In this case, the plsr() function is in the pls package, which required a library(pls) before using your code. 2. The line: text(Ym,rsltv,labels=threehem$cpd) should be: text(Ym,rsltv,labels=hemd$cpd) Here is a solution: greek - parse(text = as.character(hemd$type)) text(Ym, rsltv, labels = greek, adj=c(0, -1)) hemd$type is a factor, so it needs to be converted to a character vector before being able to be used as an expression. Using parse() then converts the character vector to an expression. The result of the first line is: greek expression(alpha, beta, alpha, beta, beta, beta, beta, beta, beta, beta, alpha, alpha, alpha, alpha, alpha, alpha, alpha, alpha, beta, beta, alpha, alpha) Thus, 'greek' can be used in text() as an expression. HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] details about lm()
Uwe Ligges a écrit : [EMAIL PROTECTED] wrote: Domenico Cozzetto a écrit : Dear all, I'd like to get a linear regression of some data, and impose that the line goes through a given point P. I've tried to use the lm() method in the package stats, but I wasn't able to specify the coordinates of the point P. Maybe I should use another method? add directly P in your data is also a way No! Sorry indeed for my not at all rigourous answer. Adding P in the data set will indeed not force the regression line to pass through P (P will only be one more points of the cloud, adding P will attract the regression line, not more.) I did make this answer because I'm yet working with very small data sets, and adding P (in more than one exemplar when needed in order to give it more weight), is a fast, (a bit ugly I agree), way to do. But on the kind of data I use, it works good enough. I should have add this precision. Apologies. Please, both of you, consult a basic textbook on linear regression. If you have a good reference or link in mind, I would thank you. You can transform the data (linear) so that P becomes (0,0), after that you can estimate the slope without intercept by specifying lm(y ~ x - 1) The slope estimate is still valid while your intercept can be calculated afterwards. Sorry for my lack of knowledge, but will the above trick really force the regression line to pass through P ? adding (0,0) in this new system of coordinates isn't it equivalent to add P to the dataset in the original system ? If my question is too basic and/or too stupid, just give it a rest. Vincent __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Question about Survey Package
To whom it may concern, I have a question referring to the calculation of variance estimation of the survey package I need to estimate the variance for different Domains but for a stratified sampling desing in several stages. Särndal et al (1992), CAP 10, makes reference to this problem. My question is if it is possible by means of survey package to obtain these calculations, and if it follows the methodology raised by Särndal or another author. I have noticed that the shown expression presents two components, one that is quiet the variance between strata for the Domain and the second is the mean square sum between strata. I beforehand thank for any commentary that can be done on the matter. Rigoberto Real ___ Rigoberto Real Miranda Oficina de Métodos Cuantitativos Banco de México Av. 5 de Mayo No. 18, 5° piso, secc. A Col. Centro, 06059 '**5237 2000 ext. 3667 ** *** [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] lmer / variance-covariance matrix random effects
Hello, has someone written by chance a function to extract the variance-covariance matrix from a lmer-object? I've noticed the VarCorr function, but it gives unhandy output. Regards, Roel de Jong __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] details about lm()
[EMAIL PROTECTED] wrote: Uwe Ligges a écrit : [EMAIL PROTECTED] wrote: Domenico Cozzetto a écrit : Dear all, I'd like to get a linear regression of some data, and impose that the line goes through a given point P. I've tried to use the lm() method in the package stats, but I wasn't able to specify the coordinates of the point P. Maybe I should use another method? add directly P in your data is also a way No! Sorry indeed for my not at all rigourous answer. Adding P in the data set will indeed not force the regression line to pass through P (P will only be one more points of the cloud, adding P will attract the regression line, not more.) I did make this answer because I'm yet working with very small data sets, and adding P (in more than one exemplar when needed in order to give it more weight), is a fast, (a bit ugly I agree), way to do. But on the kind of data I use, it works good enough. I should have add this precision. Apologies. Please, both of you, consult a basic textbook on linear regression. If you have a good reference or link in mind, I would thank you. E.g., among several other, the great comprehensive books by John Fox are really well written and easy to understand ... You can transform the data (linear) so that P becomes (0,0), after that you can estimate the slope without intercept by specifying lm(y ~ x - 1) The slope estimate is still valid while your intercept can be calculated afterwards. Sorry for my lack of knowledge, but will the above trick really force the regression line to pass through P ? adding (0,0) in this new system of coordinates isn't it equivalent to add P to the dataset in the original system ? Well, you do not add that point, but transform the others: Say you have (let's make a very simple 1-D example) points P_i = (x_i, y_i), and P = (x_0, y_0). Then calculate for all i: P'_i = (x_i - x_0, y_i - y_0) Now you can calculate a regression without any Intercept by lm(y ~ x - 1) You got the slope now and the Intercept is 0 so far for P'. After that, you can re-transform to get the real data's intercept: Intercept = -(slope * x_0) + y_0 Uwe Ligges If my question is too basic and/or too stupid, just give it a rest. Vincent __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] R.app window size
Hi all, This is a question for any of you who use R.app (OS X). Is there any way to resize the quartz plot window from within R? I know that you can resize the window by dragging the corner of the window, and fro the preferences panel. But is there a way to specify the window size from the console? I want to specify the size of the plot window from inside an R function. Also a related question: I notice that text does not resize proportionately - it stays the same size when you resize the window. Can this be controlled from the console as well? Is there a way to make text resize proportionately with window size? Thanks, - Jason Jason Horn Boston University Department of Biology 5 Cumington Street Boston, MA 02215 [EMAIL PROTECTED] office: 617 353 6987 cell: 401 588 2766 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] decreasing performance of for() loop
Dear useRs, I'm wondering why the for() loop below runs slower as it progresses. On a Win XP box, the iterations at the beginning run much faster than those at the end: 1%, iteration 2000, 10:10:16 2%, iteration 4000, 10:10:17 3%, iteration 6000, 10:10:17 98%, iteration 196000, 10:24:04 99%, iteration 198000, 10:24:24 100%, iteration 20, 10:24:38 Is there something that can be done about this? Would such a loop run faster in C/C++/Fortran? Thank you, b. #---sample code loop.progress - function(loop,iterations,steps,toprint=NULL) { marks - c(1,floor(iterations/steps)*(1:steps)) if (loop %in% marks) { if (is.null(toprint)) prt - loop else prt - toprint cat(paste(round((which(marks == loop)-1)*(100/steps),0),%, iteration , prt,, ,format(Sys.time(),%H:%M:%S),sep=),\n) } } #---loop that runs slower and slower test - runif(20) out - vector(mode=numeric) lg - 30 for (i in (lg+1):length(test)) { loop.progress(i,length(test),100) out[i] - sum(test[(i-lg):i]) } __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] wildcards and removing variables
All, Is there are a wildcard in R for varible names as in unix? For example, rm(results*) to remove all variable or function names that begin w/ results? cheers, Dave ps - please respond directly to [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] decreasing performance of for() loop
Nevermind, I found the fix. Declaring the length for out eliminates the performance decrease, out - vector(mode=numeric,length=length(test)) On 10/10/05, bogdan romocea [EMAIL PROTECTED] wrote: Dear useRs, I'm wondering why the for() loop below runs slower as it progresses. On a Win XP box, the iterations at the beginning run much faster than those at the end: 1%, iteration 2000, 10:10:16 2%, iteration 4000, 10:10:17 3%, iteration 6000, 10:10:17 98%, iteration 196000, 10:24:04 99%, iteration 198000, 10:24:24 100%, iteration 20, 10:24:38 Is there something that can be done about this? Would such a loop run faster in C/C++/Fortran? Thank you, b. #---sample code loop.progress - function(loop,iterations,steps,toprint=NULL) { marks - c(1,floor(iterations/steps)*(1:steps)) if (loop %in% marks) { if (is.null(toprint)) prt - loop else prt - toprint cat(paste(round((which(marks == loop)-1)*(100/steps),0),%, iteration , prt,, ,format(Sys.time(),%H:%M:%S),sep=),\n) } } #---loop that runs slower and slower test - runif(20) out - vector(mode=numeric) lg - 30 for (i in (lg+1):length(test)) { loop.progress(i,length(test),100) out[i] - sum(test[(i-lg):i]) } __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] wildcards and removing variables
On Mon, 2005-10-10 at 10:37 -0400, Afshartous, David wrote: All, Is there are a wildcard in R for varible names as in unix? For example, rm(results*) to remove all variable or function names that begin w/ results? cheers, Dave ps - please respond directly to [EMAIL PROTECTED] See ?ls, which has a 'pattern' argument, enabling the use of Regex to define the objects to be listed and subsequently removed using rm(). You can then use something like: rm(list = ls(pattern = \\bresults.)) HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] sqlFetch on MySQL-DB
Am 10 Oct 2005 um 7:51 hat christian schulz geschrieben: Hi, there is a problem with the type of attributes - is it varchar!? IMHO you should play a bit with different type's in mysql and the consequence in R. I recognize similar problems with RMySQL, if you have variables with type decimal in mysql you get numerics in chr. But it's possible to change the decimal in double (mysql) to get num in R. Thanks to Christian Schulz and Prof. Ripley for their valuable suggestions. The use of author-sqlFetch(test,author,as.is=17) does the job without any problems. Bernd __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] wildcards and removing variables
rm() can take a list of object names as an argument and ls(pattern='^results') gives such a list. So rm(ls(pattern='^results')) would remove all objects that are matched by the regular expression, that is all that begin with 'results' HTH, Johan 2005/10/10, Marc Schwartz (via MN) [EMAIL PROTECTED]: On Mon, 2005-10-10 at 10:37 -0400, Afshartous, David wrote: All, Is there are a wildcard in R for varible names as in unix? For example, rm(results*) to remove all variable or function names that begin w/ results? cheers, Dave ps - please respond directly to [EMAIL PROTECTED] See ?ls, which has a 'pattern' argument, enabling the use of Regex to define the objects to be listed and subsequently removed using rm(). You can then use something like: rm(list = ls(pattern = \\bresults.)) HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Johan Sandblom N8, MRC, Karolinska sjh t +46851776108 17176 Stockholm m +46735521477 Sweden What is wanted is not the will to believe, but the will to find out, which is the exact opposite - Bertrand Russell __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] wildcards and removing variables
On 10/10/05, Marc Schwartz (via MN) [EMAIL PROTECTED] wrote: On Mon, 2005-10-10 at 10:37 -0400, Afshartous, David wrote: All, Is there are a wildcard in R for varible names as in unix? For example, rm(results*) to remove all variable or function names that begin w/ results? cheers, Dave ps - please respond directly to [EMAIL PROTECTED] See ?ls, which has a 'pattern' argument, enabling the use of Regex to define the objects to be listed and subsequently removed using rm(). You can then use something like: rm(list = ls(pattern = \\bresults.)) Also, in R 2.2.0 (or look in sfsmisc package for older versions of R) you can use glob2rx to get shell-style wildcards (aka globbing): ls(pattern = glob2rx(results*)) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] wildcards and removing variables
On Mon, 10 Oct 2005, Marc Schwartz (via MN) wrote: On Mon, 2005-10-10 at 10:37 -0400, Afshartous, David wrote: All, Is there are a wildcard in R for varible names as in unix? For example, rm(results*) to remove all variable or function names that begin w/ results? cheers, Dave ps - please respond directly to [EMAIL PROTECTED] See ?ls, which has a 'pattern' argument, enabling the use of Regex to define the objects to be listed and subsequently removed using rm(). You can then use something like: rm(list = ls(pattern = \\bresults.)) One new feature of R-2.2.0 is glob2rx, which converts wildcards to regexps for you. E.g. rm(list = ls(pattern = glob2rc(results*))) (I think if does it a little better, as that trailing dot is not I think correct: result* matches result.) -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] wildcards and removing variables
In R 2.2.0, there is the function 'glob2rx()' which can be used for this purpose. As in rm(list = ls(pattern = glob2rx(results*))) -roger Afshartous, David wrote: All, Is there are a wildcard in R for varible names as in unix? For example, rm(results*) to remove all variable or function names that begin w/ results? cheers, Dave ps - please respond directly to [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Roger D. Peng http://www.biostat.jhsph.edu/~rpeng/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] wildcards and removing variables
On Mon, 2005-10-10 at 16:01 +0100, Prof Brian Ripley wrote: On Mon, 10 Oct 2005, Marc Schwartz (via MN) wrote: On Mon, 2005-10-10 at 10:37 -0400, Afshartous, David wrote: All, Is there are a wildcard in R for varible names as in unix? For example, rm(results*) to remove all variable or function names that begin w/ results? cheers, Dave ps - please respond directly to [EMAIL PROTECTED] See ?ls, which has a 'pattern' argument, enabling the use of Regex to define the objects to be listed and subsequently removed using rm(). You can then use something like: rm(list = ls(pattern = \\bresults.)) One new feature of R-2.2.0 is glob2rx, which converts wildcards to regexps for you. E.g. rm(list = ls(pattern = glob2rc(results*))) (I think if does it a little better, as that trailing dot is not I think correct: result* matches result.) Thanks to both Gabor and Prof. Ripley for pointing out the use of glob2rc(). One of the new features I had forgotten about since reading NEWS. On the trailing dot, I was just in the process of drafting a follow up after realizing my error, since as you point out, 'results' would not be matched in that case. Thanks, Marc __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] greek symbols using pch
FISCHER, Matthew [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] In a plot, can I specify pch to be a greek symbol? (I looked at show.pch() in the Hmisc package but couldn't see the right symbols in there). If not, I guess I can get around this using text(x,y,expression()). I'm not sure where this is explained very well. Having ?font give a clue about this would be nice. Use font=5, the symbol font. To see what's in font=5: par(font=5, las=1) plot(0:15,0:15,type=n,ylim=c(15,0), main=Symbols in Font=5, xlab=, ylab=,xaxt=n, yaxt=n) axis(BOTTOM-1, at=0:15, 1:16) axis(LEFT -2, at=0:15) abline(v=0.5 + 0:14, h=0.5 + 0:14, col=grey, lty=dotted) # pch index of any cell is 16*row + column for(i in 0:255) { x - i %%16; y - i %/% 16; points(x,y,pch=i+1) } The Greek letters are from 65 to 90 and 97 to 122 in this font. Here are random points with Greek letters as the plot character: par(font=5) # Use Greek letter for plot characters from font=5 plot(0:1, 0:1, axes=F, type=n, xlab=, ylab=, main=Greek plotting characters) box() points(runif(100), runif(100), pch=c(65:90, 97:122)) -- efg Earl F. Glynn Scientific Programmer Stowers Institute for Medical Research __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] passing char to Fortran routine
Hello all, I am using an existing Fortran routine that takes a single character string as argument. The routine echoes the argument that I provide. When working on OS X 3.9 there seems to be no problem, ie the Fortran routine nicely echoes my argument. However, I compiled the same package on a PC (using all the tools provided in the R for windows faq), and the routine only echoes the first letter of each character string that I pass on to it. My questions are: 1) Is this somehow compiler specific? 2) Should I explicitly provide the Fortran routine with the length of the character string? 3) I am at a loss as to what is happening here, so any hint is welcome (-; The call to the Fortran routine is as follows: .Fortran(npoptn,as.character(opt),PACKAGE=depmix) where opt is a character string such as opt=Iteration limit = 100 best, ingmar __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] plot - no main title and missing abscissa value
For anyone who's looked at my previously posted problem I have managed to solve the missing graph title by removing the main=Graph Title call from my plot definition and adding a line defining the graph title as a title call. i.e. from plot(Day, Ym1Imp, ylim=c(0,100), type=b, bty=l, main=Ym1 Expression, cex=1.3, xaxt=n, yaxt=n) #plot implant data to plot(Day, Ym1Imp, ylim=c(0,100), type=b, bty=l, cex=1.3, xaxt=n, yaxt=n) #plot implant data title(main=Ym1 Expression)# add title which for some reason works. Still have the missing abscissa value though :-( Iain __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] trouble installing AnalyzeFMRI package: please help
maintainer if I can figure out who he is. Any clues? Try reading the docs! library(help='AnalyzeFMRI') -- Bert Gunter __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R.app window size
On Mon, 10 Oct 2005, Jason Horn wrote: This is a question for any of you who use R.app (OS X). Is there any way to resize the quartz plot window from within R? I know that you can resize the window by dragging the corner of the window, and fro the preferences panel. But is there a way to specify the window size from the console? I want to specify the size of the plot window from inside an R function. You had a problem with the width height arguments? Probably best to use device independent method for scripting. grdev - function(...) { get(getOption(device))(...) } grdev(width = 7.8, height = 5.8) #quartz(width = 7.8, height = 5.8) -- SIGSIG -- signature too long (core dumped) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] passing char to Fortran routine
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Programming questions are appropriate for R-devel, as it says there. The issue is OS-specific, but we don't see what your Fortran code is. If you send a reproducible example to the R-devel list, people may be able to suggest what the problem is. On Mon, 10 Oct 2005, Ingmar Visser wrote: Hello all, I am using an existing Fortran routine that takes a single character string as argument. The routine echoes the argument that I provide. When working on OS X 3.9 there seems to be no problem, ie the Fortran routine nicely echoes my argument. However, I compiled the same package on a PC (using all the tools provided in the R for windows faq), and the routine only echoes the first letter of each character string that I pass on to it. My questions are: 1) Is this somehow compiler specific? 2) Should I explicitly provide the Fortran routine with the length of the character string? 3) I am at a loss as to what is happening here, so any hint is welcome (-; The call to the Fortran routine is as follows: .Fortran(npoptn,as.character(opt),PACKAGE=depmix) where opt is a character string such as opt=Iteration limit = 100 -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R.app window size
Jason, ?quartz lists the options, e.g. quartz(width=6, height=7, pointsize=24) All from the console. A better alias for these questions is R-Sig-Mac (r-sig- [EMAIL PROTECTED]). Rob On Oct 10, 2005, at 7:25 AM, Jason Horn wrote: Hi all, This is a question for any of you who use R.app (OS X). Is there any way to resize the quartz plot window from within R? I know that you can resize the window by dragging the corner of the window, and fro the preferences panel. But is there a way to specify the window size from the console? I want to specify the size of the plot window from inside an R function. Also a related question: I notice that text does not resize proportionately - it stays the same size when you resize the window. Can this be controlled from the console as well? Is there a way to make text resize proportionately with window size? Thanks, - Jason Jason Horn Boston University Department of Biology 5 Cumington Street Boston, MA 02215 [EMAIL PROTECTED] office: 617 353 6987 cell: 401 588 2766 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting- guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R: integration problem
Hi, If your limits were to be from -1 to +1 (instead of lower limit being 0), your integral is: pi * I_0(b) Where I_0 is the modified Bessel's function of the zeroth order. If it is from 0 to 1, then there is no closed form (the integrand is not symmetric about 0). You must evaluate the integral with exp(a*cos(t)) as the integrand from 0 to pi/2. Hope this is helpful, Ravi. -Original Message- From: [EMAIL PROTECTED] [mailto:r-help- [EMAIL PROTECTED] On Behalf Of Clark Allan Sent: Monday, October 10, 2005 4:07 AM To: r-help@stat.math.ethz.ch Subject: [R] R: integration problem hi all an integration problem. i would like an exact or good approximation for the following, but i do not want to use a computer. any suggestions: integral of exp(b*x)/sqrt(1-x^2) where b is a constant greater than or equal to 0 and the integral runs from 0 to 1 any help would be apreciated / allan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] problem with lapply(x, subset, ...) and variable select argument
I need to extract identically named columns from several data frames in a list. the column name is a variable (i.e. not known in advance). the whole thing occurs within a function body. I'd like to use lapply with a variable 'select' argument. example: tt - function (n) { x - list(data.frame(a=1,b=2), data.frame(a=3,b=4)) for (xx in x) print(subset(xx, select = n)) ### works print (lapply(x, subset, select = a)) ### works print (lapply(x, subset, select = a)) ### works print (lapply(x, subset, select = n)) ### does not work as intended } n = b tt(a) #works (but selects not the intended column) rm(n) tt(a) #no longer works in the lapply call including variable 'n' question: how can I enforce evaluation of the variable n such that the lapply call works? I suspect it has something to do with eval and specifying the correct evaluation frame, but how? many thanks joerg __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] details about lm()
Uwe Ligges a écrit : [EMAIL PROTECTED] wrote: Sorry for my lack of knowledge, but will the above trick really force the regression line to pass through P ? adding (0,0) in this new system of coordinates isn't it equivalent to add P to the dataset in the original system ? Well, you do not add that point, but transform the others: Say you have (let's make a very simple 1-D example) points P_i = (x_i, y_i), and P = (x_0, y_0). Then calculate for all i: P'_i = (x_i - x_0, y_i - y_0) Now you can calculate a regression without any Intercept by lm(y ~ x - 1) You got the slope now and the Intercept is 0 so far for P'. After that, you can re-transform to get the real data's intercept: Intercept = -(slope * x_0) + y_0 Thank you very much for the kind answer and for your time. (I'll read that carefully and take my rule, pencil and R). Vincent __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Question about Survey Package
On Mon, 10 Oct 2005, Real Miranda Rigoberto wrote: I have a question referring to the calculation of variance estimation of the survey package I need to estimate the variance for different Domains but for a stratified sampling desing in several stages. S?rndal et al (1992), CAP 10, makes reference to this problem. My question is if it is possible by means of survey package to obtain these calculations, and if it follows the methodology raised by S?rndal or another author. Yes, it is possible. The computations for totals are based on the use of domain indicator variables when computing variances, as in Sarndal et al (1992), and the handling of multistage sampling is as in chapter 4.4 of that book. The computations for statistics other than totals are based on estimating the total of a suitable estimating function and then solving the estimating equation. In fact, for domain means there are three equivalent ways to compute the estimator and its variance, and one of the package tests checks that these give the same answer With the data set from example(mu284) we could compute the mean for the completely artificial domain id21 by svymean(~y1, subset(dmu284, id21)) The subset() function knows how to handle survey designs to give correct domain estimation. This is equivalent to two more obviously correct estimators based on the whole sample: a regression estimator summary(svyglm(y1~factor(id21)+0, design=dmu284) and to a ratio estimator svyratio(~as.numeric(y1*(id21)), ~as.numeric(id21), design=dmu284) All three give the same mean estimator and standard error. -thomas Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle__ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] RE : interpretation output glmmPQL
Thank you for your response. Sorry for insisting but I havent understood if the data do not permit to include an individual effect or if it is just the models I run. We have several flowers and several fruits per individual plant. So there is a correlation between the flowers/fruits of one plant. But when we run the models here after which are apparently adapted for this type of data (and which should treat the flowers/fruits and not the individual plants) the number of observations given is equal to the number of individuals and not to the number of fruits + the number of flowers. Do you think that our model is good and that we cannot ask for an individual effect in our case or do you think that there are some other functions which permit to take account of the dependence between flowers/fruits of a same individual? Thank you by advance Emmanuelle y - cbind(indnbfruits,indnbflowers); model1 -glm(y~red*yellow+I(red^2)+I(yellow^2)+densite8+I(densite8^2)+freq8_4+I (freq8_4^2), quasibinomial); model2 - glmmPQL(y~red*yellow+I(red^2)+I(yellow^2)+densite8+I(densite8^2)+freq8_4 +I(freq8_4^2), random=~1|num, quasibinomial); Emmanuelle TASTARD UMR 5174 'Evolution et Diversité Biologique' Université Paul Sabatier Bat 4R3 31062 TOULOUSE CEDEX 9 France tel : 05 61 55 67 59 -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de [EMAIL PROTECTED] Envoyé : lundi 10 octobre 2005 10:22 À : r-help@stat.math.ethz.ch Objet : Re: [R] interpretation output glmmPQL We study the effect of several variables on fruit set for 44 individuals (plants). For each individual, we have the number of fruits, the number of flowers and a value for each variable. ... - Glm does not take account of the correlation between the flowers of a unique individual. So we would like to add a random effect 'individual' but the model2 (here after) gives an output similar to the one of model1 for estimated coefficients and p-values. ... Does it mean that there is no individual effect or is my model not good (number of groups (individuals)=number of observations, is it possible?). If you have only one observation per indiviudal plant, how could there be dependence within the plant? This would only make sense if your observations were the individual flowers. Data on those could be correlated within plant and then a random term for the plant is meaningful. Cheers, Lorenz - Lorenz Gygax Centre for proper housing of ruminants and pigs Swiss Federal Veterinary Office agroscope FAT Tänikon, CH-8356 Ettenhausen / Switzerland __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] problem with lapply(x, subset, ...) and variable select argument
On Mon, 10 Oct 2005, joerg van den hoff wrote: I need to extract identically named columns from several data frames in a list. the column name is a variable (i.e. not known in advance). the whole thing occurs within a function body. I'd like to use lapply with a variable 'select' argument. You would probably be better off using [ rather than subset(). tt - function (n) { x - list(data.frame(a=1,b=2), data.frame(a=3,b=4)) print(lapply(x,[,n)) } seems to do what you want. -thomas example: tt - function (n) { x - list(data.frame(a=1,b=2), data.frame(a=3,b=4)) for (xx in x) print(subset(xx, select = n)) ### works print (lapply(x, subset, select = a)) ### works print (lapply(x, subset, select = a)) ### works print (lapply(x, subset, select = n)) ### does not work as intended } n = b tt(a) #works (but selects not the intended column) rm(n) tt(a) #no longer works in the lapply call including variable 'n' question: how can I enforce evaluation of the variable n such that the lapply call works? I suspect it has something to do with eval and specifying the correct evaluation frame, but how? many thanks joerg __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] problem with lapply(x, subset, ...) and variable select argument
The problem is that subset looks into its parent frame but in this case the parent frame is not the environment in tt but the environment in lapply since tt does not call subset directly but rather lapply does. Try this which is similar except we have added the line beginning with environment before the print statement. tt - function (n) { x - list(data.frame(a=1,b=2), data.frame(a=3,b=4)) environment(lapply) - environment() print(lapply(x, subset, select = n)) } n - b tt(a) What this does is create a new version of lapply whose parent is the environment in tt. On 10/10/05, joerg van den hoff [EMAIL PROTECTED] wrote: I need to extract identically named columns from several data frames in a list. the column name is a variable (i.e. not known in advance). the whole thing occurs within a function body. I'd like to use lapply with a variable 'select' argument. example: tt - function (n) { x - list(data.frame(a=1,b=2), data.frame(a=3,b=4)) for (xx in x) print(subset(xx, select = n)) ### works print (lapply(x, subset, select = a)) ### works print (lapply(x, subset, select = a)) ### works print (lapply(x, subset, select = n)) ### does not work as intended } n = b tt(a) #works (but selects not the intended column) rm(n) tt(a) #no longer works in the lapply call including variable 'n' question: how can I enforce evaluation of the variable n such that the lapply call works? I suspect it has something to do with eval and specifying the correct evaluation frame, but how? many thanks joerg __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] R on a supercomputer
I am using R with Bioconductor to perform analyses on large datasets using bootstrap methods. In an attempt to speed up my work, I have inquired about using our local supercomputer and asked the administrator if he thought R would run faster on our parallel network. I received the following reply: The second benefit is that the processors have large caches. Briefly, everything is loaded into cache before going into the processor. With large caches, there is less movement of data between memory and cache, and this can save quite a bit of time. Indeed, when programmers optimize code they usually think about how to do things to keep data in cache as long as possible. Whether you would receive any benefit from larger cache depends on how R is written. If it's written such that data remain in cache, the speed-up could be considerable, but I have no way to predict it. My question is, is R written such that data remain in cache? Thanks, Mark W. Kimpel MD Indiana University School of Medicine [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Under-dispersion - a stats question?
Hello all: I frequently have glm models in which the residual variance is much lower than the residual degrees of freedom (e.g. Res.Dev=30.5, Res.DF = 82). Is it appropriate for me to use a quasipoisson error distribution and test it with an F distribution? It seems to me that I could stand to gain a much-reduced standard error if I let the procedure estimate my dispersion factor (which is what I assume the quasi- distributions do). Thank you for any input at all. Hank Dr. Martin Henry H. Stevens, Assistant Professor 338 Pearson Hall Botany Department Miami University Oxford, OH 45056 Office: (513) 529-4206 Lab: (513) 529-4262 FAX: (513) 529-4243 http://www.cas.muohio.edu/~stevenmh/ http://www.muohio.edu/ecology/ http://www.muohio.edu/botany/ E Pluribus Unum __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R on a supercomputer
In general, R is not written in such a way that data remain in cache. However, R can use optimized BLAS libraries, and these are. So if your version of R is compiled to use an optimized BLAS library appropriate to the machine (e.g., ATLAS, or Prof. Goto's Blas), AND a considerable amount of the computation done in your R program involves basic linear algebra (matrix multiplication, etc.), then you might see a good speedup. -- Tony Plate Kimpel, Mark William wrote: I am using R with Bioconductor to perform analyses on large datasets using bootstrap methods. In an attempt to speed up my work, I have inquired about using our local supercomputer and asked the administrator if he thought R would run faster on our parallel network. I received the following reply: The second benefit is that the processors have large caches. Briefly, everything is loaded into cache before going into the processor. With large caches, there is less movement of data between memory and cache, and this can save quite a bit of time. Indeed, when programmers optimize code they usually think about how to do things to keep data in cache as long as possible. Whether you would receive any benefit from larger cache depends on how R is written. If it's written such that data remain in cache, the speed-up could be considerable, but I have no way to predict it. My question is, is R written such that data remain in cache? Thanks, Mark W. Kimpel MD Indiana University School of Medicine [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Under-dispersion - a stats question?
Martin Henry H. Stevens [EMAIL PROTECTED] writes: Hello all: I frequently have glm models in which the residual variance is much lower than the residual degrees of freedom (e.g. Res.Dev=30.5, Res.DF = 82). Is it appropriate for me to use a quasipoisson error distribution and test it with an F distribution? It seems to me that I could stand to gain a much-reduced standard error if I let the procedure estimate my dispersion factor (which is what I assume the quasi- distributions do). Thank you for any input at all. I don't think it is safe to say anything general about this without knowledge of the model and the subject matter. Residual deviances can be terribly misleading. Consider for instance this: y - c(0,1); w - c(50,50) summary(glm(y~1, binomial, weights=w)) y1 - .5; w1 - 100 summary(glm(y1~1, binomial, weights=w1)) Notice that coeff. and s.e. is exactly the same, but not the residual deviances. Now, in the first case, did the zeros and ones sort themselves into two completely separated groups, or was that just because data was given pre-tabulated? -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] plot - no main title and missing abscissa value
Iain Gallagher wrote: Hi. Sorry (esp to Uwe for the repeated messages!) Here is the data and my code in full. Thanks for the help. Data. Day Ym1Imp Ym1sham Semimp Semsham 0 5.785.781.221.36 1 44.36 42.116.26 18.83 3 38.39 14.66 18.02 2.86 5 57.76 1.0315.28 0.29 7 72.93 2.7118.61.06 1048.57 4.6111.26 5.21 1474.08 1.539.660.11 2173.86 0.147.2 0.02 Code ym- read.table(ym1expression.csv, header=T, sep=\t, quote=\) #read in ym data attach(ym)# make data visible to R par(mar=c(5,5,4,5),las=1, xpd=NA) x- c(0,1,3,5,7,10,14,21) plot(Day, Ym1Imp, ylim=c(0,100), type=b, bty=l, main=Ym1 Expression, cex=1.3, xaxt=n, yaxt=n) #plot implant data axis(side=1, at=c(0,1,3,5,7,10,14,21), labels=c(0,1,3,5,7,10,14,21)) # label x axis mtext(Day, side =1, at=10, line=3, cex=1.2) # title x axis mtext(AU, side=2, at=50, line=3, cex=1.2)# y axis title axis(side=2, at=c(0, 25, 50, 75, 100), labels=expression(0, 25, 50, 75, 100)) # label y axis arrows(x, Ym1Imp-Semimp, x, Ym1Imp+Semimp, code=3, angle=90, length=0.1)# place error bars points(Day, Ym1sham, type=b, pch=16, cex=1.3)# plot sham data arrows(x, Ym1sham-Semsham, x, Ym1sham+Semsham, code=3, angle=90, length=0.1)# plot sham error bars legend(20, 60, legend=Implant, pch=1, lty=1, bty=n)# implant legend legend(20, 50, legend=Sham, pch=16, lty=1, bty=n)# sham legend Iain Three points: 1. The main title appears for me under the Windows device. I really wonder why you do not see it, this seems to be quite a strange device dependence I would not expect in this case. Since you told us you have R 2.1, we do not know exactly what you have got - there is no such version. There are versions R-2.0.1, R-2.1.0 and R-2.1.1, though. Anyway, you told us you found a workaround. 2. In order to re-plot the axis labels, you should specify xlab=NA, ylab=NA in your call to plot() as in: plot(Day, Ym1Imp, ylim=c(0,100), type=b, bty=l, xlab=NA, ylab=NA, main=Ym1 Expression, cex=1.3, xaxt=n, yaxt=n) 3. As I have already guessed, the axis annotation of the tick at position 1 is left out because R thinks there is not enough space left. You can workaround this point by making the label appear separately as in: axis(side=1, at=c(0,3,5,7,10,14,21)) axis(1, 1) Uwe Ligges __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Has anyone written scripts to read CPS data?
Hello, Has anyone ever written the R code that would extract data from the CPS March Supplements? If not, I'll give it a go. --Bill __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] labels of a conditioning variable in xyplot
I am running R 2.1.1 on a Mac g5 under Mac OS 10.4.2. I have an xyplot with a single conditioning variable (8 levels) . Here is the code for the conditioning variable used in the formula argument of xyplot: factor( drugauthoryear, levels = c( 'bupicapogna1999', 'levobenhamou2003', 'ropicapogna1999', 'ropipolley1999', 'bupipolley1999', 'levopolley2003', 'ropibenhamou2003', 'ropipolley2003' ), labels = c( 'Bupi. Reference 2.', 'Levo. Reference 4.', 'Ropi. Reference 2.', 'Ropi. Reference 3.', 'Bupi. Reference 3.', 'Levo. Reference 5.', 'Ropi. Reference 4.', 'Ropi. Reference 5.' ) ) The object is not created and I get the following error message: Error in do.call(pmax, lapply(cond, is.na)) : symbol print-name too long When I delete the labels vector, the code runs without difficulty. Any thoughts on this error message? Thanks, Nathan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] labels of a conditioning variable in xyplot
Error in do.call(pmax, lapply(cond, is.na)) : symbol print-name too long When I delete the labels vector, the code runs without difficulty. Any thoughts on this error message? Yes ... the labels are too long to be printed in the space available. Use shorter labels. For example, remove Reference or abbreviate it to Ref , as it provides no unique identifying info anyway. (Am I missing something? -- I would have thought this was obvious) -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nathan Leon Pace, MD, MStat Sent: Monday, October 10, 2005 3:53 PM To: r-help@stat.math.ethz.ch Cc: Nathan Leon Pace, MD, MStat Subject: [R] labels of a conditioning variable in xyplot I am running R 2.1.1 on a Mac g5 under Mac OS 10.4.2. I have an xyplot with a single conditioning variable (8 levels) . Here is the code for the conditioning variable used in the formula argument of xyplot: factor( drugauthoryear, levels = c( 'bupicapogna1999', 'levobenhamou2003', 'ropicapogna1999', 'ropipolley1999', 'bupipolley1999', 'levopolley2003', 'ropibenhamou2003', 'ropipolley2003' ), labels = c( 'Bupi. Reference 2.', 'Levo. Reference 4.', 'Ropi. Reference 2.', 'Ropi. Reference 3.', 'Bupi. Reference 3.', 'Levo. Reference 5.', 'Ropi. Reference 4.', 'Ropi. Reference 5.' ) ) The object is not created and I get the following error message: Error in do.call(pmax, lapply(cond, is.na)) : symbol print-name too long When I delete the labels vector, the code runs without difficulty. Any thoughts on this error message? Thanks, Nathan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] labels of a conditioning variable in xyplot
This error is a curious one. When I remove the labels vector, the names of the levels are printed by default in the strip without difficulty. The names of the levels have lengths of 14 to 16 characters. My labels had length 18 characters. When I reduce the labels to length 10 characters (as you suggest), I get the same error message and no object is created. Nathan On Oct 10, 2005, at 17:14, Berton Gunter wrote: Error in do.call(pmax, lapply(cond, is.na)) : symbol print-name too long When I delete the labels vector, the code runs without difficulty. Any thoughts on this error message? Yes ... the labels are too long to be printed in the space available. Use shorter labels. For example, remove Reference or abbreviate it to Ref , as it provides no unique identifying info anyway. (Am I missing something? -- I would have thought this was obvious) -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nathan Leon Pace, MD, MStat Sent: Monday, October 10, 2005 3:53 PM To: r-help@stat.math.ethz.ch Cc: Nathan Leon Pace, MD, MStat Subject: [R] labels of a conditioning variable in xyplot I am running R 2.1.1 on a Mac g5 under Mac OS 10.4.2. I have an xyplot with a single conditioning variable (8 levels) . Here is the code for the conditioning variable used in the formula argument of xyplot: factor( drugauthoryear, levels = c( 'bupicapogna1999', 'levobenhamou2003', 'ropicapogna1999', 'ropipolley1999', 'bupipolley1999', 'levopolley2003', 'ropibenhamou2003', 'ropipolley2003' ), labels = c( 'Bupi. Reference 2.', 'Levo. Reference 4.', 'Ropi. Reference 2.', 'Ropi. Reference 3.', 'Bupi. Reference 3.', 'Levo. Reference 5.', 'Ropi. Reference 4.', 'Ropi. Reference 5.' ) ) The object is not created and I get the following error message: Error in do.call(pmax, lapply(cond, is.na)) : symbol print-name too long When I delete the labels vector, the code runs without difficulty. Any thoughts on this error message? Thanks, Nathan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting- guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Writing to a file with fixed precision
Hi, I'm trying to ouput to a filled with a fixed precision: eg. if I have data x=c(1.0,1.4,2.0), I want to be able to ouput the following to a file: 1.00 1.40 2.00 I was wondering if there was a function to do this in R? Thanks, Richard Richard Hedger Département de Biologie Université Laval Québec, Canada, G1K 7P4 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] iterative output to file by row
Hi, I'm sort of a newbie to using R to deal with array data. I'm trying to create a simple filtering function, which outputs only the rows of a data frame that satisfies a specific criterion. I've set up an iterative loop to apply the condition to each row. I can create a new matrix and use rbind to fill it in row by row in the loop, before writing the whole matrix to file. But it seems really inefficient, especially considering my very large dataset. In fact, I'm worried it will cause memory problems if I run the function on the full data set. Each row is from a data frame and is associated with a row name and a column name. I'm wondering if there's a way to write each row that satisfy the condition to file within the iterative loop directly, while keeping the data structure. I've read the help on the 'cat' function; but I'm still not entirely sure how to use it in my situation, or if it is the correctly function to use. Any advice will be greatly appreciated. Thanks, Christina [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] labels of a conditioning variable in xyplot
Well -- that **IS** curious. It sounds to me like a software bug or a typo somewhere (are all your little 's OK?), but now you exceed my modest expertise -- especially on a Mac (which apparently can be curious little devils at times). Deepayan -- where are you? Cheers, Bert -Original Message- From: Nathan Leon Pace, MD, MStat [mailto:[EMAIL PROTECTED] Sent: Monday, October 10, 2005 4:50 PM To: Berton Gunter; r-help@stat.math.ethz.ch Cc: Nathan Leon Pace, MD, MStat Subject: Re: [R] labels of a conditioning variable in xyplot This error is a curious one. When I remove the labels vector, the names of the levels are printed by default in the strip without difficulty. The names of the levels have lengths of 14 to 16 characters. My labels had length 18 characters. When I reduce the labels to length 10 characters (as you suggest), I get the same error message and no object is created. Nathan On Oct 10, 2005, at 17:14, Berton Gunter wrote: Error in do.call(pmax, lapply(cond, is.na)) : symbol print-name too long When I delete the labels vector, the code runs without difficulty. Any thoughts on this error message? Yes ... the labels are too long to be printed in the space available. Use shorter labels. For example, remove Reference or abbreviate it to Ref , as it provides no unique identifying info anyway. (Am I missing something? -- I would have thought this was obvious) -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nathan Leon Pace, MD, MStat Sent: Monday, October 10, 2005 3:53 PM To: r-help@stat.math.ethz.ch Cc: Nathan Leon Pace, MD, MStat Subject: [R] labels of a conditioning variable in xyplot I am running R 2.1.1 on a Mac g5 under Mac OS 10.4.2. I have an xyplot with a single conditioning variable (8 levels) . Here is the code for the conditioning variable used in the formula argument of xyplot: factor( drugauthoryear, levels = c( 'bupicapogna1999', 'levobenhamou2003', 'ropicapogna1999', 'ropipolley1999', 'bupipolley1999', 'levopolley2003', 'ropibenhamou2003', 'ropipolley2003' ), labels = c( 'Bupi. Reference 2.', 'Levo. Reference 4.', 'Ropi. Reference 2.', 'Ropi. Reference 3.', 'Bupi. Reference 3.', 'Levo. Reference 5.', 'Ropi. Reference 4.', 'Ropi. Reference 5.' ) ) The object is not created and I get the following error message: Error in do.call(pmax, lapply(cond, is.na)) : symbol print-name too long When I delete the labels vector, the code runs without difficulty. Any thoughts on this error message? Thanks, Nathan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting- guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Writing to a file with fixed precision
On Mon, 2005-10-10 at 19:50 -0400, Richard Hedger wrote: Hi, I'm trying to ouput to a filled with a fixed precision: eg. if I have data x=c(1.0,1.4,2.0), I want to be able to ouput the following to a file: 1.00 1.40 2.00 I was wondering if there was a function to do this in R? Thanks, Richard It is possible that someone has written such a function somewhere. However, this is relatively easy using write.table(). You just need to pre-format the numeric values prior to writing to the file: write.table(sprintf(%.14f, x), data.txt, col.names = FALSE, row.names = FALSE, quote = FALSE) Using sprintf(), we force the floats to have 14 decimal places. sprintf() outputs character vectors, so we remove the quoting of the resultant character vectors and don't write column/row names. Note that if 'x' is a matrix, using sprintf() will return a vector. So you might want to use the following instead to retain the dims: x [,1] [,2] [,3] [,4] [1,]147 10 [2,]258 11 [3,]369 12 x.fmt - apply(x, 1, function(x) sprintf(%.14f, x)) x.fmt [,1][,2][,3] [1,] 1.00 2.00 3.00 [2,] 4.00 5.00 6.00 [3,] 7.00 8.00 9.00 [4,] 10.00 11.00 12.00 write.table(x.fmt, data.txt, col.names = FALSE, row.names = FALSE, quote = FALSE) If needed, you can of course change the default delimiter from a to another character in write.table(). See ?write.table and ?sprintf. HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Multiple expressions, when using substitute()
Have you received a reply to this post? I couldn't find one, and I couldn't find a solution, even though one must exist. I can get the substitute to work in main but not legend: B - 2:3 eB - substitute(y==a*x^b, list(a=B[1], b=B[2])) plot(1:2, 1:2, main=eB) You should be able to construct it using mtext, but I couldn't get the desired result using legend. hope this helps. spencer graves John Maindonald wrote: expression() accepts multiple expressions as arguments, thus: plot(1:2, 1:2) legend(topleft, expression(y == a * x^b, where * paste(y==wood; , x==dbh))) Is there a way to do this when values are to be substituted for a and b? i.e., the first element of the legend argument to legend() becomes, effectively: substitute(y == a * x^b, list(a = B[1], b=B[2])) John Maindonald email: [EMAIL PROTECTED] phone : +61 2 (6125)3473fax : +61 2(6125)5549 Centre for Bioinformation Science, Room 1194, John Dedman Mathematical Sciences Building (Building 27) Australian National University, Canberra ACT 0200. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Spencer Graves, PhD Senior Development Engineer PDF Solutions, Inc. 333 West San Carlos Street Suite 700 San Jose, CA 95110, USA [EMAIL PROTECTED] www.pdf.com http://www.pdf.com Tel: 408-938-4420 Fax: 408-280-7915 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] iterative output to file by row
On Mon, 2005-10-10 at 17:04 -0700, Christina Yau wrote: Hi, I'm sort of a newbie to using R to deal with array data. I'm trying to create a simple filtering function, which outputs only the rows of a data frame that satisfies a specific criterion. I've set up an iterative loop to apply the condition to each row. I can create a new matrix and use rbind to fill it in row by row in the loop, before writing the whole matrix to file. But it seems really inefficient, especially considering my very large dataset. In fact, I'm worried it will cause memory problems if I run the function on the full data set. Each row is from a data frame and is associated with a row name and a column name. I'm wondering if there's a way to write each row that satisfy the condition to file within the iterative loop directly, while keeping the data structure. I've read the help on the 'cat' function; but I'm still not entirely sure how to use it in my situation, or if it is the correctly function to use. Any advice will be greatly appreciated. If you can do it with the full dataset, you are probably better off using subset() to select the rows that meet your criteria and then use write.table() to write the resultant smaller data frame to a file. Alternatively, if you do need to do this within the loop, you can use write.table() with the 'append' argument set to TRUE, so that each new row from the data frame that meets your criteria gets added to the existing file, rather than overwriting it. This will be a little slower, since each time write.table() is called, it opens the file, writes the line and closes the file, so there is some file I/O overhead. You don't need to create a new matrix in the loop, just pass the resultant single row of your subsetting operation to write.table(). See ?subset and ?write.table for more information. HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Sometimes having problems finding a minimum using optim(), optimize(), and nlm() (while searching for noncentral F parameters)
Hi everyone. I have a problem that I have been unable to determine either the best way to proceed and why the methods I'm trying to use sometimes fail. I'm using the pf() function in an optimization function to find a noncentrality parameter that leads to a specific value at a specified quantile. My goal is to have a general function that returns the noncentrality parameter that leads to a given value at a defined quantile. For example, with 5 and 200 degrees of freedom, what noncentrality parameter has at its .975 quantile a value of 4 (it is 3.0725 by the way)? The code I've written, using three different methods works great at times, but at other times it fails (sometimes all sometimes not). It isn't even that the functions I'm trying to write fail, but the reason they sometimes fail and sometimes do not is what is really bothering me; I simply don't understand why the functions at times stop the iterative process of minimization and return what the function believes to be a successful convergence value (e.g., optim() sometimes returns a 0 stating successful convergence when it clearly is not). I'm using three function [optim(), optimize(), and nlm()] to try and accomplish the same goal (which was stated above). I believe that they should all return the same value, and at times they do just that, but at other times the methods return inappropriate results. I'll paste my code that illustrates an example where all is well and one where things fail. Is there are easier way to do what I'm trying to accomplish? The analog in SAS of what I'm trying to come up with is FNONCT. #Begin code ## # Define necessary values. F.value - 4 tol - 1e-8 df.1 - 5 df.2 - 200 alpha.lower - .025 maxit-1000 # The function to be minimized. Here we are looking for the noncentral # value, 'Lambda', that has at its .975 quantile 'F.value'. Low.Lim.NC.F - function(Lambda, alpha.lower, F.value, df.1, df.2) { abs(pf(q=F.value, df1=df.1, df2=df.2, ncp=Lambda) - (1-alpha.lower)) # This will be near zero when an appropriate Lambda value is found. # The Lambda value that leads to a solution of zero is the noncentrality # value that has at its .975 quantile a value of 'F.value'. } # Use the quantile from a central F distribution as a minimum. LL.0 - qf(p=alpha.lower, df1=df.1, df2=df.2) optim(par=LL.0, fn=Low.Lim.NC.F, method=L-BFGS-B, # Others return the same result usually. lower=LL.0, upper = Inf, control = list(maxit=maxit, reltol=1e-10), hessian = FALSE, alpha.lower=alpha.lower, F.value=F.value, df.1=df.1, df.2=df.2) # Try to accomplish the same task with a different R function. optimize(f=Low.Lim.NC.F, lower=LL.0, upper=50, maximum=FALSE, tol=tol, alpha.lower=alpha.lower, F.value=F.value, df.1=df.1, df.2=df.2) # Try to accomplish the same task with a different R function. nlm(f=Low.Lim.NC.F, p=LL.0, fscale=1, print.level = 0, ndigit=12, gradtol = 1e-6, stepmax = max(1000 * sqrt(sum((LL.0/10)^2)), 1000), steptol = 1e-6, iterlim = 1000, check.analyticals = TRUE, alpha.lower=alpha.lower, F.value=F.value, df.1=df.1, df.2=df.2) # The answer in each case is 3.0725. Thus, a noncentral F with # 5 and 200 df with a noncentrality parameter 3.0725 has at its .975 # quantile a value of 4 (this has been verified in another software). # But, suppose we triple the F.value to 12 and rerun the code. F.value - 12 # The function to be minimized. Here we are looking for the noncentral # value, 'Lambda', that has at its .975 quantile 'F.value'. Low.Lim.NC.F - function(Lambda, alpha.lower, F.value, df.1, df.2) { abs(pf(q=F.value, df1=df.1, df2=df.2, ncp=Lambda) - (1-alpha.lower)) } # Use the quantile from a central F distribution as a minimum. LL.0 - qf(p=alpha.lower, df1=df.1, df2=df.2) optim(par=LL.0, fn=Low.Lim.NC.F, method=L-BFGS-B, # Others return the same result usually. lower=LL.0, upper = Inf, control = list(maxit=maxit, reltol=1e-10), hessian = FALSE, alpha.lower=alpha.lower, F.value=F.value, df.1=df.1, df.2=df.2) # Try to accomplish the same task with a different R function. optimize(f=Low.Lim.NC.F, lower=LL.0, upper=500, maximum=FALSE, tol=tol, alpha.lower=alpha.lower, F.value=F.value, df.1=df.1, df.2=df.2) # Try to accomplish the same task with a different R function. nlm(f=Low.Lim.NC.F, p=LL.0, fscale=1, gradtol = 1e-6, stepmax = max(1000 * sqrt(sum((LL.0/10)^2)), 1000), steptol = 1e-6, iterlim = 1000, check.analyticals = TRUE, alpha.lower=alpha.lower, F.value=F.value, df.1=df.1, df.2=df.2) # Now only optimize() works and optim() and nlm() both return the # same (wrong) answer. Why would the function stop when the # minimized value was .025 (when it should stop when the value is # very close to zero)? # But, optimize() isn't always the answer either, because if the # upper limit is too large, the function will fail. # For example, changing the upper limit of optimize in # this example to 1000 leads to a failure.
Re: [R] greek symbols using pch
On 11/10/05 01:12, Earl F. Glynn wrote,: FISCHER, Matthew [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] In a plot, can I specify pch to be a greek symbol? (I looked at show.pch() in the Hmisc package but couldn't see the right symbols in there). If not, I guess I can get around this using text(x,y,expression()). I'm not sure where this is explained very well. Having ?font give a clue about this would be nice. Use font=5, the symbol font. To see what's in font=5: par(font=5, las=1) plot(0:15,0:15,type=n,ylim=c(15,0), main=Symbols in Font=5, xlab=, ylab=,xaxt=n, yaxt=n) axis(BOTTOM-1, at=0:15, 1:16) axis(LEFT -2, at=0:15) abline(v=0.5 + 0:14, h=0.5 + 0:14, col=grey, lty=dotted) # pch index of any cell is 16*row + column for(i in 0:255) { x - i %%16; y - i %/% 16; points(x,y,pch=i+1) } When I execute this code, I get a calligraphic R or P occurring with all of the nifty characters, e.g. \clubsuit. For example par(font=5, las=1) plot(0:1, 0:1, type=n) points(.5, .5, pch=167) This occurs on screen and in postscript() output. And with R2.1.0 and R2.2.0. Is this a bug? Ted. R.Version() $platform [1] i686-pc-linux-gnu $arch [1] i686 $os [1] linux-gnu $system [1] i686, linux-gnu $status [1] $major [1] 2 $minor [1] 2.0 $year [1] 2005 $month [1] 10 $day [1] 06 $svn rev [1] 35749 $language [1] R -- Dr E.A. Catchpole Visiting Fellow Univ of New South Wales at ADFA, Canberra, Australia and University of Kent, Canterbury, England - www.ma.adfa.edu.au/~eac - fax: +61 2 6268 8786 - ph: +61 2 6268 8895 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Sometimes having problems finding a minimum using optim(), optimize(), and nlm() (while searching for noncentral F parameters)
I haven't look at your code but here a couple of things to try: 1. try using the square of the difference rather than the absolute value as your objective so that your objective is differentiable. 2. your objective function may be relatively flat in which case it will be difficult to get a precise answer. plot your objective function to see and try transforming the variable being optimized, e.g. 1/lambda, and then plotting that to see if its less flat in the region of interest. On 10/11/05, Ken Kelley [EMAIL PROTECTED] wrote: Hi everyone. I have a problem that I have been unable to determine either the best way to proceed and why the methods I'm trying to use sometimes fail. I'm using the pf() function in an optimization function to find a noncentrality parameter that leads to a specific value at a specified quantile. My goal is to have a general function that returns the noncentrality parameter that leads to a given value at a defined quantile. For example, with 5 and 200 degrees of freedom, what noncentrality parameter has at its .975 quantile a value of 4 (it is 3.0725 by the way)? The code I've written, using three different methods works great at times, but at other times it fails (sometimes all sometimes not). It isn't even that the functions I'm trying to write fail, but the reason they sometimes fail and sometimes do not is what is really bothering me; I simply don't understand why the functions at times stop the iterative process of minimization and return what the function believes to be a successful convergence value (e.g., optim() sometimes returns a 0 stating successful convergence when it clearly is not). I'm using three function [optim(), optimize(), and nlm()] to try and accomplish the same goal (which was stated above). I believe that they should all return the same value, and at times they do just that, but at other times the methods return inappropriate results. I'll paste my code that illustrates an example where all is well and one where things fail. Is there are easier way to do what I'm trying to accomplish? The analog in SAS of what I'm trying to come up with is FNONCT. #Begin code ## # Define necessary values. F.value - 4 tol - 1e-8 df.1 - 5 df.2 - 200 alpha.lower - .025 maxit-1000 # The function to be minimized. Here we are looking for the noncentral # value, 'Lambda', that has at its .975 quantile 'F.value'. Low.Lim.NC.F - function(Lambda, alpha.lower, F.value, df.1, df.2) { abs(pf(q=F.value, df1=df.1, df2=df.2, ncp=Lambda) - (1-alpha.lower)) # This will be near zero when an appropriate Lambda value is found. # The Lambda value that leads to a solution of zero is the noncentrality # value that has at its .975 quantile a value of 'F.value'. } # Use the quantile from a central F distribution as a minimum. LL.0 - qf(p=alpha.lower, df1=df.1, df2=df.2) optim(par=LL.0, fn=Low.Lim.NC.F, method=L-BFGS-B, # Others return the same result usually. lower=LL.0, upper = Inf, control = list(maxit=maxit, reltol=1e-10), hessian = FALSE, alpha.lower=alpha.lower, F.value=F.value, df.1=df.1, df.2=df.2) # Try to accomplish the same task with a different R function. optimize(f=Low.Lim.NC.F, lower=LL.0, upper=50, maximum=FALSE, tol=tol, alpha.lower=alpha.lower, F.value=F.value, df.1=df.1, df.2=df.2) # Try to accomplish the same task with a different R function. nlm(f=Low.Lim.NC.F, p=LL.0, fscale=1, print.level = 0, ndigit=12, gradtol = 1e-6, stepmax = max(1000 * sqrt(sum((LL.0/10)^2)), 1000), steptol = 1e-6, iterlim = 1000, check.analyticals = TRUE, alpha.lower=alpha.lower, F.value=F.value, df.1=df.1, df.2=df.2) # The answer in each case is 3.0725. Thus, a noncentral F with # 5 and 200 df with a noncentrality parameter 3.0725 has at its .975 # quantile a value of 4 (this has been verified in another software). # But, suppose we triple the F.value to 12 and rerun the code. F.value - 12 # The function to be minimized. Here we are looking for the noncentral # value, 'Lambda', that has at its .975 quantile 'F.value'. Low.Lim.NC.F - function(Lambda, alpha.lower, F.value, df.1, df.2) { abs(pf(q=F.value, df1=df.1, df2=df.2, ncp=Lambda) - (1-alpha.lower)) } # Use the quantile from a central F distribution as a minimum. LL.0 - qf(p=alpha.lower, df1=df.1, df2=df.2) optim(par=LL.0, fn=Low.Lim.NC.F, method=L-BFGS-B, # Others return the same result usually. lower=LL.0, upper = Inf, control = list(maxit=maxit, reltol=1e-10), hessian = FALSE, alpha.lower=alpha.lower, F.value=F.value, df.1=df.1, df.2=df.2) # Try to accomplish the same task with a different R function. optimize(f=Low.Lim.NC.F, lower=LL.0, upper=500, maximum=FALSE, tol=tol, alpha.lower=alpha.lower, F.value=F.value, df.1=df.1, df.2=df.2) # Try to accomplish the same task with a different R function. nlm(f=Low.Lim.NC.F, p=LL.0, fscale=1, gradtol = 1e-6, stepmax = max(1000 *
[R] Is this correct?
Dear userR, With the following results, are they correct or acceptable? x - c(1.4, 1.2, 2.8) sum(x) [1] 5.4 sum(x) == 5.4 [1] FALSE (1.4 + 1.2 + 2.8) - 5.4 [1] -8.881784e-16 (1.4 + 1.2) - 2.6 [1] -4.440892e-16 2.6 - 1.5 - 1.1 [1] 0 version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor2.0 year 2005 month10 day 06 svn rev 35749 language R What can I do to correct them if they are not correct? Thanks! -- C. Joseph Lu Department of Statistics National Cheng-Kung University Tainan, Taiwan, ROC __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Is this correct?
See the R FAQ list, section 7. Why doesn't R think these numbers are equal? Ted. On 11/10/05 15:42, Joe wrote,: Dear userR, With the following results, are they correct or acceptable? x - c(1.4, 1.2, 2.8) sum(x) [1] 5.4 sum(x) == 5.4 [1] FALSE (1.4 + 1.2 + 2.8) - 5.4 [1] -8.881784e-16 (1.4 + 1.2) - 2.6 [1] -4.440892e-16 2.6 - 1.5 - 1.1 [1] 0 version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor2.0 year 2005 month10 day 06 svn rev 35749 language R What can I do to correct them if they are not correct? Thanks! -- C. Joseph Lu Department of Statistics National Cheng-Kung University Tainan, Taiwan, ROC __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Dr E.A. Catchpole Visiting Fellow Univ of New South Wales at ADFA, Canberra, Australia and University of Kent, Canterbury, England - www.ma.adfa.edu.au/~eac - fax: +61 2 6268 8786 - ph: +61 2 6268 8895 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html