RE: [R] postscript/eps label clipping
I guess I was wrong there. However it does seem that it will come down to fontsize 9 without clipping (or if it does I find it hard to see). -Original Message- From: Mulholland, Tom Sent: Friday, 11 July 2003 1:38 PM To: David Forrest; [EMAIL PROTECTED] Subject: RE: [R] postscript/eps label clipping Never having used postscript as an output method I looked to see what you were talking about. I noted that ps.options needs to be called before calling postscript. ps.options does have pointsize within it and silly though it may seem, its what I would do next. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Sections for help files
When compiling a package, is there any way of making the help files (html or chtml) have separate sections for functions and data sets? When looking at the help file for a package with a large number of help pages, it would be nice to have the functions appear first and the data sets appear second rather than have them jumbled together alphabetically. Currently, under Windows, chtml files have an tree index with object names under one node and object Titles under another node. Something like this would work with one node for functions and one node for data sets. Can this be done? Would it be possible to incorporate such a feature into future releases, either optionally or as the standard for all packages? Rob Hyndman ___ Rob J Hyndman Associate Professor Director of Consulting Department of Econometrics Business Statistics Monash University, VIC 3800, Australia. http://www-personal.buseco.monash.edu.au/~hyndman/ __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] info
HI I'm a student in chemical engineering, and i have to implement an algoritm about FIVE PARAMETERS INTERPOLATION for a calibration curve (dose, optical density) y = a + (c - a) /(1+ e[-b(x-m]) where x = ln(analyte dose + 1) y = the optical absorbance data a = the curves top asymptote b = the slope of the curve c = the curves bottom asymptote m = the curve X intercept Have you never seen this formula, because i don't fine information or lecterature about solution of this!!! Can i help me Hi Mr. Calandra __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Exporting data
On 07/11/03 09:58, C.E.Marshall wrote: I am running simulations calculating correlation coefficients from bivariate data and I was wondering whether there is a way of exporting 1000 simulation results from R to a text file or to another file for further manipulation. I am having difficulty I think because of the text combined in with the numerical results. If I understand you, it would seem that the trick is to put the results of your simulation into a matrix or data frame, possibly with one row or column per result. I assume that each result consists of a few numbers, each representing some variable. Then use write.table, write.matrix, or write. -- Jonathan Baron, Professor of Psychology, University of Pennsylvania Home page:http://www.sas.upenn.edu/~baron R page: http://finzi.psych.upenn.edu/ __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] info
I assume you mean the following: chemYield - function(a, x)(a[1]+(a[3]-a[2])/(1+exp(-a[2]*(x-a[4])) If you want to estimate parameters a[1:4] from data on pairs of (x, y=chemYield), create a data.frame(x, y), and estimate the parameter vector a using nls. If you have trouble getting nls to converge, I would plot the data and make a serious effort to get good starting values for a from the plot. If I still have trouble, I'd try optim, then feed the output from optim into nls. I seem to recall having seen problems like this discussed in Bates and Watts (1988) Nonlinear Regression Analysis and Its Applications (Wiley). I don't have the book in hand at the moment, so I can't give you a page reference, but they discuss problems of this nature. Bates was a pioneer in developing measures of intrinsic vs. parameter effects curvature. Bates and Watts studied many published data sets and found that in nearly all cases, the parameter effects curvature was at least an order of magnitude larger than the intrinsic curvature. That means that numerical difficulties can often (usually?) be improved by trying different parameterizations for the same problem. The function nls and similar functions are described among other places in Venables and Ripley (2002) Modern Applied Statistics with S, 4th ed. (Springer, ch. 8). hope this helps. spencer graves Andrea Calandra wrote: HI I'm a student in chemical engineering, and i have to implement an algoritm about FIVE PARAMETERS INTERPOLATION for a calibration curve (dose, optical density) y = a + (c - a) /(1+ e[-b(x-m]) where x = ln(analyte dose + 1) y = the optical absorbance data a = the curves top asymptote b = the slope of the curve c = the curves bottom asymptote m = the curve X intercept Have you never seen this formula, because i don't fine information or lecterature about solution of this!!! Can i help me Hi Mr. Calandra __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] unz()
I am having problems getting the unz() function to work as a connection to start reading a file... z - unz(c:/temp/stoxx.zip, close_tmi_components.txt, r) readLines(z,2) yields the following problems: z - unz(c:/temp/stoxx.zip, close_tmi_components.txt, r) Error in unz(c:/temp/stoxx.zip, close_tmi_components.txt, r) : unable to open connection In addition: Warning message: cannot locate file `close_tmi_components.txt' in zip file `c:/temp/stoxx.zip' readLines(z,2) Error in readLines(z, 2) : cannot open the connection In addition: Warning message: cannot locate file `close_tmi_components.txt' in zip file `c:/temp/stoxx.zip' can anybody offer any advice? Regards, John Marsland ** This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] unimodality test
Dear R users, I am interested in uni- bi- multimodality tests, for analysing reaction times data. I was lead to Hartigan's dip test (Ann. Statistics, 13, 1985, pp. 70-84, Applied Statistics, 34, 1985, 320-325). Not being a programmer I am unable to translate the Fortran code given in ref. 2 into a R function. I'd be glad to learn that someone already did it, or has devised a better solution for this kind of problem.. Thanks a lot in advance, J. Sackur Inserm U562 Orsay, France __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] short puzzles
Dear R users, can someone help with these short puzzles? 1) Is there a function like outer() that evaluates a three-argument function on a threedimensional grid - or else how to define such a function, say, outer.3()? E.g., calculate (x/y)^z on (x,y,z) element of {1,2,3}x{3,4}x{4,5} and return the results in a 3-dimensional array. I would naively use outer() on two of the arguments within a for() loop for the third argument and somehow glue the array together. Is there a better way? What about outer.4(), or even outer.n(), generalizing outer() to functions with an arbitrary number of arguments? 2) Define a function dimnames.outer() such that dimnames.outer(x, y, *) returns, for x - 1:2, y - 2:3, the following matrix: y x 2 3 1 2 3 2 4 6 (Or does such such a function already exist?) 3) How to combine puzzle 1 and puzzle 2? A function dimnames.outer.n() would be a nice little tool. 4) How can I access, within a function, the name of a variable that I have passed to the function? E.g., letting a - 2, and subsequently calling function f(a) as defined below, f - function (x) { # How can I get a out of x? } 5) Finally: Letting x - 2, how can I transform x+y into 2+y (as some suitable object), or generally func(x,y) into func(2,y)? Many thanks, Marc -- Jetzt ein- oder umsteigen und USB-Speicheruhr als Prämie sichern! __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] FITS File Reader
On Thu, 10 Jul 2003 19:09:16 -0700 (PDT), Nicholas Konidaris [EMAIL PROTECTED] wrote : Dear R users, I have searched the web and CRAN fairly carefully. Does a FITS format file reader for R currently exist that I can download? www.wotsit.org has a 13 year old document describing FITS, which seems to be a fairly open-ended format, so it may not cover what you need. However, it looks reasonably straightforward to read it using the stream functions: look at the help topics ?file, ?readLines, and ?readBin. If you do locate code to read it, or you end up writing some yourself, you should consider contributing it to the foreign package. Duncan Murdoch __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] short puzzles
Marc Vandemeulebroecke wrote: Dear R users, can someone help with these short puzzles? 1) Is there a function like outer() that evaluates a three-argument function on a threedimensional grid - or else how to define such a function, say, outer.3()? E.g., calculate (x/y)^z on (x,y,z) element of {1,2,3}x{3,4}x{4,5} and return the results in a 3-dimensional array. I would naively use outer() on two of the arguments within a for() loop for the third argument and somehow glue the array together. Is there a better way? What about outer.4(), or even outer.n(), generalizing outer() to functions with an arbitrary number of arguments? 2) Define a function dimnames.outer() such that dimnames.outer(x, y, *) returns, for x - 1:2, y - 2:3, the following matrix: y x 2 3 1 2 3 2 4 6 (Or does such such a function already exist?) 3) How to combine puzzle 1 and puzzle 2? A function dimnames.outer.n() would be a nice little tool. Here's what I came up with. If you need the other functions you mentioned, you can extract them from this example. outer.3 - function(x, y, z, FUN, ...) { print(deparse(substitute(x))) # for question 2 n.x - NROW(x) n.y - NROW(y) n.z - NROW(z) nm.x - if(is.array(x)) dimnames(x)[[1]] else names(x) nm.y - if(is.array(y)) dimnames(y)[[1]] else names(y) nm.z - if(is.array(z)) dimnames(z)[[1]] else names(z) X - expand.grid(x = x, y = y, z = z) f - FUN(X$x, X$y, X$z, ...) array(f, dim = c(n.x, n.y, n.z), dimnames = list(nm.x, nm.y, nm.z)) } a - 1:3 b - 3:4 c - 4:5 names(a) - a names(b) - b names(c) - c outer.3(a, b, c, function(x, y, z) (x/y)^z) outer.3(as.matrix(a), as.matrix(b), as.matrix(c), function(x, y, z) (x/y)^z) 4) How can I access, within a function, the name of a variable that I have passed to the function? E.g., letting a - 2, and subsequently calling function f(a) as defined below, f - function (x) { # How can I get a out of x? } Use deparse(substitute(x)). See example above. 5) Finally: Letting x - 2, how can I transform x+y into 2+y (as some suitable object), or generally func(x,y) into func(2,y)? Use substitute(func(x, y), list(x = 2)). Hope this is useful, Sundar __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] FITS File Reader
Duncan Murdoch wrote: If you do locate code to read it, or you end up writing some yourself, you should consider contributing it to the foreign package. There's a C (and fortran)-level library for reading FITS files here: http://heasarc.gsfc.nasa.gov/docs/software/fitsio/fitsio.html - together with addons for Perl, Python, C++ etc. Coding an R interface would be a nice exercise in R coding. I would have already written this if not for the fact that most of the high-dimensional data that I deal with gets written with some awful unformatted fortran IO rubbish that needs reverse-engineering and byte-swapping. Haven't these people heard of HDF or FITS?? *sigh* Also, I notice that SciLab can read FITS files, by using ImageMagick, which can read FITS files ImageMagick could convert it to something readable by R, I guess This would be the dirty hack solution. Baz __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Nonliner Rgression using Neural Nnetworks
On Fri, 11 Jul 2003 18:56:58 +0900 Yukihiro Ishii [EMAIL PROTECTED] wrote: Hi, I am an old hand at chemistry but a complete beginner at statistics including R computations. My question is whether you can carry out nonlinear multivariate regression analysis in R using neural networks, where the output variable can range from -Inf to + Inf., unlike discriminant analysis where the output is confined to one or zero. The library nnet seems to work only in the latter case but then I could be wrong. Please help me there. Thanks in advance. Y.Ishii [EMAIL PROTECTED] 257-0002 Japan You might want to look at the paper at http://brain.cs.unr.edu/publications/goodman.ann_advantages.jasa99.pdf The work was done using a nice standalone neural net program Nevprop by Goodman and colleagues, which is intended for binary outcomes and incorporates bootstrapping for estimating predictive accuracy of the network. You may obtain Nevprop at http://brain.cs.unr.edu --- Frank E Harrell Jr Prof. of Biostatistics Statistics Div. of Biostatistics Epidem. Dept. of Health Evaluation Sciences U. Virginia School of Medicine http://hesweb1.med.virginia.edu/biostat __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] info
The most commonly used dose-response functions for nonlinear calibration curves are the four- and five-parameter logistic functions. The four- parameter logistic is specified as F(z) = delta + (alpha - delta)/(1 + (z/gamma)^beta) so I'm not sure where you are getting your dose-response functional form from. In any case, you can fit this model using either nls( ) or nlme( ), depending on whether or not you want to fit a random-effects model. For references related to the four- and five-parameter logistic functions, you can read 1. Rodbard, D., and Frazier, G.R. (1975) Statistical analysis of radioligand assay data, Methods Enzymol., vol. 37, p. 3 - 22. 2. Dudley, R.A., Edwards, P., and Ekins, R.P. (1985) Guidelines for immunoassay data processing, Clin. Chem., vol. 31, no. 8, p. 1264 - 1271 The first of these articles introduces the four-parameter logistic, and the second refines its parametrization as well as introduces the five-parameter logistic for use in situations where the calibration curve is asymmetric. You should also acquire Mixed Effects Models in S and Splus, by Drs. Pinheiro and Bates if you intend to do anything with mixed effects models. Best, david paul -Original Message- From: Andrea Calandra [mailto:[EMAIL PROTECTED] Sent: Thursday, July 10, 2003 11:39 AM To: [EMAIL PROTECTED] Subject: [R] info HI I'm a student in chemical engineering, and i have to implement an algoritm about FIVE PARAMETERS INTERPOLATION for a calibration curve (dose, optical density) y = a + (c - a) /(1+ e[-b(x-m]) where x = ln(analyte dose + 1) y = the optical absorbance data a = the curves top asymptote b = the slope of the curve c = the curves bottom asymptote m = the curve X intercept Have you never seen this formula, because i don't fine information or lecterature about solution of this!!! Can i help me Hi Mr. Calandra __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] correlation, import of large tables,test for point-biserial c.c.?
Dear R help community, I want to calculate correlations between environment parameters and species abundance data. When I use the cor() for my table (121 columns 91 rows) R generates a dataset with the correlations between all columns; 1) How can I limit the calculations to the correlations of only the first column with every other ? (Or:) How can I extract the line/row in question from the cor() dataset produced by R ? 2) I assume that with one continuous factor and the other binary (0/1), cor() gives the point-biserial correlation coefficient, but how can I find the method used by R ? 3) I was not able to import (from Excel) the whole 121x67 table, for instance I divided it into pieces. Is there a simple solution to import the whole file ? 4) In the end I want to test the correlation coefficients. Where do I find an appropriated test for the point biserial correlation ? Can R calculate the coefficient and test it for all data in one step ? I just started working learning with R, but even after reading the R-help and Introduction to R, I still have big difficulties, so Thanks in advance for your help !! Arne Saatkamp Arne Saatkamp Inst. f. Biol. II - Abt. f. Geobotanik Schänzlestr. 1 79104 Freiburg Germany -- Jetzt ein- oder umsteigen und USB-Speicheruhr als Prämie sichern! __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] unimodality test
Jerome == Jerome Sackur [EMAIL PROTECTED] on Fri, 11 Jul 2003 12:17:33 +0200 (MET DST) writes: Jerome Dear R users, I am interested in uni- bi- Jerome multimodality tests, for analysing reaction times Jerome data. I was lead to Hartigan's dip test Jerome (Ann. Statistics, 13, 1985, pp. 70-84, Applied Jerome Statistics, 34, 1985, 320-325). Not being a Jerome programmer I am unable to translate the Fortran code Jerome given in ref. 2 into a R function. I'd be glad to Jerome learn that someone already did it, or has devised a Jerome better solution for this kind of problem.. I had got a version with Fortran and S-plus from Dario Ringach (@ NYU.edu) in 1994 (from what I see) and had worked on it in 2000, made it into an R package back then. The reason it hasn't made its way to CRAN was that the Fortran code (which I f2c'ed to C) still has bugs (leading to segmentation faults) that I've not yet found time to debug. Let me have a look at it before making it available (not on CRAN) but via FTP as a source package. Martin Maechler [EMAIL PROTECTED] http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO C16Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] hazard estimate
Dear list, is there a function available which provides an estimate of the hazard function based on a cox proportional hazard model? I only found the cumulative hazard and the survival function as survfit options. Thanks for your help Peter __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] Exporting data
This really depends on what your output is. As previously suggested save() and write() are excellent suggestions. for(ii in 1:1000){ out - cor( x[ii, ], y[ii, ] ) # or whatever cat(ii, \t, out, \n, append=TRUE, file=output.txt) } This method is really not worth it for small simulations but I found this to be extremely useful with large simulations. The output file can act both as log/progress report file and provide partial results even if your program crashes. More sophisticated method can be found under connections(). -Original Message- From: C.E.Marshall [mailto:[EMAIL PROTECTED] Sent: Friday, July 11, 2003 4:59 PM To: [EMAIL PROTECTED] Subject: [R] Exporting data Dear All I am a new user to R and so I have a question which I hope you can help me with. I am running simulations calculating correlation coefficients from bivariate data and I was wondering whether there is a way of exporting 1000 simulation results from R to a text file or to another file for further manipulation. I am having difficulty I think because of the text combined in with the numerical results. Many Thanks Carolyn Marshall __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Offsets in glmmPQL?
I've got a colleague who's using a GLMM to analyse her data, and I've told her that she needs to include an offset. However, glmmPQL doesn't seem to allow one to be included. Is there anyway of doing this? Bob -- Bob O'Hara Rolf Nevanlinna Institute P.O. Box 4 (Yliopistonkatu 5) FIN-00014 University of Helsinki Finland Telephone: +358-9-191 23743 Mobile: +358 50 599 0540 Fax: +358-9-191 22 779 WWW: http://www.RNI.Helsinki.FI/~boh/ __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] info
Calandra's dose-response function is very close to what you wrote: She has x = ln(z+1), while x = ln(z) and m = ln(gamma) would give what you wrote. I would guess that your comments and references should help her. Spencer Graves Paul, David A wrote: The most commonly used dose-response functions for nonlinear calibration curves are the four- and five-parameter logistic functions. The four- parameter logistic is specified as F(z) = delta + (alpha - delta)/(1 + (z/gamma)^beta) so I'm not sure where you are getting your dose-response functional form from. In any case, you can fit this model using either nls( ) or nlme( ), depending on whether or not you want to fit a random-effects model. For references related to the four- and five-parameter logistic functions, you can read 1. Rodbard, D., and Frazier, G.R. (1975) Statistical analysis of radioligand assay data, Methods Enzymol., vol. 37, p. 3 - 22. 2. Dudley, R.A., Edwards, P., and Ekins, R.P. (1985) Guidelines for immunoassay data processing, Clin. Chem., vol. 31, no. 8, p. 1264 - 1271 The first of these articles introduces the four-parameter logistic, and the second refines its parametrization as well as introduces the five-parameter logistic for use in situations where the calibration curve is asymmetric. You should also acquire Mixed Effects Models in S and Splus, by Drs. Pinheiro and Bates if you intend to do anything with mixed effects models. Best, david paul -Original Message- From: Andrea Calandra [mailto:[EMAIL PROTECTED] Sent: Thursday, July 10, 2003 11:39 AM To: [EMAIL PROTECTED] Subject: [R] info HI I'm a student in chemical engineering, and i have to implement an algoritm about FIVE PARAMETERS INTERPOLATION for a calibration curve (dose, optical density) y = a + (c - a) /(1+ e[-b(x-m]) where x = ln(analyte dose + 1) y = the optical absorbance data a = the curves top asymptote b = the slope of the curve c = the curves bottom asymptote m = the curve X intercept Have you never seen this formula, because i don't fine information or lecterature about solution of this!!! Can i help me Hi Mr. Calandra __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] hazard estimate
The hazard function is the derivative of the cumulate hazard. There was a discussion only a few days ago on smoothing the hazard rate, which as I recall may have dealt with smoothing the cumulative hazard and then differentiating that. Have you checked http://www.r-project.org/ - search - R site search? I just got 24 hits for smooth hazard. If you don't get the answer from someone else here and an R site search does not produce what you want, then try r-help again. hope this helps. spencer graves Dr. Peter Schlattmann wrote: Dear list, is there a function available which provides an estimate of the hazard function based on a cox proportional hazard model? I only found the cumulative hazard and the survival function as survfit options. Thanks for your help Peter __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] correlation, import of large tables, test for point-biserialc.c.?
Did you look at ?cor? The documentation observes that cor accepts an optional second argument. The following works: df1 - data.frame(a=1:8, b=rep(c(-1, 1), 4), + c=rep(c(-1, 1), each=4)) cor(df1[,1], df1[, -1]) b c [1,] 0.2182179 0.8728716 hope this helps. spencer graves [EMAIL PROTECTED] wrote: Dear R help community, I want to calculate correlations between environment parameters and species abundance data. When I use the cor() for my table (121 columns 91 rows) R generates a dataset with the correlations between all columns; 1) How can I limit the calculations to the correlations of only the first column with every other ? (Or:) How can I extract the line/row in question from the cor() dataset produced by R ? 2) I assume that with one continuous factor and the other binary (0/1), cor() gives the point-biserial correlation coefficient, but how can I find the method used by R ? 3) I was not able to import (from Excel) the whole 121x67 table, for instance I divided it into pieces. Is there a simple solution to import the whole file ? 4) In the end I want to test the correlation coefficients. Where do I find an appropriated test for the point biserial correlation ? Can R calculate the coefficient and test it for all data in one step ? I just started working learning with R, but even after reading the R-help and Introduction to R, I still have big difficulties, so Thanks in advance for your help !! Arne Saatkamp Arne Saatkamp Inst. f. Biol. II - Abt. f. Geobotanik Schänzlestr. 1 79104 Freiburg Germany __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] correlation, import of large tables,test for point-biserial c.c.?
1) Calculating a 121 x 121 correlation matrix and then extracting the relevant correlating is extremely inefficient and slow. Instead try this : data - as.matrix( data ) # data is your 91 x 121 matrix or dataframe colInterest - data[ ,1] apply( data, 2, function(x) cor(x , colInterest) ) Here you take each column of data (at which point it becomes a vector called x) and calculates its correlation. apply() is an efficient form of for() loop. 3) I have imported files of much bigger dimensions without any problem. First of all ensure that the data is in tab delimited or comma seperated not .xls. Next use read.delim or read.csv to read in the file. If the file is only partially loaded or garbled up, then check for special characters. Most often the culprit is the comment character #. Sometimes % @ etc can also cause a problem. I have no idea about the other questions. If you type in help.start(), you will get a help page where you can do a keyword search etc. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, July 11, 2003 10:01 PM To: [EMAIL PROTECTED] Subject: [R] correlation, import of large tables,test for point-biserial c.c.? Dear R help community, I want to calculate correlations between environment parameters and species abundance data. When I use the cor() for my table (121 columns 91 rows) R generates a dataset with the correlations between all columns; 1) How can I limit the calculations to the correlations of only the first column with every other ? (Or:) How can I extract the line/row in question from the cor() dataset produced by R ? 2) I assume that with one continuous factor and the other binary (0/1), cor() gives the point-biserial correlation coefficient, but how can I find the method used by R ? 3) I was not able to import (from Excel) the whole 121x67 table, for instance I divided it into pieces. Is there a simple solution to import the whole file ? 4) In the end I want to test the correlation coefficients. Where do I find an appropriated test for the point biserial correlation ? Can R calculate the coefficient and test it for all data in one step ? I just started working learning with R, but even after reading the R-help and Introduction to R, I still have big difficulties, so Thanks in advance for your help !! Arne Saatkamp Arne Saatkamp Inst. f. Biol. II - Abt. f. Geobotanik Schänzlestr. 1 79104 Freiburg Germany -- Jetzt ein- oder umsteigen und USB-Speicheruhr als Prämie sichern! __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] hazard estimate
library(survival) ?basehaz gives For `basehaz', a dataframe with the baseline hazard, times, and strata. Ruud *** REPLY SEPARATOR *** On 7/11/2003 at 4:01 Dr. Peter Schlattmann wrote: Dear list, is there a function available which provides an estimate of the hazard function based on a cox proportional hazard model? I only found the cumulative hazard and the survival function as survfit options. Thanks for your help Peter __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Thanks: [R] short puzzles
Thanks to Andy Liaw, Patrick Burns, Sundar Dorai-Raj and Matthiew Wiener for the answers to my puzzles. Here is a summary: ** The original question: ** Dear R users, can someone help with these short puzzles? 1) Is there a function like outer() that evaluates a three-argument function on a threedimensional grid - or else how to define such a function, say, outer.3()? E.g., calculate (x/y)^z on (x,y,z) element of {1,2,3}x{3,4}x{4,5} and return the results in a 3-dimensional array. I would naively use outer() on two of the arguments within a for() loop for the third argument and somehow glue the array together. Is there a better way? What about outer.4(), or even outer.n(), generalizing outer() to functions with an arbitrary number of arguments? 2) Define a function dimnames.outer() such that dimnames.outer(x, y, *) returns, for x - 1:2, y - 2:3, the following matrix: y x 2 3 1 2 3 2 4 6 (Or does such such a function already exist?) 3) How to combine puzzle 1 and puzzle 2? A function dimnames.outer.n() would be a nice little tool. 4) How can I access, within a function, the name of a variable that I have passed to the function? E.g., letting a - 2, and subsequently calling function f(a) as defined below, f - function (x) { # How can I get a out of x? } 5) Finally: Letting x - 2, how can I transform x+y into 2+y (as some suitable object), or generally func(x,y) into func(2,y)? Many thanks, Marc Answer to 5 ** The solution is of course substitute(func(x, y), list(x = 2)) Answer to 4 ** This was easy, too: deparse(substitute(x)) * Answer to 1 in easy situations Where the three arguments are easily isolated, outer() can be used twice: outer(outer(a,b, /),c,^) Answer to 1, 2 and 3 ** A valuable idea came from Sundar Dorai-Raj who uses expand.grid() and then transforms the grid into a matrix. Here is his code: outer.3 - function(x, y, z, FUN, ...) { print(deparse(substitute(x))) # for question 2 n.x - NROW(x) n.y - NROW(y) n.z - NROW(z) nm.x - if(is.array(x)) dimnames(x)[[1]] else names(x) nm.y - if(is.array(y)) dimnames(y)[[1]] else names(y) nm.z - if(is.array(z)) dimnames(z)[[1]] else names(z) X - expand.grid(x = x, y = y, z = z) f - FUN(X$x, X$y, X$z, ...) array(f, dim = c(n.x, n.y, n.z), dimnames = list(nm.x, nm.y, nm.z)) } a - 1:3 b - 3:4 c - 4:5 names(a) - a names(b) - b names(c) - c outer.3(a, b, c, function(x, y, z) (x/y)^z) outer.3(as.matrix(a), as.matrix(b), as.matrix(c), function(x, y, z) (x/y)^z) Finally, I have included the following code in my Rprofile. Here only vector arguments are allowed, the dimnames are handeled in a slightly different manner, and the choice of creating dimnames is controlled by the logical argument dn. outer.2 - function (x, y, f, dn=TRUE, ...) { if (!(is.vector(x) is.vector(y) is.numeric(x) is.numeric(y))) { stop(arguments not numeric vectors) } ### The suitability of f is not checked ### result - outer(x, y, f, ...) if (dn) { lab.x - deparse(substitute(x)) lab.y - deparse(substitute(y)) dimnames(result)- list(x, y) names(dimnames(result)) - c(lab.x, lab.y) } result } outer.3 - function(x, y, z, f, dn=TRUE, ...) { if (!(is.vector(x) is.vector(y) is.vector(z) is.numeric(x) is.numeric(y) is.numeric(z))) { stop(arguments not numeric vectors) } ### The suitability of f is not checked ### X - expand.grid(x=x, y=y, z=z) temp - f(X$x, X$y, X$z, ...) result - array(temp, dim = c(length(x), length(y), length(z))) if (dn) { lab.x - deparse(substitute(x)) lab.y - deparse(substitute(y)) lab.z - deparse(substitute(z)) dimnames(result)- list(x, y, z) names(dimnames(result)) - c(lab.x, lab.y, lab.z) } result } A similar function outer.4() is straightforward. -- Jetzt ein- oder umsteigen und USB-Speicheruhr als Prämie sichern! __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] unz()
I've solve my own problem! apologies. For the record: the filename argument should include the full path of the file within the directory structure of the zip file. but there seeks to be an issue with readLines: readLines(z,2) Error in readLines(z, 2) : seek not enabled for this connection readLines(z) works fine for the whole file, but unfortunately you cannot use things like read.table etc. -Original Message- From: Marsland, John [mailto:[EMAIL PROTECTED] Sent: 11 July 2003 11:44 To: Subject: [R] unz() I am having problems getting the unz() function to work as a connection to start reading a file... z - unz(c:/temp/stoxx.zip, close_tmi_components.txt, r) readLines(z,2) yields the following problems: z - unz(c:/temp/stoxx.zip, close_tmi_components.txt, r) Error in unz(c:/temp/stoxx.zip, close_tmi_components.txt, r) : unable to open connection In addition: Warning message: cannot locate file `close_tmi_components.txt' in zip file `c:/temp/stoxx.zip' readLines(z,2) Error in readLines(z, 2) : cannot open the connection In addition: Warning message: cannot locate file `close_tmi_components.txt' in zip file `c:/temp/stoxx.zip' can anybody offer any advice? Regards, John Marsland ** This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help ** This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] metapost device in R (again ;-)
Hi, I read the 2000 thread on a MetaPost device in R. If I understand correctly, the main problem with the concept is that R wants the device driver to give back information on the size of strings/labels. To the bet of my knowledge, MetaPost _does_ make it possible to measure the bounding box of text (see section 7.3: Measuring text in the MetaPost manual). For example, one could get the size of the bounding box of btex $\int_a^b x^2$ etex -- would that be enough to make an implementation possible? Or are the size of individual characters and kerning information necessary? Another question: can graphics devices be implemented solely in R (ie without writing C code)? I realize that it will be much slower, but first I would like to see how it works before writing in C. What source files should I be looking at? You may ask why I should bother about using Metapost. Well, I'd like my TeX documents to be more consistent typographically, and MP has quite a lot of useful features (such as the possibility to include its eps output in LaTeX directly, EVEN when generating PDF files with latexpdf). But the biggest bonus would clearly be the ability to typeset math formulas nicely. (I realize that this would require one to start a MetaPost process, but IMO the benefits would be worth the overhead). Is anyone else interested in a MetaPost device? Thanks, Tamas -- Tamás K. Papp E-mail: [EMAIL PROTECTED] (preferred, especially for large messages) [EMAIL PROTECTED] Please try to send only (latin-2) plain text, not HTML or other garbage. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] How to plot a scatter-plot matrix?
Hey, R-listers I am going to plot a scatter-plot matrix using R. For example, give a matrix X=[x1, x2, ..., xn] where each xi is a column vector, how to plot all the pair scatter-plots between two different xi and xj? Is PAIRS able to achieve this function? Thanks for your help. Fred __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] 3d plot with different levels done in different colors
I would like a 3d plot of a matrix such that individual trapezoids that make up the surface are colored according to the z-value of that point (or preferably the midpoint of its four corners, or something similar). MS Excel has something like that. I know that persp can have an nx by ny matrix its col argument, I just don't know how to generate that matrix. To calculate the midpoint of the tiles for the matrix z, I could use something like zz - (z[-1,-1] + z[-1,-nrow(z)] + z[-ncol(z),-1] + z[-ncol(z),-nrow(z)])/4 but I don't know how to assign a color to that value. For example if I have boundaries - c(0, .5, 1, 1.5) and colors - c(red, green, blue) I am looking for a function that assigns red to the elements of zz between 0 and .5, etc. Alternative solutions are welcome, maybe somebody has already wrote a library that does the whole thing neatly. Thanks, Tamas -- Tamás K. Papp E-mail: [EMAIL PROTECTED] (preferred, especially for large messages) [EMAIL PROTECTED] Please try to send only (latin-2) plain text, not HTML or other garbage. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] info
Andrea Calandra [EMAIL PROTECTED] writes: I'm a student in chemical engineering, and i have to implement an algoritm about FIVE PARAMETERS INTERPOLATION for a calibration curve (dose, optical density) y = a + (c - a) /(1+ e[-b(x-m]) where x = ln(analyte dose + 1) y = the optical absorbance data a = the curves top asymptote b = the slope of the curve c = the curves bottom asymptote m = the curve X intercept Have you never seen this formula, because i don't fine information or lecterature about solution of this!!! This is one parameterization of the four-parameter logistic growth curve. A slightly different version is available as the selfStart model SSfpl in the nls package. In R try library(nls) ?SSfpl example(SSfpl) to see how nls and SSfpl can be used. The example even produces a figure for you showing what the SSfpl parameters represent. A literature reference for the SSfpl form of the four-parameter logistic is Appendix C.6 in Pinheiro and Bates (2000), Mixed-effects Models in S and S-PLUS, Springer. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] hazard estimate
On Fri, 11 Jul 2003, Ruud H. Koning wrote: library(survival) ?basehaz gives For `basehaz', a dataframe with the baseline hazard, times, and strata. Yes, but that's the cumulative hazard, not the hazard rate. -thomas Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] using SVD to get an inverse matrix of covariance matrix
Dear R-users, I have one question about using SVD to get an inverse matrix of covariance matrix Sometimes I met many singular values d are close to 0: look this example $d [1] 4.178853e+00 2.722005e+00 2.139863e+00 1.867628e+00 1.588967e+00 [6] 1.401554e+00 1.256964e+00 1.185750e+00 1.060692e+00 9.932592e-01 [11] 9.412768e-01 8.530497e-01 8.211395e-01 8.077817e-01 7.706618e-01 [16] 7.007119e-01 6.237449e-01 5.709922e-01 5.550645e-01 5.062633e-01 [21] 4.792278e-01 4.222183e-01 3.660419e-01 3.293667e-01 3.026312e-01 [26] 2.942821e-01 2.811098e-01 2.626359e-01 2.199134e-01 1.943776e-01 [31] 1.712359e-01 1.561616e-01 1.359116e-01 1.280704e-01 1.099847e-01 [36] 1.013633e-01 9.622151e-02 8.396722e-02 7.083654e-02 6.755967e-02 [41] 5.392306e-02 3.807169e-02 2.942905e-02 2.726249e-02 4.555067e-16 [46] 3.095299e-16 2.918951e-16 2.672369e-16 2.336190e-16 2.239488e-16 [51] 2.089471e-16 1.970283e-16 1.863823e-16 1.775903e-16 1.698164e-16 [56] 1.594850e-16 1.500927e-16 1.469157e-16 1.406057e-16 1.366468e-16 [61] 1.319553e-16 1.252144e-16 1.193341e-16 1.142526e-16 1.064905e-16 [66] 1.040117e-16 1.005124e-16 9.310727e-17 8.995158e-17 8.529797e-17 [71] 8.204344e-17 7.759612e-17 7.478445e-17 7.225679e-17 6.709050e-17 [76] 5.996665e-17 5.830386e-17 5.687619e-17 5.121094e-17 4.848857e-17 [81] 4.549679e-17 4.307547e-17 3.830520e-17 3.450571e-17 3.312035e-17 [86] 3.260300e-17 2.399392e-17 2.141970e-17 1.996962e-17 1.881993e-17 [91] 1.567323e-17 1.062695e-17 6.730278e-18 2.118570e-18 4.991002e-19 Since the inverse matrix = u * inverse(d) * v', If I calculate inverse d based on formula : 1/d, then most values of inverse matrix will be huge. This must be not a good way. MOre special case, if a single value is 0, then we can not calculate inverse d based on 1/d. Therefore, my question is how I can calculate inverse d (that is inverse diag(d) more efficiently??? Thanks ping __ Post your free ad now! http://personals.yahoo.ca __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] How to plot a scatter-plot matrix?
Fred, [from help on pairs() ]: ... Arguments: x: the coordinates of points given as columns of a matrix. So yes, pairs will do what you ask. See ?pairs for more info. Also you might consider the alternative function from the lattice package: library(lattice) #load lattice graphics package ?splom #help for splom() Which is called differently using a formula interface. HTH G Feng Zhang wrote: Hey, R-listers I am going to plot a scatter-plot matrix using R. For example, give a matrix X=[x1, x2, ..., xn] where each xi is a column vector, how to plot all the pair scatter-plots between two different xi and xj? Is PAIRS able to achieve this function? Thanks for your help. Fred __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [T] +44 (0)20 7679 5522 ENSIS Research Fellow [F] +44 (0)20 7679 7565 ENSIS Ltd. ECRC [E] [EMAIL PROTECTED] UCL Department of Geography [W] http://www.ucl.ac.uk/~ucfagls/cv/ 26 Bedford Way[W] http://www.ucl.ac.uk/~ucfagls/ London. WC1H 0AP. %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Offsets in glmmPQL?
Anon. [EMAIL PROTECTED] writes: I've got a colleague who's using a GLMM to analyse her data, and I've told her that she needs to include an offset. However, glmmPQL doesn't seem to allow one to be included. Is there anyway of doing this? We just discovered and fixed a similar problem in the GLMM function in the lme4 package. I have uploaded the 0.2-4 release of lme4 to CRAN. Please wait a few days for it to be transferred to the packages directory and for a Windows package to be created then try it. Remember to check for version 0.2-4 or later. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] using SVD to get an inverse matrix of covariance matrix
If some of the eigenvalues of a square matrix are (close to) zero, then it's inverse does not exist. However, you can always calculate it's generalized inverse ginv(). library(MASS) help(ginv) It'll allow you to specify a tol argument: tol: A relative tolerance to detect zero singular values. Hope that helps, Jerome On July 11, 2003 08:49 am, ge yreyt wrote: Content-Length: 2154 Status: R X-Status: N Dear R-users, I have one question about using SVD to get an inverse matrix of covariance matrix Sometimes I met many singular values d are close to 0: look this example snip Since the inverse matrix = u * inverse(d) * v', If I calculate inverse d based on formula : 1/d, then most values of inverse matrix will be huge. This must be not a good way. MOre special case, if a single value is 0, then we can not calculate inverse d based on 1/d. Therefore, my question is how I can calculate inverse d (that is inverse diag(d) more efficiently??? Thanks ping __ Post your free ad now! http://personals.yahoo.ca __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Constraining asymptote in SSasymp
Hi all, Is there a simple way to constrain the Asym argument in the SSasymp function so that it does not exceed some maximum value? Thanks! Martin -- Martin Biuw Sea Mammal Research Unit Gatty Marine Laboratory, University of St Andrews St Andrews, Fife KY16 8PA Scotland Ph: +44-(0)1334-462637 Fax: +44-(0)1334-462632 Web: http://smub.st.and.ac.uk __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Indexing with NA as FALSE??
Hi Folks, Example: t-c(1,2,3,4,5,6,7,8,9) u-c(1,NA,3,NA,5,NA,7,NA,9) t[u==5] -- NA NA 5 NA NA Now, if I could somehow set things so that NA was FALSE for indexing, then t[u==5] -- 5 I know I can do it with t[(u==5)(!is.na(u))] but in the situation I am dealing with this leads to massively cumbersome, typo-prone and hard-to-read code. Also, as an extra, it would be very useful if, for instance, t[u==NA] -- 2 4 6 8 (I realise that working round this is less cumbersome, but even so). What I'm really trying to work round is the don't know way that R handles NA. Reasonable in the logical sence, in that in the first example R is saying Can't tell whether u[2], u[4], u[6], u[8] are equal to 5 or not, so will return a result which represents this uncertainty, and in the second You're telling me you don't know what value you want to match, so ... . Instead of that, since NA is one of the three values TRUE, FALSE, NA of a logical, I'd like to be able to (a) treat NA as FALSE, (b) test for a match between NA (as specified by me) and NA (as the value of a logical variable). Is there any non-cumbersome way to achieve this? With thanks, Ted __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Indexing with NA as FALSE??
[EMAIL PROTECTED] wrote: I know I can do it with t[(u==5)(!is.na(u))] but in the situation I am dealing with this leads to massively cumbersome, typo-prone and hard-to-read code. You could redefine '[' or '==', but that would lead to massively dangerous code. Anything could happen. Anyone who writes code that redefines such basic stuff may need their head examined. I think you are going to have to work round it with the !is.na(u) thing, but you could wrap it up in a function: true4sure-function(v){v !is.na(v)} then t[true4sure(u==5)] [1] 5 although perhaps you could give it a less whimsical name Also, as an extra, it would be very useful if, for instance, t[u==NA] -- 2 4 6 8 (I realise that working round this is less cumbersome, but even so). Here is a way of doing that. It redefines '=='. It will break things that depend on NA's remaining NA's in comparisons. Do not use this code. Do not even let it pollute your files. Consider it a dangerous virus: assign(==,function(a,b){a[is.na(a)]-FALSE; b[is.na(b)]-FALSE; get(==,package:base)(a,b)}) and then you get: c(1,2,3,NA,NA,NA) == c(1,NA,2,NA,NA,4) [1] TRUE FALSE FALSE TRUE TRUE FALSE Instead of that, since NA is one of the three values TRUE, FALSE, NA of a logical, I'd like to be able to (a) treat NA as FALSE, (b) test for a match between NA (as specified by me) and NA (as the value of a logical variable). Thats what it does. Of course it has a bug/feature in that NA is now == to FALSE But then you arent going to use that code. Safer would be to define a new binary operator: assign(%=na%,function(a,b){a[is.na(a)]-FALSE; b[is.na(b)]-FALSE; get(==,package:base)(a,b)}) Then you can do: c(1,2,3,NA,NA,NA) %=na% c(1,NA,2,NA,NA,4) [1] TRUE FALSE FALSE TRUE TRUE FALSE again this has the same NA==FALSE property. Here's a truth table for that operator: outer(c(T,F,NA),c(T,F,NA),%=na%) [,1] [,2] [,3] [1,] TRUE FALSE FALSE [2,] FALSE TRUE TRUE [3,] FALSE TRUE TRUE You just need to write an operator that returns TRUE on the diagonal only Easy modification of %=na% but its late on a Friday and I have a poker game to attend... Did I say not to use my code that redefines '=='? Well dont use it. Ever. Baz __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Indexing with NA as FALSE??
On Fri, 11 Jul 2003 [EMAIL PROTECTED] wrote: Hi Folks, Example: t-c(1,2,3,4,5,6,7,8,9) u-c(1,NA,3,NA,5,NA,7,NA,9) t[u==5] -- NA NA 5 NA NA Now, if I could somehow set things so that NA was FALSE for indexing, then t[u==5] -- 5 t[u %in% 5] I know I can do it with t[(u==5)(!is.na(u))] but in the situation I am dealing with this leads to massively cumbersome, typo-prone and hard-to-read code. Also, as an extra, it would be very useful if, for instance, t[u==NA] -- 2 4 6 8 t[ u %in% NA] -thomas Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] three short questions
Hi all; This is my first message to the list, and I've got three basic questions: How could I insert comments in a file with commands to be used as source in R? Is it possible to quickly display a window with all the colors available in colors()? How? I'm displaying points, but they overlap, wether points() uses triangles, bullets or whatever. Is it possible to change (diminish) the size of the symbols? Thanks all, Javier __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Question regarding irts class
I'm using the new irts class from package tseries which I find quite useful. However, I have data of different type being sample at irregular times (i.e. my data is more of a data frame than a matrix). Function irts that is used to create irts objects demands that the value component is either a vector or a matrix. Is there any reason for not allowing it to be a data frame? Looking at the code of this function it seems straightforward to allow the function to accept data frames, but maybe there is some reason for not allowing this that I'm not aware. Thanks, Luis Torgo -- Luis Torgo FEP/LIACC, University of Porto Phone : (+351) 22 607 88 30 Machine Learning Group Fax : (+351) 22 600 36 54 R. Campo Alegre, 823 email : [EMAIL PROTECTED] 4150 PORTO - PORTUGAL WWW : http://www.liacc.up.pt/~ltorgo __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] three short questions
This is my first message to the list, and I've got three basic questions: How could I insert comments in a file with commands to be used as source in R? use the pound sign # Is it possible to quickly display a window with all the colors available in colors()? How? I've got such a thing on my web page, though it may be dated http://www.rand.org/methodology/stat/members/lockwood/downloads/R-built-in-colors.pdf I'm displaying points, but they overlap, wether points() uses triangles, bullets or whatever. Is it possible to change (diminish) the size of the symbols? yes; use pch to change symbols and cex to change sizes of symbols. See the help page for par J.R. Lockwood 412-683-2300 x4941 [EMAIL PROTECTED] http://www.rand.org/methodology/stat/members/lockwood/ __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Reading data from the console
I want to be able to write a program in R that does the following: - it allows the user to enter the dimensions of the matrix from the console - it allows the user then to enter each element of the matrix from the console. I am looking for an equivalent for the C++ command read, or read.ln. read.table would not work, since the data is not in a table and, furthermore, since the data does not exist prior to the execution of the program; the user has to be able to introduce the data from the console. scan would not work either. For example, in the following bit of code cat('Number of populations:', '\n') m-scan(,n=1, quiet=TRUE) cat('Number of categories:', '\n') k-scan(,n=1, quiet=TRUE) N-matrix(0,m,k) for(i in 1:m) for(j in 1:k) { N[i,j]-scan(,n=1, quiet=TRUE) } scan will take m to be the next command rather than wait for me to introduce the number I want for m. Any ideas? Thanks a lot! Doru Cojoc __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Reading data from the console
Put your code in a function. See below. Cheers, Jerome mat - function() { cat('Number of populations:', '\n') m-scan(,n=1, quiet=TRUE) cat('Number of categories:', '\n') k-scan(,n=1, quiet=TRUE) N-matrix(0,m,k) for(i in 1:m) for(j in 1:k) { N[i,j]-scan(,n=1, quiet=TRUE) } N } mat() Number of populations: 1: 2 Number of categories: 1: 2 1: 1 1: 2 1: 3 1: 4 [,1] [,2] [1,]12 [2,]34 On July 11, 2003 01:29 pm, Doru Cojoc wrote: I want to be able to write a program in R that does the following: - it allows the user to enter the dimensions of the matrix from the console - it allows the user then to enter each element of the matrix from the console. I am looking for an equivalent for the C++ command read, or read.ln. read.table would not work, since the data is not in a table and, furthermore, since the data does not exist prior to the execution of the program; the user has to be able to introduce the data from the console. scan would not work either. For example, in the following bit of code cat('Number of populations:', '\n') m-scan(,n=1, quiet=TRUE) cat('Number of categories:', '\n') k-scan(,n=1, quiet=TRUE) N-matrix(0,m,k) for(i in 1:m) for(j in 1:k) { N[i,j]-scan(,n=1, quiet=TRUE) } scan will take m to be the next command rather than wait for me to introduce the number I want for m. Any ideas? Thanks a lot! Doru Cojoc __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] three short questions
On Fri, 2003-07-11 at 12:27, J.R. Lockwood wrote: This is my first message to the list, and I've got three basic questions: How could I insert comments in a file with commands to be used as source in R? use the pound sign # Is it possible to quickly display a window with all the colors available in colors()? How? I've got such a thing on my web page, though it may be dated http://www.rand.org/methodology/stat/members/lockwood/downloads/R-built-in-colors.pdf I'm displaying points, but they overlap, wether points() uses triangles, bullets or whatever. Is it possible to change (diminish) the size of the symbols? yes; use pch to change symbols and cex to change sizes of symbols. See the help page for par A couple other possibilities on your third query, depending upon the nature of your data and the type of plot you are using: 1. Adjust the limits of the x and/or y axis in your plot to enhance the separation of the points. Generally, this can be done with the 'xlim' and/or 'ylim' arguments to your plotting function. For example, see ?plot.default for more information. 2. You can try to use jitter() [ie. plot(jitter(x), jitter(y))] if you have a lot of points that overlap at common coordinates. This introduces a level of 'noise' to the x and/or y values and can result in a level of dispersion of these points. See ?jitter for more information. This can result in a visual clustering of points, so keep that in mind. Be aware that each of the above can impact in a positive or deleterious fashion, the visual presentation and interpretation of your data so proceed with caution. HTH, Marc Schwartz __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] using SVD to get an inverse matrix of covariance matrix
More presicely, if M is singular, then M%*%x = b will have multiple solutions only if b is in the subspace spanned by columns of M. Example: M - array(1:2, dim=c(2,2)) (svdM - svd(M)) $d [1] 3.162278 0.00 $u [,1] [,2] [1,] -0.4472136 -0.8944272 [2,] -0.8944272 0.4472136 $v [,1] [,2] [1,] -0.7071068 -0.7071068 [2,] -0.7071068 0.7071068 This M is not symmetrical and so cannot be a covariance matrix, but you can get the same effect with a symmetrical matrix. I'm using this example because it is the simplest thing that comes to mind to illustrate the point. By the definition of the singular value decomposition, M = svdM$u %*% diag(svdM$d) %*% t(svdM$v). Since svdM$d[2] == 0, M%*%x = svdM$u[, 1]*svdM$d[1]*t(svdM$v[,1])%*%x = x1 * svdM$u[,1], where x1 = svdM$d[1]*t(svdM$v[,1])%*%x Thus, if b is proportional to svdM$u[,1], the system has a solution. That solution will be proportional to svdM$v[,1] + x2*svdM$v[,2], for any arbitrary value of x2. hope this helps. spencer graves Thomas Lumley wrote: On Fri, 11 Jul 2003, ge yreyt wrote: Dear R-users, I have one question about using SVD to get an inverse matrix of covariance matrix Sometimes I met many singular values d are close to 0: look this example snip most values of inverse matrix will be huge. This must be not a good way. MOre special case, if a single value is 0, then we can not calculate inverse d based on 1/d. Therefore, my question is how I can calculate inverse d (that is inverse diag(d) more efficiently??? If singular values are zero the matrix doesn't have an inverse: that is, the equation Mx=b will have multiple solutions for any given b. It is possible to get a pseudoinverse, a matrix M that picks out one of the solutions. One way to do this is to set the diagonal to 1/d where d is not (nearly) zero and to 0 when d is (nearly) zero. One place to find a discussion of this is `Matrix Computations' by Golub and van Loan. -thomas __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] postscript/eps label clipping
On Fri, 11 Jul 2003, Mulholland, Tom wrote: I guess I was wrong there. However it does seem that it will come down to fontsize 9 without clipping (or if it does I find it hard to see). Thanks. It seemed like that is the way it was working, but it also seems counterintuitive: reduced pointsizes in postscript output make the graphs bigger, up to a point, after which the letters are too big(small?) to fit without clipping. Thanks again, Dave. -- Dave Forrest(434)924-3954w(111B) (804)642-0662h (804)695-2026p [EMAIL PROTECTED]http://mug.sys.virginia.edu/~drf5n/ __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] getAnyhwhere behavior
I would have expected the function getAnywhere to have behaved differently in the following: search() [1] .GlobalEnv file:C:/R/Rdata/miya/.Rdata [3] package:bootpackage:methods [5] package:ctest package:mva [7] package:modreg package:nls [9] package:ts Autoloads [11] package:base getAnywhere(basic.ci) Error in getAnywhere(basic.ci) : Object basic.ci not found basic.ci-get(basic.ci,environment(boot)) getAnywhere(basic.ci) A single object matching `basic.ci' was found It was found in the following places .GlobalEnv registered S3 method for basic from namespace boot namespace:boot with value function (t0, t, conf = 0.95, hinv = function(t) t) { qq - norm.inter(t, (1 + c(conf, -conf))/2) out - cbind(conf, matrix(qq[, 1], ncol = 2), matrix(hinv(2 * t0 - qq[, 2]), ncol = 2)) out } environment: namespace:boot Why did getAnywhere not see basic.ci in the environment from which I got it? ** Cliff Lunneborg, Professor Emeritus, Statistics Psychology, University of Washington, Seattle [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] spdep
Hi everyone, The Spatial Dependence (spdep) library, has a function called 'dnearneigh', which identifies neighbours of region points by Euclidean distance between lower (greater than) and upper (less than or equal to) bounds. The function returns a list of integer vectors giving the region id numbers for neighbours satisfying the distance criteria. I have used this to identify the euclidean distance of all points falling within 0-2000m of each of my surveys locations. Once distances are converted to inverse euclidean distances, the list looks something like this: [[1]] [1] 15.617376 0.535176 0.569497 [[2]] [1] 15.6173762 0.5415378 0.5773159 [[3]] [1] NA etc. For each of these points I also have presence/absence data for a particular owl species (all the location, PA, etc. is kept in a single data frame). Is there a way of creating a similar list to the one above, identifying the Presence or Absence of an owl at each of the points that fall with in 0-2000m of the interested site?? I am attempting to determine the following equation for each site, at a number of spatial lags, i.e. 0-2000, 0-4000, etc Autocovariatei = Sum wij yj / Sum wij Variables: Autocovariate for stop i yj = Presence (1) or Absence (0) at stop j wij = the inverse Euclidean distance between stops i and j Any help would be greatly appreciated. Mark [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] 3d plot with different levels done in different colors
Hi, Consider this example which I have modified from the persp() help file. It uses topo.colors() to create a series of colors. Cheers, Jerome x - seq(-10, 10, length= 30) y - x f - function(x,y) { r - sqrt(x^2+y^2); 10 * sin(r)/r } z - outer(x, y, f) z[is.na(z)] - 1 op - par(bg = white) zz - (z[-1,-1] + z[-1,-ncol(z)] + z[-nrow(z),-1] + z[-nrow(z),-ncol(z)])/4 cols - topo.colors(length(zz)) cols[order(zz)] - cols persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = cols) On July 11, 2003 08:26 am, Tamas Papp wrote: Content-Length: 1223 Status: R X-Status: N I would like a 3d plot of a matrix such that individual trapezoids that make up the surface are colored according to the z-value of that point (or preferably the midpoint of its four corners, or something similar). MS Excel has something like that. I know that persp can have an nx by ny matrix its col argument, I just don't know how to generate that matrix. To calculate the midpoint of the tiles for the matrix z, I could use something like zz - (z[-1,-1] + z[-1,-nrow(z)] + z[-ncol(z),-1] + z[-ncol(z),-nrow(z)])/4 but I don't know how to assign a color to that value. For example if I have boundaries - c(0, .5, 1, 1.5) and colors - c(red, green, blue) I am looking for a function that assigns red to the elements of zz between 0 and .5, etc. Alternative solutions are welcome, maybe somebody has already wrote a library that does the whole thing neatly. Thanks, Tamas __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] How to generate regression matrix with correlation matrix
Dear R community: I want to simulate a regression matrix which is generated from an orthonormal matrix X of dimension 30*10 with different between-column pairwise correlation coefficients generated from uniform distribution U(-1,1). Thanks in advance! Rui [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] How to generate regression matrix with correlation matrix
What problem are you really trying to solve? The problem statement as I read it contains two logical contradictions that I see: 1. Orthonormal means X'X = Identity matrix (10 x 10). That means the pairwise correlation coefficients can NOT be different from 0. 2. Not all symmetric matrices with 1's on the diagonal and random numbers U(-1, 1) on the off diagonal are correlation matrices. Consider the following example: Cormat - array(c(1, -0.9, -0.9, -0.9, 1, -0.9, -0.9, -0.9, 1), dim=c(3,3)) Cormat [,1] [,2] [,3] [1,] 1.0 -0.9 -0.9 [2,] -0.9 1.0 -0.9 [3,] -0.9 -0.9 1.0 eigen(Cormat) $values [1] 1.9 1.9 -0.8 The fact that one eigenvalue is negative means that this Cormat is not positive definite. hope this helps. spencer graves rui wrote: Dear R community: I want to simulate a regression matrix which is generated from an orthonormal matrix X of dimension 30*10 with different between-column pairwise correlation coefficients generated from uniform distribution U(-1,1). Thanks in advance! Rui [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] ss's are incorrect from aov with multiple factors
Hi, I have been trying to work with error terms given back from aov to make confidence intervals. However, the numbers seem to be incorrect. If there is more than one term in the ANOVA then the error terms can be inflated by the number of factors in the extra terms. The F's are correct so it is right back to the SS. I was wondering if this is standard practice for stats programs or unique to R? __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] More clear statement about the question of how to generateregression matrix with correlation matrix
Dear R community: I am trying to do a simulation study mentioned by Fu (1998), Journal of Computational and Graphical Statistics, Volume7, Number 3, Page 397-416. In order to give a clear statement of quesion I copy the following paragraph from the article: We compare the bridge model with the OLS, the lasso and the ridge in a simulation of a linear regression model of 30 observations and 10 regressors Y = beta0 + beta1*x1 + ... + beta10*x10 + epsilon, where epsilon follows a normal distribution with mean mu and standard deviation sigma. Ten regression matrices {X}m, m=1,...,10, are generated from an orthonormal matrix X of dimension 30*10 with different between-column pairwise correlation coefficients {rho}m generated from uniform distribution U(-1, 1). Thanks in advance. Rui [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] ss's are incorrect from aov with multiple factors
On 11 Jul 03, at 21:20, John Christie wrote: Hi, I have been trying to work with error terms given back from aov to make confidence intervals. However, the numbers seem to be incorrect. If there is more than one term in the ANOVA then the error terms can be inflated by the number of factors in the extra terms. The F's are correct so it is right back to the SS. I was wondering if this is standard practice for stats programs or unique to R? __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help In what sense are the SSs incorrect, exactly? And what do you think the correct values should be? ---JRG John R. Gleason Associate Professor Syracuse University 430 Huntington Hall Voice: 315-443-3107 Syracuse, NY 13244-2340 USA FAX: 315-443-4085 PGP public key at keyservers __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] More clear statement about the question of how to generateregression matrix with correlation matrix
Dear Rui: If noone else responds, I suggest you forward my earlier comments to Fu and ask him. Spencer Graves rui wrote: Dear R community: I am trying to do a simulation study mentioned by Fu (1998), Journal of Computational and Graphical Statistics, Volume7, Number 3, Page 397-416. In order to give a clear statement of quesion I copy the following paragraph from the article: We compare the bridge model with the OLS, the lasso and the ridge in a simulation of a linear regression model of 30 observations and 10 regressors Y = beta0 + beta1*x1 + ... + beta10*x10 + epsilon, where epsilon follows a normal distribution with mean mu and standard deviation sigma. Ten regression matrices {X}m, m=1,...,10, are generated from an orthonormal matrix X of dimension 30*10 with different between-column pairwise correlation coefficients {rho}m generated from uniform distribution U(-1, 1). Thanks in advance. Rui [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] ss's are incorrect from aov with multiple factors
On Friday, July 11, 2003, at 09:38 PM, JRG wrote: On 11 Jul 03, at 21:20, John Christie wrote: In what sense are the SSs incorrect, exactly? And what do you think the correct values should be? Well, if I take the residuals for one of the main effects I should be able to calculate a confidence interval from it that has some relationship to the actual values for that effect so that an accurate plot can be made. The transformation isn't too hard, I just need to divide them by the number of factors in the other term. But, my recollection is that this isn't true for other stats packages and may lead people who are new and trying to calculate them for the first time to incorrect conclusions. The reported values should be corrected. Although, my recollection could be wrong. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Nonliner Rgression using Neural Nnetworks
On 11 Jul 2003 at 18:56, Yukihiro Ishii wrote: Hi, I am an old hand at chemistry but a complete beginner at statistics including R computations. My question is whether you can carry out nonlinear multivariate regression analysis in R using neural networks, where the output variable can range from -Inf to + Inf., unlike discriminant analysis where the output is confined to one or zero. The library nnet seems to work only in the latter case but then I could be wrong. You are wrong. nnet can be used to predict a continous variable, for instance by setting the arguments linout=TRUE. For ways to set different types of networks, see ?nnet ans especially the arguments linout entropy softmax censored Kjetil Halvorsen Please help me there. Thanks in advance. Y.Ishii [EMAIL PROTECTED] 2-3-28 $B!! (BTsurumaki-minami, Hadano 257-0002 Japan __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] ss's are incorrect from aov with multiple factors
Dear John Christie: People tend to get the quickest and most helpful responses when they provide a toy problem that produces what they think are anamolous results. This increases the chances that someone will be able to provide a sensible answer in the few seconds they have available for your question. Often, the process of preparing a toy problem leads them to an answer to their question. Sorry I couldn't be more helpful. spencer graves JRG wrote: On 11 Jul 03, at 21:20, John Christie wrote: Hi, I have been trying to work with error terms given back from aov to make confidence intervals. However, the numbers seem to be incorrect. If there is more than one term in the ANOVA then the error terms can be inflated by the number of factors in the extra terms. The F's are correct so it is right back to the SS. I was wondering if this is standard practice for stats programs or unique to R? __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help In what sense are the SSs incorrect, exactly? And what do you think the correct values should be? ---JRG John R. Gleason Associate Professor Syracuse University 430 Huntington Hall Voice: 315-443-3107 Syracuse, NY 13244-2340 USA FAX: 315-443-4085 PGP public key at keyservers __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] help with bivariate density plot question
Dear R users: I have a dataset with two variables (2 observations, two samples from same subject) and I used kernSur from library(Genkern) to get a estimated bivariate density and corresponding plots as follows: new.data.normal-data.normal[!is.na(data.normal[,2]),] x-new.data.normal[,2] y-new.data.normal[,3] op - KernSur(x,y, xgridsize=50, ygridsize=50, correlation=0.4968023, xbandwidth=1, ybandwidth=1) #3D density plot persp(op$xvals, op$yvals, op$zden, theta=30,phi=10,expand=0.5,ltheta=120, xlab=TECH3661.A,ylab=TECH3661.B,zlab=Prob,col=pink, , main=3D DENSITY PLOT-TECH3661 , sub= TECH3661.A AND TECH3661.B, box = T, axes = TRUE,ticktype = detailed, ) #countour plot image(op$xvals, op$yvals, op$zden, col=terrain.colors(100), axes=TRUE,xlab=TECH3661.A,ylab=TECH3661.B) points(x,y,pch=*) Now after above step, how can I use 'contour' or other commands to draw ellipse curves over above plots indicating including about 68% data, including about 84% data, etc. similar to the (-std,std), (-2*std,2*std),(-3*std, 3*std) intervals for univariate variable. any suggestin will be appreciated. liping [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] ss's are incorrect from aov with multiple factors (EXAMPLE!)
OK, I do see that there is a problem in my first email. I have noticed this with repeated measures designs. Otherwise, of course, there is only one error term for all factors. But, with repeated measures designs this is not the case. On Friday, July 11, 2003, at 10:00 PM, Spencer Graves wrote: People tend to get the quickest and most helpful responses when they provide a toy problem that produces what they think are anamolous results here is an admittedly poor example with factors a and b and s subjects. a-factor(rep(c(0,1),12)) b-factor(rep(c(0,0,1,1),6)) s- factor(rep(1:6,each=4)) x - c(49.5, 62.8, 46.8, 57, 59.8, 58.5, 55.5, 56, 62.8, 55.8, 69.5, 55, 62, 48.8, 45.5, 44.2, 52, 51.5, 49.8, 48.8, 57.2, 59, 53.2, 56) now summary(aov(x~a*b+Error(s/(a*b gives a table of results but, if one wanted to generate a confidence interval for factor b one needs to reanalyze the results thusly ss-aggregate(x, list(s=s, b=b), mean) summary(aov(x~b+Error(s/b), data=ss)) This yields an error term half the size as that reported for b in the combined ANOVA. I would suggest that the way the ss and MSE are reported is erroneous since they should be able to be used to directly calculate confidence intervals or make mean comparisons without having to collapse and reanalyze for every effect. Furthermore, I am guessing that this problem makes it impossible to get a correct average MSE that includes the interaction term. OK, far from impossible, but very difficult to verify that the term is correct. NOTE F for b is the same in the first ANOVA and the second. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help