[R] anyone has C++ STL classes stability issue if used with R
Hello, is there any one who uses C++ STL classes when programming shared libs for R and has had any problems with STL? In the very simple example below I am constantly getting segfaults when trying to populate the queue. The segfault occurs at what looks like a random index in the loop when pushing another element to the queue. Reproduced on 4 machines. Object x is an Image as in EBImage, i.e. a 3D R-array of numerics for the purpose of this code. LENGTH(x) can be up to 1e6 and the number of elements potentially to be in the queue is about 20% of those. But I get segfaults often on a third of fours element being added. Tried on R2.5.0-devel, R2.4.1-release and all machines were 64bit Linux with kernels 2.6.9 (stable CentOS), 2.6.17 (stable Ubuntu) and 2.6.20 (Ubuntu devel). Here are the compilation options of this particular module (built as part of EBImage, which generally compiles and works just fine): -- g++ -I/home/osklyar/R/R-2.5.0-40659/include -I/home/osklyar/R/R-2.5.0-40659/include -I/usr/local/include -DUSE_GTK -DGLIB_GETTEXT -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -Wall -g -O2 -Wall -pthread -I/usr/include -O2 -g -O2 -g -fpic -O2 -g -c filters_watershed.cpp -o filters_watershed.o -- And the linker: -- g++ -shared -L/usr/local/lib64 -o EBImage.so colors.o conversions.o display.o filters_distmap.o filters_magick.o filters_morph.o filters_propagate.o filters_thresh.o filters_watershed.o init.o io.o object_counting.o tools.o -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lfontconfig -lXext -lXrender -lXinerama -lXi -lXrandr -lXcursor -lXfixes -lpango-1.0 -lcairo -lX11 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 -L/usr/lib -L/usr/X11R6/lib -lfreetype -lz -L/usr/lib -lMagick -llcms -ltiff -lfreetype -ljasper -ljpeg -lpng -lXext -lSM -lICE -lX11 -lbz2 -lxml2 -lz -lpthread -lm -lpthread -- It could be I am missing something totally simple and therefore get these errors, but I cannot identify what. Thanks for help, Oleg - // common.h also includes R includes: // #include R.h // #include Rdefines.h // #include R_ext/Error.h #include common.h #include queue using namespace std; struct Pixel { int x, y; double intens; /* the code will also fail with the same segfault if I remove all * the constructors here and use the commented block below instead * of pq.push( Pixel(i, j, val) */ Pixel() {x = 0; y = 0; intens = 0; }; Pixel(const Pixel px) { x = px.x; y = px.y; intens = px.intens; }; Pixel(int i, int j, double val): x(i), y(j), intens(val) {}; }; bool operator (const Pixel a, const Pixel b) { return a.intens b.intens; }; typedef priority_queuePixel PixelPrQueue; SEXP lib_filterInvWS (SEXP x) { SEXP res; int i, j, index; double val; PixelPrQueue pq; int nx = INTEGER ( GET_DIM(x) )[0]; int ny = INTEGER ( GET_DIM(x) )[1]; int nz = INTEGER ( GET_DIM(x) )[2]; int nprotect = 0; PROTECT ( res = Rf_duplicate(x) ); nprotect++; // Pixel px; for (int im = 0; im nz; im++ ) { double * src = ( REAL(x)[ im * nx * ny ] ); double * tgt = ( REAL(res)[ im * nx * ny ] ); for ( j = 0; j ny; j++ ) for ( i = 0; i nx; i++ ) { index = i + nx * j; val = src[ index ]; if ( val BG ) { tgt[ index ] = -1; // px.x = i; px.y = j; px.intens = val; pq.push(px); pq.push( Pixel(i, j, val) ); continue; } tgt[ index ] = BG; } } /* my main code was here, but deleted for debug */ UNPROTECT (nprotect); return res; } -- Dr Oleg Sklyar * EBI/EMBL, Cambridge CB10 1SD, England * +44-1223-494466 __ 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] anyone has C++ STL classes stability issue if used with R
Continued: With the following modifications (using pointers) it works (needs memory cleaning afterwards and new less operator though) and I do not understand why: typedef priority_queuePixel * PixelPrQueue; ... pq.push( new Pixel(i, j, val) ); ... Oleg Sklyar wrote: Hello, is there any one who uses C++ STL classes when programming shared libs for R and has had any problems with STL? In the very simple example below I am constantly getting segfaults when trying to populate the queue. The segfault occurs at what looks like a random index in the loop when pushing another element to the queue. Reproduced on 4 machines. Object x is an Image as in EBImage, i.e. a 3D R-array of numerics for the purpose of this code. LENGTH(x) can be up to 1e6 and the number of elements potentially to be in the queue is about 20% of those. But I get segfaults often on a third of fours element being added. Tried on R2.5.0-devel, R2.4.1-release and all machines were 64bit Linux with kernels 2.6.9 (stable CentOS), 2.6.17 (stable Ubuntu) and 2.6.20 (Ubuntu devel). Here are the compilation options of this particular module (built as part of EBImage, which generally compiles and works just fine): -- g++ -I/home/osklyar/R/R-2.5.0-40659/include -I/home/osklyar/R/R-2.5.0-40659/include -I/usr/local/include -DUSE_GTK -DGLIB_GETTEXT -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -Wall -g -O2 -Wall -pthread -I/usr/include -O2 -g -O2 -g -fpic -O2 -g -c filters_watershed.cpp -o filters_watershed.o -- And the linker: -- g++ -shared -L/usr/local/lib64 -o EBImage.so colors.o conversions.o display.o filters_distmap.o filters_magick.o filters_morph.o filters_propagate.o filters_thresh.o filters_watershed.o init.o io.o object_counting.o tools.o -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lfontconfig -lXext -lXrender -lXinerama -lXi -lXrandr -lXcursor -lXfixes -lpango-1.0 -lcairo -lX11 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 -L/usr/lib -L/usr/X11R6/lib -lfreetype -lz -L/usr/lib -lMagick -llcms -ltiff -lfreetype -ljasper -ljpeg -lpng -lXext -lSM -lICE -lX11 -lbz2 -lxml2 -lz -lpthread -lm -lpthread -- It could be I am missing something totally simple and therefore get these errors, but I cannot identify what. Thanks for help, Oleg - // common.h also includes R includes: // #include R.h // #include Rdefines.h // #include R_ext/Error.h #include common.h #include queue using namespace std; struct Pixel { int x, y; double intens; /* the code will also fail with the same segfault if I remove all * the constructors here and use the commented block below instead * of pq.push( Pixel(i, j, val) */ Pixel() {x = 0; y = 0; intens = 0; }; Pixel(const Pixel px) { x = px.x; y = px.y; intens = px.intens; }; Pixel(int i, int j, double val): x(i), y(j), intens(val) {}; }; bool operator (const Pixel a, const Pixel b) { return a.intens b.intens; }; typedef priority_queuePixel PixelPrQueue; SEXP lib_filterInvWS (SEXP x) { SEXP res; int i, j, index; double val; PixelPrQueue pq; int nx = INTEGER ( GET_DIM(x) )[0]; int ny = INTEGER ( GET_DIM(x) )[1]; int nz = INTEGER ( GET_DIM(x) )[2]; int nprotect = 0; PROTECT ( res = Rf_duplicate(x) ); nprotect++; // Pixel px; for (int im = 0; im nz; im++ ) { double * src = ( REAL(x)[ im * nx * ny ] ); double * tgt = ( REAL(res)[ im * nx * ny ] ); for ( j = 0; j ny; j++ ) for ( i = 0; i nx; i++ ) { index = i + nx * j; val = src[ index ]; if ( val BG ) { tgt[ index ] = -1; // px.x = i; px.y = j; px.intens = val; pq.push(px); pq.push( Pixel(i, j, val) ); continue; } tgt[ index ] = BG; } } /* my main code was here, but deleted for debug */ UNPROTECT (nprotect); return res; } -- Dr Oleg Sklyar * EBI/EMBL, Cambridge CB10 1SD, England * +44-1223-494466 __ 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 neural network in R
Here is the list of NN related packages http://cran.r-project.org/src/contrib/Views/MachineLearning.html I also have written some bindings from R to the SNNS (Stuttgart neural network simulator), however, they are still not on the release stage. vinod gullu wrote: I am interested in Neural network models in R. Is there any reference material/tutorial which i can use. Regards, -- View this message in context: http://www.nabble.com/Help-neural-network-in-R-tf3215374.html#a8941445 Sent from the R help mailing list archive at Nabble.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.
Re: [R] Trying to replicate error message in subset()
Hi On 12 Feb 2007 at 10:42, Michael Rennie wrote: Date sent: Mon, 12 Feb 2007 10:42:21 -0500 To: Petr Pikal [EMAIL PROTECTED], r-help@stat.math.ethz.ch From: Michael Rennie [EMAIL PROTECTED] Subject:Re: [R] Trying to replicate error message in subset() Okay First- I apologise for my poor use of terminology (error vs. warning). Second- thanks for pointing out what I hadn't noticed before- when I pass one case for selection to subset, I get all observations. When I pass two cases (as a vector), I get every second case for both cases (if both are present, if not, I just get every second case for the one that is present). Same happens for three cases, as pointed out by Petr below. So, trying the %in% operator, I get slightly different behabviour, but the selection still seems dependent on the length of the vector given as a selector: b-c(D, F, A) new2.dat-subset(ex.dat, a%in%x1) new2.dat y1 x1 x2 12.34870479 A B 31.66090055 A B 5 -0.07904798 A B 72.07053656 A B 92.97980444 A B . Now, I just get every second observation, over all cases of x1. Probably doesn't get as far as A because F is not present? Are you completely sure? I get table(ex.dat$x1) A B C D E 40 40 40 40 40 table(new.dat$x1) A B C D E 40 0 0 40 0 so all ceses for A and D with subset like this a-c(D, F, A) new.dat-subset(ex.dat, x1 %in% a) and ex.dat constructed according to your example. If I get something what I do not expect: 1. I check if my data are what they should be 2. I check if search path and working directory does not contain some objects with conflicting names 3. If my functions are complicated I try to look how their parts really work If everything seems OK and unexpected behaviour still occures, I go through docummentation, help archives and finally I try to seek an advice from help list. I must say that this is a bit time consuming but I usually learn a lot from my mistakes which I am able to resolve myself. HTH Petr According to the documentation on subset(), the function works on rows of dataframes. I'm guessing this explains the behaviour I'm seeing- somehow, the length of the vector being passed as the subset argument is dictating which rows to evaluate. So, can anyone offer advice on how to select EVERY instance for multiple cases in a dataframe (i.e., all cases of both A and D from ex.dat), or will subset always be tied to the length of the 'subset' argument when a vector is passed to it? Cheers, Mike At 02:46 AM 12/02/2007, Petr Pikal wrote: Hi it is not error it is just warning (Beeping a tea kettle with boiling water is also not an error :-) and it tells you pretty explicitly what is wrong see length of your objects a-c(D, F, A) new.dat-subset(ex.dat, x1 == a) Warning messages: 1: longer object length is not a multiple of shorter object length in: is.na(e1) | is.na(e2) 2: longer object length is not a multiple of shorter object length in: `==.default`(x1, a) new.dat y1 x1 x2 30.5977786 A B 62.5470739 A B 90.9128595 A B 12 1.0953531 A D 15 2.4984470 A D 18 1.7289529 A D 61 -0.4848938 D B 6 you can do better with %in% operator. HTH Petr On 12 Feb 2007 at 1:51, Michael Rennie wrote: Date sent: Mon, 12 Feb 2007 01:51:54 -0500 To: r-help@stat.math.ethz.ch From: Michael Rennie [EMAIL PROTECTED] Subject:[R] Trying to replicate error message in subset() Hi, there I am trying to replicate an error message in subset() to see what it is that I'm doing wrong with the datasets I am trying to work with. Essentially, I am trying to pass a string vector to subset() in order to select a specific collection of cases (i.e., I have data for these cases in one table, and want to select data from another table that match up with the cases in the first table). The error I get is as follows: Warning messages: 1: longer object length is not a multiple of shorter object length in: is.na(e1) | is.na(e2) 2: longer object length is not a multiple of shorter object length in: `==.default`(LAKE, g) Here is an example case I've been working with (which works) that I've been trying to breaksuch that I can get this error message to figure out what I am doing wrong in my case. y1-rnorm(100, 2) x1-rep(1:5, each=20) x2-rep(1:2, each=10, times=10) ex.dat-data.frame(cbind(y1,x1,x2)) ex.dat$x1-factor(ex.dat$x1, labels=c(A, B, C, D, E)) ex.dat$x2-factor(ex.dat$x2, labels=c(B, D)) a-c(D, F) a new.dat-subset(ex.dat, x1 == a) new.dat I thought maybe I was getting errors because I had cases
[R] Unable to load RMySQL
Hi R users, I am unable to load RMySQL. The zip file is not available which I guess is needed to load this pakage. I also tried extracting the package from RMySQL_0.5-11.tar.gz and then pasted the package in the directory where R is loaded for which I am getting the following error message Error in library(RMySQL) : 'RMySQL' is not a valid package -- installed 2.0.0? Any help would be welcome Thank you, Ravi [[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] isoMDS vs. other non-metric non-R routines
Dear useRs, last week I asked you about a problem related to isoMDS. It turned out that in my case isoMDS was trapped. Nonetheless, I still have some problems with other data sets. Therefore I would like to know if anyone here has experience with how well isoMDS performs in comparison to other non-metric MDS routines, like Minissa. I have the feeling that for large data sets with a high stress value (e.g. around 0.20) in cases where the intrinsic dimensionality of the data cannot be significantly reduced without considerably increasing stress, isoMDS performs worse (and yields a stress value of 0.31 in my example), while solutions tend to be similar for better fits and lower intrinsic dimensionality. I tried this on another data set where isoMDS yields a stress value of 0.19 and Minissa a stress value of 0.14. Now the latter would still be considered a fair solution by some people while the former indicates a poor fit regardless of how strict your judgment is. I generally prefer using R over mixing with different programs, so it would be nice if results were of comparable quality... Cheers Phil __ 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] Can a data.frame column contain lists/arrays?
--- Christian Convey [EMAIL PROTECTED] wrote: I'd like to have a data.frame structured something like the following: d - data.frame ( x=list( c(1,2), c(5,2), c(9,1) ), y=c( 1, -1, -1) ) The reason is this: 'd' is the training data for a machine learning algorithm. d$x is the independent data, and d$y is the dependent data. In general my machine learning code will work where each element of d$x is a vector of one or more real numbers. So for instance, the same code should work when d$x[1] = 42, or when d$x[1] = (42, 3, 5). All that matters is that all element within d$x are lists/vectors of the same length. Does anyone know if/how I can get a data.frame set up like that? Thanks, Christian I doubt it. A data.frame is a specific subset of a list. You should be able to do anything you want with a list. Have a look at the Lists and Dataframes chapter of Intro to R. __ 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] anyone has C++ STL classes stability issue if used with R
On 2/13/2007 3:55 AM, Oleg Sklyar wrote: Hello, is there any one who uses C++ STL classes when programming shared libs for R and has had any problems with STL? I don't, but I'd suggest asking a technical question like this on R-devel instead of R-help if you don't get help here. I can see a few probably innocuous changes I'd suggest in your code below, but nothing obvious: use Rinternals.h instead of Rdefines.h, don't use the Rf_ prefix, check the length of inputs before working with the values. Duncan Murdoch In the very simple example below I am constantly getting segfaults when trying to populate the queue. The segfault occurs at what looks like a random index in the loop when pushing another element to the queue. Reproduced on 4 machines. Object x is an Image as in EBImage, i.e. a 3D R-array of numerics for the purpose of this code. LENGTH(x) can be up to 1e6 and the number of elements potentially to be in the queue is about 20% of those. But I get segfaults often on a third of fours element being added. Tried on R2.5.0-devel, R2.4.1-release and all machines were 64bit Linux with kernels 2.6.9 (stable CentOS), 2.6.17 (stable Ubuntu) and 2.6.20 (Ubuntu devel). Here are the compilation options of this particular module (built as part of EBImage, which generally compiles and works just fine): -- g++ -I/home/osklyar/R/R-2.5.0-40659/include -I/home/osklyar/R/R-2.5.0-40659/include -I/usr/local/include -DUSE_GTK -DGLIB_GETTEXT -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -Wall -g -O2 -Wall -pthread -I/usr/include -O2 -g -O2 -g -fpic -O2 -g -c filters_watershed.cpp -o filters_watershed.o -- And the linker: -- g++ -shared -L/usr/local/lib64 -o EBImage.so colors.o conversions.o display.o filters_distmap.o filters_magick.o filters_morph.o filters_propagate.o filters_thresh.o filters_watershed.o init.o io.o object_counting.o tools.o -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lfontconfig -lXext -lXrender -lXinerama -lXi -lXrandr -lXcursor -lXfixes -lpango-1.0 -lcairo -lX11 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 -L/usr/lib -L/usr/X11R6/lib -lfreetype -lz -L/usr/lib -lMagick -llcms -ltiff -lfreetype -ljasper -ljpeg -lpng -lXext -lSM -lICE -lX11 -lbz2 -lxml2 -lz -lpthread -lm -lpthread -- It could be I am missing something totally simple and therefore get these errors, but I cannot identify what. Thanks for help, Oleg - // common.h also includes R includes: // #include R.h // #include Rdefines.h // #include R_ext/Error.h #include common.h #include queue using namespace std; struct Pixel { int x, y; double intens; /* the code will also fail with the same segfault if I remove all * the constructors here and use the commented block below instead * of pq.push( Pixel(i, j, val) */ Pixel() {x = 0; y = 0; intens = 0; }; Pixel(const Pixel px) { x = px.x; y = px.y; intens = px.intens; }; Pixel(int i, int j, double val): x(i), y(j), intens(val) {}; }; bool operator (const Pixel a, const Pixel b) { return a.intens b.intens; }; typedef priority_queuePixel PixelPrQueue; SEXP lib_filterInvWS (SEXP x) { SEXP res; int i, j, index; double val; PixelPrQueue pq; int nx = INTEGER ( GET_DIM(x) )[0]; int ny = INTEGER ( GET_DIM(x) )[1]; int nz = INTEGER ( GET_DIM(x) )[2]; int nprotect = 0; PROTECT ( res = Rf_duplicate(x) ); nprotect++; // Pixel px; for (int im = 0; im nz; im++ ) { double * src = ( REAL(x)[ im * nx * ny ] ); double * tgt = ( REAL(res)[ im * nx * ny ] ); for ( j = 0; j ny; j++ ) for ( i = 0; i nx; i++ ) { index = i + nx * j; val = src[ index ]; if ( val BG ) { tgt[ index ] = -1; // px.x = i; px.y = j; px.intens = val; pq.push(px); pq.push( Pixel(i, j, val) ); continue; } tgt[ index ] = BG; } } /* my main code was here, but deleted for debug */ UNPROTECT (nprotect); return res; } __ 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
Re: [R] isoMDS vs. other non-metric non-R routines
Dear Phil, I don't have experiences with Minissa but I know that isoMDS is bad in some situations. I have even seen situations with non-metric dissimilarities in which the classical MDS was preferable. Some alternatives that you have: 1) Try to start isoMDS from other initial configurations (by default, it starts from the classical solution). 2) Try sammon mapping (command should be sammon). 3) Have a look at XGvis/GGvis (which may be part of XGobi/GGobi). These are not directly part of R but have R interfaces. They allow you to toy around quite a lot with different algorithms, stress functions (the isoMDS stress is not necessarily what you want) and initial configurations so that you can find a better solution and understand your data better. Unfortunately I don't have the time to give you more detail, but google for it (or somebody else will tell you more). Best, Christian On Tue, 13 Feb 2007, Philip Leifeld wrote: Dear useRs, last week I asked you about a problem related to isoMDS. It turned out that in my case isoMDS was trapped. Nonetheless, I still have some problems with other data sets. Therefore I would like to know if anyone here has experience with how well isoMDS performs in comparison to other non-metric MDS routines, like Minissa. I have the feeling that for large data sets with a high stress value (e.g. around 0.20) in cases where the intrinsic dimensionality of the data cannot be significantly reduced without considerably increasing stress, isoMDS performs worse (and yields a stress value of 0.31 in my example), while solutions tend to be similar for better fits and lower intrinsic dimensionality. I tried this on another data set where isoMDS yields a stress value of 0.19 and Minissa a stress value of 0.14. Now the latter would still be considered a fair solution by some people while the former indicates a poor fit regardless of how strict your judgment is. I generally prefer using R over mixing with different programs, so it would be nice if results were of comparable quality... Cheers Phil __ 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. *** --- *** Christian Hennig University College London, Department of Statistical Science Gower St., London WC1E 6BT, phone +44 207 679 1698 [EMAIL PROTECTED], www.homepages.ucl.ac.uk/~ucakche __ 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] anyone has C++ STL classes stability issue if used with R
Duncan, you are right about Rf_..., otherwise the lengths are checked in the R side, this is just one of the functions I have in the package and all arguments are thoroughly checked. But apparently, the same code if redefined for using pointers instead of references works just perfectly fine (given below). And I do not see why the one I posted before fails. I will try to run it outside of R to see if the issue is anyhow connected to R. // comparison operator redefined for pointers: struct Pixel_compare: public binary_functionPixel*, Pixel*, bool { bool operator() (Pixel* a, Pixel* b) { return a-intens b-intens; } }; // was: // struct Pixel_compare: public binary_functionPixel, Pixel, bool { //bool operator() (Pixel a, Pixel b) { //return a.intens b.intens; //} // }; // the queue redefined for pointers typedef priority_queuePixel*, vectorPixel*, Pixel_compare PixelPrQueue; // was: typedef priority_queuePixel, vectorPixel, Pixel_compare PixelPrQueue; SEXP lib_filterInvWS (SEXP x) { SEXP res; int i, j, index; double val; int nx = INTEGER ( GET_DIM(x) )[0]; int ny = INTEGER ( GET_DIM(x) )[1]; int nz = INTEGER ( GET_DIM(x) )[2]; int nprotect = 0; PROTECT ( res = Rf_duplicate(x) ); nprotect++; for (int im = 0; im nz; im++ ) { double * src = ( REAL(x)[ im * nx * ny ] ); double * tgt = ( REAL(res)[ im * nx * ny ] ); PixelPrQueue pq; for ( j = 0; j ny; j++ ) for ( i = 0; i nx; i++ ) { index = i + nx * j; val = src[ index ]; if ( val BG ) { tgt[ index ] = -1; // new pixels are created as pointer to objects // was: pq.push( Pixel(i, j, val) ); pq.push( new Pixel(i, j, val) ); continue; } tgt[ index ] = BG; } // printed and all pointers deleted Pixel * px; while ( !pq.empty() ) { px = pq.top(); pq.pop(); Rprintf(%f\n, px-intens); delete px; } } UNPROTECT (nprotect); return res; } The above works fine. The Compare operator is defined differently from my previous post, but both fail if used with references. Oleg Duncan Murdoch wrote: On 2/13/2007 3:55 AM, Oleg Sklyar wrote: Hello, is there any one who uses C++ STL classes when programming shared libs for R and has had any problems with STL? I don't, but I'd suggest asking a technical question like this on R-devel instead of R-help if you don't get help here. I can see a few probably innocuous changes I'd suggest in your code below, but nothing obvious: use Rinternals.h instead of Rdefines.h, don't use the Rf_ prefix, check the length of inputs before working with the values. Duncan Murdoch In the very simple example below I am constantly getting segfaults when trying to populate the queue. The segfault occurs at what looks like a random index in the loop when pushing another element to the queue. Reproduced on 4 machines. Object x is an Image as in EBImage, i.e. a 3D R-array of numerics for the purpose of this code. LENGTH(x) can be up to 1e6 and the number of elements potentially to be in the queue is about 20% of those. But I get segfaults often on a third of fours element being added. Tried on R2.5.0-devel, R2.4.1-release and all machines were 64bit Linux with kernels 2.6.9 (stable CentOS), 2.6.17 (stable Ubuntu) and 2.6.20 (Ubuntu devel). Here are the compilation options of this particular module (built as part of EBImage, which generally compiles and works just fine): -- g++ -I/home/osklyar/R/R-2.5.0-40659/include -I/home/osklyar/R/R-2.5.0-40659/include -I/usr/local/include -DUSE_GTK -DGLIB_GETTEXT -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -Wall -g -O2 -Wall -pthread -I/usr/include -O2 -g -O2 -g -fpic -O2 -g -c filters_watershed.cpp -o filters_watershed.o -- And the linker: -- g++ -shared -L/usr/local/lib64 -o EBImage.so colors.o conversions.o display.o filters_distmap.o filters_magick.o filters_morph.o filters_propagate.o filters_thresh.o filters_watershed.o init.o io.o object_counting.o tools.o -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lfontconfig -lXext -lXrender -lXinerama -lXi -lXrandr -lXcursor -lXfixes -lpango-1.0 -lcairo -lX11 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 -L/usr/lib -L/usr/X11R6/lib -lfreetype -lz -L/usr/lib -lMagick -llcms -ltiff -lfreetype -ljasper -ljpeg
[R] Fatigued R
Hi R, Please solve my problem... I am extracting Bloomberg data from R, in a loop. R is getting fatigued by doing this process and gives some errors. I introduced sleep function. Doing this sometimes I get the results and sometimes not. I even noticed that if I give complete rest for R (don't open R window) for 1 day and then run my code with the sleep function, then the program works. But if I keep on doing this with on R, repeatedly I get errors. Please can anyone do something for this? Is there any function of refreshing R completely.Or any other techniques?...I am really getting bugged with this... Thanks, Shubha [[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] Fatigued R
Hi Shubha, Perhaps you haven't gotten any help because you haven't provided a reproducible example, or even told us what you are trying to do (specifically) or what errors you are receiving. Frankly, your problem statement doesn't make any sense to me, and I can't provide advice without more information. As the footer of every email says: PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Sarah On 2/13/07, Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote: Hi R, Please solve my problem... I am extracting Bloomberg data from R, in a loop. R is getting fatigued by doing this process and gives some errors. I introduced sleep function. Doing this sometimes I get the results and sometimes not. I even noticed that if I give complete rest for R (don't open R window) for 1 day and then run my code with the sleep function, then the program works. But if I keep on doing this with on R, repeatedly I get errors. Please can anyone do something for this? Is there any function of refreshing R completely.Or any other techniques?...I am really getting bugged with this... Thanks, Shubha -- Sarah Goslee http://www.functionaldiversity.org __ 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] Fatigued R
OhkkkI will try to do that now This is my download function... download-function(fil) { con-blpConnect(show.days=show_day, na.action=na_action, periodicity=periodicity) for(i in 1:lent) { Sys.sleep(3) cdaily-blpGetData(con,unique(t[,i]),fil,start=as.chron(as.Date(1/1/199 6, %m/%d/%Y)),end=as.chron(as.Date(12/28/2006, %m/%d/%Y))) #Sys.sleep(3) if(!exists(d_mer)) d_mer=cdaily else d_mer=merge(d_mer,cdaily) rm(cdaily) } dat-data.frame(Date=index(d_mer),d_mer) dat$ABCDEFG=NULL path1-paste(D:\\SAS\\Project2\\Daily\\,fil,_root.sas7bdat,sep=) path2-paste(D:\\SAS\\Project2\\Daily\\CODEFILES\\,fil,.sas,sep=) sasname-paste(x1,fil,',sep=) write.foreign(dat,path1,path2,package=SAS,dataname=sasname) blpDisconnect(con) } for(j in 1:lenf) { fname-paste(D:\\SAS\\Project2\\Daily\\,filename[j],_root.sas7bdat,s ep=) Sys.sleep(600) if(!file.exists(fname)) download(fil=filename[j]) } And lent=58 and lenf=8... 8 text files will be generated in this process if the program would have run properly, and each would be of size 4,000 KB. The error message I get if the program is not run is: Error in dimnames(x) - dn : length of 'dimnames' [2] not equal to array extent In addition: Warning message: Index vectors are of different classes: chron chron dates in: merge(d_mer,cdaily) Please could any one help on this? -Original Message- From: Sarah Goslee [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 13, 2007 7:09 PM To: Shubha Vishwanath Karanth Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Fatigued R Hi Shubha, Perhaps you haven't gotten any help because you haven't provided a reproducible example, or even told us what you are trying to do (specifically) or what errors you are receiving. Frankly, your problem statement doesn't make any sense to me, and I can't provide advice without more information. As the footer of every email says: PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Sarah On 2/13/07, Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote: Hi R, Please solve my problem... I am extracting Bloomberg data from R, in a loop. R is getting fatigued by doing this process and gives some errors. I introduced sleep function. Doing this sometimes I get the results and sometimes not. I even noticed that if I give complete rest for R (don't open R window) for 1 day and then run my code with the sleep function, then the program works. But if I keep on doing this with on R, repeatedly I get errors. Please can anyone do something for this? Is there any function of refreshing R completely.Or any other techniques?...I am really getting bugged with this... Thanks, Shubha -- Sarah Goslee http://www.functionaldiversity.org __ 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] lag orders with ADF.test
Hello! I do not understand what is meant by: aic and bic follow a top-down strategy based on the Akaike's and Schwarz's information criteria in the datails to the ADF.test function. What does a top-down strategy mean? Probably the respective criterion is minimized and the mode vector contains the lag orders at which the criterion attains it local minima? When the calculation is over, the ADF.test function gives info about Lag orders. What are these lag orders? Are they the local minima of the criterion? I will be very thankful if you clarify this to me. I browsed a lot, but I could not find a clear answer. Thank you for your attention. Regards, Martin - http://auto-motor-und-sport.bg/ С бензин в кръвта! __ 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] glpk package
Hi All, I want to read MPS format file using this file. I am able to read cofficient of objective function,number of columns, number of rows etc. But not able to read constraint matrix its rhs values. Could anyone please help in this? is there any good documentation available other than glpk.pdf glpk_intro.pdf? My program is as follows-- p-lpx_read_mps(c:/ex2.mps) numrows-lpx_get_num_rows(lp) numcols-lpx_get_num_cols(lp) numnz-lpx_get_num_nz(lp) print(objective function coefficient) for (j in 1:numcols) { print(lpx_get_obj_coef(lp, j)) } print(rows names) for (i in 1:numrows) { print(lpx_get_row_name(lp, i)) print(lpx_get_row_prim(lp, i)) # for this it is returning me zeros only } print(columns Names) for (j in 1:numcols) { print(lpx_get_col_name(lp, j)) print(lpx_get_col_prim(lp, j)) } Could anyone help me out? Thanks in advance, Ujjwal [[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] lme4/lmer: P-Values from mcmc samples or chi2-tests?
Dear R users, I have now tried out several options of obtaining p-values for (quasi)poisson lmer models, including Markov-chain Monte Carlo sampling and single-term deletions with subsequent chi-square tests (although I am aware that the latter may be problematic). However, I encountered several problems that can be classified as (1) the quasipoisson lmer model does not give p-values when summary() is called (see below) (2) dependence on the size of the mcmc sample (3) lack of correspondence between different p-value estimates. How can I proceed, left with these uncertainties in the estimations of the p-values? Below is the corresponding R code with some output so that you can see it all for your own: ## m1-lmer(number_pollinators~logpatch+loghab+landscape_diversity+(1|site),primula,poisson,method=ML) m2-lmer(number_pollinators~logpatch+loghab+landscape_diversity+(1|site),primula,quasipoisson,method=ML) summary(m1);summary(m2) #m1: [...] Fixed effects: Estimate Std. Error z value Pr(|z|) (Intercept) -0.403020.57403 -0.7021 0.48262 logpatch 0.109150.04111 2.6552 0.00793 ** loghab 0.087500.06128 1.4279 0.15331 landscape_diversity 1.023380.40604 2.5204 0.01172 * #m2: [...] #for the quasipoisson model, no p values are shown?! Fixed effects: Estimate Std. Error t value (Intercept) -0.4030 0.6857 -0.5877 logpatch 0.1091 0.0491 2.2228 loghab0.0875 0.0732 1.1954 landscape_diversity 1.0234 0.4850 2.1099 ## anova(m1) #here, no p-values appear (only in the current version of lme4) Analysis of Variance Table Df Sum Sq Mean Sq logpatch 1 11.6246 11.6246 loghab 1 6.0585 6.0585 landscape_diversity 1 6.3024 6.3024 anova(m2) Analysis of Variance Table Df Sum Sq Mean Sq logpatch 1 11.6244 11.6244 loghab 1 6.0581 6.0581 landscape_diversity 1 6.3023 6.3023 So I am left with the p-values estimated from the poisson model; single-term deletion tests for each of the individual terms lead to different p-values; I restrict this here to m2: ## m2a=update(m2,~.-loghab) anova(m2,m2a,test=Chi) Data: primula Models: m2a: number_pollinators ~ logpatch + landscape_diversity + (1 | site) m2: number_pollinators ~ logpatch + loghab + landscape_diversity + (1 | site) Df AIC BIC logLik Chisq Chi Df Pr(Chisq) m2a 4 84.713 91.850 -38.357 m2 5 84.834 93.755 -37.417 1.8793 1 0.1704 ## m2b=update(m2,~.-logpatch) anova(m2,m2b,test=Chi) Data: primula Models: m2b: number_pollinators ~ loghab + landscape_diversity + (1 | site) m2: number_pollinators ~ logpatch + loghab + landscape_diversity + m2b: (1 | site) Df AIC BIC logLik Chisq Chi Df Pr(Chisq) m2b 4 90.080 97.217 -41.040 m2 5 84.834 93.755 -37.417 7.246 1 0.007106 ** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## m2c=update(m2,~.-landscape_diversity) anova(m2,m2c,test=Chi) Data: primula Models: m2c: number_pollinators ~ logpatch + loghab + (1 | site) m2: number_pollinators ~ logpatch + loghab + landscape_diversity + m2c: (1 | site) Df AIC BIC logLik Chisq Chi Df Pr(Chisq) m2c 4 89.036 96.173 -40.518 m2 5 84.834 93.755 -37.417 6.2023 10.01276 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 The p-values from mcmc are: ## markov1=mcmcsamp(m2,5000) HPDinterval(markov1) lower upper (Intercept) -1.394287660 0.6023229 logpatch 0.031154910 0.1906861 loghab0.002961281 0.2165285 landscape_diversity 0.245623183 1.6442544 log(site.(In)) -41.156007604 -1.6993996 attr(,Probability) [1] 0.95 ## mcmcpvalue(as.matrix(markov1[,1])) #i.e. the p value for the intercept [1] 0.3668 mcmcpvalue(as.matrix(markov1[,2])) #i.e. the p-value for logpatch [1] 0.004 mcmcpvalue(as.matrix(markov1[,3])) #i.e. the p-value for loghab [1] 0.0598 mcmcpvalue(as.matrix(markov1[,4])) #i.e. the p-value for landscape.div [1] 0.0074 If one runs the mcmcsamp function for, say, 50,000 runs, the p-values are slightly different (not shown here). ##here are the p-values summarized in tabular form: (Intercept) 0.3668 logpatch0.004 loghab 0.0598 landscape_diversity 0.0074 ##and from the single-term deletions: (Intercept)N.A. logpatch0.007106 loghab 0.1704 landscape_diversity 0.01276 ## Compare this with the p-values from the poisson model: Fixed effects: Estimate Std. Error z value Pr(|z|) (Intercept) -0.403020.57403 -0.7021 0.48262 logpatch 0.109150.04111 2.6552 0.00793 ** loghab 0.087500.06128 1.4279 0.15331 landscape_diversity 1.023380.40604 2.5204
[R] Suddenly Subscript out of bounds
Hello Using R Version 2.3.1 I have setup a cronjob to update packages, which worked successfully almost a year (it was called daily). Basically, it runs like this: Sys.getenv(http_proxy) update.packages(ask=F,repos=http://cran.r-project.org;) (the http_proxy environment variable is set prior to the call). All of a sudden, I started to get this error: Error in inherits(x, factor) : subscript out of bounds I have no clue about what this means. Is factor a buggy package? Clearly, that kind of things can happen when you just update things automatically... Any help with be appreciated! Bye Rick __ 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] Fatigued R
That's a help. It isn't actually reproducible since I have no idea where for example blpConnect() comes from, but it's still an improvement. Moving the important bit to the top: The error message I get if the program is not run is: Error in dimnames(x) - dn : length of 'dimnames' [2] not equal to array extent In addition: Warning message: Index vectors are of different classes: chron chron dates in: merge(d_mer,cdaily) These seem to mean that your data don't (always?) look like you are expecting, and have nothing to do with fatigue or sleepiness. Except maybe yours? I would suggest going through your function one command at a time (without the loop, but set the loop index manually if needed), and check carefully the format of the data. If it works sometimes and not others, identify a loop index for which it doesn't work and repeat the process. Someone familiar with Bloomberg data might be able to provide more assistance. Sarah On 2/13/07, Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote: OhkkkI will try to do that now This is my download function... download-function(fil) { con-blpConnect(show.days=show_day, na.action=na_action, periodicity=periodicity) for(i in 1:lent) { Sys.sleep(3) cdaily-blpGetData(con,unique(t[,i]),fil,start=as.chron(as.Date(1/1/199 6, %m/%d/%Y)),end=as.chron(as.Date(12/28/2006, %m/%d/%Y))) #Sys.sleep(3) if(!exists(d_mer)) d_mer=cdaily else d_mer=merge(d_mer,cdaily) rm(cdaily) } dat-data.frame(Date=index(d_mer),d_mer) dat$ABCDEFG=NULL path1-paste(D:\\SAS\\Project2\\Daily\\,fil,_root.sas7bdat,sep=) path2-paste(D:\\SAS\\Project2\\Daily\\CODEFILES\\,fil,.sas,sep=) sasname-paste(x1,fil,',sep=) write.foreign(dat,path1,path2,package=SAS,dataname=sasname) blpDisconnect(con) } for(j in 1:lenf) { fname-paste(D:\\SAS\\Project2\\Daily\\,filename[j],_root.sas7bdat,s ep=) Sys.sleep(600) if(!file.exists(fname)) download(fil=filename[j]) } And lent=58 and lenf=8... 8 text files will be generated in this process if the program would have run properly, and each would be of size 4,000 KB. The error message I get if the program is not run is: Error in dimnames(x) - dn : length of 'dimnames' [2] not equal to array extent In addition: Warning message: Index vectors are of different classes: chron chron dates in: merge(d_mer,cdaily) Please could any one help on this? -Original Message- From: Sarah Goslee [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 13, 2007 7:09 PM To: Shubha Vishwanath Karanth Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Fatigued R Hi Shubha, Perhaps you haven't gotten any help because you haven't provided a reproducible example, or even told us what you are trying to do (specifically) or what errors you are receiving. Frankly, your problem statement doesn't make any sense to me, and I can't provide advice without more information. As the footer of every email says: PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Sarah On 2/13/07, Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote: Hi R, Please solve my problem... I am extracting Bloomberg data from R, in a loop. R is getting fatigued by doing this process and gives some errors. I introduced sleep function. Doing this sometimes I get the results and sometimes not. I even noticed that if I give complete rest for R (don't open R window) for 1 day and then run my code with the sleep function, then the program works. But if I keep on doing this with on R, repeatedly I get errors. Please can anyone do something for this? Is there any function of refreshing R completely.Or any other techniques?...I am really getting bugged with this... Thanks, Shubha -- Sarah Goslee http://www.functionaldiversity.org __ 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] Polygon triangulation?
Can anyone point me to a package that contains code to triangulate a polygon? This is easy if the polygon is convex, but tricky if not. One algorithm to do it is due to Meister, and is described here: www.math.gatech.edu/~randall/AlgsF06/planartri.pdf 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] Generating MVN Data
Dear All I want to generate multivariate normal data in R for a given covariance matrix, i.e. my generated data must have the given covariance matrix. I know the rmvnorm command is to be used but may be I am failing to properly assign the covariance matrix. Any help will be greatly appreciated thanks. M. R. Ahmad __ 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] Generating MVN Data
Hi give rmvnorm() any symmetric positive definite matrix and it should work: rmvnorm(n=10,mean=1:2,sigma=matrix(c(1,0.5,0.5,1),2,2)) [,1] [,2] [1,] -0.1118 2.514 [2,] 1.8667 1.628 [3,] 3.2477 2.263 [4,] 1.0166 2.381 [5,] -0.0888 -0.132 [6,] -0.9249 0.610 [7,] 1.5046 3.578 [8,] 0.8530 0.802 [9,] 2.2940 2.240 [10,] 1.1660 2.528 HTH rksh On 13 Feb 2007, at 14:14, Rauf Ahmad wrote: Dear All I want to generate multivariate normal data in R for a given covariance matrix, i.e. my generated data must have the given covariance matrix. I know the rmvnorm command is to be used but may be I am failing to properly assign the covariance matrix. Any help will be greatly appreciated thanks. M. R. Ahmad __ 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. -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ 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] Fatigued R
Dear Shubha, The error message tells you that the error occurs in the line: merge(d_mer,cdaily) And the problem is that d_mer and cdaily have a different class. It looks as you need to convert cdaily to the correct class (same class as d_mer). Don't forget to use traceback() when debugging your program. You code could use some tweaking. Don't be afraid to add spaces and indentation. That will make you code a lot more readable. I noticed that you have defined some variables within your function (lent, t). This might lead to strange behaviour of your function, as it will use the global variables. Giving a variable the same name as a function (t) is confusing. t[2] and t(2) look very similar but do something very different. Sometimes it pays off to covert for-loop in apply-type functions. Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Shubha Vishwanath Karanth Verzonden: dinsdag 13 februari 2007 14:51 Aan: Sarah Goslee; r-help@stat.math.ethz.ch Onderwerp: Re: [R] Fatigued R OhkkkI will try to do that now This is my download function... download-function(fil) { con-blpConnect(show.days=show_day, na.action=na_action, periodicity=periodicity) for(i in 1:lent) { Sys.sleep(3) cdaily-blpGetData(con,unique(t[,i]),fil,start=as.chron(as.Date(1/1/199 6, %m/%d/%Y)),end=as.chron(as.Date(12/28/2006, %m/%d/%Y))) #Sys.sleep(3) if(!exists(d_mer)) d_mer=cdaily else d_mer=merge(d_mer,cdaily) rm(cdaily) } dat-data.frame(Date=index(d_mer),d_mer) dat$ABCDEFG=NULL path1-paste(D:\\SAS\\Project2\\Daily\\,fil,_root.sas7bdat,sep=) path2-paste(D:\\SAS\\Project2\\Daily\\CODEFILES\\,fil,.sas,sep=) sasname-paste(x1,fil,',sep=) write.foreign(dat,path1,path2,package=SAS,dataname=sasname) blpDisconnect(con) } for(j in 1:lenf) { fname-paste(D:\\SAS\\Project2\\Daily\\,filename[j],_root.sas7bdat,s ep=) Sys.sleep(600) if(!file.exists(fname)) download(fil=filename[j]) } And lent=58 and lenf=8... 8 text files will be generated in this process if the program would have run properly, and each would be of size 4,000 KB. The error message I get if the program is not run is: Error in dimnames(x) - dn : length of 'dimnames' [2] not equal to array extent In addition: Warning message: Index vectors are of different classes: chron chron dates in: merge(d_mer,cdaily) Please could any one help on this? -Original Message- From: Sarah Goslee [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 13, 2007 7:09 PM To: Shubha Vishwanath Karanth Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Fatigued R Hi Shubha, Perhaps you haven't gotten any help because you haven't provided a reproducible example, or even told us what you are trying to do (specifically) or what errors you are receiving. Frankly, your problem statement doesn't make any sense to me, and I can't provide advice without more information. As the footer of every email says: PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Sarah On 2/13/07, Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote: Hi R, Please solve my problem... I am extracting Bloomberg data from R, in a loop. R is getting fatigued by doing this process and gives some errors. I introduced sleep function. Doing this sometimes I get the results and sometimes not. I even noticed that if I give complete rest for R (don't open R window) for 1 day and then run my code with the sleep function, then the program works. But if I keep on doing this with on R, repeatedly I get errors. Please can anyone do something for this? Is there any function of refreshing R completely.Or any other techniques?...I am really getting bugged with this... Thanks, Shubha -- Sarah Goslee http://www.functionaldiversity.org __ 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
Re: [R] Polygon triangulation?
Have you tried the tri-package? Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Duncan Murdoch Verzonden: dinsdag 13 februari 2007 15:27 Aan: r-help@stat.math.ethz.ch Onderwerp: [R] Polygon triangulation? Can anyone point me to a package that contains code to triangulate a polygon? This is easy if the polygon is convex, but tricky if not. One algorithm to do it is due to Meister, and is described here: www.math.gatech.edu/~randall/AlgsF06/planartri.pdf 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-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] lag orders with ADF.test
Hello! I do not understand what is meant by: aic and bic follow a top-down strategy based on the Akaike's and Schwarz's information criteria in the datails to the ADF.test function. What does a top-down strategy mean? Probably the respective criterion is minimized Hello Martin, are you referring to ADF.test() in package uroot? If so, it would be good to adress this question to the package maintainer first, which I have cc'ed. Different approaches for determining an appropriate lag length for ADF tests are propagated in the literature. One of them is the usage of information criteria; a second one starting from a high lag number and cutting the lag length down by signifcance (top to bottom) or vice versa (bottom to top); or finally inspect the ACF/PACF's of the residuals in the ADF-test regression and choose the lowest possible lag length such that the residuals are uncorrelated. Best, Bernhard and the mode vector contains the lag orders at which the criterion attains it local minima? When the calculation is over, the ADF.test function gives info about Lag orders. What are these lag orders? Are they the local minima of the criterion? I will be very thankful if you clarify this to me. I browsed a lot, but I could not find a clear answer. Thank you for your attention. Regards, Martin - http://auto-motor-und-sport.bg/ С бензин в кръвта! __ 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. * Confidentiality Note: The information contained in this mess...{{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] Generating MVN Data
Rauf Ahmad wrote: Dear All I want to generate multivariate normal data in R for a given covariance matrix, i.e. my generated data must have the given covariance matrix. I know the rmvnorm command is to be used but may be I am failing to properly assign the covariance matrix. Any help will be greatly appreciated library(MASS) mat - mvrnorm(100, mu=rep(0,4), Sigma = diag(4), empirical=TRUE) cov(mat) [,1] [,2] [,3] [,4] [1,] 1.00e+00 -1.634448e-16 -1.004223e-16 -2.015521e-16 [2,] -1.634448e-16 1.00e+00 4.244391e-17 1.544399e-17 [3,] -1.004223e-16 4.244391e-17 1.00e+00 -1.921951e-16 [4,] -2.015521e-16 1.544399e-17 -1.921951e-16 1.00e+00 ?mvrnorm thanks. M. R. Ahmad __ 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. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ 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] Width of a plotting point (in inches) in grid package
Hello, I was thinking that was probably the case. I'm creating a series of graphics that contain smaller graphics, and was trying to reduce the bounding box as much as possible with out the plotting points bleeding over to the surrounding features. I could hard code the size of the bounding boxes (or use a creative calculation), but that would be tedious, not to mention what would happen if someone decides they would like to change the plotting point or it's size. ;) The number of predefined types of points available in a pointsGrob is handy, but I also like the idea of using circles or polygons... I might also add that I've just started using the grid graphics system in the last few months, and I'm impressed at how powerful and flexible it is. Thanks! Randy On 2/12/07 2:27 PM, Paul Murrell [EMAIL PROTECTED] wrote: Hi Randall C Johnson [Contr.] wrote: Hello, I'm trying to determine the width of a plotting point (in inches) in the grid package. I naively thought I could create a pointsGrob with only one point and get the width (as tried below), but this results in an object with a size of 0inches (changing cex has no effect). Does anyone have a better approach? Of course, it would be dependent upon the graphics parameters and viewport... The width of a pointsGrob is based on a bounding box surrounding all of the (x, y) locations at which the points are located. It takes no notice of the size of the symbol drawn at the locations. With one point, the bounding box has zero size. The wisdom of this design could be debated ... What do you need the symbol width for? Could you use a circle, rectangle, or polygon instead (all of which calculate their width based on the bounding box of the shape that is drawn)? Paul Thanks, Randy library(grid) pushViewport(viewport()) convertX(grobWidth(pointsGrob(1, 1)), 'inches') [1] 0inches # I think we're measuring the size of the point here... # changing cex has no effect. convertX(grobWidth(pointsGrob(1, 1, gp = gpar(cex = 3))), 'inches') [1] 0inches # If I add a second point, the size should increase... # how big is the plotting point though??? convertX(grobWidth(pointsGrob(1:2, 1:2)), 'inches') [1] 11.1929133858268inches sessionInfo() R version 2.4.1 (2006-12-18) i386-apple-darwin8.8.2 locale: C attached base packages: [1] grid stats graphics grDevices utils datasets [7] methods base ~~ Randall C Johnson Bioinformatics Analyst SAIC-Frederick, Inc (Contractor) Laboratory of Genomic Diversity NCI-Frederick, P.O. Box B Bldg 560, Rm 11-85 Frederick, MD 21702 Phone: (301) 846-1304 Fax: (301) 846-1686 ~~ __ 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. ~~ Randall C Johnson Bioinformatics Analyst SAIC-Frederick, Inc (Contractor) Laboratory of Genomic Diversity NCI-Frederick, P.O. Box B Bldg 560, Rm 11-85 Frederick, MD 21702 Phone: (301) 846-1304 Fax: (301) 846-1686 ~~ __ 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] Generating MVN Data
you probably want to use mvrnorm() from package MASS, e.g., library(MASS) mu - c(-3, 0, 3) Sigma - rbind(c(5,3,2), c(3,4,1), c(2,1,3)) x - mvrnorm(1000, mu, Sigma, empirical = TRUE) colMeans(x) var(x) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Rauf Ahmad [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Tuesday, February 13, 2007 3:14 PM Subject: [R] Generating MVN Data Dear All I want to generate multivariate normal data in R for a given covariance matrix, i.e. my generated data must have the given covariance matrix. I know the rmvnorm command is to be used but may be I am failing to properly assign the covariance matrix. Any help will be greatly appreciated thanks. M. R. Ahmad __ 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. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ 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] Generating MVN Data
'should work', yes. Do what he asked for (in any reasonable reading), no. set.seed(1) library(mvtnorm) ## you both omitted to mention that X - rmvnorm(n=10,mean=1:2,sigma=matrix(c(1,0.5,0.5,1),2,2)) var(X) [,1] [,2] [1,] 0.4878773 0.1238040 [2,] 0.1238040 0.9508090 Fortunately there is a way to do it, and without even adding unstated packages to your R installation: library(MASS) set.seed(1) X - mvrnorm(n=10, mu=1:2, Sigma=matrix(c(1,0.5,0.5,1),2,2), emp=TRUE) var(X) [,1] [,2] [1,] 1.0 0.5 [2,] 0.5 1.0 On Tue, 13 Feb 2007, Robin Hankin wrote: Hi give rmvnorm() any symmetric positive definite matrix and it should work: rmvnorm(n=10,mean=1:2,sigma=matrix(c(1,0.5,0.5,1),2,2)) [,1] [,2] [1,] -0.1118 2.514 [2,] 1.8667 1.628 [3,] 3.2477 2.263 [4,] 1.0166 2.381 [5,] -0.0888 -0.132 [6,] -0.9249 0.610 [7,] 1.5046 3.578 [8,] 0.8530 0.802 [9,] 2.2940 2.240 [10,] 1.1660 2.528 HTH rksh On 13 Feb 2007, at 14:14, Rauf Ahmad wrote: Dear All I want to generate multivariate normal data in R for a given covariance matrix, i.e. my generated data must have the given covariance matrix. I know the rmvnorm command is to be used but may be I am failing to properly assign the covariance matrix. Any help will be greatly appreciated thanks. M. R. Ahmad __ 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. -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ 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. -- 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] Fatigued R
Shubha, You suggested the solution yourself: first make sure that the downloaded data has no errors and reload it when it has errors. But that's something you'll have to do yourself. Have a look at the data downloaded with and without errors and try to see the difference. Again: it's impossible to solve your problem without an example of the correct and faulty data. Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: Shubha Vishwanath Karanth [mailto:[EMAIL PROTECTED] Verzonden: dinsdag 13 februari 2007 16:06 Aan: ONKELINX, Thierry; r-help@stat.math.ethz.ch; [EMAIL PROTECTED] Onderwerp: RE: [R] Fatigued R Hi all, thanks for your reply But I have to make one thing clear that there are no errors in programming...I assure that to you, because I have extracted the data many times from the same program... The problem is with the connection of R with Bloomberg, sometimes the data is not fetched at all and so I get the below errors...It is mainly due to some network jam problems and all... Could anyone suggest me how to refresh R, or how to always make sure that the data is downloaded without any errors for each loop? I tried with Sys.sleep() to give some free time to R...but it is not successful always... Could anybody help me out? Thank you, Shubha -Original Message- From: ONKELINX, Thierry [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 13, 2007 7:56 PM To: Shubha Vishwanath Karanth; r-help@stat.math.ethz.ch Subject: RE: [R] Fatigued R Dear Shubha, The error message tells you that the error occurs in the line: merge(d_mer,cdaily) And the problem is that d_mer and cdaily have a different class. It looks as you need to convert cdaily to the correct class (same class as d_mer). Don't forget to use traceback() when debugging your program. You code could use some tweaking. Don't be afraid to add spaces and indentation. That will make you code a lot more readable. I noticed that you have defined some variables within your function (lent, t). This might lead to strange behaviour of your function, as it will use the global variables. Giving a variable the same name as a function (t) is confusing. t[2] and t(2) look very similar but do something very different. Sometimes it pays off to covert for-loop in apply-type functions. Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Shubha Vishwanath Karanth Verzonden: dinsdag 13 februari 2007 14:51 Aan: Sarah Goslee; r-help@stat.math.ethz.ch Onderwerp: Re: [R] Fatigued R OhkkkI will try to do that now This is my download function... download-function(fil) { con-blpConnect(show.days=show_day, na.action=na_action, periodicity=periodicity) for(i in 1:lent) { Sys.sleep(3) cdaily-blpGetData(con,unique(t[,i]),fil,start=as.chron(as.Date(1/1/199 6, %m/%d/%Y)),end=as.chron(as.Date(12/28/2006, %m/%d/%Y))) #Sys.sleep(3) if(!exists(d_mer)) d_mer=cdaily else d_mer=merge(d_mer,cdaily) rm(cdaily) } dat-data.frame(Date=index(d_mer),d_mer) dat$ABCDEFG=NULL path1-paste(D:\\SAS\\Project2\\Daily\\,fil,_root.sas7bdat,sep=) path2-paste(D:\\SAS\\Project2\\Daily\\CODEFILES\\,fil,.sas,sep=) sasname-paste(x1,fil,',sep=) write.foreign(dat,path1,path2,package=SAS,dataname=sasname) blpDisconnect(con) } for(j in 1:lenf) { fname-paste(D:\\SAS\\Project2\\Daily\\,filename[j],_root.sas7bdat,s ep=) Sys.sleep(600) if(!file.exists(fname)) download(fil=filename[j]) } And lent=58 and lenf=8... 8 text files will be generated in this process if the program would have run properly, and each would be of size 4,000 KB. The error message I get if the program is not run is: Error in dimnames(x) - dn : length of 'dimnames' [2] not equal to array extent In
Re: [R] Polygon triangulation?
On 2/13/2007 9:43 AM, ONKELINX, Thierry wrote: Have you tried the tri-package? You mean tripack? I looked and saw Delaunay triangulation (triangulating points), but triangulating polygons is a different (unrelated?) problem. Duncan Murdoch Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Duncan Murdoch Verzonden: dinsdag 13 februari 2007 15:27 Aan: r-help@stat.math.ethz.ch Onderwerp: [R] Polygon triangulation? Can anyone point me to a package that contains code to triangulate a polygon? This is easy if the polygon is convex, but tricky if not. One algorithm to do it is due to Meister, and is described here: www.math.gatech.edu/~randall/AlgsF06/planartri.pdf 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-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] Suddenly Subscript out of bounds
On 2/13/2007 9:15 AM, [EMAIL PROTECTED] wrote: Hello Using R Version 2.3.1 I have setup a cronjob to update packages, which worked successfully almost a year (it was called daily). Basically, it runs like this: Sys.getenv(http_proxy) update.packages(ask=F,repos=http://cran.r-project.org;) (the http_proxy environment variable is set prior to the call). All of a sudden, I started to get this error: Error in inherits(x, factor) : subscript out of bounds I have no clue about what this means. Is factor a buggy package? Clearly, that kind of things can happen when you just update things automatically... The error message says that there's an error in the call to inherits() with the given args, but it doesn't say why that was being called. Use traceback() to see where this error happens. And please update to R 2.4.1; R 2.3.1 is out of date. 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.
Re: [R] Fatigued R
Hi all, thanks for your reply But I have to make one thing clear that there are no errors in programming...I assure that to you, because I have extracted the data many times from the same program... The problem is with the connection of R with Bloomberg, sometimes the data is not fetched at all and so I get the below errors...It is mainly due to some network jam problems and all... Could anyone suggest me how to refresh R, or how to always make sure that the data is downloaded without any errors for each loop? I tried with Sys.sleep() to give some free time to R...but it is not successful always... Could anybody help me out? Thank you, Shubha -Original Message- From: ONKELINX, Thierry [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 13, 2007 7:56 PM To: Shubha Vishwanath Karanth; r-help@stat.math.ethz.ch Subject: RE: [R] Fatigued R Dear Shubha, The error message tells you that the error occurs in the line: merge(d_mer,cdaily) And the problem is that d_mer and cdaily have a different class. It looks as you need to convert cdaily to the correct class (same class as d_mer). Don't forget to use traceback() when debugging your program. You code could use some tweaking. Don't be afraid to add spaces and indentation. That will make you code a lot more readable. I noticed that you have defined some variables within your function (lent, t). This might lead to strange behaviour of your function, as it will use the global variables. Giving a variable the same name as a function (t) is confusing. t[2] and t(2) look very similar but do something very different. Sometimes it pays off to covert for-loop in apply-type functions. Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Shubha Vishwanath Karanth Verzonden: dinsdag 13 februari 2007 14:51 Aan: Sarah Goslee; r-help@stat.math.ethz.ch Onderwerp: Re: [R] Fatigued R OhkkkI will try to do that now This is my download function... download-function(fil) { con-blpConnect(show.days=show_day, na.action=na_action, periodicity=periodicity) for(i in 1:lent) { Sys.sleep(3) cdaily-blpGetData(con,unique(t[,i]),fil,start=as.chron(as.Date(1/1/199 6, %m/%d/%Y)),end=as.chron(as.Date(12/28/2006, %m/%d/%Y))) #Sys.sleep(3) if(!exists(d_mer)) d_mer=cdaily else d_mer=merge(d_mer,cdaily) rm(cdaily) } dat-data.frame(Date=index(d_mer),d_mer) dat$ABCDEFG=NULL path1-paste(D:\\SAS\\Project2\\Daily\\,fil,_root.sas7bdat,sep=) path2-paste(D:\\SAS\\Project2\\Daily\\CODEFILES\\,fil,.sas,sep=) sasname-paste(x1,fil,',sep=) write.foreign(dat,path1,path2,package=SAS,dataname=sasname) blpDisconnect(con) } for(j in 1:lenf) { fname-paste(D:\\SAS\\Project2\\Daily\\,filename[j],_root.sas7bdat,s ep=) Sys.sleep(600) if(!file.exists(fname)) download(fil=filename[j]) } And lent=58 and lenf=8... 8 text files will be generated in this process if the program would have run properly, and each would be of size 4,000 KB. The error message I get if the program is not run is: Error in dimnames(x) - dn : length of 'dimnames' [2] not equal to array extent In addition: Warning message: Index vectors are of different classes: chron chron dates in: merge(d_mer,cdaily) Please could any one help on this? -Original Message- From: Sarah Goslee [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 13, 2007 7:09 PM To: Shubha Vishwanath Karanth Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Fatigued R Hi Shubha, Perhaps you haven't gotten any help because you haven't provided a reproducible example, or even told us what you are trying to do (specifically) or what errors you are receiving. Frankly, your problem statement doesn't make any sense to me, and I can't provide advice without more information. As the footer of every email says: PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Sarah On 2/13/07, Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote: Hi R, Please solve my problem... I am extracting Bloomberg data from R, in a loop. R is getting fatigued by doing this process and gives some errors. I introduced sleep function. Doing this sometimes I get the results and sometimes not. I even noticed that if I give complete rest for R (don't open R window) for 1 day and then run
Re: [R] Polygon triangulation?
On Tue, 13 Feb 2007, ONKELINX, Thierry wrote: Have you tried the tri-package? Perhaps the GPC C library used in the gpclib package, and in PBSmapping will get closer - it partitions polygons into tristrip sets. Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Duncan Murdoch Verzonden: dinsdag 13 februari 2007 15:27 Aan: r-help@stat.math.ethz.ch Onderwerp: [R] Polygon triangulation? Can anyone point me to a package that contains code to triangulate a polygon? This is easy if the polygon is convex, but tricky if not. One algorithm to do it is due to Meister, and is described here: www.math.gatech.edu/~randall/AlgsF06/planartri.pdf 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-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. -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [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] help with tryCatch
Hi, google R tryCatch example and you'll find: http://www.maths.lth.se/help/R/ExceptionHandlingInR/ Hope this helps Henrik On 2/13/07, Stephen Bond [EMAIL PROTECTED] wrote: Henrik, I had looked at tryCatch before posting the question and asked the question because the help file was not adequate for me. Could you pls provide a sample code of try{ try code} catch(error){catch code} let's say you have a vector of local file names and want to source them encapsulating in a tryCatch to avoid the skipping of all good file names after a bad file name. thank you stephen Henrik Bengtsson wrote: See ?tryCatch. /Henrik On 2/12/07, Stephen Bond [EMAIL PROTECTED] wrote: Could smb please help with try-catch encapsulating a function for downloading. Let's say I have a character vector of symbols and want to download each one and surround by try and catch to be safe # get.hist.quote() is in library(tseries), but the question does not depend on it, I could be sourcing local files instead ans=null;error=null; for ( sym in sym.vec){ try(ans=cbind(ans,get.hist.quote(sym,start=start))) #accumulate in a zoo matrix catch(theurlerror){error=c(error,sym)} #accumulate failed symbols } I know the code above does not work, but it conveys the idea. tryCatch help page says it is similar to Java try-catch, but I know how to do a try-catch in Java and still can't do it in R. Thank you very much. stephen __ 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] make check failure, internet.Rout.fail, Error in strsplit
Thanks for giving it a try. It is very odd that you got Content-Length when I am getting Content-length. I just tried curl (I had been using telnet to port 80) and I got the same (error causing) length result: curl --head http://www.stats.ox.ac.uk/pub/datasets/csb/ch11b.dat HTTP/1.1 200 OK Date: Tue, 13 Feb 2007 16:10:41 GMT Server: Apache/2.0.40 (Red Hat Linux) Last-Modified: Fri, 19 May 1995 10:27:04 GMT ETag: 7bc27-836-39a78e00 Accept-Ranges: bytes Content-Type: text/plain; charset=ISO-8859-1 Content-length: 2102 Connection: Keep-Alive Perhaps we are hitting different web servers? I ran nslookup on www.stats.ox.ac.uk, and it appears to be an alias for web2.stats.ox.ac.uk. Is that the machine you are getting? What happens if you run curl against web2, i.e.: curl --head http://web2.stats.ox.ac.uk/pub/datasets/csb/ch11b.dat ? (I get Content-length). Thanks, --Paul On 2/12/07, Charilaos Skiadas [EMAIL PROTECTED] wrote: On Feb 12, 2007, at 6:28 PM, Paul Lynch wrote: I'm trying to build R on RedHat EL4. The compile went fine, but a make check ran into a problem and produced a file internet.Rout.fail. Judging by the last part of that file, it was trying to run an R routine called httpget to retrieve the URL http://www.stats.ox.ac.uk/pub/datasets/csb/ch11b.dat. The precise error it encountered was: Error in strsplit(grep(Content-Length, b, value = TRUE), :)[[1]] : subscript out of bounds So, it looks like the data it read from that URL was not what was expected. I tried mimicking the script's request of the header information for that URL, and got back the following header lines: HTTP/1.1 200 OK Date: Mon, 12 Feb 2007 23:22:06 GMT Server: Apache/2.0.40 (Red Hat Linux) Last-Modified: Fri, 19 May 1995 10:27:04 GMT ETag: 7bc27-836-39a78e00 Accept-Ranges: bytes Content-Type: text/plain; charset=ISO-8859-1 Content-length: 2102 Connection: Keep-Alive The script appears to be looking for a Content-Length field, but as you can see the returned header is Content-length with a lower-case l. I don't know R yet, so I'm not sure if the grep in the test code is case-sensitive or not, but if it is, that would seem to be the problem. But then, surely everyone would be hitting this error? The grep is indeed case sensitive, as a quick test can show. However, the header I got back when I tried the above address had Length in it: HTTP/1.1 200 OK Date: Tue, 13 Feb 2007 01:40:48 GMT Server: Apache/2.0.40 (Red Hat Linux) Last-Modified: Fri, 19 May 1995 10:27:04 GMT ETag: 7bc27-836-39a78e00 Accept-Ranges: bytes Content-Length: 2102 Content-Type: text/plain; charset=ISO-8859-1 X-Pad: avoid browser bug ( I used curl for this, if it makes a difference) Hope this helps in some way. --Paul Haris __ 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] Hierarchical ANOVA
Hello, Does somebody could help me in the computation(formulation) of a hierarchical ANOVA using linear model in R? I'm working in a population biology study of an endangered species. My aim is to see if I have effects of Density of individuals/m2 on several measured plants fitness traits. As independent variables I have: Humidity (continuous) Nutritive substance (continuous) LUX (continuous) Density of individuals/m2 (continuous) Population (categorical) Year (categorical) I want to test the 4 continous variables with Population as error term. And the Population, the Year and interaction term, with the error of Population x Year. Thank you for any help, best regards. Romain Mayor __ 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] GEV by weighted moments method
Hi R-users, Could anyone point me to package of GEV (not the POT package) including function that estimates parameters by weighted moments method? Best regrads Lassana KOITA Chargé d'Etudes de Sécurité et d'Exploitation aéroportuaires / Project Engineer Airport Safety Studies Statistical analysis Service Technique de l'Aviation Civile (STAC) / Civil Aviation Technical Department Direction Générale de l'Aviation Civile (DGAC) / French Civil Aviation Authority Tel: 01 49 56 80 60 Fax: 01 49 56 82 14 E-mail: [EMAIL PROTECTED] http://www.stac.aviation-civile.gouv.fr/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Advanced graphics for points
On Tue, 2007-02-13 at 08:31 -0800, Strongbad78 wrote: Hi all, For aestethic purposes, I would like to plot points on an xy plot that consist of a filled circle with a black outline. I can sort of bodge it by plotting pch=21, col=black and pch=16, col=red on the same plot, but it looks a bit ugly and there are problems when points overlap. Can anyone think of a way around this? Thanks in advance Tony Is this what you want? plot(rnorm(10), col = black, bg = red, pch = 21) See the Details in ?points 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] RE2: Suddenly Subscript out of bounds
If you tell me how to update R itself automatically, I will go for your advice. I am not aware of any method to do it... Bye Rick ONKELINX, Thierry Thierry.ONKELINX An @inbo.be [EMAIL PROTECTED] Kopie 13.02.2007 15:29 Thema RE: [R] Suddenly Subscript out of bounds You update all packages but not R itself? ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens [EMAIL PROTECTED] Verzonden: dinsdag 13 februari 2007 15:15 Aan: r-help@stat.math.ethz.ch Onderwerp: [R] Suddenly Subscript out of bounds Hello Using R Version 2.3.1 I have setup a cronjob to update packages, which worked successfully almost a year (it was called daily). Basically, it runs like this: Sys.getenv(http_proxy) update.packages(ask=F,repos=http://cran.r-project.org;) (the http_proxy environment variable is set prior to the call). All of a sudden, I started to get this error: Error in inherits(x, factor) : subscript out of bounds I have no clue about what this means. Is factor a buggy package? Clearly, that kind of things can happen when you just update things automatically... Any help with be appreciated! Bye Rick __ 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] Fatigued R
The problem with your code is that it doesn't check for errors. See ?try, ?tryCatch. For example: my.download - function(forloop) { notok - vector() for (i in forloop) { cdaily - try(blpGetData(...)) if (class(cdaily) == try-error) { notok - c(notok, i) } else { #proceed as usual } } notok } forloop - 1:x repeat { ddata - my.download(forloop) forloop - ddata if (length(forloop) == 0) break #no download errors; stop } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Shubha Vishwanath Karanth Sent: Tuesday, February 13, 2007 10:06 AM To: ONKELINX, Thierry; r-help@stat.math.ethz.ch; [EMAIL PROTECTED] Subject: Re: [R] Fatigued R Hi all, thanks for your reply But I have to make one thing clear that there are no errors in programming...I assure that to you, because I have extracted the data many times from the same program... The problem is with the connection of R with Bloomberg, sometimes the data is not fetched at all and so I get the below errors...It is mainly due to some network jam problems and all... Could anyone suggest me how to refresh R, or how to always make sure that the data is downloaded without any errors for each loop? I tried with Sys.sleep() to give some free time to R...but it is not successful always... Could anybody help me out? Thank you, Shubha -Original Message- From: ONKELINX, Thierry [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 13, 2007 7:56 PM To: Shubha Vishwanath Karanth; r-help@stat.math.ethz.ch Subject: RE: [R] Fatigued R Dear Shubha, The error message tells you that the error occurs in the line: merge(d_mer,cdaily) And the problem is that d_mer and cdaily have a different class. It looks as you need to convert cdaily to the correct class (same class as d_mer). Don't forget to use traceback() when debugging your program. You code could use some tweaking. Don't be afraid to add spaces and indentation. That will make you code a lot more readable. I noticed that you have defined some variables within your function (lent, t). This might lead to strange behaviour of your function, as it will use the global variables. Giving a variable the same name as a function (t) is confusing. t[2] and t(2) look very similar but do something very different. Sometimes it pays off to covert for-loop in apply-type functions. Cheers, Thierry -- -- ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Shubha Vishwanath Karanth Verzonden: dinsdag 13 februari 2007 14:51 Aan: Sarah Goslee; r-help@stat.math.ethz.ch Onderwerp: Re: [R] Fatigued R OhkkkI will try to do that now This is my download function... download-function(fil) { con-blpConnect(show.days=show_day, na.action=na_action, periodicity=periodicity) for(i in 1:lent) { Sys.sleep(3) cdaily-blpGetData(con,unique(t[,i]),fil,start=as.chron(as.Dat e(1/1/199 6, %m/%d/%Y)),end=as.chron(as.Date(12/28/2006, %m/%d/%Y))) #Sys.sleep(3) if(!exists(d_mer)) d_mer=cdaily else d_mer=merge(d_mer,cdaily) rm(cdaily) } dat-data.frame(Date=index(d_mer),d_mer) dat$ABCDEFG=NULL path1-paste(D:\\SAS\\Project2\\Daily\\,fil,_root.sas7bdat,sep=) path2-paste(D:\\SAS\\Project2\\Daily\\CODEFILES\\,fil,.sas ,sep=) sasname-paste(x1,fil,',sep=) write.foreign(dat,path1,path2,package=SAS,dataname=sasname) blpDisconnect(con) } for(j in 1:lenf) { fname-paste(D:\\SAS\\Project2\\Daily\\,filename[j],_root.s as7bdat,s ep=) Sys.sleep(600) if(!file.exists(fname)) download(fil=filename[j]) } And lent=58 and lenf=8... 8 text files will be generated in this process if the program would have run properly, and each would be of size 4,000 KB. The error message I get if the program is not run is: Error in dimnames(x) - dn : length of 'dimnames' [2] not equal to array extent In addition: Warning message: Index vectors are of different classes: chron chron dates in: merge(d_mer,cdaily) Please could any one help on this? -Original Message- From: Sarah Goslee [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 13, 2007 7:09 PM To: Shubha Vishwanath Karanth Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Fatigued R Hi Shubha, Perhaps you haven't gotten any help because you
[R] Missing variable in new dataframe for prediction
Hi, I'm using a loop to evaluate several models by taking adjacent variables from my dataframe. When i try to get predictions for new values, i get an error message about a missing variable in my new dataframe. Below is an example adapted from ?gam in mgcv package library(mgcv) set.seed(0) n-400 sig-2 x0 - runif(n, 0, 1) x1 - runif(n, 0, 1) x2 - runif(n, 0, 1) x3 - runif(n, 0, 1) f0 - function(x) 2 * sin(pi * x) f1 - function(x) exp(2 * x) f2 - function(x) 0.2*x^11*(10*(1-x))^6+10*(10*x)^3*(1-x)^10 f3 - function(x) 0*x f - f0(x0) + f1(x1) + f2(x2) e - rnorm(n, 0, sig) y - f + e Mydata-data.frame(y=y,x0=x0,x1=x1,x2=x2,x3=x3) remove(list=c(y,x0,x1,x2,x3)) # Note below the syntax of the 3rd variable required for my loop for (i in 4:5){ b-gam(y~s(x0)+ s(x1)+ ns(Mydata[,i], 3), data=Mydata) newd - data.frame(x0=(0:399)/30,x1=(0:399)/30,x2=(0:399)/30,x3=(0:399)/30) pred - predict.gam(b,newd) } Erreur dans model.frame(formula, rownames, variables, varnames, extras, extranames, : type (list) incorrect pour la variable 'Mydata' De plus : Warning message: not all required variables have been supplied in newdata! in: predict.gam(b, newd) #Defining the name for the variable as in the gam function doesn't solve the problem newd - data.frame(x0=(0:399)/30,x1=(0:399)/30,x2=(0:399)/30,Mydata[,i]=(0:399)/30) Erreur dans model.frame(formula, rownames, variables, varnames, extras, extranames, : type (list) incorrect pour la variable 'Mydata' De plus : Warning message: not all required variables have been supplied in newdata! in: predict.gam(b, newd) How should i define my new dataset to be able to get my predictions ? Thanks in advance O__ Alain Le Tertre c/ /'_ --- Institut de Veille Sanitaire (InVS)/ Département Santé Environnement (*) \(*) -- Responsable de l'unité Systèmes d'Information Statistiques ~~ - 12 rue du val d'Osne 94415 Saint Maurice cedex FRANCE Voice: 33 1 41 79 68 76 Fax: 33 1 41 79 67 68 email: [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] RE2: Suddenly Subscript out of bounds
Roderick, I'm not suggesting that you need a script to update R automatically. I don't think it is possible to do that. I just was wondering why you are so eager to update all the packages daily, but still are working with an outdated version of R. Myself, I tend to check the R lists for new updates on R and it's packages. Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Verzonden: dinsdag 13 februari 2007 18:04 Aan: ONKELINX, Thierry CC: r-help@stat.math.ethz.ch Onderwerp: RE2: [R] Suddenly Subscript out of bounds If you tell me how to update R itself automatically, I will go for your advice. I am not aware of any method to do it... Bye Rick ONKELINX, Thierry Thierry.ONKELINX An @inbo.be [EMAIL PROTECTED] Kopie 13.02.2007 15:29 Thema RE: [R] Suddenly Subscript out of bounds You update all packages but not R itself? ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens [EMAIL PROTECTED] Verzonden: dinsdag 13 februari 2007 15:15 Aan: r-help@stat.math.ethz.ch Onderwerp: [R] Suddenly Subscript out of bounds Hello Using R Version 2.3.1 I have setup a cronjob to update packages, which worked successfully almost a year (it was called daily). Basically, it runs like this: Sys.getenv(http_proxy) update.packages(ask=F,repos=http://cran.r-project.org;) (the http_proxy environment variable is set prior to the call). All of a sudden, I started to get this error: Error in inherits(x, factor) : subscript out of bounds I have no clue about what this means. Is factor a buggy package? Clearly, that kind of things can happen when you just update things automatically... Any help with be appreciated! Bye Rick __ 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] matlab style plotting in R
Hello I was wondering how I can achieve matlab style plotting in R, in the sense that matlab allows you to plot multiple sets of variables within the same x-y axes. plot in R does not seem to cater for this. I tried 'overplot' from the gplots package but this assumes different y axes for the variables. any suggestions would be very appreciated Maria [[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] Missing variable in new dataframe for prediction
The call to library(splines) is missing and also try replacing the line b - ... with fo - as.formula(sprintf(y ~ s(x0) + s(x1) + ns(%s, 3), names(Mydata)[i])) b - do.call(gam, list(fo, data = Mydata)) to dynamically recreate the formula on each iteration of the loop with the correct name, x2 or x3, inserted. On 2/13/07, LE TERTRE Alain [EMAIL PROTECTED] wrote: Hi, I'm using a loop to evaluate several models by taking adjacent variables from my dataframe. When i try to get predictions for new values, i get an error message about a missing variable in my new dataframe. Below is an example adapted from ?gam in mgcv package library(mgcv) set.seed(0) n-400 sig-2 x0 - runif(n, 0, 1) x1 - runif(n, 0, 1) x2 - runif(n, 0, 1) x3 - runif(n, 0, 1) f0 - function(x) 2 * sin(pi * x) f1 - function(x) exp(2 * x) f2 - function(x) 0.2*x^11*(10*(1-x))^6+10*(10*x)^3*(1-x)^10 f3 - function(x) 0*x f - f0(x0) + f1(x1) + f2(x2) e - rnorm(n, 0, sig) y - f + e Mydata-data.frame(y=y,x0=x0,x1=x1,x2=x2,x3=x3) remove(list=c(y,x0,x1,x2,x3)) # Note below the syntax of the 3rd variable required for my loop for (i in 4:5){ b-gam(y~s(x0)+ s(x1)+ ns(Mydata[,i], 3), data=Mydata) newd - data.frame(x0=(0:399)/30,x1=(0:399)/30,x2=(0:399)/30,x3=(0:399)/30) pred - predict.gam(b,newd) } Erreur dans model.frame(formula, rownames, variables, varnames, extras, extranames, : type (list) incorrect pour la variable 'Mydata' De plus : Warning message: not all required variables have been supplied in newdata! in: predict.gam(b, newd) #Defining the name for the variable as in the gam function doesn't solve the problem newd - data.frame(x0=(0:399)/30,x1=(0:399)/30,x2=(0:399)/30,Mydata[,i]=(0:399)/30) Erreur dans model.frame(formula, rownames, variables, varnames, extras, extranames, : type (list) incorrect pour la variable 'Mydata' De plus : Warning message: not all required variables have been supplied in newdata! in: predict.gam(b, newd) How should i define my new dataset to be able to get my predictions ? Thanks in advance O__ Alain Le Tertre c/ /'_ --- Institut de Veille Sanitaire (InVS)/ Département Santé Environnement (*) \(*) -- Responsable de l'unité Systèmes d'Information Statistiques ~~ - 12 rue du val d'Osne 94415 Saint Maurice cedex FRANCE Voice: 33 1 41 79 68 76 Fax: 33 1 41 79 67 68 email: [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] multinomial logistic regression with equality constraints?
Many thanks for this, Jas. I was successfully able to use the revised version of multinomRob, and it satisfies exactly the needs I was looking for. Thanks once again. Best, Roger Jasjeet Singh Sekhon wrote: As we noted earlier and as is clearly stated in the docs, multinomRob is estimating an OVERDISPERSED multinomial model. And in your models here the overdispersion parameter is not identified; you need more observations. Walter pointed out using the print.level trick to get the coefs for the standard MNL model, but when the model the function is actually trying to estimate is not identified, that trick will not work. As I also previously noted, it is a simple matter to change the multinomMLE function to estimate the standard MNL model. Since you don't want to change that file and since nnet's multinom function doesn't have some functionality people need, we'll add a MLEonly function to multinomRob which will allow you to do what you want. We'll post a new version on my webpage later tonight: http://sekhon.berkeley.edu/robust. And after some testing, we'll forward the new version to CRAN. Jas. === Jasjeet S. Sekhon Associate Professor Travers Department of Political Science Survey Research Center UC Berkeley http://sekhon.berkeley.edu/ V: 510-642-9974 F: 617-507-5524 === Roger Levy writes: Walter Mebane wrote: Roger, Error in if (logliklambda loglik) bvec - blambda : missing value where TRUE/FALSE needed In addition: Warning message: NaNs produced in: sqrt(sigma2GN) That message comes from the Newton algorithm (defined in source file multinomMLE.R). It would be better if we bullet-proofed it a bit more. The first thing is to check the data. I don't have the multinomLogis() function, so I can't run your code. Whoops, sorry about that -- I'm putting revised code at the end of the message. But do you really mean for(i in 1:length(choice)) { and dim(counts) - c(length(choice),length(choice)) Should that be for(i in 1:n) { and dim(counts) - c(n, length(choice)) or instead of n, some number m length(choice). As it is it seems to me you have three observations for three categories, which isn't going to work (there are five coefficient parameters, plus sigma for the dispersion). I really did mean for(i in 1:length(choice)) -- once again, the proper code is at the end of this message. Also, I notice that I get the same error with another kind of data, which works for multinom from nnet: library(nnet) library(multinomRob) dtf - data.frame(y1=c(1,1),y2=c(2,1),y3=c(1,2),x=c(0,1)) summary(multinom(as.matrix(dtf[,1:3]) ~ x, data=dtf)) summary(multinomRob(list(y1 ~ 0, y2 ~ x, y3 ~ x), data=dtf,print.level=128)) The call to multinom fits the following coefficients: Coefficients: (Intercept) x y2 0.6933809622 -0.6936052 y3 0.0001928603 0.6928327 but the call to multinomRob gives me the following error: multinomRob(): Grouped MNL Estimation [1] multinomMLE: -loglik initial: 9.48247391895106 Error in if (logliklambda loglik) bvec - blambda : missing value where TRUE/FALSE needed In addition: Warning message: NaNs produced in: sqrt(sigma2GN) Does this shed any light on things? Thanks again, Roger *** set.seed(10) library(multinomRob) multinomLogis - function(vector) { x - exp(vector) z - sum(x) x/z } n - 20 choice - c(A,B,C) intercepts - c(0.5,0.3,0.2) prime.strength - rep(0.4,length(intercepts)) counts - c() for(i in 1:length(choice)) { u - intercepts[1:length(choice)] u[i] - u[i] + prime.strength[i] counts - c(counts,rmultinomial(n = n, pr = multinomLogis(u))) } dim(counts) - c(length(choice),length(choice)) counts - t(counts) row.names(counts) - choice colnames(counts) - choice data - data.frame(Prev.Choice=choice,counts) for(i in 1:length(choice)) { data[[paste(last,choice[i],sep=.)]] - ifelse(data$Prev.Choice==choice[i],1,0) } multinomRob(list(A ~ last.A , B ~ last.B , C ~ last.C - 1 , ), data=data, print.level=128) I obtained this output: Your Model (xvec): A B C (Intercept)/(Intercept)/last.C 1 1 1 last.A/last.B/NA 1 1 0 [1] multinomRob: WARNING. Limited regressor variation... [1] WARNING. ... A regressor has a distinct value for only one observation.
Re: [R] Missing variable in new dataframe for prediction
Actually this simpler replacement for the b - ... line would work just as well: fo - as.formula(sprintf(y ~ s(x0) + s(x1) + ns(%s, 3), names(Mydata)[i])) b - gam(fo, data = Mydata) On 2/13/07, Gabor Grothendieck [EMAIL PROTECTED] wrote: The call to library(splines) is missing and also try replacing the line b - ... with fo - as.formula(sprintf(y ~ s(x0) + s(x1) + ns(%s, 3), names(Mydata)[i])) b - do.call(gam, list(fo, data = Mydata)) to dynamically recreate the formula on each iteration of the loop with the correct name, x2 or x3, inserted. On 2/13/07, LE TERTRE Alain [EMAIL PROTECTED] wrote: Hi, I'm using a loop to evaluate several models by taking adjacent variables from my dataframe. When i try to get predictions for new values, i get an error message about a missing variable in my new dataframe. Below is an example adapted from ?gam in mgcv package library(mgcv) set.seed(0) n-400 sig-2 x0 - runif(n, 0, 1) x1 - runif(n, 0, 1) x2 - runif(n, 0, 1) x3 - runif(n, 0, 1) f0 - function(x) 2 * sin(pi * x) f1 - function(x) exp(2 * x) f2 - function(x) 0.2*x^11*(10*(1-x))^6+10*(10*x)^3*(1-x)^10 f3 - function(x) 0*x f - f0(x0) + f1(x1) + f2(x2) e - rnorm(n, 0, sig) y - f + e Mydata-data.frame(y=y,x0=x0,x1=x1,x2=x2,x3=x3) remove(list=c(y,x0,x1,x2,x3)) # Note below the syntax of the 3rd variable required for my loop for (i in 4:5){ b-gam(y~s(x0)+ s(x1)+ ns(Mydata[,i], 3), data=Mydata) newd - data.frame(x0=(0:399)/30,x1=(0:399)/30,x2=(0:399)/30,x3=(0:399)/30) pred - predict.gam(b,newd) } Erreur dans model.frame(formula, rownames, variables, varnames, extras, extranames, : type (list) incorrect pour la variable 'Mydata' De plus : Warning message: not all required variables have been supplied in newdata! in: predict.gam(b, newd) #Defining the name for the variable as in the gam function doesn't solve the problem newd - data.frame(x0=(0:399)/30,x1=(0:399)/30,x2=(0:399)/30,Mydata[,i]=(0:399)/30) Erreur dans model.frame(formula, rownames, variables, varnames, extras, extranames, : type (list) incorrect pour la variable 'Mydata' De plus : Warning message: not all required variables have been supplied in newdata! in: predict.gam(b, newd) How should i define my new dataset to be able to get my predictions ? Thanks in advance O__ Alain Le Tertre c/ /'_ --- Institut de Veille Sanitaire (InVS)/ Département Santé Environnement (*) \(*) -- Responsable de l'unité Systèmes d'Information Statistiques ~~ - 12 rue du val d'Osne 94415 Saint Maurice cedex FRANCE Voice: 33 1 41 79 68 76 Fax: 33 1 41 79 67 68 email: [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] matlab style plotting in R
Hi Maria, I'm interested in the responses you get. The way I do this is to use par(new=TRUE), which tells R not to clean the frame before plotting the next plot. So, eg ###Overlaid plot op - par(mar = c(5, 4, 4, 5) + 0.1, las = 2) plot(x=1:5,y=rnorm(5)+1:5,type='b',xlab=xlab,ylab=ylab,main=Title) par(new=TRUE) plot(x=1:5,y=rnorm(5),axes=FALSE,ylab=,xlab=,type='b',col=red) axis(4,at=c(-2,-1,0,1,2),labels=c(6,7,8,9,10)) par(las=0) mtext(Other Y,side=4,line=3) The trick is this: if your 2nd set of Y variables are on a different scale than your 1st set of Y-variables, you'll need to transform the second set so that they'll be on the same scale - otherwise they won't show up on the old plot. You'll also, of course, need to back-transform your labels for the 2nd set of Y variables so that they read appropriately. A terrific site for R graphics, with lots of worked examples (including ones similar to the one I just did), is here: http://zoonek2.free.fr/UNIX/48_R/all.html On 2/13/07, Maria Vatapitakapha [EMAIL PROTECTED] wrote: Hello I was wondering how I can achieve matlab style plotting in R, in the sense that matlab allows you to plot multiple sets of variables within the same x-y axes. plot in R does not seem to cater for this. I tried 'overplot' from the gplots package but this assumes different y axes for the variables. any suggestions would be very appreciated Maria [[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. -- Matthew C Keller Postdoctoral Fellow Virginia Institute for Psychiatric and Behavioral Genetics __ 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] matlab style plotting in R [Broadcast]
In traditional R graphics, you can take a look at matplot. You might also want to look at the lattice package. Hope this helps, Matt Wiener -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Maria Vatapitakapha Sent: Tuesday, February 13, 2007 12:20 PM To: r-help@stat.math.ethz.ch Subject: [R] matlab style plotting in R [Broadcast] Hello I was wondering how I can achieve matlab style plotting in R, in the sense that matlab allows you to plot multiple sets of variables within the same x-y axes. plot in R does not seem to cater for this. I tried 'overplot' from the gplots package but this assumes different y axes for the variables. any suggestions would be very appreciated Maria [[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. -- Notice: This e-mail message, together with any attachments,...{{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] matlab style plotting in R
try ?lines ?points On 2/13/07, Maria Vatapitakapha [EMAIL PROTECTED] wrote: Hello I was wondering how I can achieve matlab style plotting in R, in the sense that matlab allows you to plot multiple sets of variables within the same x-y axes. plot in R does not seem to cater for this. I tried 'overplot' from the gplots package but this assumes different y axes for the variables. any suggestions would be very appreciated Maria [[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-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] Advice on visual graph packages
Hey, all. I'm looking for packages that are good at two things 1) Drawing directed graphs (i.e nodes and edges), both with single and double headed arrows, as well as allowing for differences in line width and solid versus dashed. Note: I've tried Rgraphviz here, but have run into some problems (which seem fixable and I may go with it in the end), and it doesn't satisfy need # 2 (which would be ideal if there is a package that does both). 2) Allowing a user to create a directed graph, and have some text object created that can be reprocessed easily reprocessed into a matrix representation, or other representation of my choosing. I've tried dynamicGraph, but it seems buggy, and continually either crashes, behaves very erratically (nodes disappearing when I modify edges), nor is it clear from the UI how one outputs a new graph, nor how one even accesses many graph attributes. This may be my own ignorance on the latter. Do you have any suggestions? Thanks! -Jarrett -- A Quick and (Very) Dirty Guide to Stats in R http://didemnid.ucdavis.edu/rtutorial.html [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] simulating from Langevin distributions
Dear all, I have been looking for a while for ways to simulate from Langevin distributions and I thought I would ask here. I am ok with finding an algorithmic reference, though of course, a R package would be stupendous! Btw, just to clarify, the Langevin distribution with (mu, K), where mu is a vector and K0 the concentration parameter is defined to be: f(x) = exp(K*mu'x) / const where both mu and x are p-variate vectors with norm 1. For p=2, this corresponds to von-Mises (for which algorithms exist, including in R/Splus) while for p=3, I believe it is called the Fisher distribution. I am looking for general p. Can anyone please help in this? Many thanks and best wishes, Ranjan __ 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] Advice on visual graph packages
Also try gplot in the sna package to see if it does what you want. Here are some examples from the r-help archives: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/87003.html http://finzi.psych.upenn.edu/R/Rhelp02a/archive/84442.html On 2/13/07, Jarrett Byrnes [EMAIL PROTECTED] wrote: Hey, all. I'm looking for packages that are good at two things 1) Drawing directed graphs (i.e nodes and edges), both with single and double headed arrows, as well as allowing for differences in line width and solid versus dashed. Note: I've tried Rgraphviz here, but have run into some problems (which seem fixable and I may go with it in the end), and it doesn't satisfy need # 2 (which would be ideal if there is a package that does both). 2) Allowing a user to create a directed graph, and have some text object created that can be reprocessed easily reprocessed into a matrix representation, or other representation of my choosing. I've tried dynamicGraph, but it seems buggy, and continually either crashes, behaves very erratically (nodes disappearing when I modify edges), nor is it clear from the UI how one outputs a new graph, nor how one even accesses many graph attributes. This may be my own ignorance on the latter. Do you have any suggestions? Thanks! -Jarrett -- A Quick and (Very) Dirty Guide to Stats in R http://didemnid.ucdavis.edu/rtutorial.html [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html 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] Advice on visual graph packages
Jarrett, check the gplot function in package SNA and the plot.igraph and tkplot functions in package 'igraph'. SNA's gplot is more flexible, it knows different shapes, edges can be curved, etc, tkplot is interactive if you desire that. It is also easy to convert between the two graph representations of the two packages, see the graph.adjacency and get.adjacency function in igraph. Gabor On Tue, Feb 13, 2007 at 10:11:04AM -0800, Jarrett Byrnes wrote: Hey, all. I'm looking for packages that are good at two things 1) Drawing directed graphs (i.e nodes and edges), both with single and double headed arrows, as well as allowing for differences in line width and solid versus dashed. Note: I've tried Rgraphviz here, but have run into some problems (which seem fixable and I may go with it in the end), and it doesn't satisfy need # 2 (which would be ideal if there is a package that does both). 2) Allowing a user to create a directed graph, and have some text object created that can be reprocessed easily reprocessed into a matrix representation, or other representation of my choosing. I've tried dynamicGraph, but it seems buggy, and continually either crashes, behaves very erratically (nodes disappearing when I modify edges), nor is it clear from the UI how one outputs a new graph, nor how one even accesses many graph attributes. This may be my own ignorance on the latter. Do you have any suggestions? Thanks! -Jarrett -- A Quick and (Very) Dirty Guide to Stats in R http://didemnid.ucdavis.edu/rtutorial.html [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Csardi Gabor [EMAIL PROTECTED]MTA RMKI, ELTE TTK __ 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] isoMDS vs. other non-metric non-R routines
Sorry for not threading: I don't subscribe to this list, and the linking of web browser and email seems to be rudimentary. I don't know what is Minissa. Sounds like a piece of software. What is the method it implements? That is, is it supposed to implement the same method as isoMDS or something else? IsoMDS implements Kruskal's (and Young's and Sheperd's and Torgeson's) NMDS, but there are other methods too. You are supposed to get similar results only with the same method. For instance, there are various definitions of stress, two of them amusingly called stress-1 and stress-2, but there are others. You didn't give much detail about how you used isoMDS. We already discussed the danger of trapping in the starting configuration which you can avoid with trying (several) random starting configurations. Have you used 'tol' (and 'maxit') arguments in isoMDS? The default 'tol' is rather slack, and 'maxit' fairly low, since (speculation) the function was written a long time ago when computer were slow, but if you have something better than 75MHz i486, you can try with other values. I have used isoMDS quite a lot, and I have had good experience. Cheers, Jari Oksanen __ 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] Advice on visual graph packages
You might also want to look at the network package, which includes a plot method for network objects that is pretty flexible. It also enables you to convert a network object into various different matrix reprentations. On 13/02/07, Jarrett Byrnes [EMAIL PROTECTED] wrote: Hey, all. I'm looking for packages that are good at two things 1) Drawing directed graphs (i.e nodes and edges), both with single and double headed arrows, as well as allowing for differences in line width and solid versus dashed. Note: I've tried Rgraphviz here, but have run into some problems (which seem fixable and I may go with it in the end), and it doesn't satisfy need # 2 (which would be ideal if there is a package that does both). 2) Allowing a user to create a directed graph, and have some text object created that can be reprocessed easily reprocessed into a matrix representation, or other representation of my choosing. I've tried dynamicGraph, but it seems buggy, and continually either crashes, behaves very erratically (nodes disappearing when I modify edges), nor is it clear from the UI how one outputs a new graph, nor how one even accesses many graph attributes. This may be my own ignorance on the latter. Do you have any suggestions? Thanks! -Jarrett -- A Quick and (Very) Dirty Guide to Stats in R http://didemnid.ucdavis.edu/rtutorial.html [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html 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] matlab style plotting in R
There are many ways if I understood what you indend to do: example data: toplot-data.frame(x=c(1:5,1:5),y=rnorm(10),sbs=c(rep(a,5),rep(b,5))) 1st with plot itself: plot(y~x,data=toplot,type=n) lines(y~x,data=subset(toplot,sbs==a),type=b,pch=4,col=blue) lines(y~x,data=subset(toplot,sbs==b),type=b,pch=2,col=red) 2nd with xyplot out of the lattice package: library(lattice) xyplot(y~x,groups=sbs,data=toplot,pch=c(2,4),main=Title) to see some variants. My advice is to look at a good documentation at the homepage (contributed documentation) or book ... Maria Vatapitakapha wrote: Hello I was wondering how I can achieve matlab style plotting in R, in the sense that matlab allows you to plot multiple sets of variables within the same x-y axes. plot in R does not seem to cater for this. I tried 'overplot' from the gplots package but this assumes different y axes for the variables. any suggestions would be very appreciated Maria [[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-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] Computing stats on common parts of multiple dataframes
Folks, I have three dataframes storing some information about two currency pairs, as follows: R a EUR-USD NOK-SEK 1.231.33 1.221.43 1.261.42 1.241.50 1.211.36 1.261.60 1.291.44 1.251.36 1.271.39 1.231.48 1.221.26 1.241.29 1.271.57 1.211.55 1.231.35 1.251.41 1.251.30 1.231.11 1.281.37 1.271.23 R b EUR-USD NOK-SEK 1.231.22 1.211.36 1.281.61 1.231.34 1.211.22 R d EUR-USD NOK-SEK 1.271.39 1.231.48 1.221.26 1.241.29 1.271.57 1.211.55 1.231.35 1.251.41 1.251.33 1.231.11 1.281.37 1.271.23 The twist is that these entries correspond to dates where the *last* rows in each frame are today's entries, and so on backwards in time. I would like to create a matrix of medians (a median for each row and for each currency pair), but only for those rows where all dataframes have entries. My answer in this case should look like: EUR-USD NOK-SEK 1.251.41 1.251.33 1.231.11 1.281.37 1.271.23 where the last EUR-USD entry = median(1.27, 1.21, 1.27), etc. Notice that the output is of the same dimensions as the smallest dataframe (in this case 'b'). I can do it in a clumsy fashion by first obtaining the number of rows in the smallest matrix, chopping off the top rows of the other matrices to reduce them this size, then doing a for-loop across each currency pair, row-wise, to create a 3-vector which I then apply median() on. Surely there's a better way to do this? Please advise. Thanks, Murali Menon _ Valentines Day -- Shop for gifts that spell L-O-V-E at MSN Shopping __ 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] Fatigued R
I can't be sure what is happening to Shubhak, but I know that the Bloomberg server bbcomm.exe throws unhandled exceptions in a unreproducable and uncatchable way, somewhere in their tcp code. It is one of the big frustrations for me in my work. Shubhak, I think you will just have to look carefully at what is returned, as Bogdan suggested in general, and take action based on that. It may be that try[Catch] will catch some problems, but other times, you will just get something that is not right, but you can tell since it has the wrong structure. The bbcomm.exe essentially crashes and gets restarted automatically, so the next time you try to get something, it works; so sleeping after an error is a good idea. HTH, David David L. Reiner Rho Trading Securities, LLC Chicago IL 60605 312-362-4963 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of bogdan romocea Sent: Tuesday, February 13, 2007 10:49 AM To: [EMAIL PROTECTED] Cc: r-help Subject: Re: [R] Fatigued R The problem with your code is that it doesn't check for errors. See ?try, ?tryCatch. For example: my.download - function(forloop) { notok - vector() for (i in forloop) { cdaily - try(blpGetData(...)) if (class(cdaily) == try-error) { notok - c(notok, i) } else { #proceed as usual } } notok } forloop - 1:x repeat { ddata - my.download(forloop) forloop - ddata if (length(forloop) == 0) break #no download errors; stop } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Shubha Vishwanath Karanth Sent: Tuesday, February 13, 2007 10:06 AM To: ONKELINX, Thierry; r-help@stat.math.ethz.ch; [EMAIL PROTECTED] Subject: Re: [R] Fatigued R Hi all, thanks for your reply But I have to make one thing clear that there are no errors in programming...I assure that to you, because I have extracted the data many times from the same program... The problem is with the connection of R with Bloomberg, sometimes the data is not fetched at all and so I get the below errors...It is mainly due to some network jam problems and all... Could anyone suggest me how to refresh R, or how to always make sure that the data is downloaded without any errors for each loop? I tried with Sys.sleep() to give some free time to R...but it is not successful always... Could anybody help me out? Thank you, Shubha -Original Message- From: ONKELINX, Thierry [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 13, 2007 7:56 PM To: Shubha Vishwanath Karanth; r-help@stat.math.ethz.ch Subject: RE: [R] Fatigued R Dear Shubha, The error message tells you that the error occurs in the line: merge(d_mer,cdaily) And the problem is that d_mer and cdaily have a different class. It looks as you need to convert cdaily to the correct class (same class as d_mer). Don't forget to use traceback() when debugging your program. You code could use some tweaking. Don't be afraid to add spaces and indentation. That will make you code a lot more readable. I noticed that you have defined some variables within your function (lent, t). This might lead to strange behaviour of your function, as it will use the global variables. Giving a variable the same name as a function (t) is confusing. t[2] and t(2) look very similar but do something very different. Sometimes it pays off to covert for-loop in apply-type functions. Cheers, Thierry -- -- ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Shubha Vishwanath Karanth Verzonden: dinsdag 13 februari 2007 14:51 Aan: Sarah Goslee; r-help@stat.math.ethz.ch Onderwerp: Re: [R] Fatigued R OhkkkI will try to do that now This is my download function... download-function(fil) { con-blpConnect(show.days=show_day, na.action=na_action, periodicity=periodicity) for(i in 1:lent) { Sys.sleep(3) cdaily-blpGetData(con,unique(t[,i]),fil,start=as.chron(as.Dat e(1/1/199 6, %m/%d/%Y)),end=as.chron(as.Date(12/28/2006, %m/%d/%Y))) #Sys.sleep(3) if(!exists(d_mer)) d_mer=cdaily else d_mer=merge(d_mer,cdaily) rm(cdaily) } dat-data.frame(Date=index(d_mer),d_mer) dat$ABCDEFG=NULL path1-paste(D:\\SAS\\Project2\\Daily\\,fil,_root.sas7bdat,sep=)
Re: [R] simulating from Langevin distributions
Hi Ranjan, I think that the following would work: library(MASS) rlangevin - function(n, mu, K) { q - length(mu) norm.sim - mvrnorm(n, mu=mu, Sigma=diag(1/K, q)) cp - apply(norm.sim, 1, function(x) sqrt(crossprod(x))) sweep(norm.sim, 1, cp, FUN=/) } mu - runif(7) mu - mu / sqrt(crossprod(mu)) K - 1.2 ylang - rlangevin(n=10, mu=mu, K=K) apply(ylang,1,crossprod) [1] 1 1 1 1 1 1 1 1 1 1 I hope that this helps. 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ranjan Maitra Sent: Tuesday, February 13, 2007 1:04 PM To: r-help@stat.math.ethz.ch Subject: [R] simulating from Langevin distributions Dear all, I have been looking for a while for ways to simulate from Langevin distributions and I thought I would ask here. I am ok with finding an algorithmic reference, though of course, a R package would be stupendous! Btw, just to clarify, the Langevin distribution with (mu, K), where mu is a vector and K0 the concentration parameter is defined to be: f(x) = exp(K*mu'x) / const where both mu and x are p-variate vectors with norm 1. For p=2, this corresponds to von-Mises (for which algorithms exist, including in R/Splus) while for p=3, I believe it is called the Fisher distribution. I am looking for general p. Can anyone please help in this? Many thanks and best wishes, Ranjan __ 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] Polygon triangulation?
On 2/13/2007 10:10 AM, Roger Bivand wrote: On Tue, 13 Feb 2007, ONKELINX, Thierry wrote: Have you tried the tri-package? Perhaps the GPC C library used in the gpclib package, and in PBSmapping will get closer - it partitions polygons into tristrip sets. That would be just what I need. Thanks! Duncan Murdoch Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Duncan Murdoch Verzonden: dinsdag 13 februari 2007 15:27 Aan: r-help@stat.math.ethz.ch Onderwerp: [R] Polygon triangulation? Can anyone point me to a package that contains code to triangulate a polygon? This is easy if the polygon is convex, but tricky if not. One algorithm to do it is due to Meister, and is described here: www.math.gatech.edu/~randall/AlgsF06/planartri.pdf 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-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] adf test: trend, no drift - rep: invalid 'times' argument
Hello! I am applying the ADF.test function from package uroot to a time series of data. When I apply the full test, incorporating drift and trend terms, the regressor estimate of the drift term is not significantly different from zero. So I apply the test to a model without drift term, with deterministic trend only. But then I always get the following error: summary(ADF.test(wts=ts(seasons$summer, start=1850, frequency=1), itsd=c(0,1,c(0)), regvar=0, selectlags=list(mode=c(1,2,3 Error in rep(NA, ncol(table)) : invalid 'times' argument Error in summary(ADF.test(wts = ts(seasons$summer, start = 1850, frequency = 1), : error in evaluating the argument 'object' in selecting a method for function 'summary' I have no idea why this error occurs. Any suggestions will be appreciated. Regards, Martin - http://auto-motor-und-sport.bg/ С бензин в кръвта! __ 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] Multidimensional Integration over arbitrary sets
Hi, I need to integrate a 2D function over range where the limits depend on the other e.g integrate f(x,y)=x*y over {x,0,1} and {y,x,1}. i.e \int_0^1 \int_x^1 xy dydx I checked adapt but it doesn't seem to help here. Are they any packages for this sort of thing? I tried RSitesearch but couldn't find the answer to this. Many thanks for you help. Regards Saptarshi Saptarshi Guha | [EMAIL PROTECTED] | http://www.stat.purdue.edu/~sguha [[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] Questions about results from PCAproj for robust principal component analysis
Hi. I have been looking at the PCAproj function in package pcaPP (R 2.4.1) for robust principal components, and I'm trying to interpret the results. I started with a data matrix of dimensions RxC (R is the number of rows / observations, C the number of columns / variables). PCAproj returns a list of class princomp, similar to the output of the function princomp. In a case where I can run princomp, I would get the following, from executing dmpca = princomp(datamatrix) : - the vector, sdev, of length C, contains the standard deviations of the components in order by descending value; the squares are the eigenvalues of the covariance matrix - the matrix, loadings, has dimension CxC, and the columns are the eigenvectors of the covariance matrix, in the same order as the sdev vector; the columns are orthonormal: sum(dmpca$loadings[,i]*dmpca$loadings[,j]) = 1 if i == j, ~ 0 if i != j - the vector, center, of length C, contains the means of the variable columns in the original data matrix, in the same order as the original columns - the vector, scale, of length C, contains the scalings applied to each variable, in the same order as the original columns - n.obs contains the number of observations used in the computation; this number equals R when there is no missing data - the matrix, scores, has dimension RxC, and it can be thought of as the projection of the eigenvector matrix, loadings, back onto the original data; these columns of scores are the principal components. princomp typically removes the mean, so the formula is: dmpca$scores = t(t(datamatrix) - dmpca$center)%*%dmpca$loadings and apply(dmpca$scores,2,mean) returns a length C vector of (effectively) zeroes; also the principal components (columns of scores) are orthogonal (but not orthonormal): sum(dmpca$scores[,i]*dmpca$scores[,j]) ~ 0 if i != j, 0 if i == j - call contains the function call, in this case princomp(x = datamatrix) That is all as it should be. In my case R C, which produces singular results for standard PCA, but robust methods, like PCAproj, are designed to handle this. Also, I had de-meaned the data beforehand, so apply(datamatrix,2,mean) produces a length C vector of (effectively) zeroes. I ran the following: dmpcaprj=PCAproj(datamatrix,k=4,CalcMethod=sphere,update=TRUE) to get the first four robust components. When I look at the princomp object returned as dmpcaprj, some of the results are just what I expect. For example, - dmpcaprj$loadings has dimensions Cx4, as expected, and the first four eigenvectors of the (robust) covariance matrix are orthonormal: sum(dmpcaprj$loadings[,i]*dmpcaprj$loadings[,j]) = 1 if i == j, ~ 0 if i != j - dmpcaprj$sdev contains the square roots of the four corresponding eigenvalues. - dmpcaprj$n.obs equals R. - dmpcaprj$scores has dimensions Rx4, as it should. HOWEVER, the columns of dmpcaprj$scores are neither de-meaned nor orthogonal. So, apply(dmpcaprj$scores,2,mean) is a non-zero vector, and sum(dmpcaprj$scores[,i]*dmpcaprj$scores[,j]) != 0 if i != j, 0 if i == j ALSO, - dmpcaprj$scale is in this case a vector of all 1's, as expected. But the length is C, not R. - dmpcaprj$center is a vector of length C, not R, and the entries are not equal to either apply(datamatrix,1,mean) or apply(datamatrix,2,mean); I can't figure out where they came from. One interesting thing is that the columns of the Rx4 matrix, dmpcaprj$scores - datamatrix%*%dmpcaprj$loadings are all identically constant vectors, such that each row equals apply(dmpcaprj$scores,2,mean), since apply(datamatrix%*%dmpcaprj$loadings,2,mean) is a length four vector of (effectively) zeroes, but I can't interpret the values of these means of dmpcaprj$scores. Can anyone please explain to me what is happening with the scores, scale, and center parts of the PCAproj results? Thanks! -- TMK -- 212-460-5430home 917-656-5351cell __ 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] Computing stats on common parts of multiple dataframes
Murali - I've come up with something that might with work, with gratutious use of the *apply functions. See ?apply, ?lappy, and ?mapply for how this would work. Basically, just set my.list equal to a list of data.frames you would like included. I made this to work with matrices first, so it does use as.matrix() in my function. Also, this could be turned into a general function so that you could specify a different function other than median. #Make my.list equal to a list of dataframes you want my.list - list(df1,df2) #What's the shortest? minrow - min(sapply(my.list,nrow)) #Chop all to the shortest tmp - lapply(my.list, function(x) x[(nrow(x)-(minrow-1)):nrow(x),]) #Do the computation, could change median to mean, or a user defined #function matrix(apply(mapply([,lapply(tmp,as.matrix), MoreArgs=list(1:(minrow*2))), 1, median), ncol=2) HTH, whether or not this is any better than your for loop solution is left up to you. Erik Murali Menon wrote: Folks, I have three dataframes storing some information about two currency pairs, as follows: R a EUR-USDNOK-SEK 1.231.33 1.221.43 1.261.42 1.241.50 1.211.36 1.261.60 1.291.44 1.251.36 1.271.39 1.231.48 1.221.26 1.241.29 1.271.57 1.211.55 1.231.35 1.251.41 1.251.30 1.231.11 1.281.37 1.271.23 R b EUR-USDNOK-SEK 1.231.22 1.211.36 1.281.61 1.231.34 1.211.22 R d EUR-USDNOK-SEK 1.271.39 1.231.48 1.221.26 1.241.29 1.271.57 1.211.55 1.231.35 1.251.41 1.251.33 1.231.11 1.281.37 1.271.23 The twist is that these entries correspond to dates where the *last* rows in each frame are today's entries, and so on backwards in time. I would like to create a matrix of medians (a median for each row and for each currency pair), but only for those rows where all dataframes have entries. My answer in this case should look like: EUR-USDNOK-SEK 1.251.41 1.251.33 1.231.11 1.281.37 1.271.23 where the last EUR-USD entry = median(1.27, 1.21, 1.27), etc. Notice that the output is of the same dimensions as the smallest dataframe (in this case 'b'). I can do it in a clumsy fashion by first obtaining the number of rows in the smallest matrix, chopping off the top rows of the other matrices to reduce them this size, then doing a for-loop across each currency pair, row-wise, to create a 3-vector which I then apply median() on. Surely there's a better way to do this? Please advise. Thanks, Murali Menon _ Valentine’s Day -- Shop for gifts that spell L-O-V-E at MSN Shopping __ 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] make check failure, internet.Rout.fail, Error in strsplit
I just happen to also have a MacOS 10.4 machine, but when I tried from there, I still got Content-length. Anyway, I am fairly certain that headers received from web servers would not be modified by the receiving machine or anything in-between. I suspect that the machine at www.stats.ox.ac.uk, even though we see it as the same IP, must be doing some sort of load balancing, probably on the basis of our IP addresses, and sending our requests to different servers. If this is correct, then it would seem that the test code for this part of the make test should be modified to do the grep in a case-insensitive way, or at the very least to support Content-length. I guess the next thing to do would be to submit a bug report. Thanks a lot for helping me look into this problem, --Paul On 2/13/07, Charilaos Skiadas [EMAIL PROTECTED] wrote: On Feb 13, 2007, at 11:16 AM, Paul Lynch wrote: Thanks for giving it a try. It is very odd that you got Content-Length when I am getting Content-length. I just tried curl (I had been using telnet to port 80) and I got the same (error causing) length result: Perhaps we are hitting different web servers? I ran nslookup on www.stats.ox.ac.uk, and it appears to be an alias for web2.stats.ox.ac.uk. Is that the machine you are getting? I get: Server: 192.200.129.190 Address:192.200.129.190#53 Non-authoritative answer: www.stats.ox.ac.uk canonical name = web2.stats.ox.ac.uk. Name: web2.stats.ox.ac.uk Address: 163.1.210.2 What happens if you run curl against web2, i.e.: curl --head http://web2.stats.ox.ac.uk/pub/datasets/csb/ch11b.dat ? (I get Content-length). I get Content-Length. I'm on MacOSX 10.4.8, don't know if that makes any difference. Thanks, --Paul Haris __ 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] SAS, SPSS Product Comparison Table
Hi All, Thanks to lots of good ideas from R-helpers, I've polished up the table and posted it here: http://oit.utk.edu/scc/RforSASSPSSproducts.pdf To be consistent with its product orientation, I dropped mixed models (it's not a separate product in either SAS or SPSS). I also added SAS/QC and links to similar pages such as CRAN's Task Views. People (especially Patrick Burns) sent the following list of topics that are not SAS or SPSS products, but which might make good additions to Task Views: resampling techniques: boot, coin (and many others) report generation: R (the Sweave function) neural networks: nnet, AMORE, neural, grnnR finance: Rmetrics, portfolio (and several more) designed experiments: BHH2, blockrand, conf.design, spc Bayesian: BRugs, R2WinBUGS, bayesm (and many more) circular statistics: CircStats, circular robustness: R and many packages medical imaging: DICOM, AnalyzeFMRI, fmri functional data analysis: fda, MFDA Robust spatial statistics: spatial, spatstat, pastecs, fields, geoR (and more) Markov chain Monte Carlo: MCMCpack, mcmc meta-analysis: meta graphical models: mimR, ggm Mixed Models: lmer, nlme, lme4 mixture models: mixreg, mixtools pharmacokinetics: PK, PKfit, PKtools musicology: tuneR sudoku: sudoku Frank Harrell made an excellent suggestion that this be a page at the R-wiki. It's unlikely that any one person would know all these areas so it might work out if everyone could edit the sections they know. If anyone wants to put it up there, let me know I'll be happy to send it to you in any form you like. I expect once a table format was established editing it would be easy. I acknowledged everyone who wrote at the bottom of the table. If I forgot anyone, it was an oversight. Drop me a line I'll put you on there. Thanks again to everyone for all the help! Cheers, Bob = Bob Muenchen (pronounced Min'-chen), Manager Statistical Consulting Center U of TN Office of Information Technology 200 Stokely Management Center, Knoxville, TN 37996-0520 Voice: (865) 974-5230 FAX: (865) 974-4810 Email: [EMAIL PROTECTED] Web: http://oit.utk.edu/scc, News: http://listserv.utk.edu/archives/statnews.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Multidimensional Integration over arbitrary sets
Hi, By defining your function appropriately (e.g. using indicator functions), you can make adapt work: myfunc - function(x) { x[1]*x[2] * (x[1] = x[2]) } # Exact answer is 1/8 library(adapt) adapt(2, lo=c(0,0), up=c(1,1), functn=myfunc) value relerr minpts lenwrk ifail 0.1250612 0.00999505459071123 0 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Saptarshi Guha Sent: Tuesday, February 13, 2007 3:34 PM To: R-Help Subject: [R] Multidimensional Integration over arbitrary sets Hi, I need to integrate a 2D function over range where the limits depend on the other e.g integrate f(x,y)=x*y over {x,0,1} and {y,x,1}. i.e \int_0^1 \int_x^1 xy dydx I checked adapt but it doesn't seem to help here. Are they any packages for this sort of thing? I tried RSitesearch but couldn't find the answer to this. Many thanks for you help. Regards Saptarshi Saptarshi Guha | [EMAIL PROTECTED] | http://www.stat.purdue.edu/~sguha [[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-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-pkgs] New version of rattle released
A new version of Rattle (2.1.123), a Gnome-base GUI for data mining, written copmletely in R, and available on GNU/Linux, Unix, Mac OSX, and MS/Windows, has been released to CRAN. There has been quite a lot of activity since the last update, including: Transform: Now include basic imputation of missing values. More to follow. Models: Move to using ada for boosting. Better missing value handling for random forest Use arules package for market basket analysis Add more model visualisations Export: RPart PMML export completed. PMML export has been separated out to its own package (pmml) Complete change log available at http://rattle.togaware.com/changes.html Rattle mailing list at http://groups.google.com/group/rattle-users Regards, Graham ___ R-packages mailing list R-packages@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-packages __ 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] nls: missing value or an infinity (Error in numericDeriv) and singular gradient matrixError in nlsModel
Hi, I am a non-expert user of R. I am essaying the fit of two different functions to my data, but I receive two different error messages. I suppose I have two different problems here... But, of which nature? In the first instance I did try with some different starting values for the parameters, but without success. If anyone could suggest a sensible way to proceed to solve these I would be really thankful! Daniela *** Details on data and formulas: polcurve=read.table(polcurve.txt,header=TRUE) polcurve distfath 1 1 0.138908965 2 2 0.113768871 3 3 0.114361753 4 4 0.051065765 5 5 0.095787946 6 6 0.123601131 7 7 0.117340746 8 8 0.054049434 9 9 0.112000962 10 10 0.074843028 11 11 0.064735196 12 12 0.098210497 13 13 0.093786895 14 14 0.033752379 15 15 0.038961039 16 16 0.023048216 17 17 0.010018243 18 18 0.007177034 19 19 0.003787879 20 20 0.0 21 21 0.0 #Exponential power function s=nls(fath~((b^2)/(a^2))*exp((-dist/a)^b),polcurve) Error in numericDeriv(form[[3]], names(ind), env) : Missing value or an infinity produced when evaluating the model In addition: Warning message: No starting values specified for some parameters. Intializing 'b', 'a' to '1.'. Consider specifying 'start' or using a selfStart model in: nls(fath ~ ((b^2)/(a^2)) * exp((-dist/a)^b), polcurve) #Geometric function s=nls(fath~((b-1)*(b-2)/a)*((1+dist/a)^-b),polcurve) Error in nlsModel(formula, mf, start, wts) : singular gradient matrix at initial parameter estimates In addition: Warning message: No starting values specified for some parameters. Intializing 'b', 'a' to '1.'. Consider specifying 'start' or using a selfStart model in: nls(fath ~ ((b - 1) * (b - 2)/a) * ((1 + dist/a)^-b), Daniela Salvini Ph.D. student University of Copenhagen, Faculty of Life Sciences, Centre for Forest and Landscape Hørsholm Kongevej 11 2970 Hørsholm, Denmark e-mail: [EMAIL PROTECTED] Tel.: (+45)35281639 / 35281645 Fax.: (+45)35281517 __ 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] Computing stats on common parts of multiple dataframes
Suppose our data frames are called DF1, DF2 and DF3. Then find the least number of rows, n, among them. Create a list, DFs, of the last n rows of the data frames and another list, mats, which is the same but in which each component is a matrix. Create a parallel median function, pmedian, analogous to pmax and mapply it to the matrices. Finally replace that back into a data frame. n - min(sapply(L, nrow)) DFs - lapply(list(DF1, DF2, DF3), tail, n) mats - lapply(DFs, as.matrix) pmedian - function(...) median(c(...)) medians - do.call(mapply, c(pmedian, mats)) replace(DFs[[1]], TRUE, medians) On 2/13/07, Murali Menon [EMAIL PROTECTED] wrote: Folks, I have three dataframes storing some information about two currency pairs, as follows: R a EUR-USD NOK-SEK 1.231.33 1.221.43 1.261.42 1.241.50 1.211.36 1.261.60 1.291.44 1.251.36 1.271.39 1.231.48 1.221.26 1.241.29 1.271.57 1.211.55 1.231.35 1.251.41 1.251.30 1.231.11 1.281.37 1.271.23 R b EUR-USD NOK-SEK 1.231.22 1.211.36 1.281.61 1.231.34 1.211.22 R d EUR-USD NOK-SEK 1.271.39 1.231.48 1.221.26 1.241.29 1.271.57 1.211.55 1.231.35 1.251.41 1.251.33 1.231.11 1.281.37 1.271.23 The twist is that these entries correspond to dates where the *last* rows in each frame are today's entries, and so on backwards in time. I would like to create a matrix of medians (a median for each row and for each currency pair), but only for those rows where all dataframes have entries. My answer in this case should look like: EUR-USD NOK-SEK 1.251.41 1.251.33 1.231.11 1.281.37 1.271.23 where the last EUR-USD entry = median(1.27, 1.21, 1.27), etc. Notice that the output is of the same dimensions as the smallest dataframe (in this case 'b'). I can do it in a clumsy fashion by first obtaining the number of rows in the smallest matrix, chopping off the top rows of the other matrices to reduce them this size, then doing a for-loop across each currency pair, row-wise, to create a 3-vector which I then apply median() on. Surely there's a better way to do this? Please advise. Thanks, Murali Menon _ Valentine's Day -- Shop for gifts that spell L-O-V-E at MSN Shopping __ 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] Computing stats on common parts of multiple dataframes
Sorry, I switched variable names part way through. Here it is again: DFs - list(DF1, DF2, DF3) n - min(sapply(DFs, nrow)) DFs - lapply(DFs, tail, n) mats - lapply(DFs, as.matrix) pmedian - function(...) median(c(...)) medians - do.call(mapply, c(pmedian, mats)) replace(DFs[[1]], TRUE, medians) On 2/13/07, Gabor Grothendieck [EMAIL PROTECTED] wrote: Suppose our data frames are called DF1, DF2 and DF3. Then find the least number of rows, n, among them. Create a list, DFs, of the last n rows of the data frames and another list, mats, which is the same but in which each component is a matrix. Create a parallel median function, pmedian, analogous to pmax and mapply it to the matrices. Finally replace that back into a data frame. n - min(sapply(L, nrow)) DFs - lapply(list(DF1, DF2, DF3), tail, n) mats - lapply(DFs, as.matrix) pmedian - function(...) median(c(...)) medians - do.call(mapply, c(pmedian, mats)) replace(DFs[[1]], TRUE, medians) On 2/13/07, Murali Menon [EMAIL PROTECTED] wrote: Folks, I have three dataframes storing some information about two currency pairs, as follows: R a EUR-USD NOK-SEK 1.231.33 1.221.43 1.261.42 1.241.50 1.211.36 1.261.60 1.291.44 1.251.36 1.271.39 1.231.48 1.221.26 1.241.29 1.271.57 1.211.55 1.231.35 1.251.41 1.251.30 1.231.11 1.281.37 1.271.23 R b EUR-USD NOK-SEK 1.231.22 1.211.36 1.281.61 1.231.34 1.211.22 R d EUR-USD NOK-SEK 1.271.39 1.231.48 1.221.26 1.241.29 1.271.57 1.211.55 1.231.35 1.251.41 1.251.33 1.231.11 1.281.37 1.271.23 The twist is that these entries correspond to dates where the *last* rows in each frame are today's entries, and so on backwards in time. I would like to create a matrix of medians (a median for each row and for each currency pair), but only for those rows where all dataframes have entries. My answer in this case should look like: EUR-USD NOK-SEK 1.251.41 1.251.33 1.231.11 1.281.37 1.271.23 where the last EUR-USD entry = median(1.27, 1.21, 1.27), etc. Notice that the output is of the same dimensions as the smallest dataframe (in this case 'b'). I can do it in a clumsy fashion by first obtaining the number of rows in the smallest matrix, chopping off the top rows of the other matrices to reduce them this size, then doing a for-loop across each currency pair, row-wise, to create a 3-vector which I then apply median() on. Surely there's a better way to do this? Please advise. Thanks, Murali Menon _ Valentine's Day -- Shop for gifts that spell L-O-V-E at MSN Shopping __ 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] nls: missing value or an infinity (Error in numericDeriv) andsingular gradient matrixError in nlsModel
Hi Daniela, Please read the error message from nls. The problem is with the start values for the parameters a and b. You haven't specified any, so it uses default values of a=1 and b=1, which may not be very good. So, you should specify good start values, if you have a reasonable idea of what they should be. If you don't, then you could try selfStart, as the error message tells you to do. 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Daniela Salvini Sent: Tuesday, February 13, 2007 4:09 PM To: r-help@stat.math.ethz.ch Subject: [R] nls: missing value or an infinity (Error in numericDeriv) andsingular gradient matrixError in nlsModel Hi, I am a non-expert user of R. I am essaying the fit of two different functions to my data, but I receive two different error messages. I suppose I have two different problems here... But, of which nature? In the first instance I did try with some different starting values for the parameters, but without success. If anyone could suggest a sensible way to proceed to solve these I would be really thankful! Daniela *** Details on data and formulas: polcurve=read.table(polcurve.txt,header=TRUE) polcurve distfath 1 1 0.138908965 2 2 0.113768871 3 3 0.114361753 4 4 0.051065765 5 5 0.095787946 6 6 0.123601131 7 7 0.117340746 8 8 0.054049434 9 9 0.112000962 10 10 0.074843028 11 11 0.064735196 12 12 0.098210497 13 13 0.093786895 14 14 0.033752379 15 15 0.038961039 16 16 0.023048216 17 17 0.010018243 18 18 0.007177034 19 19 0.003787879 20 20 0.0 21 21 0.0 #Exponential power function s=nls(fath~((b^2)/(a^2))*exp((-dist/a)^b),polcurve) Error in numericDeriv(form[[3]], names(ind), env) : Missing value or an infinity produced when evaluating the model In addition: Warning message: No starting values specified for some parameters. Intializing 'b', 'a' to '1.'. Consider specifying 'start' or using a selfStart model in: nls(fath ~ ((b^2)/(a^2)) * exp((-dist/a)^b), polcurve) #Geometric function s=nls(fath~((b-1)*(b-2)/a)*((1+dist/a)^-b),polcurve) Error in nlsModel(formula, mf, start, wts) : singular gradient matrix at initial parameter estimates In addition: Warning message: No starting values specified for some parameters. Intializing 'b', 'a' to '1.'. Consider specifying 'start' or using a selfStart model in: nls(fath ~ ((b - 1) * (b - 2)/a) * ((1 + dist/a)^-b), Daniela Salvini Ph.D. student University of Copenhagen, Faculty of Life Sciences, Centre for Forest and Landscape Hørsholm Kongevej 11 2970 Hørsholm, Denmark e-mail: [EMAIL PROTECTED] Tel.: (+45)35281639 / 35281645 Fax.: (+45)35281517 __ 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] Matrix manipulation
Hi, let's say I have this A = matrix(c(1, 2, 4), nrow=1) colnames(A)=c(YOO1, YOO2, YOO3) # ie # YOO1 YOO2 YOO3 #[1,]124 HELLO - NULL HELLO$YOO1=BOO HELLO$YOO2=BOO HELLO$YOO3=HOO and I want a matrix that will sum my categorization.. how can I do it efficiently without any loop? #ie BOO HOO #[1,] 3 4 Thanks a lot! -- View this message in context: http://www.nabble.com/Matrix-manipulation-tf3223616.html#a8953806 Sent from the R help mailing list archive at Nabble.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.
Re: [R] isoMDS vs. other non-metric non-R routines
Thanks for your message. I don't know what is Minissa. Sounds like a piece of software. What is the method it implements? That is, is it supposed to implement the same method as isoMDS or something else? IsoMDS implements Kruskal's (and Young's and Sheperd's and Torgeson's) NMDS, but there are other methods too. You are supposed to get similar results only with the same method. For instance, there are various definitions of stress, two of them amusingly called stress-1 and stress-2, but there are others. Yes, Minissa uses Kruskal's NMDS and stress1, so results should be comparable. You didn't give much detail about how you used isoMDS. We already discussed the danger of trapping in the starting configuration which you can avoid with trying (several) random starting configurations. Have you used 'tol' (and 'maxit') arguments in isoMDS? The default 'tol' is rather slack, and 'maxit' fairly low, since (speculation) the function was written a long time ago when computer were slow, but if you have something better than 75MHz i486, you can try with other values. Cheers, Jari Oksanen This was my initial call: mds - isoMDS(dist, y = cmdscale(dist, k = 2), k=2, tol = 1e-3, maxit = 500) I played around a little bit with tol and maxit (adding some zeros...) and increased the number of dimensions, but it did not change the results significantly. Using initMDS did not improve the result either. Unfortunately, my data set is too large to be displayed here. Any other ideas? My stress value is still 1.5 as much as in other implementations of NMDS. Cheers Phil __ 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] Matrix manipulation
Hi, let's say I have this A = matrix(c(1, 2, 4), nrow=1) colnames(A)=c(YOO1, YOO2, YOO3) # ie # YOO1 YOO2 YOO3 #[1,]124 HELLO - NULL HELLO$YOO1=BOO HELLO$YOO2=BOO HELLO$YOO3=HOO and I want a matrix that will sum my categorization.. how can I do it efficiently without any loop? #ie BOO HOO #[1,] 3 4 Thanks a lot! -- View this message in context: http://www.nabble.com/Matrix-manipulation-tf3223618.html#a8953808 Sent from the R help mailing list archive at Nabble.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.
Re: [R] get.hist.quote problem yahoo
Rene Braeckman writes: I had the same problem some time ago. Below is a function that I picked up on the web somewhere (can't remember where; may have been a newsletter). It's based on the tseries function but the difference is that this function produces a data frame with a column containing the dates of the quotes, instead of a time series object. I had to replace %d-%b-%y by %Y-%m-%d to make it work, probably as you stated because the format was changed by Yahoo. This issue should be taken care of now by a new release of tseries I put out two days ago. -k Hope this helps. Rene # -- # df.get.hist.quote() function # # Based on code by A. Trapletti (package tseries) # # The main difference is that this function produces a data frame with # a column containing the dates of the quotes, instead of a time series # object. df.get.hist.quote - function (instrument = ibm, start, end, quote = c(Open,High, Low, Close,Volume), provider = yahoo, method = auto) { if (missing(start)) start - 1970-01-02 if (missing(end)) end - format(Sys.time() - 86400, %Y-%m-%d) provider - match.arg(provider) start - as.POSIXct(start, tz = GMT) end - as.POSIXct(end, tz = GMT) if (provider == yahoo) { url - paste(http://chart.yahoo.com/table.csv?s=;, instrument, format(start, a=%mb=%dc=%Y), format(end, d=%me=%df=%Y), g=dq=qy=0z=, instrument, x=.csv, sep = ) destfile - tempfile() status - download.file(url, destfile, method = method) if (status != 0) { unlink(destfile) stop(paste(download error, status, status)) } status - scan(destfile, , n = 1, sep = \n, quiet = TRUE) if (substring(status, 1, 2) == No) { unlink(destfile) stop(paste(No data available for, instrument)) } x - read.table(destfile, header = TRUE, sep = ,) unlink(destfile) nser - pmatch(quote, names(x)) if (any(is.na(nser))) stop(This quote is not available) n - nrow(x) lct - Sys.getlocale(LC_TIME) Sys.setlocale(LC_TIME, C) on.exit(Sys.setlocale(LC_TIME, lct)) dat - gsub( , 0, as.character(x[, 1])) dat - as.POSIXct(strptime(dat, %Y-%m-%d), tz = GMT) if (dat[n] != start) cat(format(dat[n], time series starts %Y-%m-%d\n)) if (dat[1] != end) cat(format(dat[1], time series ends %Y-%m-%d\n)) return(data.frame(cbind(Date=I(format(dat[n:1],%Y-%m-%d)),x[n:1,nser]),row .names=1:n)) } else stop(Provider not implemented) } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Daniele Amberti Sent: Friday, February 09, 2007 5:22 AM To: r-help Subject: [R] get.hist.quote problem yahoo I have functions using get.hist.quote() from library tseries. It seems that something changed (yahoo) and function get broken. try with a simple get.hist.quote('IBM') and let me kow if for someone it is still working. I get this error: Error in if (!quiet dat[n] != start) cat(format(dat[n], time series starts %Y-%m-%d\n)) : missing value where TRUE/FALSE needed Looking at the code it seems that before the format of dates in yahoo's cv file was not iso. Now it is iso standard year-month-day Anyone get the same problem? -- Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom http://click.libero.it/infostrada9feb07 __ 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] simulating from Langevin distributions
Thanks to Ravi Varadhan for providing the solution. I guess the answer is that if X is MVN with mean mu and dispersion matrix given by I/K, then X/norm(X) is Langevin with the required parameters. A reference for this is Watson's Statistics on Spheres. Many thanks again and best wishes. Ranjan On Tue, 13 Feb 2007 14:44:08 -0500 Ravi Varadhan [EMAIL PROTECTED] wrote: Hi Ranjan, I think that the following would work: library(MASS) rlangevin - function(n, mu, K) { q - length(mu) norm.sim - mvrnorm(n, mu=mu, Sigma=diag(1/K, q)) cp - apply(norm.sim, 1, function(x) sqrt(crossprod(x))) sweep(norm.sim, 1, cp, FUN=/) } mu - runif(7) mu - mu / sqrt(crossprod(mu)) K - 1.2 ylang - rlangevin(n=10, mu=mu, K=K) apply(ylang,1,crossprod) [1] 1 1 1 1 1 1 1 1 1 1 I hope that this helps. 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ranjan Maitra Sent: Tuesday, February 13, 2007 1:04 PM To: r-help@stat.math.ethz.ch Subject: [R] simulating from Langevin distributions Dear all, I have been looking for a while for ways to simulate from Langevin distributions and I thought I would ask here. I am ok with finding an algorithmic reference, though of course, a R package would be stupendous! Btw, just to clarify, the Langevin distribution with (mu, K), where mu is a vector and K0 the concentration parameter is defined to be: f(x) = exp(K*mu'x) / const where both mu and x are p-variate vectors with norm 1. For p=2, this corresponds to von-Mises (for which algorithms exist, including in R/Splus) while for p=3, I believe it is called the Fisher distribution. I am looking for general p. Can anyone please help in this? Many thanks and best wishes, Ranjan __ 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] Multiple comparisons
Dear list, I have to do an ANOVA analysis with one fixed effect A and one random effect SUBJECT. TO do this I used aov in the form aov.m1 - aov(depvar ~ A + Error(SUBJECT/(A))); My question is if I obtain significant differences within the strata, does it make any sense to make multiple comparisons in order to know what levels of the factor are significant?. I asked this because I get an error when I try TukeyHSD(aov.m1), and I am not sure if this is correct. thanks Pablo Hoffmann __ 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] errors when installing new packages
Dear all, I met a problem when installing new packages on R, my system is linux fedora 6.0, the following is output. please help me. Thanks. install.packages('lars') --- Please select a CRAN mirror for use in this session --- Loading Tcl/Tk interface ... done trying URL 'http://www.stathy.com/cran/src/contrib/lars_0.9-5.tar.gz' Content type 'application/x-tar' length 188248 bytes opened URL == downloaded 183Kb * Installing *source* package 'lars' ... ** libs gfortran -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -c delcol.f -o delcol.o make: gfortran: Command not found make: *** [delcol.o] Error 127 ERROR: compilation failed for package 'lars' ** Removing '/usr/lib/R/library/lars' The downloaded packages are in /tmp/RtmpxYqqFS/downloaded_packages Warning message: installation of package 'lars' had non-zero exit status in: install.packages(lars) Get your own web address. __ 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] to loosenes
Hi, Save over 50% on your medication http://www.ledrx .com Remove space in the above link month will affect you, with reference to your personal chart, she snapped, sounding much more like Professor McGonagall than her usual airy-fairy self. I want it ready to hand in next Monday, and no excuses! __ 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] Advice on visual graph packages
Hi Jarrett, would the coercion methods for the graph class, provided by the package of the same name at Bioconductor be useful for doing what you want? This is the same class that also Rgraphviz works on. Try library(graph) example(graphNEL-class) as(gR, matrix) class ? graph class ? graphNEL ? toGXL There is a rich sets of methods for setting and accessing node and edge attributes, and it is straightforward R to convert into any other representation you like. See the vignette Attributes for Graph Objects. I am looking at version = 1.13.6 of the package as I write this, Best wishes -- -- Wolfgang Huber EBI/EMBL Cambridge UK http://www.ebi.ac.uk/huber Hey, all. I'm looking for packages that are good at two things 1) Drawing directed graphs (i.e nodes and edges), both with single and double headed arrows, as well as allowing for differences in line width and solid versus dashed. Note: I've tried Rgraphviz here, but have run into some problems (which seem fixable and I may go with it in the end), and it doesn't satisfy need # 2 (which would be ideal if there is a package that does both). 2) Allowing a user to create a directed graph, and have some text object created that can be reprocessed easily reprocessed into a matrix representation, or other representation of my choosing. I've tried dynamicGraph, but it seems buggy, and continually either crashes, behaves very erratically (nodes disappearing when I modify edges), nor is it clear from the UI how one outputs a new graph, nor how one even accesses many graph attributes. This may be my own ignorance on the latter. Do you have any suggestions? Thanks! -Jarrett __ 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] Matrix manipulation
Hi, let's say I have this A = matrix(c(1, 2, 4), nrow=1) colnames(A)=c(YOO1, YOO2, YOO3) Why do you need A to be a matrix and not simply a vector? # ie # YOO1 YOO2 YOO3 #[1,]124 HELLO - NULL HELLO$YOO1=BOO HELLO$YOO2=BOO HELLO$YOO3=HOO Why do you need HELLO to be a list and not simply a character vector? and I want a matrix that will sum my categorization.. how can I do it efficiently without any loop? #ie BOO HOO #[1,] 3 4 Anyway, here is a solution: x - tapply(A, match(unlist(HELLO), unique(unlist(HELLO))), sum) names(x) - unique(unlist(HELLO)) x HTH, Giovanni -- Giovanni Petris [EMAIL PROTECTED] Associate Professor Department of Mathematical Sciences University of Arkansas - Fayetteville, AR 72701 Ph: (479) 575-6324, 575-8630 (fax) http://definetti.uark.edu/~gpetris/ __ 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] Hierarchical ANOVA
Romain, Look for info on mixed models. In R you do this either with the library nlme or lme4. A good starting point is an article by Doug Bates in Rnews http://cran.r-project.org/doc/Rnews/Rnews_2005-1.pdf Joris [EMAIL PROTECTED] wrote on 13/02/2007 17:16:41: Hello, Does somebody could help me in the computation(formulation) of a hierarchical ANOVA using linear model in R? I'm working in a population biology study of an endangered species. My aim is to see if I have effects of Density of individuals/m2 on several measured plants fitness traits. As independent variables I have: Humidity (continuous) Nutritive substance (continuous) LUX (continuous) Density of individuals/m2 (continuous) Population (categorical) Year (categorical) I want to test the 4 continous variables with Population as error term. And the Population, the Year and interaction term, with the error of Population x Year. Thank you for any help, best regards. Romain Mayor __ 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] Multidimensional Integration over arbitrary sets
Hi, Thanks! That should do it. Saptarshi Guha | [EMAIL PROTECTED] | http://www.stat.purdue.edu/~sguha On Feb 13, 2007, at 3:56 PM, Ravi Varadhan wrote: Hi, By defining your function appropriately (e.g. using indicator functions), you can make adapt work: myfunc - function(x) { x[1]*x[2] * (x[1] = x[2]) } # Exact answer is 1/8 library(adapt) adapt(2, lo=c(0,0), up=c(1,1), functn=myfunc) value relerr minpts lenwrk ifail 0.1250612 0.00999505459071123 0 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Saptarshi Guha Sent: Tuesday, February 13, 2007 3:34 PM To: R-Help Subject: [R] Multidimensional Integration over arbitrary sets Hi, I need to integrate a 2D function over range where the limits depend on the other e.g integrate f(x,y)=x*y over {x,0,1} and {y,x,1}. i.e \int_0^1 \int_x^1 xy dydx I checked adapt but it doesn't seem to help here. Are they any packages for this sort of thing? I tried RSitesearch but couldn't find the answer to this. Many thanks for you help. Regards Saptarshi Saptarshi Guha | [EMAIL PROTECTED] | http://www.stat.purdue.edu/~sguha [[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-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] errors when installing new packages
Hello Ying, This is really a Fedora Core 6 question. But anyway, it appears that you do not have gfortran which comes in the appropriate development package installed. Assuming you use yum, you find out the RPM using the following yum provides gfortran which will give you the RPM which contains the binary for gfortran. gcc-gfortran 4.1.1-51.fc6 If yum says this is installed, then your path is not set right. Otherwise, go ahead and install using yum install gcc-gfortran as root or with sudo privileges. HTH. Many thanks and best wishes, Ranjan On Tue, 13 Feb 2007 14:47:51 -0800 (PST) YI ZHANG [EMAIL PROTECTED] wrote: Dear all, I met a problem when installing new packages on R, my system is linux fedora 6.0, the following is output. please help me. Thanks. install.packages('lars') --- Please select a CRAN mirror for use in this session --- Loading Tcl/Tk interface ... done trying URL 'http://www.stathy.com/cran/src/contrib/lars_0.9-5.tar.gz' Content type 'application/x-tar' length 188248 bytes opened URL == downloaded 183Kb * Installing *source* package 'lars' ... ** libs gfortran -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -c delcol.f -o delcol.o make: gfortran: Command not found make: *** [delcol.o] Error 127 ERROR: compilation failed for package 'lars' ** Removing '/usr/lib/R/library/lars' The downloaded packages are in /tmp/RtmpxYqqFS/downloaded_packages Warning message: installation of package 'lars' had non-zero exit status in: install.packages(lars) Get your own web address. __ 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)
Hello All I am using R to find the impact of ignoring clustering, when indicated by these tests, on bias, variance and inference of estimates of interest, including population totals and regression coefficients. But when U have used the apVar function using the command test.lme1$apVar to find the var-cov matrix I got the follwing error Non-positive definite approximate variance-covariance I think the problem was with my data which contain the following two columns m - 250 g - as.factor(rep(1:m,each=10)) y - rnorm(10*m) test - data.frame(cbind(g,y)) the lme model used was test.lme1 - lme (y~1, data = test, random = ~1| g) This error affects the t-statistic value, which was NA for more than 240 value of the 250 values which I expect to have. Some times all t-stat values are NA and sometimes I don't have the NA result at all. I'll send you all of the simulation program which I've used. I hope you can help to solve this problem Thanks LOAI PhD student University of Wollongong Australia __ 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 tryCatch
Henrik, thank you for the reference. Can you please tell me why the following does not work? vec=c(hdfhjfd,jdhfhjfg)# non-existent file names catch=function(vec){ tryCatch({ ans =NULL;err=NULL; for (i in vec) { source(i) ans=c(ans,i) } }, interrupt=function(ex){print(ex)}, error=function(er){ print(er) cat(i,\n) err=c(err,i) }, finally={ cat(finish) } ) #tryCatch } catch(vec) # throws an error after the first file and stops there while I want it to go through the list and accumulate the nonexistent filenames in err. Thank you Stephen Henrik Bengtsson wrote: Hi, google R tryCatch example and you'll find: http://www.maths.lth.se/help/R/ExceptionHandlingInR/ Hope this helps Henrik On 2/13/07, Stephen Bond [EMAIL PROTECTED] wrote: Henrik, I had looked at tryCatch before posting the question and asked the question because the help file was not adequate for me. Could you pls provide a sample code of try{ try code} catch(error){catch code} let's say you have a vector of local file names and want to source them encapsulating in a tryCatch to avoid the skipping of all good file names after a bad file name. thank you stephen Henrik Bengtsson wrote: See ?tryCatch. /Henrik On 2/12/07, Stephen Bond [EMAIL PROTECTED] wrote: Could smb please help with try-catch encapsulating a function for downloading. Let's say I have a character vector of symbols and want to download each one and surround by try and catch to be safe # get.hist.quote() is in library(tseries), but the question does not depend on it, I could be sourcing local files instead ans=null;error=null; for ( sym in sym.vec){ try(ans=cbind(ans,get.hist.quote(sym,start=start))) #accumulate in a zoo matrix catch(theurlerror){error=c(error,sym)} #accumulate failed symbols } I know the code above does not work, but it conveys the idea. tryCatch help page says it is similar to Java try-catch, but I know how to do a try-catch in Java and still can't do it in R. Thank you very much. stephen __ 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] lattice graphics and source()
Hi, I am trying the lattice graphics in R. Let's say, such a little experiment in file myprog.r: f - function(){ x - 1:10 y - x^2 xyplot(y ~ x) } f() Then I run the program: source(myprog.r) but nothing happens. Manully run f() at the command line: f() then the figure is shown. This seems to be a bug only associated with lattice graphics, the old style plots do not exibit these behavior. Dongfeng Li __ 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] lattice graphics and source()
On Tue, 2007-02-13 at 16:44 -0800, Dongfeng LI wrote: Hi, I am trying the lattice graphics in R. Let's say, such a little experiment in file myprog.r: f - function(){ x - 1:10 y - x^2 xyplot(y ~ x) } f() Then I run the program: source(myprog.r) but nothing happens. Manully run f() at the command line: f() then the figure is shown. This seems to be a bug only associated with lattice graphics, the old style plots do not exibit these behavior. See the following FAQ: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f 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] model diagnostics for logistic regression
Greetings, I am using both the lrm() {Design} and glm( , family=binomial()) to perform a a logisitic regression in R. Apart from the typical summary() methods, what other methods of diagnosing logistic regression models does R provide? i.e. plotting an 'lm' object, etc. Secondly, is there any facility to calculate the R^{2)_{L} as suggested by Menard in Applied Logistic Regression Analysis (2002) ? Any thought would be greatly appreciated. Cheers, -- Dylan Beaudette Soils and Biogeochemistry Graduate Group University of California at Davis 530.754.7341 __ 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] Character size of labels in heatmap
I am using the heatmap.2 function and passing (...,xlab = label1, ylab = label2, cexRow = 0.7, cexCol = 0.7) I have even set cex.lab, cex.axis, cex to 0.7; but in the plot, label1 and label2 don't seem to scale down. Any help would be appreciated. Cheers! Harshal [[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] help with tryCatch
Put the for loop outside the tryCatch(). /H On 2/13/07, Stephen Bond [EMAIL PROTECTED] wrote: Henrik, thank you for the reference. Can you please tell me why the following does not work? vec=c(hdfhjfd,jdhfhjfg)# non-existent file names catch=function(vec){ tryCatch({ ans =NULL;err=NULL; for (i in vec) { source(i) ans=c(ans,i) } }, interrupt=function(ex){print(ex)}, error=function(er){ print(er) cat(i,\n) err=c(err,i) }, finally={ cat(finish) } ) #tryCatch } catch(vec) # throws an error after the first file and stops there while I want it to go through the list and accumulate the nonexistent filenames in err. Thank you Stephen Henrik Bengtsson wrote: Hi, google R tryCatch example and you'll find: http://www.maths.lth.se/help/R/ExceptionHandlingInR/ Hope this helps Henrik On 2/13/07, Stephen Bond [EMAIL PROTECTED] wrote: Henrik, I had looked at tryCatch before posting the question and asked the question because the help file was not adequate for me. Could you pls provide a sample code of try{ try code} catch(error){catch code} let's say you have a vector of local file names and want to source them encapsulating in a tryCatch to avoid the skipping of all good file names after a bad file name. thank you stephen Henrik Bengtsson wrote: See ?tryCatch. /Henrik On 2/12/07, Stephen Bond [EMAIL PROTECTED] wrote: Could smb please help with try-catch encapsulating a function for downloading. Let's say I have a character vector of symbols and want to download each one and surround by try and catch to be safe # get.hist.quote() is in library(tseries), but the question does not depend on it, I could be sourcing local files instead ans=null;error=null; for ( sym in sym.vec){ try(ans=cbind(ans,get.hist.quote(sym,start=start))) #accumulate in a zoo matrix catch(theurlerror){error=c(error,sym)} #accumulate failed symbols } I know the code above does not work, but it conveys the idea. tryCatch help page says it is similar to Java try-catch, but I know how to do a try-catch in Java and still can't do it in R. Thank you very much. stephen __ 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] help with tryCatch
To be more precise, put the tryCatch() only around the code causing the problem, i.e. around source(). /H On 2/13/07, Henrik Bengtsson [EMAIL PROTECTED] wrote: Put the for loop outside the tryCatch(). /H On 2/13/07, Stephen Bond [EMAIL PROTECTED] wrote: Henrik, thank you for the reference. Can you please tell me why the following does not work? vec=c(hdfhjfd,jdhfhjfg)# non-existent file names catch=function(vec){ tryCatch({ ans =NULL;err=NULL; for (i in vec) { source(i) ans=c(ans,i) } }, interrupt=function(ex){print(ex)}, error=function(er){ print(er) cat(i,\n) err=c(err,i) }, finally={ cat(finish) } ) #tryCatch } catch(vec) # throws an error after the first file and stops there while I want it to go through the list and accumulate the nonexistent filenames in err. Thank you Stephen Henrik Bengtsson wrote: Hi, google R tryCatch example and you'll find: http://www.maths.lth.se/help/R/ExceptionHandlingInR/ Hope this helps Henrik On 2/13/07, Stephen Bond [EMAIL PROTECTED] wrote: Henrik, I had looked at tryCatch before posting the question and asked the question because the help file was not adequate for me. Could you pls provide a sample code of try{ try code} catch(error){catch code} let's say you have a vector of local file names and want to source them encapsulating in a tryCatch to avoid the skipping of all good file names after a bad file name. thank you stephen Henrik Bengtsson wrote: See ?tryCatch. /Henrik On 2/12/07, Stephen Bond [EMAIL PROTECTED] wrote: Could smb please help with try-catch encapsulating a function for downloading. Let's say I have a character vector of symbols and want to download each one and surround by try and catch to be safe # get.hist.quote() is in library(tseries), but the question does not depend on it, I could be sourcing local files instead ans=null;error=null; for ( sym in sym.vec){ try(ans=cbind(ans,get.hist.quote(sym,start=start))) #accumulate in a zoo matrix catch(theurlerror){error=c(error,sym)} #accumulate failed symbols } I know the code above does not work, but it conveys the idea. tryCatch help page says it is similar to Java try-catch, but I know how to do a try-catch in Java and still can't do it in R. Thank you very much. stephen __ 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] model diagnostics for logistic regression
Dylan Beaudette wrote: Greetings, I am using both the lrm() {Design} and glm( , family=binomial()) to perform a a logisitic regression in R. Apart from the typical summary() methods, what other methods of diagnosing logistic regression models does R provide? i.e. plotting an 'lm' object, etc. The best way of checking fit in a lrm is to do directed regression tests (e.g. extend linear effects into regression splines; interactions). An omnibus test is in residuals.lrm as is partial residual plots. Secondly, is there any facility to calculate the R^{2)_{L} as suggested by Menard in Applied Logistic Regression Analysis (2002) ? Don't know that paper but lrm has various indexes including Nagelkerke-Maddala R^2. Frank Any thought would be greatly appreciated. Cheers, -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ 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] linear coefficient combination stderr?
dear r-experts---I have scrounged around in google (searching r-help) for the really obvious, but failed. could someone please point me to whatever function computes the standard error of a linear combination of the coefficients? m=lm( y ~ x1 + x2 + x3 ); t.stat= (coef(m)[2]+coef(m)[3])) / mystery.function( m, x2 + x3 ); obviously, this does not work, but hopefully explains my intent. quick pointer appreciated. regards, /iaw __ 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] nested model: lme, aov and LSMeans
I'm working with a nested model (mixed). I have four factors: Patients, Tissue, sex, and tissue_stage. Totally I have 10 patients, for each patient, there are 2 tissues (Cancer vs. Normal). I think Tissue and sex are fixed. Patient is nested in sex,Tissue is nested in patient, and tissue_stage is nested in Tissue. I tried aov and lme as the following, aov(gene ~ tissue + gender + patients%in%gender + stage%in%tissue lme(gene ~ tissue + gender, random = list(patients = ~1 , stage = ~ 1)) I got results from aov, but I got error message from lme which is false convergence (8). so I could not compare the results of aov with lme. Could anybody tell me whether I use the correct command? How can I get LSMeans for Cancer vs. Normal in R ( I know it is easy in SAS)? Thanks, Shirley __ 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] Legend function
Dear Sir Lengend add a bix containing plot discription in the existing plot. Is there any function which decribe the lines in a plot outside the existing plot? I have also a question related to following statement. In this statement * is used for plot discription. If we have plotted type=o of plot then what pch is to be used. legend(30,3.5, c(Fuel,Smoothed Fuel), pch=* , lty=c(0,1)) Please Help in this regard AMINA SHAHZADI Department of Statistics GC University Lahore, Pakistan. Email: [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Can a data.frame column contain lists/arrays?
I'd like to have a data.frame structured something like the following: d - data.frame ( x=list( c(1,2), c(5,2), c(9,1) ), y=c( 1, -1, -1) ) The reason is this: 'd' is the training data for a machine learning algorithm. d$x is the independent data, and d$y is the dependent data. In general my machine learning code will work where each element of d$x is a vector of one or more real numbers. So for instance, the same code should work when d$x[1] = 42, or when d$x[1] = (42, 3, 5). All that matters is that all element within d$x are lists/vectors of the same length. Does anyone know if/how I can get a data.frame set up like that? You certainly can, although it requires a little work. A data.frame is a list of vectors, each of the same length, and a list is a type of vector. I use this structure fairly often in my own work, and find it quite useful. However, the data.frame and as.data.frame functions try to be helpful at converting lists to regular columns so you must first create your data.frame and then add the column which is a list: df - data.frame(a=1:2) df$b - list(1:5, 6:10) df a b 1 1 1, 2, 3, 4, 5 2 2 6, 7, 8, 9, 10 str(df) 'data.frame': 2 obs. of 2 variables: $ a: int 1 2 $ b:List of 2 ..$ : int 1 2 3 4 5 ..$ : int 6 7 8 9 10 but data.frame(a=1:2, b = list(1:5, 6:10)) Error in data.frame(a = 1:2, b = list(1:5, 6:10)) : arguments imply differing number of rows: 2, 5 Note that it is possible to create structures like this which do not print, but still contain valid objects: df$b - list(lm(mpg~wt, data=mtcars), lm(mpg~vs, data=mtcars)) df Error in unlist(x, recursive, use.names) : argument not a list summary(df[1,2]) Length Class Mode [1,] 12 lmlist summary(df[1,2][[1]]) Call: lm(formula = mpg ~ wt, data = mtcars) Residuals: Min 1Q Median 3Q Max -4.5432 -2.3647 -0.1252 1.4096 6.8727 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 37.2851 1.8776 19.858 2e-16 *** wt -5.3445 0.5591 -9.559 1.29e-10 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 3.046 on 30 degrees of freedom Multiple R-Squared: 0.7528, Adjusted R-squared: 0.7446 F-statistic: 91.38 on 1 and 30 DF, p-value: 1.294e-10 There are some functions in the reshape package, in particular stamp, which make this a bit easier for particular types of data. Regards, Hadley __ 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] linear coefficient combination stderr?
Try the esticon function in the doBy package. Regards Søren Fra: [EMAIL PROTECTED] på vegne af ivo welch Sendt: on 14-02-2007 04:21 Til: r-help Emne: [R] linear coefficient combination stderr? dear r-experts---I have scrounged around in google (searching r-help) for the really obvious, but failed. could someone please point me to whatever function computes the standard error of a linear combination of the coefficients? m=lm( y ~ x1 + x2 + x3 ); t.stat= (coef(m)[2]+coef(m)[3])) / mystery.function( m, x2 + x3 ); obviously, this does not work, but hopefully explains my intent. quick pointer appreciated. regards, /iaw __ 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] Fatigued R
Hi all, So, is there any method to make bbcomm.exe to sleep for sometime...? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 14, 2007 12:42 AM To: bogdan romocea; Shubha Vishwanath Karanth Cc: r-help Subject: RE: [R] Fatigued R I can't be sure what is happening to Shubhak, but I know that the Bloomberg server bbcomm.exe throws unhandled exceptions in a unreproducable and uncatchable way, somewhere in their tcp code. It is one of the big frustrations for me in my work. Shubhak, I think you will just have to look carefully at what is returned, as Bogdan suggested in general, and take action based on that. It may be that try[Catch] will catch some problems, but other times, you will just get something that is not right, but you can tell since it has the wrong structure. The bbcomm.exe essentially crashes and gets restarted automatically, so the next time you try to get something, it works; so sleeping after an error is a good idea. HTH, David David L. Reiner Rho Trading Securities, LLC Chicago IL 60605 312-362-4963 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of bogdan romocea Sent: Tuesday, February 13, 2007 10:49 AM To: [EMAIL PROTECTED] Cc: r-help Subject: Re: [R] Fatigued R The problem with your code is that it doesn't check for errors. See ?try, ?tryCatch. For example: my.download - function(forloop) { notok - vector() for (i in forloop) { cdaily - try(blpGetData(...)) if (class(cdaily) == try-error) { notok - c(notok, i) } else { #proceed as usual } } notok } forloop - 1:x repeat { ddata - my.download(forloop) forloop - ddata if (length(forloop) == 0) break #no download errors; stop } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Shubha Vishwanath Karanth Sent: Tuesday, February 13, 2007 10:06 AM To: ONKELINX, Thierry; r-help@stat.math.ethz.ch; [EMAIL PROTECTED] Subject: Re: [R] Fatigued R Hi all, thanks for your reply But I have to make one thing clear that there are no errors in programming...I assure that to you, because I have extracted the data many times from the same program... The problem is with the connection of R with Bloomberg, sometimes the data is not fetched at all and so I get the below errors...It is mainly due to some network jam problems and all... Could anyone suggest me how to refresh R, or how to always make sure that the data is downloaded without any errors for each loop? I tried with Sys.sleep() to give some free time to R...but it is not successful always... Could anybody help me out? Thank you, Shubha -Original Message- From: ONKELINX, Thierry [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 13, 2007 7:56 PM To: Shubha Vishwanath Karanth; r-help@stat.math.ethz.ch Subject: RE: [R] Fatigued R Dear Shubha, The error message tells you that the error occurs in the line: merge(d_mer,cdaily) And the problem is that d_mer and cdaily have a different class. It looks as you need to convert cdaily to the correct class (same class as d_mer). Don't forget to use traceback() when debugging your program. You code could use some tweaking. Don't be afraid to add spaces and indentation. That will make you code a lot more readable. I noticed that you have defined some variables within your function (lent, t). This might lead to strange behaviour of your function, as it will use the global variables. Giving a variable the same name as a function (t) is confusing. t[2] and t(2) look very similar but do something very different. Sometimes it pays off to covert for-loop in apply-type functions. Cheers, Thierry -- -- ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Shubha Vishwanath Karanth Verzonden: dinsdag 13 februari 2007 14:51 Aan: Sarah Goslee; r-help@stat.math.ethz.ch Onderwerp: Re: [R] Fatigued R OhkkkI will try to do that now This is my download function... download-function(fil) { con-blpConnect(show.days=show_day, na.action=na_action, periodicity=periodicity) for(i in 1:lent) { Sys.sleep(3) cdaily-blpGetData(con,unique(t[,i]),fil,start=as.chron(as.Dat e(1/1/199 6,