Re: [R] Comparison of correlation coefficients
Dear Donglei Hu, If you have two correlation coefficients, you may try cordif {multilevel} and cordif.dep {multilevel} for the independent correlations and for the dependent correlations, respectively. However, they are both based on the sampling distribution of correlation coeficient. A better approach may be the one based on the Fisher z transformation as suggested. The papers by Olkin and Finn (1995) and Steiger (1980) may be relevant for you. If you have more than two independent correlation coefficients, meta-analysis may be a better choice. You may also choose between the approaches based on correlations (Hunter and Schmidt) or Fisher z transformation (Hedges and Olkin). If the correlations are dependent, structural equation modeling (SEM) is a more convenient approach (e.g., Cheung & Chan, 2004). Cheung, M.W.L., & Chan, W. (2004). Testing dependent correlation coefficients via structural equation modeling. Organizational Research Methods, 7, 206-223. Olkin, I., & Finn, J. D. (1995). Correlation redux. Psychological Bulletin, 118, 155-164. Steiger, J. H. (1980). Tests for comparing elements of a correlation matrix. Psychological Bulletin, 87, 245-251. Regards, Mike -- --- Mike W.L. Cheung Department of Psychology National University of Singapore Homepage: http://courses.nus.edu.sg/course/psycwlm/internet/ --- On 19 Sep 2006 01:22:47 +0200, Peter Dalgaard <[EMAIL PROTECTED]> wrote: > > "David Barron" <[EMAIL PROTECTED]> writes: > > > Is cor.test() in the stats packages what you mean? > > No, he wants to compare two correlation coefficients, not test that > one is zero. That's usually a misguided question, but if need be, the > Fisher z transform atanh(r) can be used to convert r to an > approximately normal variate with a known variance 1/(N-3) and > comparing r1 and r2 from two independent samples is straightforward. > The correlated case (like cor(x,y) vs cor(x,z)) is more complicated. > > > > > On 18/09/06, Hu, Donglei <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > > > > > > > > > I calculated a few correlation coefficients. Now I want to know > whether > > > they are different from each other. Is there an R package that can do > > > such a comparison? Thanks for any suggestion. > > > > > > > > > > > > Best, > > > > > > Donglei Hu > > > > > > Department of Medicine > > > > > > UCSF > > > > > > > > > [[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 > > > and provide commented, minimal, self-contained, reproducible code. > > > > > > > > > -- > > = > > David Barron > > Said Business School > > University of Oxford > > Park End Street > > Oxford OX1 1HP > > > > __ > > 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 > > and provide commented, minimal, self-contained, reproducible code. > > > > -- >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 > and provide commented, minimal, self-contained, reproducible code. > [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] non linear modelling with nls: starting values
You could try fitting several cases: - fit the reduced model with only one exp term, i.e. one of the alphas is 0 - fit the model with both alpha's constrained to be positive & sufficiently away from 0 - fit the model with both alpha's negative & sufficiently away from 0 - fit the model with one positive and one negative and sufficiently away from 0 On 9/18/06, Sebastian P. Luque <[EMAIL PROTECTED]> wrote: > On 18 Sep 2006 17:55:24 +0200, > Peter Dalgaard <[EMAIL PROTECTED]> wrote: > > > "Gabor Grothendieck" <[EMAIL PROTECTED]> writes: > >> Here are some approaches: > > >> - we only have 4 parameters so just use grid search to get starting > >> values as in: > > >> https://stat.ethz.ch/pipermail/r-help/2005-September/079617.html > > >> - there are singularities near beta_1 = beta_2 and near alpha_1 = 0 and > >> near alpha_2 = 0 so reparameterize and use the upper and lower bounds > >> to avoid those regions. You could try a separate reduced model for > >> those. > > > > Or just use SSbiexp and reparametrize (it is exactly the same model) > > Thank you Gabor and Peter. With your help, I was able to fit the model > using SSbiexp as Peter suggested. However, the dependent variable spans > both negative and positive values, and the negative values cause the > fitting procedure to fail with a NA/NaN/Inf error. This might be related > to the singularities that Gabor mentioned. If the dependent variable is > shifted upwards, so all values are positive, the model is fit without > problems. Any ideas on how to get around this issue without shifting the > data, so that the parameters are expressed in the original scale? > Hopefully it's possible to do it using SSbiexp. Thanks again. > > > Cheers, > > -- > Seb > > __ > 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 > and provide commented, minimal, self-contained, reproducible code. > __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] non linear modelling with nls: starting values
On 18 Sep 2006 17:55:24 +0200, Peter Dalgaard <[EMAIL PROTECTED]> wrote: > "Gabor Grothendieck" <[EMAIL PROTECTED]> writes: >> Here are some approaches: >> - we only have 4 parameters so just use grid search to get starting >> values as in: >> https://stat.ethz.ch/pipermail/r-help/2005-September/079617.html >> - there are singularities near beta_1 = beta_2 and near alpha_1 = 0 and >> near alpha_2 = 0 so reparameterize and use the upper and lower bounds >> to avoid those regions. You could try a separate reduced model for >> those. > Or just use SSbiexp and reparametrize (it is exactly the same model) Thank you Gabor and Peter. With your help, I was able to fit the model using SSbiexp as Peter suggested. However, the dependent variable spans both negative and positive values, and the negative values cause the fitting procedure to fail with a NA/NaN/Inf error. This might be related to the singularities that Gabor mentioned. If the dependent variable is shifted upwards, so all values are positive, the model is fit without problems. Any ideas on how to get around this issue without shifting the data, so that the parameters are expressed in the original scale? Hopefully it's possible to do it using SSbiexp. Thanks again. Cheers, -- Seb __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] dotplot/Dotplot: connecting points within factor level across time
Many thanks to Gabor and Deepayan. In case of conditioning, one can also do this inside the panel function, using subscripts as necessary. The segplot package is also a nice touch. Ben Gabor Grothendieck wrote: > Try this: > > print(p) > trellis.focus("panel", 1, 1) > with(z, panel.segments(x, as.numeric(y), x+d, as.numeric(y))) > trellis.unfocus() > > On 9/16/06, Benjamin Tyner <[EMAIL PROTECTED]> wrote: > >> For each level of the factor in dotplot, I have time points I'd like to >> connect with a line. In the example below, 'x' represents a starting >> time and 'd' a duration, and I wish to connect 'x' to 'x+d'. Ordinarily >> I would use Dotplot from hmisc for this, but I have not been able to >> find a time class that Dotplot will allow. I can get lattice dotplot to >> put the points up, but I've not figured out how to connect them. Any >> suggestions? >> >> require(lattice) >> z<-data.frame(y=factor(letters), >> x=structure(1:26,class=c("POSIXt","POSIXct"),tzone=""), >> d=runif(26)) >> >> # this puts the points, but does not connect them >> p<-dotplot(y~x+I(x+d), >> data=z, >> scales=list(x=list(format="%M:%S")) >> ) >> >> zh<-z >> zh$x<-as.numeric(zh$x) >> require(hmisc) >> # this connects them, but at the expense of the time info >> ph<-Dotplot(y~Cbind(x,x,x+d), >>data=zh, >>pch=" ") >> >> >> >> Thanks, >> Ben >> >> __ >> 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 >> and provide commented, minimal, self-contained, reproducible code. >> __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] R CMD check fails at package dependencies check on Fedora Core 5, works on other systems
I'm testing a FC5 machine for use in a student lab. R 2.3.1 is installed and seems to work fine. There is one peculiarity - the logins are authenticating to a server, and a "verbose" flag is set somewhere, leading to lots of spurious messages like this request done: ld 0xa227598 msgid 1 which may be confusing R. However, R CMD check seems to fail for packages with no dependencies at the dependencies check stage. I've tried this with two packages, my own gld and also zipfR. Both fail in the same way. [Desktop]$ R CMD check zipfR_0.6-0.tar.gz * checking for working latex ... OK request done: ld 0x8dfb170 msgid 1 request done: ld 0x8dfb170 msgid 2 * using log directory '/home/rak776/Desktop/zipfR.Rcheck' * using Version 2.3.1 (2006-06-01) * checking for file 'zipfR/DESCRIPTION' ... OK * checking extension type ... Package * this is package 'zipfR' version '0.6-0' * checking package dependencies ... ERROR [Desktop]$ R CMD check gld * checking for working latex ... OK * using log directory '/home/rak776/Desktop/gld.Rcheck' * using Version 2.3.1 (2006-06-01) * checking for file 'gld/DESCRIPTION' ... OK * this is package 'gld' version '1.8' * checking package dependencies ... ERROR Both these work on two other systems - one a debian/sarge AMD64 and a debian/sarge i386 A package with dependencies checks for dependencies correctly - for example ade4: Desktop]$ R CMD check ade4_1.4-1.tar.gz * checking for working latex ... OK request done: ld 0x994b168 msgid 1 request done: ld 0x994b168 msgid 2 request done: ld 0x994b168 msgid 3 * using log directory '/home/rak776/Desktop/ade4.Rcheck' * using Version 2.3.1 (2006-06-01) * checking for file 'ade4/DESCRIPTION' ... OK * this is package 'ade4' version '1.4-1' * checking package dependencies ... ERROR request done: ld 0xa458598 msgid 1 request done: ld 0xa458598 msgid 2 request done: ld 0xa458598 msgid 3 Packages required but not available: waveslim splancs maptools spdep pixmap ape tripack Does anyone have ideas on what is going wrong? Regards, Robert King -- Robert King, Statistics, School of Mathematical & Physical Sciences, University of Newcastle, Australia Room V133 ph +61 2 4921 5548 [EMAIL PROTECTED] http://tolstoy.newcastle.edu.au/~rking/ __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] dotplot/Dotplot: connecting points within factor level across time
On 9/16/06, Benjamin Tyner <[EMAIL PROTECTED]> wrote: > For each level of the factor in dotplot, I have time points I'd like to > connect with a line. In the example below, 'x' represents a starting > time and 'd' a duration, and I wish to connect 'x' to 'x+d'. Ordinarily > I would use Dotplot from hmisc for this, but I have not been able to > find a time class that Dotplot will allow. I can get lattice dotplot to > put the points up, but I've not figured out how to connect them. Any > suggestions? > > require(lattice) > z<-data.frame(y=factor(letters), > x=structure(1:26,class=c("POSIXt","POSIXct"),tzone=""), > d=runif(26)) > > # this puts the points, but does not connect them > p<-dotplot(y~x+I(x+d), >data=z, >scales=list(x=list(format="%M:%S")) >) > > zh<-z > zh$x<-as.numeric(zh$x) > require(hmisc) > # this connects them, but at the expense of the time info > ph<-Dotplot(y~Cbind(x,x,x+d), > data=zh, > pch=" ") If you can install packages from source, you could try installing http://www.stat.wisc.edu/~deepayan/R/segplot_0.0-1.tar.gz after which you could try: library(segplot) segplot(y ~ x + (x+d), z, scales=list(x=list(format="%M:%S"))) segplot(y ~ x + (x+d), z, draw.bands = FALSE, scales=list(x=list(format="%M:%S"))) - I have been meaning to submit this to CRAN for a while, I haven't because it's lacking a good example (I think I'll go ahead and submit it anyway). Deepayan __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] GOLDSTAR LOTTO - Wheel E-game
*NOTICE OF CONSOLATION PRIZE WINNING* This email confirms that you have been notified of by the DE GOLDSTAR E-GAMES LOTTO BV DE Netherlands of your email lottery winning for 2006 GOLDSTAR LOTTO - Wheel E-game held on 18th September 2006. We wish to congratulate you on the selection of your email coupon number, which was selected among the 45 lucky consolation prize winners. Your email ID identified with Coupon No.NL132478 and was selected by Electronic Random Selection System (ERSS) with entries from the 50,000 different email addresses enrolled for the Lotto-Wheel E-game. Your email ID included among the 50,000 different email addresses where submitted by our partner international email provider companies. Ref Number: 35149/337-5247/LNI Lottery Group: Consolation Prize Group Prize Amount: 1.500,000 (One Million Five Hundred Thousand Euro Only) You are required to file claims for your lottery prize winning by contacting the Award Department to Processing your winning information provided above before 14 working days. Award Department Officer: Mr.carpenter elizebath TEL:31-645-535-301 FAX:31-847-520-740 Email:[EMAIL PROTECTED] Congratulations once more from our members of staff and thank you for being part of our promotional program. Note: Anybody under the age of 18 is automatically disqualified. Yours truly, Mrs.Mavis Cook (Secretary) For Goldstar E-games Netherlands. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Comparison of correlation coefficients
"David Barron" <[EMAIL PROTECTED]> writes: > Is cor.test() in the stats packages what you mean? No, he wants to compare two correlation coefficients, not test that one is zero. That's usually a misguided question, but if need be, the Fisher z transform atanh(r) can be used to convert r to an approximately normal variate with a known variance 1/(N-3) and comparing r1 and r2 from two independent samples is straightforward. The correlated case (like cor(x,y) vs cor(x,z)) is more complicated. > On 18/09/06, Hu, Donglei <[EMAIL PROTECTED]> wrote: > > Hi, > > > > > > > > I calculated a few correlation coefficients. Now I want to know whether > > they are different from each other. Is there an R package that can do > > such a comparison? Thanks for any suggestion. > > > > > > > > Best, > > > > Donglei Hu > > > > Department of Medicine > > > > UCSF > > > > > > [[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 > > and provide commented, minimal, self-contained, reproducible code. > > > > > -- > = > David Barron > Said Business School > University of Oxford > Park End Street > Oxford OX1 1HP > > __ > 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 > and provide commented, minimal, self-contained, reproducible code. > -- 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] acos(0.5) == pi/3 FALSE
Ben Bolker <[EMAIL PROTECTED]> writes: > > Time for folks to re-read the posting guide? > > * When responding to a very simple question, use the following algorithm: > 1. compose your response > 2. type 4*runif(1) at the R prompt, and wait this many hours > 3. check for new posts to R-help; if no similar suggestion, post your > response > (This is partly in jest, but if you know immediately why it is > suggested, > you probably should use it! Also, it's a nice idea to replace 4 by the number > of > years you have been using R or S-plus.) I've always wondered why step 1. - often the time-consuming bit - is not listed last. -- 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] acos(0.5) == pi/3 FALSE
Time for folks to re-read the posting guide? * When responding to a very simple question, use the following algorithm: 1. compose your response 2. type 4*runif(1) at the R prompt, and wait this many hours 3. check for new posts to R-help; if no similar suggestion, post your response (This is partly in jest, but if you know immediately why it is suggested, you probably should use it! Also, it's a nice idea to replace 4 by the number of years you have been using R or S-plus.) [inspired by Romain Francois's similar post back in March] cheers Ben Bolker __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] 2007 Computing/Graphics Student Paper Competition
Statistical Computing and Statistical Graphics Sections American Statistical Association Student Paper Competition 2007 The Statistical Computing and Statistical Graphics Sections of the ASA are co-sponsoring a student paper competition on the topics of Statistical Computing and Statistical Graphics. Students are encouraged to submit a paper in one of these areas, which might be original methodological research, some novel computing or graphical application in statistics, or any other suitable contribution (for example, a software-related project). The selected winners will present their papers in a topic-contributed session at the 2007 Joint Statistical Meetings. The Sections will pay registration fees for the winners as well as a substantial allowance for transportation to the meetings and lodging (which in most cases covers these expenses completely). Anyone who is a student (graduate or undergraduate) on or after September 1, 2006 is eligible to participate. An entry must include an abstract, a six page manuscript (including figures, tables and references), a blinded version of the manuscript (with no authors and no references that easily lead to identifying the authors), a C.V., and a letter from a faculty member familiar with the student's work. The applicant must be the first author of the paper. The faculty letter must include a verification of the applicant's student status and, in the case of joint authorship, should indicate what fraction of the contribution is attributable to the applicant. We prefer that electronic submissions of papers be in Postscript or PDF. All materials must be in English. All application materials MUST BE RECEIVED by 5:00 PM EST, Monday, December 18, 2006 at the address below. They will be reviewed by the Student Paper Competition Award committee of the Statistical Computing and Graphics Sections. The selection criteria used by the committee will include innovation and significance of the contribution. Award announcements will be made in late January, 2007. Additional important information on the competition can be accessed on the website of the Statistical Computing Section, www.statcomputing.org. A current pointer to the website is available from the ASA website at www.amstat.org. Inquiries and application materials should be emailed or mailed to: Student Paper Competition c/o J.R. Lockwood The RAND Corporation 4570 Fifth Avenue, Suite 600 Pittsburgh, PA 15213 [EMAIL PROTECTED] This email message is for the sole use of the intended recip...{{dropped}} __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] R questions
I have a few questions for R: 1. Other than using a built-in function such as mean(), how do I know if it is installed in my current version of R? 2. To get help in R, I can use several ways: ?sort help.search("sort") help(sort) apropos("sort") the help menu are there any other ways to get help? 3. When I see a help menu for a function, does it mean the function is installed? 4. If I execute a program file that contains output files that doesn't have a path specified, which path is it going to output to? Is it the Current Working Directory that the output file is going to output? if I change the working directory by using setwd(), is that going to change where the output file path permanently until I specify it again? Thanks a lot! Lynda __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with plot of prcomp object
yes, see ?points for the list and details. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Comparison of correlation coefficients
Is cor.test() in the stats packages what you mean? On 18/09/06, Hu, Donglei <[EMAIL PROTECTED]> wrote: > Hi, > > > > I calculated a few correlation coefficients. Now I want to know whether > they are different from each other. Is there an R package that can do > such a comparison? Thanks for any suggestion. > > > > Best, > > Donglei Hu > > Department of Medicine > > UCSF > > > [[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 > and provide commented, minimal, self-contained, reproducible code. > -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] acos(0.5) == pi/3 FALSE
On 18-Sep-06 Iñaki Murillo Arcos wrote: > Hello, > > I don't know if the result of > > acos(0.5) == pi/3 > > is a bug or not. It looks strange to me. > >Inaki Murillo It is not a bug, but a feature, in that acos(0.5) and pi/3 are not computed in the same way, so (because of the small inaccuracies inevitable in their finite representations) they are indeed not equal; and this is what R is telling you. acos(0.5) - pi/3 [1] 2.220446e-16 The difference, as you can see is very small. However, if for some reason (e.g. in the logic of a programming branch which depends on such a comparison) then you could make it work by computing them in the same way: pi<-3*acos(0.5) acos(0.5) - pi/3 [1] 0 I.e. redefine pi in R so that its computation is compatible with that of acos(0.5) (but this pi is only in the current environment). However, the usual way of comparing two numbers which should theoretically be equal, but might differ slightly when computed in R, is to use all.equal(x, y) See "?all.equal". Also see "?identical". all.equal(acos(0.5),pi/3) [1] TRUE (Here I'm using R's "default" value of pi, not the value I defined above). all.equal(x,y) tests whether x and y differ by more than a tolerance which by default is .Machine$double.eps but which can be set to something else if you wish. Best wishes, Ted. E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 Date: 18-Sep-06 Time: 23:05:01 -- XFMail -- __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] acos(0.5) == pi/3 FALSE
Iñaki Murillo Arcos said the following on 9/18/2006 12:31 PM: > Hello, > > I don't know if the result of > > acos(0.5) == pi/3 > > is a bug or not. It looks strange to me. > >Inaki Murillo > > __ > 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 > and provide commented, minimal, self-contained, reproducible code. This is a FAQ: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f > acos(.5) [1] 1.047198 > pi/3 [1] 1.047198 > acos(0.5) == pi/3 [1] FALSE > all.equal(acos(0.5), pi/3) [1] TRUE --sundar __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] help with plot of prcomp object
I need to plot a prcomp object from package stats with custom symbols suitable for B&W publication. My boss specifically wants filled and unfilled square, triangle, circle, inverted triangle, diamond to represent 5 brain regions of 2 types of rat. Can I specify these as a parameter? Thanks, Mark Mark W. Kimpel MD Official Business Address: Department of Psychiatry Indiana University School of Medicine PR M116 Institute of Psychiatric Research 791 Union Drive Indianapolis, IN 46202 Preferred Mailing Address: 15032 Hunter Court Westfield, IN 46074 (317) 490-5129 Work, & Mobile (317) 663-0513 Home (no voice mail please) 1-(317)-536-2730 FAX __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] acos(0.5) == pi/3 FALSE
On Mon, 18 Sep 2006, [iso-8859-1] I?aki Murillo Arcos wrote: > Hello, > > I don't know if the result of > > acos(0.5) == pi/3 > > is a bug or not. It looks strange to me. Real numbers are strange. Would the result of: acos(0.5) - pi/3 close enough to zero for you? Try help('Comparison') , ?'==' for an explanation, or 'abs(acos(0.5) - pi/3) < 1e-9' for a solution. Dave -- Dr. David Forrest [EMAIL PROTECTED](804)684-7900w [EMAIL PROTECTED] (804)642-0662h http://maplepark.com/~drf5n/ __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] acos(0.5) == pi/3 FALSE
On 9/18/06, Iñaki Murillo Arcos <[EMAIL PROTECTED]> wrote: > Hello, > > I don't know if the result of > > acos(0.5) == pi/3 > > is a bug or not. It looks strange to me. However, > all.equal(acos(0.5), pi/3) [1] TRUE so you may want to check the FAQ entry on comparisons involving floating point numbers. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] acos(0.5) == pi/3 FALSE
Iñaki Murillo Arcos <[EMAIL PROTECTED]> writes: > Hello, > > I don't know if the result of > > acos(0.5) == pi/3 > > is a bug or not. It looks strange to me. Have a look in the R FAQ: > acos(0.5) - pi/3 [1] 2.220446e-16 -- 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] acos(0.5) == pi/3 FALSE
How close do you think it should be, given finite resolution with digital computing? > acos(0.5) - pi/3 [1] 2.220446e-16 Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Iñaki Murillo Arcos Sent: Monday, September 18, 2006 1:32 PM To: r-help@stat.math.ethz.ch Subject: [R] acos(0.5) == pi/3 FALSE Hello, I don't know if the result of acos(0.5) == pi/3 is a bug or not. It looks strange to me. Inaki Murillo __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] acos(0.5) == pi/3 FALSE
If you had looked at help("==") you would have seen the following: For numerical and complex values, remember == and != do not allow for the finite representation of fractions, nor for rounding error. Using all.equal with identical is almost always preferable. Then if you had tried > all.equal(acos(0.5),pi/3) [1] TRUE On 18/09/06, Iñaki Murillo Arcos <[EMAIL PROTECTED]> wrote: > Hello, > > I don't know if the result of > > acos(0.5) == pi/3 > > is a bug or not. It looks strange to me. > >Inaki Murillo > > __ > 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 > and provide commented, minimal, self-contained, reproducible code. > -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Comparison of correlation coefficients
Hi, I calculated a few correlation coefficients. Now I want to know whether they are different from each other. Is there an R package that can do such a comparison? Thanks for any suggestion. Best, Donglei Hu Department of Medicine UCSF [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] acos(0.5) == pi/3 FALSE
On Mon, 2006-09-18 at 19:31 +0200, Iñaki Murillo Arcos wrote: > Hello, > > I don't know if the result of > > acos(0.5) == pi/3 > > is a bug or not. It looks strange to me. > >Inaki Murillo Seems reasonable to me: > acos(0.5) == pi/3 [1] FALSE > print(acos(0.5), 20) [1] 1.0471975511965978534 > print(pi/3, 20) [1] 1.0471975511965976313 See R FAQ 7.31 Why doesn't R think these numbers are equal? 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 and provide commented, minimal, self-contained, reproducible code.
[R] ISO8601 week-of-year to date
Hi, are there any way to convert ISO8601 weeks to gregorian dates? Something like coverttodate(year=2006, week=38, day=1) # Sept 18, 2006 Thanks in advance, Ott __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] acos(0.5) == pi/3 FALSE
Hello, I don't know if the result of acos(0.5) == pi/3 is a bug or not. It looks strange to me. Inaki Murillo __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] uniform integer RNG 0 to t inclusive
On 9/18/2006 3:37 AM, Sean O'Riordain wrote: > Good morning, > > I'm trying to concisely generate a single integer from 0 to n > inclusive, where n might be of the order of hundreds of millions. > This will however be used many times during the general procedure, so > it must be "reasonably efficient" in both memory and time... (at some > later stage in the development I hope to go vectorized) > > The examples I've found through searching RSiteSearch() relating to > generating random integers say to use : sample(0:n, 1) > However, when n is "large" this first generates a large sequence 0:n > before taking a sample of one... this computer doesn't have the memory > for that! You don't need to give the whole vector: just give n, and you'll get draws from 1:n. The man page is clear on this. So what you want is sample(n+1, 1) - 1. (Use "replace=TRUE" if you want a sample bigger than 1, or you'll get sampling without replacement.) > > When I look at the documentation for runif(n, min, max) it states that > the generated numbers will be min <= x <= max. Note the "<= max"... Actually it says that's the range for the uniform density. It's silent on the range of the output. But it's good defensive programming to assume that it's possible to get the endpoints. > > How do I generate an x such that the probability of being (the > integer) max is the same as any other integer from min (an integer) to > max-1 (an integer) inclusive... My attempt is: > > urand.int <- function(n,t) { > as.integer(runif(n,min=0, max=t+1-.Machine$double.eps)) > } > # where I've included the parameter n to help testing... Because of rounding error, t+1-.Machine$double.eps might be exactly equal to t+1. I'd suggest using a rejection method if you need to use this approach: but sample() is better in the cases where as.integer() will work. Duncan Murdoch > > is floor() "better" than as.integer? > > Is this correct? Is the probability of the integer t the same as the > integer 1 or 0 etc... I have done some rudimentary testing and this > appears to work, but power being what it is, I can't see how to > realistically test this hypothesis. > > Or is there a a better way of doing this? > > I'm trying to implement an algorithm which samples into an array, > hence the need for an integer - and yes I know about sample() thanks! > :-) > > { incidentally, I was surprised to note that the maximum value > returned by summary(integer_vector) is "pretty" and appears to be > rounded up to a "nice round number", and is not necessarily the same > as max(integer_vector) where the value is large, i.e. of the order of > say 50 million } > > Is version etc relevant? (I'll want to be portable) >> version _ > platform i386-pc-mingw32 > arch i386 > os mingw32 > system i386, mingw32 > status > major 2 > minor 3.1 > year 2006 > month 06 > day01 > svn rev38247 > language R > version.string Version 2.3.1 (2006-06-01) > > Many thanks in advance for your help. > Sean O'Riordain > affiliation <- NULL > > __ > 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 > and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Propensity score modeling using machine learning methods. WAS: RE: LARS for generalized linear models
There may be benefits to having a machine learning method that explicitly targets covariate balance. We have experimented with optimizing the weights directly to obtain the best covariate balance, but got some strange solutions for simple cases that made us wary of such methods. Machine learning methods that yield calibrated probability estimates should do well (e.g. those that optimize the logistic log-likelihood). Methods that only seek a decision boundary (SVM comes to mind) can be give great classifiers but offer poor probability estimates and then the propensity score weights are a mess. We've had a lot of success in practice using gbm and selecting the number of iterations to optimize balance. You can try the ps() function in the twang package which wraps up gbm and balance optimization in a single function. It's slow for large datasets but it gets the job done. Including additional variables in a weighted regression is a great protective step. It can reduce both bias and variance and can produce "doubly robust" estimates of the treatment effect (see Bang & Robins 2005 for an example). Greg -Original Message- From: Ravi Varadhan [mailto:[EMAIL PROTECTED] Sent: Monday, September 18, 2006 12:38 PM To: Ridgeway, Greg; r-help@stat.math.ethz.ch Subject: Propensity score modeling using machine learning methods. WAS: RE: [R] LARS for generalized linear models Thanks very much, Greg. I will certainly look at glmpath. My goal is to develop (nearly) automatic and flexible procedures for estimating causal effects of risk factors in observational epidemiological studies. A major part of this is the development of a propensity score model (when the exposure is binary). I would like to use tools/approaches that can do this semi-automatically so that the resulting model has both low prediction error and good covariate balance. I have read your paper (McCaffrey, Ridgeway and Morral 2004), which uses a gradient boosting machine (gbm) to build a logistic regression model for propensity score. I was wondering whether there are other tools that can also address this problem, for example, glmpath or MARS? An important question is whether these "machine learning" methods, mainly focused on a good prediction rule, can also achieve a good covariate balance between the treatment groups, since "balance" is not explicitly built into the cost function. If there is significant imbalance, incorporating such covariates into the regression model for outcomes, and performing a weighted least squares analysis (with estimated propensity score as weights) should be reasonable. Am I right? I would appreciate comments on these points. Thanks very much. Best, Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: Ridgeway, Greg [mailto:[EMAIL PROTECTED] Sent: Monday, September 18, 2006 2:17 PM To: r-help@stat.math.ethz.ch Cc: Ravi Varadhan Subject: Re: [R] LARS for generalized linear models Check out Park & Hastie's glmpath package. They have a really clever analysis and implementation of a generalized least angle regression. Greg >On Fri, 2006-09-15 at 18:49 -0400, Ravi Varadhan wrote: > > Is there an R implementation of least angle regression for binary response > > modeling? I know that this question has been asked before, and I am also > > aware of the "lasso2" package, but that only implements an L1 penalty, i.e. > > the Lasso approach. > > > Madigan and Ridgeway in their discussion of Efron et al (2004) describe a > > LARS-type algorithm for generalized linear models. Has anyone implemented > > this in R? This email message is for the sole use of the intended recip...{{dropped}} __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Propensity score modeling using machine learning methods. WAS: RE: LARS for generalized linear models
Thanks very much, Greg. I will certainly look at glmpath. My goal is to develop (nearly) automatic and flexible procedures for estimating causal effects of risk factors in observational epidemiological studies. A major part of this is the development of a propensity score model (when the exposure is binary). I would like to use tools/approaches that can do this semi-automatically so that the resulting model has both low prediction error and good covariate balance. I have read your paper (McCaffrey, Ridgeway and Morral 2004), which uses a gradient boosting machine (gbm) to build a logistic regression model for propensity score. I was wondering whether there are other tools that can also address this problem, for example, glmpath or MARS? An important question is whether these "machine learning" methods, mainly focused on a good prediction rule, can also achieve a good covariate balance between the treatment groups, since "balance" is not explicitly built into the cost function. If there is significant imbalance, incorporating such covariates into the regression model for outcomes, and performing a weighted least squares analysis (with estimated propensity score as weights) should be reasonable. Am I right? I would appreciate comments on these points. Thanks very much. Best, Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: Ridgeway, Greg [mailto:[EMAIL PROTECTED] Sent: Monday, September 18, 2006 2:17 PM To: r-help@stat.math.ethz.ch Cc: Ravi Varadhan Subject: Re: [R] LARS for generalized linear models Check out Park & Hastie's glmpath package. They have a really clever analysis and implementation of a generalized least angle regression. Greg >On Fri, 2006-09-15 at 18:49 -0400, Ravi Varadhan wrote: > > Is there an R implementation of least angle regression for binary response > > modeling? I know that this question has been asked before, and I am also > > aware of the "lasso2" package, but that only implements an L1 penalty, i.e. > > the Lasso approach. > > > Madigan and Ridgeway in their discussion of Efron et al (2004) describe a > > LARS-type algorithm for generalized linear models. Has anyone implemented > > this in R? This email message is for the sole use of the intended recip...{{dropped}} __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] make missing on Solaris (was no subject)
On Mon, 18 Sep 2006, Peter Dalgaard wrote: > "Sarosh Jamal" <[EMAIL PROTECTED]> writes: > >> Hi there, >> >> I was updating the R-cmdr add-on (v.1.1-6 to the latest v.1.2) for R >> (v.2.2.0) in a SunOS9 environment and came across some warnings during my >> installation - it seems to download the dependencies but runs into the >> following during install: >> >> * Installing *source* package 'acepack' ... >> ** libs >> /opt/sfw/R/R-2.2.0/bin/SHLIB: make: not found >> ERROR: compilation failed for package 'acepack' >> /opt/sfw/R/R-2.2.0/bin/INSTALL: test: argument expected >> ERROR: failed to lock directory '/opt/sfw/R/R-2.2.0/library' for modifying >> Try removing '/opt/sfw/R/R-2.2.0/library/00LOCK' >> >> I don't see why I would have to remove the 00LOCK file since it seems to >> have been created by the very session of R I use to run install.packages(). >> >> I'm attaching the complete log. >> >> Any insight or feedback will be much appreciated. > > Notice the _first_ issue reported: > > make: not found It is in /usr/ccs/bin, and not usually in the Parh on Solaris. BUT, your R is very old (2.2.0, and 2.4.0 is about to go into beta). Please update as we ask (see the posting guide) *before* posting about problems. > without a functioning "make" command, you're not likely to get > anything to work. Presumably, since you have a functioning R, "make" > is there somewhere, but you need to adjust your PATH. The rest could > well just be consequences. Yes, of the use of a long-outdated version of R. The 00LOCK problem was a Solaris (Bourne) sh vs bash problem fixed long ago, but since 2.2.0 AFAIR. -- 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] LARS for generalized linear models
Check out Park & Hastie's glmpath package. They have a really clever analysis and implementation of a generalized least angle regression. Greg >On Fri, 2006-09-15 at 18:49 -0400, Ravi Varadhan wrote: > > Is there an R implementation of least angle regression for binary response > > modeling? I know that this question has been asked before, and I am also > > aware of the "lasso2" package, but that only implements an L1 penalty, i.e. > > the Lasso approach. > > > Madigan and Ridgeway in their discussion of Efron et al (2004) describe a > > LARS-type algorithm for generalized linear models. Has anyone implemented > > this in R? This email message is for the sole use of the intended recip...{{dropped}} __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] symbolic matrix elements...
Seems to work also - thanks! Tony Plate wrote: > If I construct the matrix by list()ing together the expressions rather > than c()ing, then it works OK: > > > x <- matrix(list( expression(x3-5*x+4), expression(log(x2-4*x > > x[1,1] > [[1]] > expression(x3 - 5 * x + 4) > > > x[[1,1]] > expression(x3 - 5 * x + 4) > > D(x[[1,1]], "x") > -5 > > > > The reason c() doesn't work properly here might have something to do > with it creating a language object of an unconventional type: > > > c( expression(x3-5*x+4), expression(log(x2-4*x))) > expression(x3 - 5 * x + 4, log(x2 - 4 * x)) > > expression(x3-5*x+4) > expression(x3 - 5 * x + 4) > > > > Using list() with language objects is much safer if you just want to > make lists of them. > > -- Tony Plate > > Evan Cooch wrote: >> >> Eik Vettorazzi wrote: >> >>> test=matrix(c( expression(x^3-5*x+4), expression(log(x^2-4*x >>> works. >> >> Well, not really (or I'm misunderstanding). Your code enters fine (no >> errors), but I can't access individual elements - e.g., test[1,1] >> gives me an error: >> >> > test=matrix(c( expression(x^3-5*x+4), expression(log(x^2-4*x >> > test[1,1] >> Error: matrix subscripting not handled for this type >> >> Meaning...what? >> >> >>> btw. you recieved an error because D expects an expression and you >>> offered a list >> >> >> OK - so why then are each of the elements identified as an expression >> which I print out the vector? Each element is reported to be an >> expression. OK, if so, then I remain puzzled as to how this is a 'list'. >> >> __ >> 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 >> and provide commented, minimal, self-contained, reproducible code. >> > > -- -- Evan Cooch e.mail: [EMAIL PROTECTED] Department of Natural Resources voice: 607-255-1368 Fernow Hall - Cornell UniversityFAX: 607-255-0349 Ithaca, NY14853 http://canuck.dnr.cornell.edu -- A small error in the beginning is a great one in the end.- St. Thomas Aquinas __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] currency or stock trading strategy
Hi Patrick, thanks for pointing me to your work and Rmetrics. I have a few questions on my mind right now. Do you have methods for automatic download of price quote histories? I can use python to get XML data on FOREX price quotes from the NYRB and other sites. Together with Rpy and matplotlib, that data download could form the basis for an open source technical analysis platform. I still need some way to get open source price quote histories for stocks and options. Any ideas? Best, Darren On 9/18/06, Patrick Burns <[EMAIL PROTECTED]> wrote: > The Finance page of the Burns Statistics website tells > you how to sign up to R-sig-finance. > > You want to investigate Rmetrics. > > You can see an example of backtesting in R from the > 'evalstrat' package that is in the Public Domain area of > the Burns Statistics website. > > Patrick Burns > [EMAIL PROTECTED] > +44 (0)20 8525 0696 > http://www.burns-stat.com > (home of S Poetry and "A Guide for the Unwilling S User") > > Darren Weber wrote: > > >Hi, > > > >are there any good charting and analysis tools for use with > >currencies, stocks, etc. in R? I have some tools to download currency > >data from the NYFRB using python and XML. Can we get and parse an XML > >download using R? Can we have interaction in R plots? Does anyone > >use R for back-testing trading strategies? Are there any forums for > >discussion of using R for this specific purpose (apart from this > >general list)? Is anyone aware of any general open-source > >developments for these purposes (I don't see any from GNU or google > >searches)? > > > >Take care, Darren > > > >__ > >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 > >and provide commented, minimal, self-contained, reproducible code. > > > > > > > > > __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Conservative "ANOVA tables" in lmer
On 9/12/06, Douglas Bates <[EMAIL PROTECTED]> wrote: > On 9/11/06, Manuel Morales <[EMAIL PROTECTED]> wrote: [snip] > > Am I right that the MCMC sample can not be used, however, to evaluate > > the significance of parameter groups. For example, to assess the > > significance of a three-level factor? Are there better alternatives than > > simply adjusting the CI for the number of factor levels > > (1-alpha/levels). > > Hmm - I'm not sure what confidence interval and what number of levels > you mean there so I can't comment on that method. > > Suppose we go back to Spencer's example and consider if there is a > signficant effect for the Nozzle factor. That is equivalent to the > hypothesis H_0: beta_2 = beta_3 = 0 versus the general alternative. A > "p-value" could be formulated from an MCMC sample if we assume that > the marginal distribution of the parameter estimates for beta_2 and > beta_3 has roughly elliptical contours and you can evaluate that by, > say, examining a hexbin plot of the values in the MCMC sample. One > could take the ellipses as defined by the standard errors and > estimated correlation or, probably better, by the observed standard > deviations and correlations in the MCMC sample. Then determine the > proportion of (beta_2, beta_3) pairs in the sample that fall outside > the ellipse centered at the estimates and with that eccentricity and > scaling factors that passes through (0,0). That would be an empirical > p-value for the test. > > I would recommend calculating this for a couple of samples to check on > the reproducibility. There was some follow-up on this thread, including some code and results that I find encouraging. I didn't notice that the R-help list had been dropped off the cc: in later exchanges. I enclose my contribution to the conversation so that others on the list will get to see it. --- exerpt from previous private message As soon as I described the idea I knew that someone would ask for a function to perform it. Here's one mcmcpvalue <- function(samp) { ## elementary version that creates an empirical p-value for the ## hypothesis that the columns of samp have mean zero versus a ## general multivariate distribution with elliptical contours. ## differences from the mean standardized by the observed ## variance-covariance factor std <- backsolve(chol(var(samp)), cbind(0, t(samp)) - colMeans(samp), transpose = TRUE) sqdist <- colSums(std * std) sum(sqdist[-1] > sqdist[1])/nrow(samp) } At least I think I have the standardization by the Cholesky factor of the observed variance-covariance matrix correct. However I always manage to confuse myself on that calculation so please let me know if I have it wrong. As an example, consider a model fit to the AvgDailyGain data from the SASmixed package. > library(nlme) > data(AvgDailyGain, package = "SASmixed") > summary(fm1Adg <- lme(adg ~ InitWt*Treatment - 1, AvgDailyGain, random = > ~1|Block)) Linear mixed-effects model fit by REML Data: AvgDailyGain AIC BIClogLik 85.32685 97.10739 -32.66342 Random effects: Formula: ~1 | Block (Intercept) Residual StdDev: 0.5092266 0.2223268 Fixed effects: adg ~ InitWt * Treatment - 1 Value Std.Error DFt-value p-value InitWt 0.0022937 0.0017473 17 1.3126947 0.2067 Treatment0 0.4391370 0.7110881 17 0.6175564 0.5451 Treatment10 1.4261187 0.6375458 17 2.2368880 0.0390 Treatment20 0.4796285 0.5488867 17 0.8738206 0.3944 Treatment30 0.2001071 0.7751989 17 0.2581365 0.7994 InitWt:Treatment10 -0.0012108 0.0023326 17 -0.5190774 0.6104 InitWt:Treatment20 0.0010720 0.0021737 17 0.4931507 0.6282 InitWt:Treatment30 0.0021543 0.0027863 17 0.7731996 0.4500 Correlation: InitWt Trtmn0 Trtm10 Trtm20 Trtm30 IW:T10 IW:T20 Treatment0 -0.961 Treatment10 0.034 0.039 Treatment20 0.003 0.080 0.334 Treatment30 0.050 0.011 0.097 0.043 InitWt:Treatment10 -0.772 0.742 -0.631 -0.164 -0.059 InitWt:Treatment20 -0.806 0.775 -0.180 -0.555 -0.019 0.724 InitWt:Treatment30 -0.666 0.640 -0.046 0.024 -0.754 0.529 0.520 Standardized Within-Group Residuals: Min Q1 Med Q3 Max -1.82903364 -0.44913967 -0.03023488 0.44738506 1.59877700 Number of Observations: 32 Number of Groups: 8 > anova(fm1Adg) numDF denDF F-value p-value InitWt 117 91.68230 <.0001 Treatment417 8.81312 0.0005 InitWt:Treatment 317 0.93118 0.4471 Fitting the same model in lmer then generating an MCMC sample and testing for the three interaction coefficients being zero would look like > data(AvgDailyGain, package = "SASmixed") > (fm1Adg <- lmer(adg ~ InitWt*Treatment - 1 + (1|Block), AvgDailyGain)) Linear mixed-effects model fit by REML Formula: adg ~ InitWt * Treatment - 1 + (1 | Block) Data: AvgDail
Re: [R] (no subject)
On 18 Sep 2006 19:53:59 +0200, Peter Dalgaard <[EMAIL PROTECTED]> wrote: > "Sarosh Jamal" <[EMAIL PROTECTED]> writes: > > > Hi there, > > > > I was updating the R-cmdr add-on (v.1.1-6 to the latest v.1.2) for R > > (v.2.2.0) in a SunOS9 environment and came across some warnings during my > > installation - it seems to download the dependencies but runs into the > > following during install: > > > > * Installing *source* package 'acepack' ... > > ** libs > > /opt/sfw/R/R-2.2.0/bin/SHLIB: make: not found > > ERROR: compilation failed for package 'acepack' > > /opt/sfw/R/R-2.2.0/bin/INSTALL: test: argument expected > > ERROR: failed to lock directory '/opt/sfw/R/R-2.2.0/library' for modifying > > Try removing '/opt/sfw/R/R-2.2.0/library/00LOCK' > > > > I don't see why I would have to remove the 00LOCK file since it seems to > > have been created by the very session of R I use to run install.packages(). > > > > I'm attaching the complete log. > > > > Any insight or feedback will be much appreciated. > > Notice the _first_ issue reported: > > make: not found > > without a functioning "make" command, you're not likely to get > anything to work. Presumably, since you have a functioning R, "make" > is there somewhere, but you need to adjust your PATH. The rest could > well just be consequences. And please do use a meaningful subject line. If you're the type who likes to look through the list archives to try to solve problems, you'll find that good subject lines are most helpful. > > > Thank you, > > > > > > Sarosh Jamal > > Geo Computing & IT Specialist, Department of Geography > > University of Toronto at Mississauga > > e: [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 > > and provide commented, minimal, self-contained, reproducible code. > > -- >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 > and provide commented, minimal, self-contained, reproducible code. > -- Regards, Mike Nielsen __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] (no subject)
"Sarosh Jamal" <[EMAIL PROTECTED]> writes: > Hi there, > > I was updating the R-cmdr add-on (v.1.1-6 to the latest v.1.2) for R > (v.2.2.0) in a SunOS9 environment and came across some warnings during my > installation - it seems to download the dependencies but runs into the > following during install: > > * Installing *source* package 'acepack' ... > ** libs > /opt/sfw/R/R-2.2.0/bin/SHLIB: make: not found > ERROR: compilation failed for package 'acepack' > /opt/sfw/R/R-2.2.0/bin/INSTALL: test: argument expected > ERROR: failed to lock directory '/opt/sfw/R/R-2.2.0/library' for modifying > Try removing '/opt/sfw/R/R-2.2.0/library/00LOCK' > > I don't see why I would have to remove the 00LOCK file since it seems to > have been created by the very session of R I use to run install.packages(). > > I'm attaching the complete log. > > Any insight or feedback will be much appreciated. Notice the _first_ issue reported: make: not found without a functioning "make" command, you're not likely to get anything to work. Presumably, since you have a functioning R, "make" is there somewhere, but you need to adjust your PATH. The rest could well just be consequences. > Thank you, > > > Sarosh Jamal > Geo Computing & IT Specialist, Department of Geography > University of Toronto at Mississauga > e: [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 > and provide commented, minimal, self-contained, reproducible code. -- 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] symbolic matrix elements...
If I construct the matrix by list()ing together the expressions rather than c()ing, then it works OK: > x <- matrix(list( expression(x3-5*x+4), expression(log(x2-4*x > x[1,1] [[1]] expression(x3 - 5 * x + 4) > x[[1,1]] expression(x3 - 5 * x + 4) > D(x[[1,1]], "x") -5 > The reason c() doesn't work properly here might have something to do with it creating a language object of an unconventional type: > c( expression(x3-5*x+4), expression(log(x2-4*x))) expression(x3 - 5 * x + 4, log(x2 - 4 * x)) > expression(x3-5*x+4) expression(x3 - 5 * x + 4) > Using list() with language objects is much safer if you just want to make lists of them. -- Tony Plate Evan Cooch wrote: > > Eik Vettorazzi wrote: > >>test=matrix(c( expression(x^3-5*x+4), expression(log(x^2-4*x >>works. > > Well, not really (or I'm misunderstanding). Your code enters fine (no > errors), but I can't access individual elements - e.g., test[1,1] gives > me an error: > > > test=matrix(c( expression(x^3-5*x+4), expression(log(x^2-4*x > > test[1,1] > Error: matrix subscripting not handled for this type > > Meaning...what? > > >>btw. you recieved an error because D expects an expression and you >>offered a list > > > OK - so why then are each of the elements identified as an expression > which I print out the vector? Each element is reported to be an > expression. OK, if so, then I remain puzzled as to how this is a 'list'. > > __ > 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 > and provide commented, minimal, self-contained, reproducible code. > __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] symbolic matrix elements...
On 9/18/2006 1:16 PM, Evan Cooch wrote: > > Eik Vettorazzi wrote: >> test=matrix(c( expression(x^3-5*x+4), expression(log(x^2-4*x >> works. > Well, not really (or I'm misunderstanding). Your code enters fine (no > errors), but I can't access individual elements - e.g., test[1,1] gives > me an error: > > > test=matrix(c( expression(x^3-5*x+4), expression(log(x^2-4*x > > test[1,1] > Error: matrix subscripting not handled for this type > > Meaning...what? Matrices in R are just vectors with a dim attribute. The matrix function let you create the matrix, but the [ function doesn't know what to do when the vector is of mode expression. This is an unimplemented case, a limitation (or perhaps bug if it wasn't intentional) in R. >> btw. you recieved an error because D expects an expression and you >> offered a list > > OK - so why then are each of the elements identified as an expression > which I print out the vector? Each element is reported to be an > expression. OK, if so, then I remain puzzled as to how this is a 'list'. The problem is that if m is a list, then m[1] is a list with one element. You wanted m[[1]] to extract the first element and get something that's not a list. Duncan Murdoch __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] mixed models with ordinal independents
Hello, are there potential drawbacks in the use of rank (ordinal) variables as predictors in a "linear" mixed model for continuous dependents? I am trying this approach to create mixed effects models independent of the (monotonic) transform of the independent variables. The use of rank transformed independents seems the logical choice to me. Thank you for any feedback, Bruno ~~ Bruno L. Giordano, Ph.D. CIRMMT Schulich School of Music, McGill University 555 Sherbrooke Street West Montréal, QC H3A 1E3 Canada http://www.music.mcgill.ca/~bruno/ __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] (no subject)
Hi there, I was updating the R-cmdr add-on (v.1.1-6 to the latest v.1.2) for R (v.2.2.0) in a SunOS9 environment and came across some warnings during my installation - it seems to download the dependencies but runs into the following during install: * Installing *source* package 'acepack' ... ** libs /opt/sfw/R/R-2.2.0/bin/SHLIB: make: not found ERROR: compilation failed for package 'acepack' /opt/sfw/R/R-2.2.0/bin/INSTALL: test: argument expected ERROR: failed to lock directory '/opt/sfw/R/R-2.2.0/library' for modifying Try removing '/opt/sfw/R/R-2.2.0/library/00LOCK' I don't see why I would have to remove the 00LOCK file since it seems to have been created by the very session of R I use to run install.packages(). I'm attaching the complete log. Any insight or feedback will be much appreciated. Thank you, Sarosh Jamal Geo Computing & IT Specialist, Department of Geography University of Toronto at Mississauga e: [EMAIL PROTECTED] # ls BATCH config libtoolR Rdconv Sd2Rd build exec LINK Rcmd Rdiff SHLIB check f77mkinstalldirs Rd2dvi REMOVE texi2dvi COMPILEINSTALLpager Rd2txt Rprof # ./R R : Copyright 2005, The R Foundation for Statistical Computing Version 2.2.0 (2005-10-06 r35749) ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > install.packages("Rcmdr",dependencies=TRUE) --- Please select a CRAN mirror for use in this session --- Loading Tcl/Tk interface ... done dependency ''zoo'' is not available also installing the dependencies 'acepack', 'chron', 'Hmisc', 'scatterplot3d', 'quadprog', 'mlbench', 'randomForest', 'SparseM', 'xtable', 'its', 'systemfit', 'sem', 'e1071', 'tseries', 'Ecdat', 'mvtnorm', 'leaps', 'strucchange', 'sandwich', 'dynlm', 'abind', 'car', 'effects', 'lmtest', 'multcomp', 'relimp', 'RODBC' trying URL 'http://probability.ca/cran/src/contrib/acepack_1.3-2.2.tar.gz' Content type 'application/x-tar' length 18596 bytes opened URL == downloaded 18Kb trying URL 'http://probability.ca/cran/src/contrib/chron_2.3-7.tar.gz' Content type 'application/x-tar' length 29647 bytes opened URL == downloaded 28Kb trying URL 'http://probability.ca/cran/src/contrib/Hmisc_3.0-12.tar.gz' Content type 'application/x-tar' length 467466 bytes opened URL == downloaded 456Kb trying URL 'http://probability.ca/cran/src/contrib/scatterplot3d_0.3-24.tar.gz' Content type 'application/x-tar' length 504314 bytes opened URL == downloaded 492Kb trying URL 'http://probability.ca/cran/src/contrib/quadprog_1.4-9.tar.gz' Content type 'application/x-tar' length 11176 bytes opened URL == downloaded 10Kb trying URL 'http://probability.ca/cran/src/contrib/mlbench_1.1-1.tar.gz' Content type 'application/x-tar' length 1179218 bytes opened URL == downloaded 1151Kb trying URL 'http://probability.ca/cran/src/contrib/randomForest_4.5-16.tar.gz' Content type 'application/x-tar' length 82484 bytes opened URL == downloaded 80Kb trying URL 'http://probability.ca/cran/src/contrib/SparseM_0.71.tar.gz' Content type 'application/x-tar' length 537933 bytes opened URL == downloaded 525Kb trying URL 'http://probability.ca/cran/src/contrib/xtable_1.3-2.tar.gz' Content type 'application/x-tar' length 12475 bytes opened URL == downloaded 12Kb trying URL 'http://probability.ca/cran/src/contrib/its_1.1.4.tar.gz' Content type 'application/x-tar' length 33729 bytes opened URL == downloaded 32Kb trying URL 'http://probability.ca/cran/src/contrib/systemfit_0.8-0.tar.gz' Content type 'application/x-tar' length 431667 bytes opened URL == downloaded 421Kb trying URL 'http://probability.ca/cran/src/contrib/sem_0.9-5.tar.gz' Content type 'application/x-tar' length 45046 bytes opened URL == downloaded 43Kb trying URL 'http://probability.ca/cran/src/contrib/e1071_1.5-13.tar.gz' Content type 'applicatio
Re: [R] symbolic matrix elements...
Eik Vettorazzi wrote: > test=matrix(c( expression(x^3-5*x+4), expression(log(x^2-4*x > works. Well, not really (or I'm misunderstanding). Your code enters fine (no errors), but I can't access individual elements - e.g., test[1,1] gives me an error: > test=matrix(c( expression(x^3-5*x+4), expression(log(x^2-4*x > test[1,1] Error: matrix subscripting not handled for this type Meaning...what? > > btw. you recieved an error because D expects an expression and you > offered a list OK - so why then are each of the elements identified as an expression which I print out the vector? Each element is reported to be an expression. OK, if so, then I remain puzzled as to how this is a 'list'. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question on apply() with more information...
>From: =?ISO646-US?Q?Gunther_H=3Fning?= <[EMAIL PROTECTED]> >Date: 2006/09/18 Mon AM 06:26:25 CDT >To: 'Petr Pikal' <[EMAIL PROTECTED]> >Cc: r-help@stat.math.ethz.ch >Subject: Re: [R] Question on apply() with more information... I think you want something like below but it probably needs some fixing up because i don't recall the syntax exactly. predictdata<-lapply(i=1:length(Smoothlist),function predict (smthlist[[i]],xarry[i,])smthlist= SmoothList,xarry=Xarry) >Hi, > >I tried both ideas, but it isn't that what I'm looking for. >I want to avoid for loop, because the matrix is of big size(1200*1200 >entries) > >With a loop I would do: > >for ( i in seq(along = SmoothList)) >{ > Xarry[i,] <- predict(SmoothList[[i]],Xarry[i,])$y >} > >Actually I want to do more than just to predict a value, but it isn't >important for the initial question... > >Gunther > >-Ursprüngliche Nachricht- >Von: Petr Pikal [mailto:[EMAIL PROTECTED] >Gesendet: Montag, 18. September 2006 11:44 >An: Gunther Höning >Cc: r-help@stat.math.ethz.ch >Betreff: Re: AW: [R] Question on apply() with more information... > >Hi > >If I am correct apply do not choose from SmoothList as you expected. >Instead probably > >lapply(SmoothList, predict,Xarray) >or >mapply(predict,SmoothList, Xarray) > >can give you probably what you want. > >HTH >Petr > > >On 18 Sep 2006 at 9:26, Gunther Höning wrote: > >From: Gunther Höning <[EMAIL PROTECTED]> >To:"'Petr Pikal'" <[EMAIL PROTECTED]>, > >Subject: AW: [R] Question on apply() with more information... >Date sent: Mon, 18 Sep 2006 09:26:01 +0200 > >> Ok. >> I tried this too, but it still doesn't work. >> Here some more information to try out, but just an excerpt of Xarray >> >> x <- c(0.11,0.25,0.45,0.65,0.80,0.95,1) >> Y <- >> matrix(c(15,83,57,111,150,168,175,37,207,142,277,375,420,437),nrow=2) >> >> sm <- function(y,x){smooth.spline(x,y)} SmoothList <- apply(Y,1,sm,x) >> NewValues <- function(x,LIST){predict(LIST,x)} Xarray <- >> matrix(c(0.15,0.56,0.66,0.45,0.19,0.17,0.99,0.56,0.77,0.41,0.11,0.63,0 >> .42,0. 43),nrow=2) >> >> >> apply(Xarray, 2, NewValues,SmoothList) apply(Xarray, 2, >> NewValues,LIST=SmoothList) >> >> >> >> -Ursprüngliche Nachricht- >> Von: Petr Pikal [mailto:[EMAIL PROTECTED] >> Gesendet: Montag, 18. September 2006 08:43 >> An: Gunther Höning; r-help@stat.math.ethz.ch >> Betreff: Re: [R] Question on apply() >> >> Hi >> >> not much information about what can be wrong. As nobody knows your >> Xarray and SmoothList it is hard to guess. You even omitted to show >> what "does not work" So here are few guesses. >> >> predict usually expects comparable data apply(Xarray, 2, >> NewValues,LIST=SmoothList) >> >> >> HTH >> Petr >> >> >> >> >> On 18 Sep 2006 at 8:05, Gunther Höning wrote: >> >> From:Gunther Höning <[EMAIL PROTECTED]> >> To: >> Date sent: Mon, 18 Sep 2006 08:05:28 +0200 >> Subject: [R] Question on apply() >> >> > Dear list, >> > >> > I try to do the following: >> > I have an list of length n, with elements done by smooth.spline >> > (SmoothList). Now I have a matrix with n rows and m columns with >> > x-values(Xarray) Now I want ot predict the y-values. Therefor I want >> > to take the first element of SmoothList and the first row of Xarray >> > and predict for each element in Xarray the y value. And then take >> > the second element of SmoothList and second row of Xarray, third row >> > of SmoothList and third row of Xarray and so on >> > >> > I tried following: >> > >> > NewValues <- function(x,LIST){predict(LIST,x)} apply(Xarray, 2, >> > NewValues,SmoothList) >> > >> > But it don't work. >> > >> > Could anybody help please ? >> > >> > Gunther >> > >> > __ >> > 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 and provide commented, >> > minimal, self-contained, reproducible code. >> >> Petr Pikal >> [EMAIL PROTECTED] >> > >Petr Pikal >[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 >and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] R enquiry: Replace blank spaces with a character value
Dear Bob, It's not clear to me what you want to do. You provided my example, which I already know, and you didn't provide yours. Marco --- Bob Green <[EMAIL PROTECTED]> wrote: > Marco, > > I saw your January e-mail to an enquiry about > filling in missing values > with a zero I tried adapting the various syntax > suggestions without much luck. > > If I have a dataframe called test, which contains 2 > variables (var1 & var2) > which contain blank spaces. I want replace blank > spaces with the value > 'n'. How can I do this using the syntax you provided > (see below): > > > Any assistance you can offer is appreciated, > > Bob > > >foo <- data.frame(x=1:3,y=letters[1:3],z=4:6, > w=as.Date(c("02/27/92", > "02/27/92", "01/14/92"), "%m/%d/%y")) foo[2,] <- NA > >foo > x y z w > 1 1 a 4 1992-02-27 > 2 NA NA > 3 3 c 6 1992-01-14 > > class(foo$w) > [1] "Date" > >mode(foo$w) > [1] "numeric" > > a <- sapply(foo, is.numeric) > b <- !sapply(foo, class)=="Date" > > foo[!complete.cases(foo),a & b] <- 0 > >foo >x y z w > 1 1 a 4 1992-02-27 > 2 0 0 > 3 3 c 6 1992-01-14 > > __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] symbolic matrix elements...
test=matrix(c( expression(x^3-5*x+4), expression(log(x^2-4*x works. btw. you recieved an error because D expects an expression and you offered a list > class(test[1]) [1] "list" to get the error relating to the misuse of the tilde operator you have to prompt the "correct" extractor "[[" f<-test[[1]] D(f,"x") Am Mon, 18 Sep 2006 18:30:57 +0200 schrieb Evan Cooch <[EMAIL PROTECTED]>: > Normally, I do symbolics in Maple, or Mathematica, but I'm trying to > write a simple script for students to handle some *very* simple > calculations (for other purposes) with matrix or vector elements, where > the elements are coded symbolically. What I've tried with *partial" > success is use of the tilde (~) operator. So, for example, consider a > simple vector: > > test=matrix(c(~ x^3-5*x+4, ~log(x^2-4*x))) > > Now, when I look at test, I see > > > test > [,1] > [1,] Expression > [2,] Expression > > Fine. When I try to extract one of the vector elements, I see (for > example) > > > test[1] > [[1]] > ~x^3 - 5 * x + 4 > > > Fine - but now I'm trying to figure out how to use the extracted matrix > element for anything else. For example, using D for simple symbolic > derivatives > > f <- test[1]; > D(f,"x") > > should *in theory* work, but I get the following: > > > D(f,"x"); > [1] NA > > But, if I try > > f <- expression(x^3-5*x+4); > D(f,"x"); > > works fine. > > So, even though it looks as if each element of test is coded as an > expression, it seems as though it is somehow a different type of > expression than if I code it explicitly as an expression. I'm *guessing* > it has to do with the tilde operator not assigning the formula to > anything, but I'm not sure. > > Suggestions? Pointers to the obvious? > > Thanks! > -- Universität Hamburg Institut für Statistik und Ökonometrie Dipl.-Wi.-Math. Eik Vettorazzi Von-Melle-Park 5 20146 Hamburg Tel.: +49 40-42838-3540 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] (no subject)
You may want to rethink your whole approach here: 1. Pie charts are usually a poor choice of graph, there are better choices. 2. Adding percentages to a pie chart is a way of admitting that the pie chart is not doing the job. 3. If you want people to compare percentages, then a table is what is needed. 4. A pie chart with percentages added is essentially a colorful but poorly layed out table. Consider using a dotplot instead of a pie chart, it changes the job of the viewer from comparing areas/angles (done poorly by humans) to comparing positions along a common scale (done well by humans). If you still feel the need to combine the table and graphic into 1 (usually they serve different purposes and are best kept separate) then you can do something like this (at least the percentages are all aligned now for easy comparison): > library(lattice) > bull<-c(34,23,7,4) > > bull.df <- data.frame(bull=bull, name=LETTERS[1:4], pb=round(bull/sum(bull)*100,2)) > dotplot(name~pb, data=bull.df, + scales=list( + x=list(limits=c(0,100)), + ), + panel=function(x,y,...){ + panel.dotplot(x,y,...) + ltext(100,y,paste(format(x),"%",sep=''),adj=1,xpd=NA) + } + ) It would look even better if the percentages were outside the box, but I did not have the time to figure this part out. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of ERICK YEGON Sent: Monday, September 18, 2006 7:22 AM To: r-help@stat.math.ethz.ch Subject: [R] (no subject) Hi Gurus, i have a small problem with working with graphs on R. Say i have data say bull-c(34,23,7,4) and i assign names to the elements in the brackets if i do Pie(bull) i get a pie chart of bull togtjer with the names. Question. How can i add values (percentages) in the graph Thanks __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] symbolic matrix elements...
Normally, I do symbolics in Maple, or Mathematica, but I'm trying to write a simple script for students to handle some *very* simple calculations (for other purposes) with matrix or vector elements, where the elements are coded symbolically. What I've tried with *partial" success is use of the tilde (~) operator. So, for example, consider a simple vector: test=matrix(c(~ x^3-5*x+4, ~log(x^2-4*x))) Now, when I look at test, I see > test [,1] [1,] Expression [2,] Expression Fine. When I try to extract one of the vector elements, I see (for example) > test[1] [[1]] ~x^3 - 5 * x + 4 Fine - but now I'm trying to figure out how to use the extracted matrix element for anything else. For example, using D for simple symbolic derivatives f <- test[1]; D(f,"x") should *in theory* work, but I get the following: > D(f,"x"); [1] NA But, if I try f <- expression(x^3-5*x+4); D(f,"x"); works fine. So, even though it looks as if each element of test is coded as an expression, it seems as though it is somehow a different type of expression than if I code it explicitly as an expression. I'm *guessing* it has to do with the tilde operator not assigning the formula to anything, but I'm not sure. Suggestions? Pointers to the obvious? Thanks! -- -- Evan Cooch e.mail: [EMAIL PROTECTED] Department of Natural Resources voice: 607-255-1368 Fernow Hall - Cornell UniversityFAX: 607-255-0349 Ithaca, NY14853 http://canuck.dnr.cornell.edu -- Nihilism is best done by professionals. - Iggy Pop __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] prediction interval for new value
Peter et. al.: > > With those definitions (which are hardly universal), tolerance > intervals are the same as prediction intervals with k == m == 1, which > is what R provides. > > I don't believe this is the case. See also: http://www.itl.nist.gov/div898/handbook/prc/section2/prc263.htm This **is** fairly standard, I believe. For example, see the venerable classic text (INTRO TO MATH STAT) by Hogg and Craig. To be clear, since I may also be misinterpreting, what I understand/mean is: Peter's definition of a "tolerance/prediction interval" is a random interval that with a prespecified confidence contain a future predicted value; The definition I understand to be a random interval that with a prespecified confidence will contain a prespecfied proportion of the distribution of future values. ..e.g. a "95%/90%" tolerance interval will with 95% confidence contain 90% of future values (and one may well ask, "which 90%"?). Whether this is a useful idea is another issue: the parametric version is extremely sensitive (as one might imagine) to the assumption of exact normality; the nonparametric version relies on order statistics and is more robust. I believe it is nontrivial and perhaps ambiguous to extend the concept from the usual fixed distribution to the linear regression case. I seem to recall some papers on this, perhaps in JASA, in the past few years. As always, I welcome correction of any errors or misunderstandings herein. Cheers to all, 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] prediction interval for new value
Sachin, One of the references in the link is a EPA groundwater statistics training manual from the early nineties. For a more complete related discussion see pp. 50-62 of the July 1992 EPA draft addendum on groundwater monitoring statistics at http://www.epa.gov/correctiveaction/resource/guidance/sitechar/gwstats/gwstats.htm Regarding discussion the prediction interval for linear regression you might want to read sections of chapter 9 in Helsel and Hirsch: http://pubs.usgs.gov/twri/twri4a3/ I would also recommend working of the examples in these or other references with R in order to 1.) reassure yourself that the code is doing what you want and 2.) you are comfortable with the concepts. I seem to recall seeing the terms 'tolerance interval' and 'prediction interval' mingled in some discussions--shades of Peter's 'hardly universal' comment. This means that there is even more incentive to develop some facility with the concept and code by working a few out first. HTH Regards, Michael Grant --- Peter Dalgaard <[EMAIL PROTECTED]> wrote: > Sachin J <[EMAIL PROTECTED]> writes: > > > Google search gave me this: > > > > > http://ewr.cee.vt.edu/environmental/teach/smprimer/intervals/interval.html > > > > TIA > > Sachin > > With those definitions (which are hardly universal), tolerance > intervals are the same as prediction intervals with k == m == 1, which > is what R provides. > > > > > > Peter Dalgaard <[EMAIL PROTECTED]> wrote: > > Sachin J writes: > > > > > RUsers: > > > > > > Just confirming, does predict function with interval="prediction" > > > option gives prediction interval or tolerance interval?. Sorry for > > > reposting this question. > > > > > > Is there any definition of tolerance interval that is different from > > prediction interval? > > > > (Tolerance intervals in the medical sense means intervals that are > > designed to detect patients with abnormal levels of serum cholesterol > > (say).) > > > > -- > > 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 > > > > > > > > - > > Do you Yahoo!? > > -- >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 > and provide commented, minimal, self-contained, reproducible code. > __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] non linear modelling with nls: starting values
"Gabor Grothendieck" <[EMAIL PROTECTED]> writes: > Here are some approaches: > > - we only have 4 parameters so just use grid search to get > starting values as in: > > https://stat.ethz.ch/pipermail/r-help/2005-September/079617.html > > - there are singularities near beta_1 = beta_2 and near alpha_1 = 0 > and near alpha_2 = 0 so reparameterize and use the upper and > lower bounds to avoid those regions. You could try a separate > reduced model for those. Or just use SSbiexp and reparametrize (it is exactly the same model) > > On 9/18/06, Sebastian P. Luque <[EMAIL PROTECTED]> wrote: > > Hi, > > > > I'm trying to fit the following model to data using 'nls': > > > > > > y = alpha_1 * beta_1 * exp(-beta_1 * x) + > >alpha_2 * beta_2 * exp(-beta_2 * x) > > > > > > and the call I've been using is: > > > > > > nls(y ~ alpha_1 * beta_1 * exp(-beta_1 * x) + > >alpha_2 * beta_2 * exp(-beta_2 * x), > >start=list(alpha_1=4, alpha_2=2, beta_1=3.5, beta_2=2.5), > >trace=TRUE, control=nls.control(maxiter = 200)) > > > > > > So the model has 4 parameters (alpha_1, alpha_2, beta_1, beta_2), but > > providing appropriate starting values is proving difficult. Although the > > data could reasonably be fit with this model, the procedure is exiting > > with "singular gradient matrix at initial parameter estimates". How can > > one obtain appropriate starting values, assuming that is really the > > problem? The archives show some suggestions to use 'optim', but that > > requires starting values too, so I'm not sure how to proceed. > > > > Searching for self-starting functions, I found that there's one for a > > bi-exponential model, which is very similar to the one I'm trying to fit. > > Would it be reasonable to create a modified version of this function, so > > that it returns a value that can be used for the model above? I would > > greatly appreciate any comments and suggestions. > > > > > > -- > > Seb > > > > __ > > 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 > > and provide commented, minimal, self-contained, reproducible code. > > > > __ > 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 > and provide commented, minimal, self-contained, reproducible code. > -- 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] using table in R
On Sat, 16 Sep 2006 21:17:21 -0500, Bingshan Li <[EMAIL PROTECTED]> wrote: > Hi there, I have a dataframe whose elements are numbers or characters. I > want to extract the frequencies of each elements in the dataframe. For > example, > d = as.data.frame(matrix(c(1, 2, 3, 3), 2,2)) Don't use a data frame; e.g.: table(as.matrix(d)) -- Seb __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Standard error of coefficient in linear regression
I believe that your confusion is due to a typo in the formula in [3], it is missing a sumation sign (and a subscript on x if you want to be picky). To get the denominator you subtract the mean of your x variable from all the x-values, square the differences, then sum them up (the missing sumation sign) and take the square root. This is essentially the standard deviation of your x variable but without dividing by (n-1). If you want to do this in R (a good thing while learning, there are better ways for actual analysis) you could use code like: > x.e <- exped - mean(exped) > x.e2 <- x.e^2 > sx2 <- sqrt(sum(x.e2)) > sb <- Se/sx2 # where Se is your residual standard error from below Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Maciej Blizinski Sent: Sunday, September 17, 2006 12:22 PM To: R - help Subject: [R] Standard error of coefficient in linear regression Hello R users, I have a substantial question about statistics, not about R itself, but I would love to have an answer from an R user, in form of an example in R syntax. I have spent whole Sunday searching in Google and browsing the books. I've been really close to the answer but there are at least three standard errors you can talk about in the linear regression and I'm really confused. The question is: How exactly are standard errors of coefficients calculated in the linear regression? Here's an example from a website I've read [1]. A company wants to know if there is a relationship between its advertising expenditures and its sales volume. > exped <- c(4.2, 6.1, 3.9, 5.7, 7.3, 5.9) sales <- c(27.1, 30.4, 25.0, > 29.7, 40.1, 28.8) S <- data.frame(exped, sales) summary(lm(sales ~ > exped, data = S)) Call: lm(formula = sales ~ exped, data = S) Residuals: 1 2 3 4 5 6 1.7643 -1.9310 0.7688 -1.1583 3.3509 -2.7947 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 9.8725 5.2394 1.884 0.1326 exped 3.6817 0.9295 3.961 0.0167 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 2.637 on 4 degrees of freedom Multiple R-Squared: 0.7968, Adjusted R-squared: 0.7461 F-statistic: 15.69 on 1 and 4 DF, p-value: 0.01666 I can calculate the standard error of the estimate, according to the equation [2]... > S.m <- lm(sales ~ exped, data = S) > S$pred <- predict(S.m) > S$ye <- S$sales - S$pred > S$ye2 <- S$ye ^ 2 > Se <- sqrt(sum(S$ye2)/(length(S$sales) - 1 - 1)) Se [1] 2.636901 ...which matches the "Residual standard error" and I'm on the right track. Next step would be to use the equation [3] to calculate the standard error of the regression coefficient (here: exped). The equation [3] uses two variables, meaning of which I can't really figure out. As the calculated value Sb is scalar, all the parameters need also to be scalars. I've already calculated Se, so I'm missing x and \bar{x}. The latter could be the estimated coefficient. What is x then? Regards, Maciej [1] http://www.statpac.com/statistics-calculator/correlation-regression.htm [2] http://www.answers.com/topic/standard-error-of-the-estimate [3] http://www.answers.com/topic/standard-error-of-the-regression-coefficient -- Maciej Bliziński <[EMAIL PROTECTED]> http://automatthias.wordpress.com __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] using table in R
Hi there, I have a dataframe whose elements are numbers or characters. I want to extract the frequencies of each elements in the dataframe. For example, d = as.data.frame(matrix(c(1, 2, 3, 3), 2,2)) What I want is first what are the elements in the data (1,2,3 here) and second what are their frequencies (1,1,2 respectively). How to use "table" to extract these two pieces of information? I played with "table" but couldn't extract the information. Please assume that we do not know how many elements in the dataframe a priori. Thanks a lot! __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] non linear modelling with nls: starting values
Here are some approaches: - we only have 4 parameters so just use grid search to get starting values as in: https://stat.ethz.ch/pipermail/r-help/2005-September/079617.html - there are singularities near beta_1 = beta_2 and near alpha_1 = 0 and near alpha_2 = 0 so reparameterize and use the upper and lower bounds to avoid those regions. You could try a separate reduced model for those. On 9/18/06, Sebastian P. Luque <[EMAIL PROTECTED]> wrote: > Hi, > > I'm trying to fit the following model to data using 'nls': > > > y = alpha_1 * beta_1 * exp(-beta_1 * x) + >alpha_2 * beta_2 * exp(-beta_2 * x) > > > and the call I've been using is: > > > nls(y ~ alpha_1 * beta_1 * exp(-beta_1 * x) + >alpha_2 * beta_2 * exp(-beta_2 * x), >start=list(alpha_1=4, alpha_2=2, beta_1=3.5, beta_2=2.5), >trace=TRUE, control=nls.control(maxiter = 200)) > > > So the model has 4 parameters (alpha_1, alpha_2, beta_1, beta_2), but > providing appropriate starting values is proving difficult. Although the > data could reasonably be fit with this model, the procedure is exiting > with "singular gradient matrix at initial parameter estimates". How can > one obtain appropriate starting values, assuming that is really the > problem? The archives show some suggestions to use 'optim', but that > requires starting values too, so I'm not sure how to proceed. > > Searching for self-starting functions, I found that there's one for a > bi-exponential model, which is very similar to the one I'm trying to fit. > Would it be reasonable to create a modified version of this function, so > that it returns a value that can be used for the model above? I would > greatly appreciate any comments and suggestions. > > > -- > Seb > > __ > 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 > and provide commented, minimal, self-contained, reproducible code. > __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] (no subject)
Something like pie(bull, labels=paste(names(bull),": ",bull,"%", sep="")) On 18/09/06, ERICK YEGON <[EMAIL PROTECTED]> wrote: > > Hi Gurus, i have a small problem with working with graphs on R. > Say i have data say bull-c(34,23,7,4) and i assign names to the elements > in > the brackets > if i do > Pie(bull) i get a pie chart of bull togtjer with the names. > Question. How can i add values (percentages) in the graph > > Thanks > > __ > 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 > and provide commented, minimal, self-contained, reproducible code. > -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Add percentage to pie (was "(no subject)")
ERICK YEGON said the following on 9/18/2006 8:22 AM: > Hi Gurus, i have a small problem with working with graphs on R. > Say i have data say bull-c(34,23,7,4) and i assign names to the elements in > the brackets > if i do > Pie(bull) i get a pie chart of bull togtjer with the names. > Question. How can i add values (percentages) in the graph > > Thanks > > __ > 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 > and provide commented, minimal, self-contained, reproducible code. (Please use a sensible subject line!) Where do you want to add percentages? If next to the labels, then just use: bull <- c(34, 23, 7, 4) names(bull) <- LETTERS[seq(along = bull)] lbl <- sprintf("%s = %3.1f%s", names(bull), bull/sum(bull)*100, "%") pie(bull, lbl) --sundar __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] non linear modelling with nls: starting values
Hi, I'm trying to fit the following model to data using 'nls': y = alpha_1 * beta_1 * exp(-beta_1 * x) + alpha_2 * beta_2 * exp(-beta_2 * x) and the call I've been using is: nls(y ~ alpha_1 * beta_1 * exp(-beta_1 * x) + alpha_2 * beta_2 * exp(-beta_2 * x), start=list(alpha_1=4, alpha_2=2, beta_1=3.5, beta_2=2.5), trace=TRUE, control=nls.control(maxiter = 200)) So the model has 4 parameters (alpha_1, alpha_2, beta_1, beta_2), but providing appropriate starting values is proving difficult. Although the data could reasonably be fit with this model, the procedure is exiting with "singular gradient matrix at initial parameter estimates". How can one obtain appropriate starting values, assuming that is really the problem? The archives show some suggestions to use 'optim', but that requires starting values too, so I'm not sure how to proceed. Searching for self-starting functions, I found that there's one for a bi-exponential model, which is very similar to the one I'm trying to fit. Would it be reasonable to create a modified version of this function, so that it returns a value that can be used for the model above? I would greatly appreciate any comments and suggestions. -- Seb __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] prediction interval for new value
Sachin J <[EMAIL PROTECTED]> writes: > Google search gave me this: > > http://ewr.cee.vt.edu/environmental/teach/smprimer/intervals/interval.html > > TIA > Sachin With those definitions (which are hardly universal), tolerance intervals are the same as prediction intervals with k == m == 1, which is what R provides. > > Peter Dalgaard <[EMAIL PROTECTED]> wrote: > Sachin J writes: > > > RUsers: > > > > Just confirming, does predict function with interval="prediction" > > option gives prediction interval or tolerance interval?. Sorry for > > reposting this question. > > > Is there any definition of tolerance interval that is different from > prediction interval? > > (Tolerance intervals in the medical sense means intervals that are > designed to detect patients with abnormal levels of serum cholesterol > (say).) > > -- > 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 > > > > - > Do you Yahoo!? > Everyone is raving about the all-new Yahoo! Mail. -- 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] prediction interval for new value
Google search gave me this: http://ewr.cee.vt.edu/environmental/teach/smprimer/intervals/interval.html TIA Sachin Peter Dalgaard <[EMAIL PROTECTED]> wrote: Sachin J writes: > RUsers: > > Just confirming, does predict function with interval="prediction" > option gives prediction interval or tolerance interval?. Sorry for > reposting this question. Is there any definition of tolerance interval that is different from prediction interval? (Tolerance intervals in the medical sense means intervals that are designed to detect patients with abnormal levels of serum cholesterol (say).) -- 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 - [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] prediction interval for new value
Sachin J <[EMAIL PROTECTED]> writes: > RUsers: > > Just confirming, does predict function with interval="prediction" > option gives prediction interval or tolerance interval?. Sorry for > reposting this question. Is there any definition of tolerance interval that is different from prediction interval? (Tolerance intervals in the medical sense means intervals that are designed to detect patients with abnormal levels of serum cholesterol (say).) -- 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Cochrans Q Test
[...] > >> cochranq.test(K) > >Cochran's Q Test for Dependent Samples > > data: K > Cochran's Q = 23.9298, df = 11, p-value = 0.01303 > Cochran's Q fits into the `coin' framework and thus: > K <- as.table(matrix(c(1,1,0,0, 1,1,0,1, 1,1,1,1, 1,1,1,1, 1,0,0,0, + 1,1,1,1, 1,1,1,1, 0,0,0,0, 0,1,0,1, 1,1,1,1, 0,1,0,1, 0,1,0,1),ncol=12, + dimnames = list("Seating type" = c("I","II","III","IV"),"Test + subject"=c("A","B","C","D","E","F","G","H","I","J","K","L" > > df <- data.frame(success = as.vector(K), + test = factor(rep(colnames(K), rep(4, 12))), + subject = factor(rep(rownames(K), 12))) > > library("coin") > symmetry_test(success ~ test | subject, data = df, teststat = "quad") Asymptotic General Independence Test data: success by groups A, B, C, D, E, F, G, H, I, J, K, L stratified by subject chi-squared = 23.9298, df = 11, p-value = 0.01303 > can be used to compute the test without additional coding and > symmetry_test(success ~ test | subject, data = df, teststat = "quad", distribution = approximate(1)) Approximative General Independence Test data: success by groups A, B, C, D, E, F, G, H, I, J, K, L stratified by subject chi-squared = 23.9298, p-value = 0.006 > approximates the p value by Monte-Carlo procedures. Best wishes, Torsten > > BTW, a quick Google search shows that the pcochran() function is in the > 'outliers' package on CRAN, which also has a cochran.test() function > > 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 > and provide commented, minimal, self-contained, reproducible code. > > __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] (no subject)
Hi Gurus, i have a small problem with working with graphs on R. Say i have data say bull-c(34,23,7,4) and i assign names to the elements in the brackets if i do Pie(bull) i get a pie chart of bull togtjer with the names. Question. How can i add values (percentages) in the graph Thanks __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Cochrans Q Test
On Mon, 2006-09-18 at 14:01 +1000, [EMAIL PROTECTED] wrote: > Hi! > > I would like to conduct a Cochran`s Q Test in R, but have not found any > suitable function. > > My first idea was: J <- as.table(matrix(c(6,16,2,4),ncol=2, dimnames = > list("C" = c("Favorable","Unfavorable"),"Drug A Favorable"=c("B > Favorable","B Unfavorable" > L <- as.table(matrix(c(2,4,6,6),ncol=2, dimnames = list("C" = > c("Favorable","Unfavorable"),"Drug A Unfavorable"=c("B Favorable","B > Unfavorable" > mantelhaen.test(J,L, alternative="t") > > But this is obviously the wrong function. The CMH test does not consider the dependent nature of the measurements, so it is indeed the wrong test, if you have dependent measures as your data 'K' below would suggest. Cochran's Q is a generalization of the McNemar paired chi square. > Then I googled and found (different data): > > K <- as.table(matrix(c(1,1,0,0, 1,1,0,1, 1,1,1,1, 1,1,1,1, 1,0,0,0, > 1,1,1,1, 1,1,1,1, 0,0,0,0, 0,1,0,1, 1,1,1,1, 0,1,0,1, 0,1,0,1),ncol=12, > dimnames = list("Seating type" = c("I","II","III","IV"),"Test > subject"=c("A","B","C","D","E","F","G","H","I","J","K","L" > K > pcochran(K,4,12) > > But R said that this function does not exist. > Can anyone help? Here is a version of the Cochran's Q that I wrote and posted to sci.stat.consult back in June in response to a thread there. This is based upon Sheskin's Handbook of Parametric and Nonparametric Statistical Procedures (2004) page 867. You might want to secure a copy of the book and review the comments regarding the assumptions underlying this test and the considerations for it use. cochranq.test <- function(mat) { k <- ncol(mat) C <- sum(colSums(mat) ^ 2) R <- sum(rowSums(mat) ^ 2) T <- sum(rowSums(mat)) num <- (k - 1) * ((k * C) - (T ^ 2)) den <- (k * T) - R Q <- num / den df <- k - 1 names(df) <- "df" names(Q) <- "Cochran's Q" p.val <- pchisq(Q, df, lower = FALSE) QVAL <- list(statistic = Q, parameter = df, p.value = p.val, method = "Cochran's Q Test for Dependent Samples", data.name = deparse(substitute(mat))) class(QVAL) <- "htest" return(QVAL) } Using your matrix 'K': > K Test subject Seating type A B C D E F G H I J K L I 1 1 1 1 1 1 1 0 0 1 0 0 II 1 1 1 1 0 1 1 0 1 1 1 1 III 0 0 1 1 0 1 1 0 0 1 0 0 IV 0 1 1 1 0 1 1 0 1 1 1 1 > cochranq.test(K) Cochran's Q Test for Dependent Samples data: K Cochran's Q = 23.9298, df = 11, p-value = 0.01303 BTW, a quick Google search shows that the pcochran() function is in the 'outliers' package on CRAN, which also has a cochran.test() function 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem in font
Ronaldo Reis-Jr. wrote: > Hi, > > But, I have this warning in the enviromnent that have this problem: > > During startup - Warning message: > using .GlobalEnv instead of 'package:lattice' So, can you please be a bit more specific? R version, your startup files such as Rprofile files etc? Uwe Ligges > maybe this is the problem? > > How to fix it? > > Thanks > ROnaldo __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] prediction interval for new value
RUsers: Just confirming, does predict function with interval="prediction" option gives prediction interval or tolerance interval?. Sorry for reposting this question. Thanks in advance Sachin David Barron <[EMAIL PROTECTED]> wrote: Sorry, I think I may have mislead you; the documentation describes these rather ambiguously as "prediction (tolerance) intervals", but having done some comparisons with other software I believe they are what most of us call prediction intervals after all! On 15/09/06, Sachin J <[EMAIL PROTECTED]> wrote: If its true then how do I find prediction interval.? Thanx in advance. Sachin David Barron < [EMAIL PROTECTED]> wrote: I believe it is a tolerance interval On 15/09/06, Sachin J <[EMAIL PROTECTED]> wrote: David, Thanks for the quick reply. Just confirming, does predict(s.lm,data.frame(x=3),interval="prediction") gives prediction interval or tolerance interval? Thanks Sachin David Barron <[EMAIL PROTECTED] > wrote: > predict(s.lm,data.frame(x=3),interval="prediction") fit lwr upr [1,] 16073985 -9981352 42129323 > predict(s.lm,data.frame(x=3),interval="confidence") fit lwr upr [1,] 16073985 5978125 26169846 On 15/09/06, Sachin J <[EMAIL PROTECTED]> wrote: Hi, 1. How do I construct 95% prediction interval for new x values, for example - x = 3? 2. How do I construct 95% confidence interval? my dataframe is as follows : >dt structure(list(y = c(2610, 6050, 1620, 3070, 7010, 5770, 4670, 860, 1000, 6180, 3020, 5220, 7190, 5500, 1270 ), x = c(108000, 136000, 35000, 77000, 178000, 15, 126000, 24000, 28000, 214000, 108000, 19, 308000, 252000, 71000)), .Names = c("y", "x"), class = "data.frame", row.names = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15")) my regression eqn is as below: > s.lm <- lm(y ~ x) Thanks in advance. - [[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 and provide commented, minimal, self-contained, reproducible code. -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP - -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP - -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP - [[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 and provide commented, minimal, self-contained, reproducible code.
[R] write full information of class summary.lm to file
Dear list, how can I write the full information of class summary.lm to a text, latex or html file? xtable only extracts the table but not the rest of the information. Best regards, Ulrich __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] problem in font
Hi, But, I have this warning in the enviromnent that have this problem: During startup - Warning message: using .GlobalEnv instead of 'package:lattice' maybe this is the problem? How to fix it? Thanks ROnaldo -- I've been on this lonely road so long, Does anybody know where it goes, I remember last time the signs pointed home, A month ago. -- Carpenters, "Road Ode" -- > Prof. Ronaldo Reis Júnior | .''`. UNIMONTES/Depto. Biologia Geral/Lab. Ecologia Evolutiva | : :' : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil | `- Fone: (38) 3229-8190 | [EMAIL PROTECTED] | ICQ#: 5692561 | LinuxUser#: 205366 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question on apply() with more information...
Hi, I tried both ideas, but it isn't that what I'm looking for. I want to avoid for loop, because the matrix is of big size(1200*1200 entries) With a loop I would do: for ( i in seq(along = SmoothList)) { Xarry[i,] <- predict(SmoothList[[i]],Xarry[i,])$y } Actually I want to do more than just to predict a value, but it isn't important for the initial question... Gunther -Ursprüngliche Nachricht- Von: Petr Pikal [mailto:[EMAIL PROTECTED] Gesendet: Montag, 18. September 2006 11:44 An: Gunther Höning Cc: r-help@stat.math.ethz.ch Betreff: Re: AW: [R] Question on apply() with more information... Hi If I am correct apply do not choose from SmoothList as you expected. Instead probably lapply(SmoothList, predict,Xarray) or mapply(predict,SmoothList, Xarray) can give you probably what you want. HTH Petr On 18 Sep 2006 at 9:26, Gunther Höning wrote: From: Gunther Höning <[EMAIL PROTECTED]> To: "'Petr Pikal'" <[EMAIL PROTECTED]>, Subject:AW: [R] Question on apply() with more information... Date sent: Mon, 18 Sep 2006 09:26:01 +0200 > Ok. > I tried this too, but it still doesn't work. > Here some more information to try out, but just an excerpt of Xarray > > x <- c(0.11,0.25,0.45,0.65,0.80,0.95,1) > Y <- > matrix(c(15,83,57,111,150,168,175,37,207,142,277,375,420,437),nrow=2) > > sm <- function(y,x){smooth.spline(x,y)} SmoothList <- apply(Y,1,sm,x) > NewValues <- function(x,LIST){predict(LIST,x)} Xarray <- > matrix(c(0.15,0.56,0.66,0.45,0.19,0.17,0.99,0.56,0.77,0.41,0.11,0.63,0 > .42,0. 43),nrow=2) > > > apply(Xarray, 2, NewValues,SmoothList) apply(Xarray, 2, > NewValues,LIST=SmoothList) > > > > -Ursprüngliche Nachricht- > Von: Petr Pikal [mailto:[EMAIL PROTECTED] > Gesendet: Montag, 18. September 2006 08:43 > An: Gunther Höning; r-help@stat.math.ethz.ch > Betreff: Re: [R] Question on apply() > > Hi > > not much information about what can be wrong. As nobody knows your > Xarray and SmoothList it is hard to guess. You even omitted to show > what "does not work" So here are few guesses. > > predict usually expects comparable data apply(Xarray, 2, > NewValues,LIST=SmoothList) > > > HTH > Petr > > > > > On 18 Sep 2006 at 8:05, Gunther Höning wrote: > > From: Gunther Höning <[EMAIL PROTECTED]> > To: > Date sent:Mon, 18 Sep 2006 08:05:28 +0200 > Subject: [R] Question on apply() > > > Dear list, > > > > I try to do the following: > > I have an list of length n, with elements done by smooth.spline > > (SmoothList). Now I have a matrix with n rows and m columns with > > x-values(Xarray) Now I want ot predict the y-values. Therefor I want > > to take the first element of SmoothList and the first row of Xarray > > and predict for each element in Xarray the y value. And then take > > the second element of SmoothList and second row of Xarray, third row > > of SmoothList and third row of Xarray and so on > > > > I tried following: > > > > NewValues <- function(x,LIST){predict(LIST,x)} apply(Xarray, 2, > > NewValues,SmoothList) > > > > But it don't work. > > > > Could anybody help please ? > > > > Gunther > > > > __ > > 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 and provide commented, > > minimal, self-contained, reproducible code. > > Petr Pikal > [EMAIL PROTECTED] > Petr Pikal [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 and provide commented, minimal, self-contained, reproducible code.
[R] problem in font
Hi, This is a false problem. This problem is only in a .RData file, not a global R problem. Thanks ROnaldo -- I've been on this lonely road so long, Does anybody know where it goes, I remember last time the signs pointed home, A month ago. -- Carpenters, "Road Ode" -- > Prof. Ronaldo Reis Júnior | .''`. UNIMONTES/Depto. Biologia Geral/Lab. Ecologia Evolutiva | : :' : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil | `- Fone: (38) 3229-8190 | [EMAIL PROTECTED] | ICQ#: 5692561 | LinuxUser#: 205366 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Simulation of a Dirichlet Process.
I'm just getting started with R, having a lot of original work on modeling and exploring the simulation by MCMC. I want to simulate the prior and the posterior distribution of Dirichlet Process by MCMC. Is there anyone in NYC that might be a good tutor for me? -- Dr. P. NGOM, Faculté des Sciences et Techniques Département de Mathématiques et Informatique Université Cheikh Anta Diop Dakar - Sénégal Universite Cheikh Anta DIOP - DAKAR __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] merge gives me too many rows
Hi Phil and Don, Le 06-09-18 à 05:02, Phil Spector a écrit : > Denis - >As long as there is one data frame that has exactly 0 or 1 > observations > for each level of the by variables, merge in R will operate > identically > to SAS without the need for any special options. >The problem arises when there are multiple observations for some of > the levels of the by variables in both of the data frames. In > relational databases and R, new observations are created to > represent every combination of observations in the original data > set that share > the same level of the by variables. In sas, the last observation > in the data set with fewer observations having a particular level > of the by variable is repeated enough times to provide a match for > each > observation in the other data set. > You can see this with a tiny example -- look at the observations > in the output data set corresponding to id==3: > >> a = data.frame(id=c(1,2,3,3,4),x=rnorm(5)) >> b = data.frame(id=c(1,2,3,3,3,4),y=rnorm(6)) >> c = merge(a,b) >> dim(a) > [1] 5 2 >> dim(b) > [1] 6 2 >> dim(c) > [1] 9 3 >> c > id xy > 1 1 -2.15987259 -1.555878070 > 2 2 0.96856842 -0.666941824 > 3 3 1.68080409 -0.009239307 > 4 3 0.06044914 -0.009239307 > 5 3 1.68080409 -0.242538473 > 6 3 0.06044914 -0.242538473 > 7 3 1.68080409 -1.298344557 > 8 3 0.06044914 -1.298344557 > 9 4 1.76424928 -0.420144744 > > The important thing to remember is that there is no unambiguous way > to merge two data sets when there are differing numbers of > observations for a given level of > the by variable in the two data sets -- sas and R simply choose > different strategies > in this case. > >- Phil Spector >Statistical Computing Facility >Department of Statistics >UC Berkeley >[EMAIL PROTECTED] > > I knew this, but it is good to be remembered and be forced to verify one's assumptions. Originally both informations about stomach contents and fish size came from the same, larger, database. I made the 2 smaller databases to ease the memory footprint in R when not all variables were needed. The method I used, actually suggested to me on this very helpful list a long time back, insured that all rows were unique: fish <- subset(esto, select=c(predateu, origin, navire, nbpc, no_rel, trait, tagno, longueur, masse)) fish <- unique(fish) # NO NEED TO SORT FIRST Or at least it would if there were NO MISTAKES in my database to start with. It is this false feeling that all rows had to be unique that made me pull my hair last night and assume the problem was with merge. I just verified and found that some fish have 2 lengths or masses, either mistakes when entering them into the databases, or mistakes when numbering fishes (2 fish with the same number). I'll go back to the raw data to fix this! So thanks for making me verify this assumption. Le 06-09-18 à 01:38, Don MacQueen a écrit : > I think you may misunderstand the meaning of all.x = FALSE. > > Setting all.x to false ensures that only rows of x that have > matches in y will be included. Equivalently, if a row of x is not > matched in y, it will not be in the output. However, if a row in x > is matched by more than one row in y, then that row will be > repeated as many times as there are matching rows in y. That is, > you have a 1 to many match (1 in x to many in y). SAS behaves the > same way. > > Are you sure this is not what is happening? > > Also, all.x = FALSE is the default; it is not necessary to specify > it. In fact, the default is to output only rows that are found in > both x and y (matching on the specified variables, of course). > > -Don Thank you Don, Looking at my old programs using merge, I always used "all.x=T". Yesterday, because I was getting more rows than expected, I assumed that switch caused it and started setting it to F (i.e. early on when I got extra lines, I assumed that fish measured in the second dataframe but for which I did not have stomach contents were merged anyway). I never went back to all.X=T after verifying it was not the cause of the problem, instead some lines in the first database were duplicated (multiple matches, it turns out). But you are right. In fact I made some tests and the behavior I want in this and most cases is "all.x=T" but "all.y=F". That is if I ever found a case where I had a line in the first dataframe with no match in the second, I'd want to keep that line in the final dataframe. Again, many thanks, Denis > At 9:11 PM -0400 9/17/06, Denis Chabot wrote: > >> Hi, >> >> I am using merge to add some variables to an existing dataframe. I >> use the option "all.x=F" so that my final dataframe will only have >> as many rows as the
[R] problem in font
Hi, after a debian upgrade my dev.copy2eps dont work anymore. I have this message: Error in matchFont(postscriptFonts(family)[[1]], old$encoding) : unknown font I try to change the font family in my .Rprofile: setHook(packageEvent("graphics", "onLoad"), function(...) { grDevices::ps.options(family="ComputerModern") } ) But it no fix the error. How to fix it? Thanks ROnaldo -- I've been on this lonely road so long, Does anybody know where it goes, I remember last time the signs pointed home, A month ago. -- Carpenters, "Road Ode" -- > Prof. Ronaldo Reis Júnior | .''`. UNIMONTES/Depto. Biologia Geral/Lab. Ecologia Evolutiva | : :' : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil | `- Fone: (38) 3229-8190 | [EMAIL PROTECTED] | ICQ#: 5692561 | LinuxUser#: 205366 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] problems in sourcing R script
You need to print() explicitly inside sourced-ed script: auto-printing is not active. On Mon, 18 Sep 2006, Ulrich Leopold wrote: > Dear list, > > First my information: > platform i386-pc-linux-gnu > arch i386 > os linux-gnu > system i386, linux-gnu > status > major 2 > minor 3.1 > year 2006 > month 06 > day01 > svn rev38247 > language R > version.string Version 2.3.1 (2006-06-01) > > Now my question: > > How is it possible that a command in an R script is not executed completely > whereas the same command is fully executed when I copy paste it to the R > terminal? > > It is the last command "summary()" which shows such behaviour. > > > The result of the execution is: > > > Df Sum of Sq RSS AIC > 18.666 -49.277 > - Flower 1 2.113 20.779 -45.700 > > > It does not compute the summary statistics any more. > > Whereas this is the result when I copy paste the comamnd into the R terminal: > > > Df Sum of Sq RSS AIC > 18.666 -49.277 > - Flower 1 2.113 20.779 -45.700 > > Call: > lm(formula = NH4Mar04 ~ Flower, data = N) > > Residuals: >Min 1Q Median 3Q Max > -1.0750 -0.1968 -0.1518 -0.0968 2.9632 > > > > Any ideas what the problem could be? > > Is it possible that there is some kind of character problem or a hidden > control character in the text file or an encoding problem (I use UTF)? I > checked already with cat -A whether it shows unwanted control characters but > nothing showed up. > I also used 2 different text editors to see whetehr it is related to a text > editor. > > > Thanks, Ulrich > > > R.script sourced with >> source("script.R") > > > > # Load MASS library for stepAIC, truehist, etc. > library(MASS) > # Read in the data as comma separated file > N <- read.csv2("MatrixNO3_08Aug06.csv", header=TRUE, sep=";", dec=".") > > # Compute stepwise generalised linear regression > summary(stepAIC(lm(NH4Mar04~Elevation+Soil1+Soil2+Text1+Text2+Text3+Rice+Cabbage+Squash+Chilli+Flower, > N))) > > > > And here is the example for reproduction: > > N <- > structure(list(samplePCR... = as.integer(c(1, 2, 3, 4, 5, 6, > 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, > 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, > 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52)), Elevation = c(12.9, > 12.9, 12.9, 12.9, 12.9, 12.9, 13.1, 13.1, 13.2, 13.3, 13.1, 13, > 13.2, 13.3, 13.4, 13.6, 13.5, 13.5, 13.3, 13, 12.8, 13.8, 14.1, > 13.2, 13.1, 12.5, 12, 11.8, 12.4, 13.8, 13.7, 12.8, 12.9, 12.8, > 12.8, 12.7, 12.5, 12.4, 12.4, 12.5, 12.2, 12.3, 11.8, 13.7, 13.8, > 13.8, 13.9, 13, 12.9, 13.9, 13.6, 13.8), Soil1 = as.integer(c(1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > 0, 0, 1, 0, 0, 0, 0, 0, 0)), Soil2 = as.integer(c(0, 0, 0, 0, > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, > 1, 1, 1, 1, 1, 1)), Text1 = as.integer(c(1, 1, 1, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, > 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, > 1, 0, 0)), Text2 = as.integer(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1 > )), Text3 = as.integer(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), Rice = > as.integer(c(0 , > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, > 1, 1, 0, 1, 0, 0, 0, 0, 0)), Cabbage = as.integer(c(0, 0, 0, > 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > 1, 0, 0, 0, 0, 0, 0)), Squash = as.integer(c(1, 1, 1, 1, 1, 1, > 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > 0, 0, 0, 0)), Chilli = as.integer(c(0, 0, 0, 0, 0, 0, 0, 0, 0, > 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, > 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > 0)), Flower = as.integer(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), NO3Mar04 = c(16.04, > 7.24, 19.65, 19.87, 20.64, 18.72, 17.24, 8.84, 26.2, 6.04, 4.35, > 20.6, 14.44, 10.24, 19.48, 19.52, 10.8, 10.8, 2.92, 38.8, 5.38, > 41.04, 37.18, 20.6, 18.12, 6.04, 22.85, 29.56, 28.35, 28.24, > 20.35, 20.65, 22.85, 7.49, 10.8, 6.92, 31.8, 28.7,
Re: [R] problems in sourcing R script
"Ulrich Leopold" <[EMAIL PROTECTED]> writes: > Now my question: > > How is it possible that a command in an R script is not executed completely > whereas the same command is fully executed when I copy paste it to the R > terminal? It is fully executed, but you're not printing the results. Read help(source) and use echo=TRUE. -- 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question on apply() with more information...
Hi If I am correct apply do not choose from SmoothList as you expected. Instead probably lapply(SmoothList, predict,Xarray) or mapply(predict,SmoothList, Xarray) can give you probably what you want. HTH Petr On 18 Sep 2006 at 9:26, Gunther Höning wrote: From: Gunther Höning <[EMAIL PROTECTED]> To: "'Petr Pikal'" <[EMAIL PROTECTED]>, Subject:AW: [R] Question on apply() with more information... Date sent: Mon, 18 Sep 2006 09:26:01 +0200 > Ok. > I tried this too, but it still doesn't work. > Here some more information to try out, but just an excerpt of Xarray > > x <- c(0.11,0.25,0.45,0.65,0.80,0.95,1) > Y <- > matrix(c(15,83,57,111,150,168,175,37,207,142,277,375,420,437),nrow=2) > > sm <- function(y,x){smooth.spline(x,y)} > SmoothList <- apply(Y,1,sm,x) > NewValues <- function(x,LIST){predict(LIST,x)} > Xarray <- > matrix(c(0.15,0.56,0.66,0.45,0.19,0.17,0.99,0.56,0.77,0.41,0.11,0.63,0 > .42,0. 43),nrow=2) > > > apply(Xarray, 2, NewValues,SmoothList) > apply(Xarray, 2, NewValues,LIST=SmoothList) > > > > -Ursprüngliche Nachricht- > Von: Petr Pikal [mailto:[EMAIL PROTECTED] > Gesendet: Montag, 18. September 2006 08:43 > An: Gunther Höning; r-help@stat.math.ethz.ch > Betreff: Re: [R] Question on apply() > > Hi > > not much information about what can be wrong. As nobody knows your > Xarray and SmoothList it is hard to guess. You even omitted to show > what "does not work" So here are few guesses. > > predict usually expects comparable data > apply(Xarray, 2, NewValues,LIST=SmoothList) > > > HTH > Petr > > > > > On 18 Sep 2006 at 8:05, Gunther Höning wrote: > > From: Gunther Höning <[EMAIL PROTECTED]> > To: > Date sent:Mon, 18 Sep 2006 08:05:28 +0200 > Subject: [R] Question on apply() > > > Dear list, > > > > I try to do the following: > > I have an list of length n, with elements done by smooth.spline > > (SmoothList). Now I have a matrix with n rows and m columns with > > x-values(Xarray) Now I want ot predict the y-values. Therefor I want > > to take the first element of SmoothList and the first row of Xarray > > and predict for each element in Xarray the y value. And then take > > the second element of SmoothList and second row of Xarray, third row > > of SmoothList and third row of Xarray and so on > > > > I tried following: > > > > NewValues <- function(x,LIST){predict(LIST,x)} apply(Xarray, 2, > > NewValues,SmoothList) > > > > But it don't work. > > > > Could anybody help please ? > > > > Gunther > > > > __ > > 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 and provide commented, > > minimal, self-contained, reproducible code. > > Petr Pikal > [EMAIL PROTECTED] > Petr Pikal [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 and provide commented, minimal, self-contained, reproducible code.
[R] problems in sourcing R script
Dear list, First my information: platform i386-pc-linux-gnu arch i386 os linux-gnu system i386, linux-gnu status major 2 minor 3.1 year 2006 month 06 day01 svn rev38247 language R version.string Version 2.3.1 (2006-06-01) Now my question: How is it possible that a command in an R script is not executed completely whereas the same command is fully executed when I copy paste it to the R terminal? It is the last command "summary()" which shows such behaviour. The result of the execution is: Df Sum of Sq RSS AIC 18.666 -49.277 - Flower 1 2.113 20.779 -45.700 It does not compute the summary statistics any more. Whereas this is the result when I copy paste the comamnd into the R terminal: Df Sum of Sq RSS AIC 18.666 -49.277 - Flower 1 2.113 20.779 -45.700 Call: lm(formula = NH4Mar04 ~ Flower, data = N) Residuals: Min 1Q Median 3Q Max -1.0750 -0.1968 -0.1518 -0.0968 2.9632 Any ideas what the problem could be? Is it possible that there is some kind of character problem or a hidden control character in the text file or an encoding problem (I use UTF)? I checked already with cat -A whether it shows unwanted control characters but nothing showed up. I also used 2 different text editors to see whetehr it is related to a text editor. Thanks, Ulrich R.script sourced with > source("script.R") # Load MASS library for stepAIC, truehist, etc. library(MASS) # Read in the data as comma separated file N <- read.csv2("MatrixNO3_08Aug06.csv", header=TRUE, sep=";", dec=".") # Compute stepwise generalised linear regression summary(stepAIC(lm(NH4Mar04~Elevation+Soil1+Soil2+Text1+Text2+Text3+Rice+Cabbage+Squash+Chilli+Flower, N))) And here is the example for reproduction: N <- structure(list(samplePCR... = as.integer(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52)), Elevation = c(12.9, 12.9, 12.9, 12.9, 12.9, 12.9, 13.1, 13.1, 13.2, 13.3, 13.1, 13, 13.2, 13.3, 13.4, 13.6, 13.5, 13.5, 13.3, 13, 12.8, 13.8, 14.1, 13.2, 13.1, 12.5, 12, 11.8, 12.4, 13.8, 13.7, 12.8, 12.9, 12.8, 12.8, 12.7, 12.5, 12.4, 12.4, 12.5, 12.2, 12.3, 11.8, 13.7, 13.8, 13.8, 13.9, 13, 12.9, 13.9, 13.6, 13.8), Soil1 = as.integer(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0)), Soil2 = as.integer(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1)), Text1 = as.integer(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0)), Text2 = as.integer(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1 )), Text3 = as.integer(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), Rice = as.integer(c(0 , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0)), Cabbage = as.integer(c(0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0)), Squash = as.integer(c(1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), Chilli = as.integer(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), Flower = as.integer(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), NO3Mar04 = c(16.04, 7.24, 19.65, 19.87, 20.64, 18.72, 17.24, 8.84, 26.2, 6.04, 4.35, 20.6, 14.44, 10.24, 19.48, 19.52, 10.8, 10.8, 2.92, 38.8, 5.38, 41.04, 37.18, 20.6, 18.12, 6.04, 22.85, 29.56, 28.35, 28.24, 20.35, 20.65, 22.85, 7.49, 10.8, 6.92, 31.8, 28.7, 24.2, 26.76, 18.16, 20.3, 35.16, 33.73, 21.73, 22.42, 27.88, 6.84, 10.52, 10.24, 20.04, 16.92), NO3Aug04 = c(13.84, 11.36, 4.64, 13.64, 12.64, 11.42, 19.87, 2.04, 11.76, 1.28, 13.06, 11.87, 2.68, 9.12, 2.68, 4.92, 14.85, 4.08, 10.75, 12.48, 16.68, 27.16, 22.28, 2.96, 12.88, 22.84, 15.35, 8.04, 8.66, 1.28, 23.84, 25.77, 28.6, 1.28, 23.18, 8.84, 20,
Re: [R] Excluding columns from dataframe and selecting row records
check out 'cbind' to select columns. regards Isidora __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] uniform integer RNG 0 to t inclusive
Good morning, I'm trying to concisely generate a single integer from 0 to n inclusive, where n might be of the order of hundreds of millions. This will however be used many times during the general procedure, so it must be "reasonably efficient" in both memory and time... (at some later stage in the development I hope to go vectorized) The examples I've found through searching RSiteSearch() relating to generating random integers say to use : sample(0:n, 1) However, when n is "large" this first generates a large sequence 0:n before taking a sample of one... this computer doesn't have the memory for that! When I look at the documentation for runif(n, min, max) it states that the generated numbers will be min <= x <= max. Note the "<= max"... How do I generate an x such that the probability of being (the integer) max is the same as any other integer from min (an integer) to max-1 (an integer) inclusive... My attempt is: urand.int <- function(n,t) { as.integer(runif(n,min=0, max=t+1-.Machine$double.eps)) } # where I've included the parameter n to help testing... is floor() "better" than as.integer? Is this correct? Is the probability of the integer t the same as the integer 1 or 0 etc... I have done some rudimentary testing and this appears to work, but power being what it is, I can't see how to realistically test this hypothesis. Or is there a a better way of doing this? I'm trying to implement an algorithm which samples into an array, hence the need for an integer - and yes I know about sample() thanks! :-) { incidentally, I was surprised to note that the maximum value returned by summary(integer_vector) is "pretty" and appears to be rounded up to a "nice round number", and is not necessarily the same as max(integer_vector) where the value is large, i.e. of the order of say 50 million } Is version etc relevant? (I'll want to be portable) > version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 3.1 year 2006 month 06 day01 svn rev38247 language R version.string Version 2.3.1 (2006-06-01) > Many thanks in advance for your help. Sean O'Riordain affiliation <- NULL __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question on apply() with more information...
Ok. I tried this too, but it still doesn't work. Here some more information to try out, but just an excerpt of Xarray x <- c(0.11,0.25,0.45,0.65,0.80,0.95,1) Y <- matrix(c(15,83,57,111,150,168,175,37,207,142,277,375,420,437),nrow=2) sm <- function(y,x){smooth.spline(x,y)} SmoothList <- apply(Y,1,sm,x) NewValues <- function(x,LIST){predict(LIST,x)} Xarray <- matrix(c(0.15,0.56,0.66,0.45,0.19,0.17,0.99,0.56,0.77,0.41,0.11,0.63,0.42,0. 43),nrow=2) apply(Xarray, 2, NewValues,SmoothList) apply(Xarray, 2, NewValues,LIST=SmoothList) -Ursprüngliche Nachricht- Von: Petr Pikal [mailto:[EMAIL PROTECTED] Gesendet: Montag, 18. September 2006 08:43 An: Gunther Höning; r-help@stat.math.ethz.ch Betreff: Re: [R] Question on apply() Hi not much information about what can be wrong. As nobody knows your Xarray and SmoothList it is hard to guess. You even omitted to show what "does not work" So here are few guesses. predict usually expects comparable data apply(Xarray, 2, NewValues,LIST=SmoothList) HTH Petr On 18 Sep 2006 at 8:05, Gunther Höning wrote: From: Gunther Höning <[EMAIL PROTECTED]> To: Date sent: Mon, 18 Sep 2006 08:05:28 +0200 Subject:[R] Question on apply() > Dear list, > > I try to do the following: > I have an list of length n, with elements done by smooth.spline > (SmoothList). > Now I have a matrix with n rows and m columns with x-values(Xarray) > Now I want ot predict the y-values. Therefor I want to take the first > element of SmoothList and the first row of Xarray and predict for each > element in Xarray the y value. And then take the second element of > SmoothList and second row of Xarray, third row of SmoothList and third > row of Xarray and so on > > I tried following: > > NewValues <- function(x,LIST){predict(LIST,x)} apply(Xarray, 2, > NewValues,SmoothList) > > But it don't work. > > Could anybody help please ? > > Gunther > > __ > 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 and provide commented, > minimal, self-contained, reproducible code. Petr Pikal [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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] FW: R Reference Card and other help (especially useful for Newbies)
Anupam Tyagi yahoo.com> writes: > > New users may also want to look at SciViews R Graphical User Interface(GUI). > It > can be a good learning tool. Its text based editor is basic compared to WinEdt > with the R editing plug-in, or ESS and (X)Emacs combination. But it has > point-and-click menus that help in writing code, and easy view of objects, etc > can be very helpful for new users. Using this GUI may require you to install > some R packages listed on the SciViews page. > > http://www.sciviews.org/SciViews-R/ A user may need to change the file target SciViews shortcuts points to. These are added to Windows Start menu. This is needed for SciViews to work with the intalled R version. Use start menu to go to menu item SciViews-R. Go to "R Console". Right click. Go to last item in the list called "properties". You will find something like the following in the "Target field" "C:\Program Files\R\R-2.2.0\bin\Rgui.exe" --sdi LANGUAGE=en RSciViews.RData note the C:\R-2.2.0\... It assumes that you have R-2.2.0 installaed in: C:\Program Files\R\R-2.2.0 If your R installation is R-2.2.1, and is installed in C:\Program Files\R\R-2.2.1 then you need to change the "target" of SciViews-R "R console" shortcut to: "C:\Program Files\R\R-2.2.1\bin\Rgui.exe" --sdi LANGUAGE=en RSciViews.RData note the change to: C:\R-2-2.1\... note the "LANGUAGE=en" for English language GUI. You may be able to change this to a language you want to use with R. See documentation for SciViews __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Cochrans Q Test
Hi! I would like to conduct a Cochran`s Q Test in R, but have not found any suitable function. My first idea was: J <- as.table(matrix(c(6,16,2,4),ncol=2, dimnames = list("C" = c("Favorable","Unfavorable"),"Drug A Favorable"=c("B Favorable","B Unfavorable" L <- as.table(matrix(c(2,4,6,6),ncol=2, dimnames = list("C" = c("Favorable","Unfavorable"),"Drug A Unfavorable"=c("B Favorable","B Unfavorable" mantelhaen.test(J,L, alternative="t") But this is obviously the wrong function. Then I googled and found (different data): K <- as.table(matrix(c(1,1,0,0, 1,1,0,1, 1,1,1,1, 1,1,1,1, 1,0,0,0, 1,1,1,1, 1,1,1,1, 0,0,0,0, 0,1,0,1, 1,1,1,1, 0,1,0,1, 0,1,0,1),ncol=12, dimnames = list("Seating type" = c("I","II","III","IV"),"Test subject"=c("A","B","C","D","E","F","G","H","I","J","K","L" K pcochran(K,4,12) But R said that this function does not exist. Can anyone help? __ 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 and provide commented, minimal, self-contained, reproducible code.