[R] NNet value and convergence
Hi, I'm using the R nnet package and have a few simple (?) questions. What is the value that is output after every 10 iterations during the training of the network and how is it calculated? # weights: 177 initial value 506.134586 iter 10 value 128.222774 iter 20 value 95.399782 iter 30 value 87.184564 ... Is the value the error, if not, is there any way to see the error values during training? Also, how does the network decide when it has converged? Thanks Hannah [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] FW: error predicting values from the LME
HI all, I might add some more information in order to possibly solve my problem. I'm really stuck and no obvious solutions do the trick. I'm using R 1.7.1 on Windows 2000 with the packages regurarly updated. I'm using hypothetical data constructed as a pseudo population conforming to a certain Var-Cov structure. I might add that just predict(level2) works. But when I add the new dataset it doesn't. Following a suggestion I even tried refactoring of the grouping variable (inter) after I created the subset. It didn't work. I have no other factor variables in the model. I really have got no clue what could be wrong. There is a sample from my data: dnNew Grouped Data: y ~ v11 + v21 + v22 + v23 | inter v11 v21 v22 v23inter 4 5.55186635 5.6620022 24.18033 5.003409 1 13 2.03852426 5.6620022 24.18033 5.003409 1 15 2.19825772 7.5676798 31.03986 4.746891 2 16 4.51368278 7.5676798 31.03986 4.746891 2 18 3.35322702 7.5676798 31.03986 4.746891 2 19 2.46414346 7.5676798 31.03986 4.746891 2 20 2.66670834 7.5676798 31.03986 4.746891 2 and this is the model: level2 Linear mixed-effects model fit by REML Data: d.n.gr.2 Log-restricted-likelihood: -533.0011 Fixed: model$fixed (Intercept) v11 v21 v22 v23 v11:v21 3.205519074 0.298941539 -0.017743958 0.016007280 -0.410760471 0.002700954 v11:v22 v11:v23 -0.003680952 -0.018005717 Random effects: Formula: ~v11 | inter Structure: General positive-definite, Log-Cholesky parametrization StdDev Corr (Intercept) 0.385620605 (Intr) v11 0.003147431 -0.048 Residual 0.450012367 Number of Observations: 729 Number of Groups: 50 If this give you some more insight to my problem. I would reallly appreciate any suggestion. Thanks Andrej -Original Message- From: Andrej Kveder [mailto:[EMAIL PROTECTED] Sent: Monday, September 29, 2003 7:05 PM To: R-Help Subject: predicting values from the LME Dear listers, I experinced a problem prdicting the values using the LME with multilevel data. I have NA's in my dependent variable and the model is fitted only on the completed cases. I want to estimate the predicted values for the rest of the data (those cases with missing dep. variable) I extracted a subset from the original file containing the variables used in the model as well as the second level indicator. I used the following command p-predict(level2,newdata=d.n.new,level=0:1) where level2 is my LME model. But, I get the following error: Error in eval(expr, envir, enclos) : 1 argument passed to $ which requires 2. I tried with omitting the level specification (which is 0 by default) and I transformed the new data to be groupedData with no luck. I have tried the example from the Pinheiro,Bates book and it works - mine doesn't. Does anybody have an idea what could be wrong? Thanks for all the suggestions. Andrej _ Andrej Kveder, M.A. researcher Institute of Medical Sciences SRS SASA; Novi trg 2, SI-1000 Ljubljana, Slovenia phone: +386 1 47 06 440 fax: +386 1 42 61 493 [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] shared object
p hu wrote: Dear R-helper, I have one question for creating shared objects (C code) on Unix. Since there is a set of softwares (such as Rtools, Perl, etc.) to be dowloaded for generating shared objects on windows, I am wondering whether I need to install a set of these kind of softwares to generating shared objects on unix. Assume I have a c code called foo.c, I just simly typed R CMD SHLIB foo.c it tells me that 'make' not found. Therefore could you tell me what software I need to install for generating shared objects on unix??? Well, at least make and some compiler, of course. For details see Appendix Essential and useful other programs in the R Installation and Administration manual. Uwe Ligges Thanks Hu - Post your free ad now! Yahoo! Canada Personals [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] shared object
Hu == p hu [EMAIL PROTECTED] on Mon, 29 Sep 2003 23:38:24 -0400 (EDT) writes: Hu Dear R-helper, I have one question for creating shared Hu objects (C code) on Unix. Since there is a set of Hu softwares (such as Rtools, Perl, etc.) to be dowloaded Hu for generating shared objects on windows, I am wondering Hu whether I need to install a set of these kind of Hu softwares to generating shared objects on unix. What is unix here? There are many flavors of Unix around the most famous nowadays is Linux which I guess you are *not* using. Tell us what uname -a gives (or other relevant information about your Unix). Hu Assume I have a c code called foo.c, I just simly typed Hu R CMD SHLIB foo.c Hu it tells me that 'make' not found. which I guess is because make is not in your PATH, while it still exists on your computer / file server. Hu Therefore could you tell me what software I need to Hu install for generating shared objects on unix??? Do you have a system administrator (person!) for your unix environment? If yes, ask her/him ! If no, you probably should learn quite a bit more about your unix by reading a basic introduction... Martin Maechler [EMAIL PROTECTED] http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO C16Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] using identify() together with plot () and pixmap()
Dear R users I have a two-dimensional array, whose values I want to plot, using the pixmapGrey class. Plotting works fine, and now I would like to be able to identify some of the points in the plot using identify(). But I get the following message while pressing the left mouse button: plot(pixmapGrey(fmri.vtc[,,slice,volume])) identify(fmri.vtc[,,slice,volume]) warning: no point with 0.25 inches pressing the right mouse button I get: numeric(0) what is the problem here and how can I solve it? many thanks for your help Cheers! Christoph -- Christoph Lehmann [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Biclassification
Is there any R package/function for biclassification (hierarchical reciprocal clustering of 2 factors) ? Thanks, Arnaud DISCLAIMER**...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] using identify() together with plot () and pixmap()
Christoph Lehmann wrote: plot(pixmapGrey(fmri.vtc[,,slice,volume])) identify(fmri.vtc[,,slice,volume]) warning: no point with 0.25 inches pressing the right mouse button I get: numeric(0) what is the problem here and how can I solve it? The problem is that there is no method for identifying points on a pixmap (and anyway, you are feeding identify() a matrix). You'll need to write an identify.pixmapGrey function. This would do something like use the 'locator()' function to get clicks on the screen, and then it would compute which grid cell the coordinates of those clicks were in. pixmap objects store enough information for you to work this out from the attributes - look at the 'bbox' attribute for example. It would make a nice addition to the pixmap library. Although one thing that just suprised me was that the different flavours of pixmap - pixmapGrey, pixmapIndexed, pixmapRGB - dont all inherit from a 'pixmap' class, which might make it easier to write a single identify function for all the types. Baz __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] using identify() together with plot () and pixmap()
On Tue, 30 Sep 2003 10:16:11 +0200, Christoph Lehmann (CL) wrote: Dear R users I have a two-dimensional array, whose values I want to plot, using the pixmapGrey class. Plotting works fine, and now I would like to be able to identify some of the points in the plot using identify(). But I get the following message while pressing the left mouse button: plot(pixmapGrey(fmri.vtc[,,slice,volume])) identify(fmri.vtc[,,slice,volume]) warning: no point with 0.25 inches identify() needs x and y values, you are passing it the z values of the image. Maybe you want to use locator()? .f __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] BIC or AIC from nnet
Paul Green wrote: Is AIC or BIC available when using the nnet package? Given you are talking about multinom(): Yes, it returns the AIC for the fit, but that's already mentioned in the help file... Uwe Ligges Thank you Paul Green __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] using identify() together with plot () and pixmap()
On Tue, 30 Sep 2003 09:38:31 +0100, Barry Rowlingson (BR) wrote: Christoph Lehmann wrote: plot(pixmapGrey(fmri.vtc[,,slice,volume])) identify(fmri.vtc[,,slice,volume]) warning: no point with 0.25 inches pressing the right mouse button I get: numeric(0) what is the problem here and how can I solve it? The problem is that there is no method for identifying points on a pixmap (and anyway, you are feeding identify() a matrix). You'll need to write an identify.pixmapGrey function. This would do something like use the 'locator()' function to get clicks on the screen, and then it would compute which grid cell the coordinates of those clicks were in. pixmap objects store enough information for you to work this out from the attributes - look at the 'bbox' attribute for example. It would make a nice addition to the pixmap library. Although one thing that just suprised me was that the different flavours of pixmap - pixmapGrey, pixmapIndexed, pixmapRGB - dont all inherit from a 'pixmap' class, But they do, and class pixmap has the necessary geometry information, i.e., size, bounding box and resolution of the image. which might make it easier to write a single identify function for all the types. yes, shouldn't bbe too hard (all contributions welcome). .f __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] NNet value and convergence
Hannah Wood wrote: Hi, I'm using the R nnet package and have a few simple (?) questions. What is the value that is output after every 10 iterations during the training of the network and how is it calculated? # weights: 177 initial value 506.134586 iter 10 value 128.222774 iter 20 value 95.399782 iter 30 value 87.184564 ... Is the value the error, if not, is there any way to see the error values during training? From ?nnet: value of fitting criterion plus weight decay term. Also, how does the network decide when it has converged? More than one criterion. You can adjust the criterions with arguments to nnet(), see ?nnet. Please read the references given in ?nnet for more details: - Ripley, B. D. (1996) Pattern Recognition and Neural Networks. Cambridge. - Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth edition. Springer. Uwe Ligges Thanks Hannah __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] CP for rpart
weidong zhang wrote: Hi All, I have some questions on using library rpart. Given my data below, the plotcp gives me increasing 'xerrors' across different cp's with huge xstd (plot attached). What causes the problem or it's not a problem at all? I am thinking 'xerror's should be decreasing when 'cp' gets smaller. No. Why? BTW: It's calculated by cross validation. Also what the 'xstd' really tells us? If the error bars for each xerror overlap for different cp's, does that mean we don't have significant improvement for misclassification rate when we split the tree? My data have are two classes with 138 observations and 129 attributes. Your problem is called overfitting, I guess. Are you sure the class variable can be explained by the other variables in a way? Do you think the linear and othogonal separation of classes is appropriate for your problem? You might want to look into a good book on Classification Theory. Uwe Ligges Here is what I did: dim(man.dat[,c(1,8:136)]) [1] 138 130 man.dt1 - rpart(Target~.,data=man.dat[,c(1,8:136)], method='class',cp=1e-5, parms=list(split='information')) plotcp(man.dt1) printcp(man.dt1) Classification tree: rpart(formula = Target ~ ., data = man.dat[, c(1, 8:136)], method = class, parms = list(split = information), cp = 1e-05) Variables actually used in tree construction: [1] CHX.V CYN.Cu SPF.Bi Root node error: 25/138 = 0.18116 n= 138 CP nsplit rel error xerrorxstd 1 0.18667 0 1.00 1.00 0.18098 2 0.1 3 0.44 1.12 0.18897 I would appreciate your help on this, Weidong _ Instant message with integrated webcam using MSN Messenger 6.0. Try it now FREE! http://msnmessenger-download.com __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] cluster mgcv update
Hello, After reinstalling the whole OS and R as well, I tried to update.packages() and get the follwing error message: concerning the mgcv update: atlas2-base is installed and blas as well (on debian). I haven't found lf77blas, I assume it's a library or something similar associated with blas. any suggestion how to solve that, thanks Martin * Installing *source* package 'cluster' ... ** libs gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -fPIC -g -O2 -c clara.c -o clara.o g77 -mieee-fp -fPIC -g -O2 -c daisy.f -o daisy.o make: g77: Command not found make: *** [daisy.o] Error 127 ERROR: compilation failed for package 'cluster' * Installing *source* package 'mgcv' ... ** libs gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wall -pedantic -fPIC -g -O2 -c gcv.c -o gcv.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wall -pedantic -fPIC -g -O2 -c magic.c -o magic.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wall -pedantic -fPIC -g -O2 -c mat.c -o mat.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wall -pedantic -fPIC -g -O2 -c matrix.c -o matrix.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wall -pedantic -fPIC -g -O2 -c mgcv.c -o mgcv.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wall -pedantic -fPIC -g -O2 -c qp.c -o qp.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wall -pedantic -fPIC -g -O2 -c tprs.c -o tprs.o gcc -shared -o mgcv.so gcv.o magic.o mat.o matrix.o mgcv.o qp.o tprs.o -L/usr/lib/R/bin -lRlapack -lf77blas -latlas -L/usr/lib/gcc-lib/i386-linux/3.3 -L/usr/lib/gcc-lib/i386-linux/3.3/../../.. -lfrtbegin -lg2c-pic -lm -lgcc_s -L/usr/lib/R/bin -lR /usr/bin/ld: cannot find -lf77blas collect2: ld returned 1 exit status make: *** [mgcv.so] Error 1 ERROR: compilation failed for package 'mgcv' Delete downloaded files (y/N)? y Warning messages: 1: Installation of package cluster had non-zero exit status in: install.packages(update[, Package], instlib, contriburl = contriburl, 2: Installation of package mgcv had non-zero exit status in: install.packages(update[, Package], instlib, contriburl = contriburl, __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] cluster mgcv update
Martin Wegmann wrote: Hello, After reinstalling the whole OS and R as well, I tried to update.packages() and get the follwing error message: concerning the mgcv update: atlas2-base is installed and blas as well (on debian). I haven't found lf77blas, I assume it's a library or something similar associated with blas. any suggestion how to solve that, thanks Martin * Installing *source* package 'cluster' ... ** libs gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -fPIC -g -O2 -c clara.c -o clara.o g77 -mieee-fp -fPIC -g -O2 -c daisy.f -o daisy.o make: g77: Command not found make: *** [daisy.o] Error 127 ERROR: compilation failed for package 'cluster' The Fortran Compiler g77 is missing (at least not in your path), as well as some related libraries (see error message below). Uwe Ligges * Installing *source* package 'mgcv' ... ** libs gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wall -pedantic -fPIC -g -O2 -c gcv.c -o gcv.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wall -pedantic -fPIC -g -O2 -c magic.c -o magic.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wall -pedantic -fPIC -g -O2 -c mat.c -o mat.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wall -pedantic -fPIC -g -O2 -c matrix.c -o matrix.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wall -pedantic -fPIC -g -O2 -c mgcv.c -o mgcv.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wall -pedantic -fPIC -g -O2 -c qp.c -o qp.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wall -pedantic -fPIC -g -O2 -c tprs.c -o tprs.o gcc -shared -o mgcv.so gcv.o magic.o mat.o matrix.o mgcv.o qp.o tprs.o -L/usr/lib/R/bin -lRlapack -lf77blas -latlas -L/usr/lib/gcc-lib/i386-linux/3.3 -L/usr/lib/gcc-lib/i386-linux/3.3/../../.. -lfrtbegin -lg2c-pic -lm -lgcc_s -L/usr/lib/R/bin -lR /usr/bin/ld: cannot find -lf77blas collect2: ld returned 1 exit status make: *** [mgcv.so] Error 1 ERROR: compilation failed for package 'mgcv' Delete downloaded files (y/N)? y Warning messages: 1: Installation of package cluster had non-zero exit status in: install.packages(update[, Package], instlib, contriburl = contriburl, 2: Installation of package mgcv had non-zero exit status in: install.packages(update[, Package], instlib, contriburl = contriburl, __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] cluster mgcv update
You need to add atlas2-base-dev: $ apt-get install atlas2-base-dev I installed atlas2-base-dev and g77 but know I get the error messages pasted below. Both (cluster and mgcv) requires lfrtbegin, but that does not seem to be programm which I can install via apt-get. Martin * Installing *source* package 'cluster' ... ** libs gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -fPIC -g -O2 -c clara.c -o clara.o g77 -mieee-fp -fPIC -g -O2 -c daisy.f -o daisy.o g77 -mieee-fp -fPIC -g -O2 -c fanny.f -o fanny.o g77 -mieee-fp -fPIC -g -O2 -c meet.f -o meet.o g77 -mieee-fp -fPIC -g -O2 -c mona.f -o mona.o g77 -mieee-fp -fPIC -g -O2 -c pam.f -o pam.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -fPIC -g -O2 -c spannel.c -o spannel.o g77 -mieee-fp -fPIC -g -O2 -c twins.f -o twins.o gcc -shared -o cluster.so clara.o daisy.o fanny.o meet.o mona.o pam.o spannel.o twins.o -L/usr/lib/gcc-lib/i386-linux/3.3 -L/usr/lib/gcc-lib/i386-linux/3.3/../../.. -lfrtbegin -lg2c-pic -lm -lgcc_s -L/usr/lib/R/bin -lR /usr/bin/ld: cannot find -lfrtbegin collect2: ld returned 1 exit status make: *** [cluster.so] Error 1 ERROR: compilation failed for package 'cluster' * Installing *source* package 'mgcv' ... ** libs gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wall -pedantic -fPIC -g -O2 -c gcv.c -o gcv.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wall -pedantic -fPIC -g -O2 -c magic.c -o magic.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wall -pedantic -fPIC -g -O2 -c mat.c -o mat.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wall -pedantic -fPIC -g -O2 -c matrix.c -o matrix.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wall -pedantic -fPIC -g -O2 -c mgcv.c -o mgcv.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wall -pedantic -fPIC -g -O2 -c qp.c -o qp.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wall -pedantic -fPIC -g -O2 -c tprs.c -o tprs.o gcc -shared -o mgcv.so gcv.o magic.o mat.o matrix.o mgcv.o qp.o tprs.o -L/usr/lib/R/bin -lRlapack -lf77blas -latlas -L/usr/lib/gcc-lib/i386-linux/3.3 -L/usr/lib/gcc-lib/i386-linux/3.3/../../.. -lfrtbegin -lg2c-pic -lm -lgcc_s -L/usr/lib/R/bin -lR /usr/bin/ld: cannot find -lfrtbegin collect2: ld returned 1 exit status make: *** [mgcv.so] Error 1 ERROR: compilation failed for package 'mgcv' Delete downloaded files (y/N)? y Warning messages: 1: Installation of package cluster had non-zero exit status in: install.packages(update[, Package], instlib, contriburl = contriburl, 2: Installation of package mgcv had non-zero exit status in: install.packages(update[, Package], instlib, contriburl = contriburl, __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] overlay two pixmap
when I try to overlay a completely transparent pixmap on another pixmap, I get an error. For reproduction: just the transparent pixmap itself gives an error: tmp - array(0,c(x.dim,y.dim)) tmp - pixmapIndexed(tmp[,]) for (x in 1:x.dim) { for (y in 1:y.dim) { [EMAIL PROTECTED],y] - NA } } plot(tmp) Error: Error in image.default(x = X, y = Y, z = t([EMAIL PROTECTED]([EMAIL PROTECTED]):1, ]), : invalid z limits In addition: Warning messages: 1: no finite arguments to min; returning Inf 2: no finite arguments to max; returning -Inf what happened here? many thanks christoph On Fri, 2003-09-26 at 12:44, Roger Bivand wrote: Christoph Lehmann wrote: I need to overlay two pixmaps (library (pixmap)). One, a pixmapGrey, is the basis, and on this I need to overlay a pixmapIndexed, BUT: the pixmapIndexed has set only some of its pixels to an indexed color, many of its pixels should not cover the basis pixmapGrey pixel, means, for this in pixmapIndexed not defined pixels it should be transparent. What would you recommend me to do? Should I go for another solution than pixmap? Determine which of the indexed colours in the pixmapIndexed object are to be transparent, and change them to NA - you access them in say: library(pixmap) x - read.pnm(system.file(pictures/logo.ppm, package = pixmap)[1]) x plot(x) xx - as(x, pixmapIndexed) xx plot(xx) example(pixmap) z - pixmapRGB(c(z1, z2, z3), 100, 100, bbox = c(0, 0, 100, 100)) plot(z) [EMAIL PROTECTED]:20] [EMAIL PROTECTED] - NA plot(xx, add=T) Here [EMAIL PROTECTED] was white aka #FF, you could use col2rgb() to help set thresholds. Admittedly, this is messy if you don't know your threshold. Roger -- Christoph Lehmann [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] checking generic/method consistency
Hi *, thanks for all your answers and discussions. And additionally special thanks to Henrik Bengtsson for writing the first draft of the R Coding Conventions. I think that this document contains a lot of good ideas to make the code more readable. Since my package is *new* code, I adjusted it according to most recommendations of the RCC. However, one thing is still unclear to me: According to the RCC I gave the class of result of my function linProg also the name linProg, but the RCC says that classes must start with uppercase, while functions must start with lowercase, which is contradictory in this case. In one of the examples of the RCC, a function that returns an object with a class attribute starts with uppercase: Line - function(x0, y0, x1, y1) { line - list(x=c(x0,y0), y=(x1,y1)); class(line) - Line; line; } Does this mean that the names of these functions should start with uppercase? Best wishes, Arne On Friday 26 September 2003 17:43, you wrote: Hi, it looks from the names of your argument that your function is a plain function, i.e. it is not a function specific to a class. If this is true, I would avoid the period and rename your function to solveLP - function(cvec, bvec, Amat, maximum, maxiter, verbose) ... Under the S3 style of programming with classes methods coupled to classes are written in the format method.class - function(object, arg1, arg2, ... That is, the part before the period is the name of a generic function and the part after is the name of the class. This is why R CMD check believe your that you have written a method 'solve' for class 'LP'. All methods named 'solve' should have a argument signature that match the generic function 'solve' and your solve.LP doesn't. I do not think this was your intention, correct? See help.start() - R Language Definition - Object-oriented programming: for more details about the S3 style. To avoid problems like these I am working on a R Coding Conventions (RCC), http://www.maths.lth.se/help/R/RCC/ (see Naming Conventions). It is an early version and not everyone agrees with it, but the intention is to find a style that avoid problems like yours, where it says that you should avoid periods in function names except if you use it for S3 class methods. Feedback is appreciated. Cheers Henrik Bengtsson Lund University -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Arne Henningsen Sent: den 26 september 2003 17:03 To: [EMAIL PROTECTED] Subject: [R] checking generic/method consistency Hi, I wrote a package for linear programming and want to submit it to CRAN. Since the package 'quadprog' has a function with the name 'solve.QP' to perform Quadratic Programming, I named my (main) function 'solve.LP'. However 'R CMD check' gives one warning: * checking generic/method consistency ... WARNING solve: function(a, b, ...) solve.LP: function(cvec, bvec, Amat, maximum, maxiter, verbose) while 'R CMD check' gives no warnings when the function has the name 'solve.QP'. What do you recommend me to do? 1) Ignore the warning and upload the package to CRAN as it is? 2) Rename the function? (any suggestions?) 3) Change something that avoids this problem without renaming the functions? I would prefer the third point, but I don't know how. Thank you for your answers, Arne -- Arne Henningsen Department of Agricultural Economics Christian-Albrechts-University Kiel 24098 Kiel, Germany Tel: +49-431-880-4445 Fax: +49-431-880-1397 [EMAIL PROTECTED] http://www.uni- kiel.de/agrarpol/ahenningsen.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo /r-help -- Arne Henningsen Department of Agricultural Economics Christian-Albrechts-University Kiel 24098 Kiel, Germany Tel: +49-431-880-4445 Fax: +49-431-880-1397 [EMAIL PROTECTED] http://www.uni-kiel.de/agrarpol/ahenningsen/ __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] cluster mgcv update
On Tue, Sep 30, 2003 at 02:04:23PM +0200, Martin Wegmann wrote: You need to add atlas2-base-dev: $ apt-get install atlas2-base-dev I installed atlas2-base-dev and g77 but know I get the error messages pasted below. Both (cluster and mgcv) requires lfrtbegin, but that does not seem to be programm which I can install via apt-get. Weird. When R is built, certain configure values are recorded, see (on Debian) the files in /etc/R/: [EMAIL PROTECTED]:/etc/R grep frtb * Makeconf:FLIBS = -L/usr/lib/gcc-lib/i486-linux/3.3.2 -L/usr/lib/gcc-lib/i486-linux/3.3.2/../../.. -lfrtbegin -lg2c-pic -lm -lgcc_s If your Makeconf has values stored that your system doesn't have, then you may have a mismatch between the compiler used for building R (i.e. the binary you got yourself) and the one currently installed to build the package. Let's discuss off-line exactly what Debian 'flavour' and gcc/g77 versions you are using. One way out for you would be to rebuild R locally. We can discuss that too. Dirk -- Those are my principles, and if you don't like them... well, I have others. -- Groucho Marx __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] non-linear trends in kriging model
Hi I am struggling to fit a non-linear trend using the likfit function in geoR. Specifically I want a sigmoidal function, something like SSfpl in the nls package to fit the trend. But it seems trend.spatial in geoR only works with lm or glm type models. Any ideas how I can specify the model to calculate the kriging parameters using REML, including the parameters of a sigmoidal trend function (such as SSfpl)? Thanks David __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] non-linear trends in kriging model
David Indeed, the trend term in geoR must be a linear one. You can: 1) fit you model by alternating between using nls() and passing the residuals to the functions in geoR or 2) try trying to fit using the functions in the nlme() package Regards P.J. On Tue, 30 Sep 2003, David Pleydell wrote: Hi I am struggling to fit a non-linear trend using the likfit function in geoR. Specifically I want a sigmoidal function, something like SSfpl in the nls package to fit the trend. But it seems trend.spatial in geoR only works with lm or glm type models. Any ideas how I can specify the model to calculate the kriging parameters using REML, including the parameters of a sigmoidal trend function (such as SSfpl)? Thanks David __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help Paulo Justiniano Ribeiro Jr Departamento de Estatística Universidade Federal do Paraná Caixa Postal 19.081 CEP 81.531-990 Curitiba, PR - Brasil Tel: (+55) 41 361 3471 Fax: (+55) 41 361 3141 e-mail: [EMAIL PROTECTED] http://www.est.ufpr.br/~paulojus __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] FW: error predicting values from the LME
Could you dumb it down to a toy example with 4 observations for a model like y ~ 1 | inter, 2 observations for each of 2 levels of inter? If that works, then you can play with the example that works and the example that doesn't; this is one of the strategies mentioned in Poly (1971) How to Solve It (Princeton U. Pr.). With luck, this will help you figure out what you need to do to get the answers you want. If not, it should help you produce a small toy example that doesn't work, which you can then send us. Please include a data.frame call, so someone can copy your example into R and try it in 2 seconds. That should increase the chances that you would get a helpful reply. Also, have you read Pinhiero and Bates (2000) Mixed-Effect Models in S and S-Plus (Springer)? I've found that book to be indispensible for using lme. hope this helps. spencer graves Andrej Kveder wrote: HI all, I might add some more information in order to possibly solve my problem. I'm really stuck and no obvious solutions do the trick. I'm using R 1.7.1 on Windows 2000 with the packages regurarly updated. I'm using hypothetical data constructed as a pseudo population conforming to a certain Var-Cov structure. I might add that just predict(level2) works. But when I add the new dataset it doesn't. Following a suggestion I even tried refactoring of the grouping variable (inter) after I created the subset. It didn't work. I have no other factor variables in the model. I really have got no clue what could be wrong. There is a sample from my data: dnNew Grouped Data: y ~ v11 + v21 + v22 + v23 | inter v11 v21 v22 v23inter 4 5.55186635 5.6620022 24.18033 5.003409 1 13 2.03852426 5.6620022 24.18033 5.003409 1 15 2.19825772 7.5676798 31.03986 4.746891 2 16 4.51368278 7.5676798 31.03986 4.746891 2 18 3.35322702 7.5676798 31.03986 4.746891 2 19 2.46414346 7.5676798 31.03986 4.746891 2 20 2.66670834 7.5676798 31.03986 4.746891 2 and this is the model: level2 Linear mixed-effects model fit by REML Data: d.n.gr.2 Log-restricted-likelihood: -533.0011 Fixed: model$fixed (Intercept) v11 v21 v22 v23 v11:v21 3.205519074 0.298941539 -0.017743958 0.016007280 -0.410760471 0.002700954 v11:v22 v11:v23 -0.003680952 -0.018005717 Random effects: Formula: ~v11 | inter Structure: General positive-definite, Log-Cholesky parametrization StdDev Corr (Intercept) 0.385620605 (Intr) v11 0.003147431 -0.048 Residual 0.450012367 Number of Observations: 729 Number of Groups: 50 If this give you some more insight to my problem. I would reallly appreciate any suggestion. Thanks Andrej -Original Message- From: Andrej Kveder [mailto:[EMAIL PROTECTED] Sent: Monday, September 29, 2003 7:05 PM To: R-Help Subject: predicting values from the LME Dear listers, I experinced a problem prdicting the values using the LME with multilevel data. I have NA's in my dependent variable and the model is fitted only on the completed cases. I want to estimate the predicted values for the rest of the data (those cases with missing dep. variable) I extracted a subset from the original file containing the variables used in the model as well as the second level indicator. I used the following command p-predict(level2,newdata=d.n.new,level=0:1) where level2 is my LME model. But, I get the following error: Error in eval(expr, envir, enclos) : 1 argument passed to $ which requires 2. I tried with omitting the level specification (which is 0 by default) and I transformed the new data to be groupedData with no luck. I have tried the example from the Pinheiro,Bates book and it works - mine doesn't. Does anybody have an idea what could be wrong? Thanks for all the suggestions. Andrej _ Andrej Kveder, M.A. researcher Institute of Medical Sciences SRS SASA; Novi trg 2, SI-1000 Ljubljana, Slovenia phone: +386 1 47 06 440 fax: +386 1 42 61 493 [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] debugging R
Francisco J Molina [EMAIL PROTECTED] writes: To debug R from within Xemacs I have tried two different things: C-u M-x R RET - d SPC gdb RET to start an inferior R process with arguments @option{-d gdb} This is the way described in the official documentation of R. and also M-x R and then start GUD (M-x gdb) giving the R binary (using its full path name: /usr/bin/R ) as the program to debug. Use the program @command{ps} to find the process number of the currently running R process then use the attach command in gdb to attach it to that process. I have had problems with the last way: R freezes. That is because gdb has interrupted the R process. At this point I usually set a breakpoint at the function of interest, go to the gdb window and restart R by sending the 0 signal gdb sig 0 Then you are able to get a response in the ESS window with R. This technique is particularly useful if you have compiled code in a package because you can attach the package and load the shared object before invoking the debugger. Has anyone been succesfull in debugging R in last way? Yes - more times than I would care to count. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] checking generic/method consistency
Arne == Arne Henningsen [EMAIL PROTECTED] on Tue, 30 Sep 2003 14:18:11 +0200 writes: Arne Hi *, Arne thanks for all your answers and discussions. And Arne additionally special thanks to Henrik Bengtsson for Arne writing the first draft of the R Coding Arne Conventions. I think that this document contains a Arne lot of good ideas to make the code more Arne readable. Since my package is *new* code, I adjusted Arne it according to most recommendations of the RCC. Arne However, one thing is still unclear to me: According Arne to the RCC I gave the class of result of my function Arne linProg also the name linProg, but the RCC says Arne that classes must start with uppercase, while Arne functions must start with lowercase, which is Arne contradictory in this case. In one of the examples of Arne the RCC, a function that returns an object with a Arne class attribute starts with uppercase: Line - function(x0, y0, x1, y1) { line - list(x=c(x0,y0), y=(x1,y1)); class(line) - Line; line; } do not end lines with ; in S (i.e. R or S-plus); it's superfluous and considered ugly by many (incl. me) and teaches (by example) a wrong idea. Arne Does this mean that the names of these functions Arne should start with uppercase? While I agree that Henrik has put up several well thought out recommendations {and very helpful postings such as the one you cite below!} , these are *Henrik*'s recommendations and are still subject to discussion and feedback. The S language has quite a long tradition and existing function and class base which cannot be changed mostly for compatibility reasons. One thing in this tradition is to have function foobar return objects of class foobar (identical spelling including case). This particularly applies to the old or S3 class/method system on which still very much of the basic S models are based. When using S3 classes (as you are above), I'd definitely keep that S tradition. This naming scheme can well change when the S4 class/methods system is used (as it is more and more), since there, you construct objects rather by new(classname,), as(obj, classname, ) etc. Regards, Martin Maechler [EMAIL PROTECTED] http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO C16Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 Arne On Friday 26 September 2003 17:43, you wrote: Hi, it looks from the names of your argument that your function is a plain function, i.e. it is not a function specific to a class. If this is true, I would avoid the period and rename your function to solveLP - function(cvec, bvec, Amat, maximum, maxiter, verbose) ... Under the S3 style of programming with classes methods coupled to classes are written in the format method.class - function(object, arg1, arg2, ... That is, the part before the period is the name of a generic function and the part after is the name of the class. This is why R CMD check believe your that you have written a method 'solve' for class 'LP'. All methods named 'solve' should have a argument signature that match the generic function 'solve' and your solve.LP doesn't. I do not think this was your intention, correct? See help.start() - R Language Definition - Object-oriented programming: for more details about the S3 style. To avoid problems like these I am working on a R Coding Conventions (RCC), http://www.maths.lth.se/help/R/RCC/ (see Naming Conventions). It is an early version and not everyone agrees with it, but the intention is to find a style that avoid problems like yours, where it says that you should avoid periods in function names except if you use it for S3 class methods. Feedback is appreciated. Cheers Henrik Bengtsson Lund University -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Arne Henningsen Sent: den 26 september 2003 17:03 To: [EMAIL PROTECTED] Subject: [R] checking generic/method consistency Hi, I wrote a package for linear programming and want to submit it to CRAN. Since the package 'quadprog' has a function with the name 'solve.QP' to perform Quadratic Programming, I named my (main) function 'solve.LP'. However 'R CMD check' gives one warning: * checking generic/method consistency ... WARNING solve: function(a, b, ...) solve.LP: function(cvec, bvec, Amat, maximum, maxiter, verbose) while 'R CMD check' gives no warnings when the function has the name 'solve.QP'. What do you recommend me to do? 1) Ignore the warning and
[R] Stepwise procedures
Is there a function in R which performs stepwise estimation in ways similar to SAS/STATA (i.e., allows the analyst to specify the significance levels for removal/addition of terms). I've been asked to evaluate two final models: one resulting from a backwards selection in R (stepAIC) and one resulting from a backwards selection using PROC LOGISTIC in SAS. The final terms are slightly different and I'm trying to understand the differences between the two packages (approaches) so I can explain why the final terms might be different. Thanks for your help. Marc Marc W. Zodet, MS Health Statistician Agency for Healthcare Research and Quality E-mail: mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] checking generic/method consistency
On Tuesday 30 September 2003 15:23, Martin Maechler wrote: Arne == Arne Henningsen [EMAIL PROTECTED] on Tue, 30 Sep 2003 14:18:11 +0200 writes: Arne Hi *, Arne thanks for all your answers and discussions. And Arne additionally special thanks to Henrik Bengtsson for Arne writing the first draft of the R Coding Arne Conventions. I think that this document contains a Arne lot of good ideas to make the code more Arne readable. Since my package is *new* code, I adjusted Arne it according to most recommendations of the RCC. Arne However, one thing is still unclear to me: According Arne to the RCC I gave the class of result of my function Arne linProg also the name linProg, but the RCC says Arne that classes must start with uppercase, while Arne functions must start with lowercase, which is Arne contradictory in this case. In one of the examples of Arne the RCC, a function that returns an object with a Arne class attribute starts with uppercase: Line - function(x0, y0, x1, y1) { line - list(x=c(x0,y0), y=(x1,y1)); class(line) - Line; line; } do not end lines with ; in S (i.e. R or S-plus); it's superfluous and considered ugly by many (incl. me) and teaches (by example) a wrong idea. Fortunately, I adjusted my code according to *most* (and not all) recommendations of the RCC and e.g. did *not* add the (also in my opinion) ugly semicolons. Arne Does this mean that the names of these functions Arne should start with uppercase? While I agree that Henrik has put up several well thought out recommendations {and very helpful postings such as the one you cite below!} , these are *Henrik*'s recommendations and are still subject to discussion and feedback. The S language has quite a long tradition and existing function and class base which cannot be changed mostly for compatibility reasons. One thing in this tradition is to have function foobar return objects of class foobar (identical spelling including case). This particularly applies to the old or S3 class/method system on which still very much of the basic S models are based. When using S3 classes (as you are above), I'd definitely keep that S tradition. Thanks for your comment. Now I don't feel so bad if I ignore some of Henrik's RCCs ;-). However, I think it's important for us to agree on some coding conventions since the inconsistency of the syntax between R packages is a drawback of R (see e.g. Jeff Racine, Rob Hyndman: Using R to teach econometrics, Journal of Applied Econometrics 17 (2002), p. 176, http://www3.interscience.wiley.com/cgi-bin/fulltext/93514548/PDFSTART). I there a discussion on R coding conventions taking place at the moment? Best wishes, Arne This naming scheme can well change when the S4 class/methods system is used (as it is more and more), since there, you construct objects rather by new(classname,), as(obj, classname, ) etc. Regards, Martin Maechler [EMAIL PROTECTED] http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO C16 Leonhardstr. 27 ETH (Federal Inst. Technology)8092 Zurich SWITZERLAND phone: x-41-1-632-3408fax: ...-1228 Arne On Friday 26 September 2003 17:43, you wrote: Hi, it looks from the names of your argument that your function is a plain function, i.e. it is not a function specific to a class. If this is true, I would avoid the period and rename your function to solveLP - function(cvec, bvec, Amat, maximum, maxiter, verbose) ... Under the S3 style of programming with classes methods coupled to classes are written in the format method.class - function(object, arg1, arg2, ... That is, the part before the period is the name of a generic function and the part after is the name of the class. This is why R CMD check believe your that you have written a method 'solve' for class 'LP'. All methods named 'solve' should have a argument signature that match the generic function 'solve' and your solve.LP doesn't. I do not think this was your intention, correct? See help.start() - R Language Definition - Object-oriented programming: for more details about the S3 style. To avoid problems like these I am working on a R Coding Conventions (RCC), http://www.maths.lth.se/help/R/RCC/ (see Naming Conventions). It is an early version and not everyone agrees with it, but the intention is to find a style that avoid problems like yours, where it says that you should avoid periods in function names except if you use it for S3 class methods. Feedback is appreciated. Cheers Henrik Bengtsson Lund University -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
[R] Generation of labels for 2 factors
Hello, I have a data set with 10 countries, 10 sectors of public policy and 15 years like country sector year a aa 1980 a aa 1981 ... a bb 1980 a bb 1981 ... b aa 1980 b aa 1981 ... b bb 1980 b bb 1981 with 1500 observations. My cases are the couple country/sector. So, I want to have 100 cases over 15 years. (both country and sector are factors) I want to assign to each case a label (e.i. country 'a' + sector 'aa' have value '1', country 'a' + sector 'b' have value 2...) and I have been trying differents ways, but I can't. Is there a function to do it directly or I have to write a function? Thank you, Xavier __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Stepwise procedures
On Tue, 30 Sep 2003 09:24:20 -0400 [EMAIL PROTECTED] wrote: Is there a function in R which performs stepwise estimation in ways similar to SAS/STATA (i.e., allows the analyst to specify the significance levels for removal/addition of terms). I've been asked to evaluate two final models: one resulting from a backwards selection in R (stepAIC) and one resulting from a backwards selection using PROC LOGISTIC in SAS. The final terms are slightly different and I'm trying to understand the differences between the two packages (approaches) so I can explain why the final terms might be different. Thanks for your help. Marc Marc, Stepwise variable selection doesn't work well for the sample size you are using. Frank --- Frank E Harrell JrProfessor and ChairSchool of Medicine Department of BiostatisticsVanderbilt University __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] ts - unit conversion
I've been using R for a while, but now find myself needing to understand time-series objects for a short course I am teaching. I am putting together some daily financial datasets for illustration, but having some trouble in aggregating the data to months or weeks. I am getting a cannot change frequency from 1 to 12 message. I am not sure that aggregation is where I want to go anyway. Assuming for the moment that I had one full year of data, I would like the observations to relate to real months with various numbers of days, not simply 1/12th of a year. It is unclear to me how sophisticated the aggregator is in this regard. I have VR but it seems there may be some SPlus/R differences here. Any suggestions for documents that addresses these issues would be wonderful. Thanks. ibm - get.hist.quote('ibm',start='2003-01-01') trying URL `http://chart.yahoo.com/table.csv?s=ibma=11b=31c=2002d=8e=28f=2003g=dq=qy=0z=ibmx=.csv' Content type `application/octet-stream' length unknown opened URL downloaded 8990 bytes time series starts 2002-12-30 time series ends 2003-09-25 Just to check what I have attributes(ibm) $dim [1] 270 4 $dimnames $dimnames[[1]] NULL $dimnames[[2]] [1] Open High Low Close $tsp [1] 37621 37890 1 $class [1] mts ts Attempting to pull monthly means . aggregate(ibm,12,mean) Error in aggregate.ts(ibm, 12, mean) : cannot change frequency from 1 to 12 I thought perhaps I had a non-integer number of months in the data which may be causing problems. length(ibm) [1] 1080 1080/12 [1] 90 Alternatively...making the data coordinate to real months... ibm - get.hist.quote('ibm',start='2003-01-01',end='2003-08-31') trying URL `http://chart.yahoo.com/table.csv?s=ibma=11b=31c=2002d=7e=30f=2003g=dq=qy=0z=ibmx=.csv' Content type `application/octet-stream' length unknown opened URL ... downloaded 8082 bytes time series starts 2002-12-30 time series ends 2003-08-28 aggregate(ibm,12,mean) Error in aggregate.ts(ibm, 12, mean) : cannot change frequency from 1 to 12 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Grouped bar plots
Dear R experts! I'm wondering if it is possible in R to make a certain type of bar plots, in S-Plus known as Grouped Bar Plots (see the attachment for an example). In S-Plus they can be created with the guiPlot function. Thank you for any answers. Best regards, Matjaz.inline: grouped_barplot.png__ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Grouped bar plots
Matjaz Kukar wrote: Dear R experts! I'm wondering if it is possible in R to make a certain type of bar plots, in S-Plus known as Grouped Bar Plots (see the attachment for an example). In S-Plus they can be created with the guiPlot function. Thank you for any answers. ?barplot Uwe Ligges Best regards, Matjaz. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] R Production Performance
Zitan Broth wrote: Right but R is only preloaded once? Yes. The plr shared library gets loaded and initialized (which in turn loads and initializes libR) only once -- on Postgres's postmaster startup. From that point forward, every new database connection gets a forked copy of the postmaster, and hence a preinitialized copy of the R interpreter. Of course (as I think I mentioned already, but it is worth repeating) to get this performance enhancement you need to be using either Postgres 7.4 beta or a patched version of Postgres 7.3 (found at the URL on the original post), and have the following line in your postgresql.conf: preload_libraries = '$libdir/plr:plr_init' This is getting a bit off topic, so if you have any more PL/R specific questions, please write me off list. Joe __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] Generation of labels for 2 factors
Not sure exactly what you want, but try: countrySector - factor(paste(df$country, df$sector, sep=:)) where df is the data frame. This creates a factor for the combination. If you want numeric code, just coerce with as.numeric(). HTH, Andy -Original Message- From: Xavier Fernández i Marín [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 30, 2003 11:42 AM To: [EMAIL PROTECTED] Subject: [R] Generation of labels for 2 factors Hello, I have a data set with 10 countries, 10 sectors of public policy and 15 years like country sector year a aa 1980 a aa 1981 ... a bb 1980 a bb 1981 ... b aa 1980 b aa 1981 ... b bb 1980 b bb 1981 with 1500 observations. My cases are the couple country/sector. So, I want to have 100 cases over 15 years. (both country and sector are factors) I want to assign to each case a label (e.i. country 'a' + sector 'aa' have value '1', country 'a' + sector 'b' have value 2...) and I have been trying differents ways, but I can't. Is there a function to do it directly or I have to write a function? Thank you, Xavier __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo /r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] ts - unit conversion
Financial data, as you point out, is generally irregular, which is in essence what prompted the devlopment of the irregular time-series (its) package, which is posted on CRAN (v0.1.2 posted today, incidentally). In the its class, the time-stamps of the rows of a matrix are represented using the POSIXct class, so irregularity can be represented accurately. Inspection of get.hist.quote() shows that it would be quite straightforward to adapt it to return an 'its'. I would do so myself, but have no spare time in the short term to do this (and I'm behind a proxy/firewall which seems to complicate matters). Giles -Original Message- From: michaell taylor [mailto:[EMAIL PROTECTED] Sent: 30 September 2003 16:51 To: [EMAIL PROTECTED] Subject: [R] ts - unit conversion I've been using R for a while, but now find myself needing to understand time-series objects for a short course I am teaching. I am putting together some daily financial datasets for illustration, but having some trouble in aggregating the data to months or weeks. I am getting a cannot change frequency from 1 to 12 message. I am not sure that aggregation is where I want to go anyway. Assuming for the moment that I had one full year of data, I would like the observations to relate to real months with various numbers of days, not simply 1/12th of a year. It is unclear to me how sophisticated the aggregator is in this regard. I have VR but it seems there may be some SPlus/R differences here. Any suggestions for documents that addresses these issues would be wonderful. Thanks. ibm - get.hist.quote('ibm',start='2003-01-01') trying URL `http://chart.yahoo.com/table.csv?s=ibma=11b=31c=2002d=8e =28f=2003g=dq=qy=0z=ibmx=.csv' Content type `application/octet-stream' length unknown opened URL downloaded 8990 bytes time series starts 2002-12-30 time series ends 2003-09-25 Just to check what I have attributes(ibm) $dim [1] 270 4 $dimnames $dimnames[[1]] NULL $dimnames[[2]] [1] Open High Low Close $tsp [1] 37621 37890 1 $class [1] mts ts Attempting to pull monthly means . aggregate(ibm,12,mean) Error in aggregate.ts(ibm, 12, mean) : cannot change frequency from 1 to 12 I thought perhaps I had a non-integer number of months in the data which may be causing problems. length(ibm) [1] 1080 1080/12 [1] 90 Alternatively...making the data coordinate to real months... ibm - get.hist.quote('ibm',start='2003-01-01',end='2003-08-31') trying URL `http://chart.yahoo.com/table.csv?s=ibma=11b=31c=2002d=7e =30f=2003g=dq=qy=0z=ibmx=.csv' Content type `application/octet-stream' length unknown opened URL ... downloaded 8082 bytes time series starts 2002-12-30 time series ends 2003-08-28 aggregate(ibm,12,mean) Error in aggregate.ts(ibm, 12, mean) : cannot change frequency from 1 to 12 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help ** This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] ts - unit conversion
Change the line in get.hist.quote that pastes the url together so that g=d (i.e. daily) is replaced with g=m (i.e. monthly). That will cause monthly data to be downloaded. With this new get.hist.quote try this: ibm - get.hist.quote(ibm) ibm - ts( ibm[!is.na(rowSums(ibm)),], end=c(2003,8), freq=12 ) --- On Tue 09/30, michaell taylor [EMAIL PROTECTED] wrote: I've been using R for a while, but now find myself needing to understand time-series objects for a short course I am teaching. I am putting together some daily financial datasets for illustration, but having some trouble in aggregating the data to months or weeks. I am getting a cannot change frequency from 1 to 12 message. I am not sure that aggregation is where I want to go anyway. Assuming for the moment that I had one full year of data, I would like the observations to relate to real months with various numbers of days, not simply 1/12th of a year. It is unclear to me how sophisticated the aggregator is in this regard. I have VR but it seems there may be some SPlus/R differences here. Any suggestions for documents that addresses these issues would be wonderful. Thanks. ibm - get.hist.quote('ibm',start='2003-01-01') trying URL `http://chart.yahoo.com/table.csv?s=ibma=11b=31c=2002d=8e=28f=2003g=dq=qy=0z=ibmx=.csv' Content type `application/octet-stream' length unknown opened URL downloaded 8990 bytes time series starts 2002-12-30 time series ends 2003-09-25 Just to check what I have attributes(ibm) $dim [1] 270 4 $dimnames $dimnames[[1]] NULL $dimnames[[2]] [1] Open High Low Close $tsp [1] 37621 37890 1 $class [1] mts ts Attempting to pull monthly means . aggregate(ibm,12,mean) Error in aggregate.ts(ibm, 12, mean) : cannot change frequency from 1 to 12 I thought perhaps I had a non-integer number of months in the data which may be causing problems. length(ibm) [1] 1080 1080/12 [1] 90 Alternatively...making the data coordinate to real months... ibm - get.hist.quote('ibm',start='2003-01-01',end='2003-08-31') trying URL `http://chart.yahoo.com/table.csv?s=ibma=11b=31c=2002d=7e=30f=2003g=dq=qy=0z=ibmx=.csv' Content type `application/octet-stream' length unknown opened URL ... downloaded 8082 bytes time series starts 2002-12-30 time series ends 2003-08-28 aggregate(ibm,12,mean) Error in aggregate.ts(ibm, 12, mean) : cannot change frequency from 1 to 12 ___ No banners. No pop-ups. No kidding. Introducing My Way - http://www.myway.com __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Remove comma (,) in data set
Dear R-helper, I am new learning R. Now, I have a data set like: 24,2,3,3,1,1,2,3,0,1 45,1,3,10,1,1,3,4,0,1 43,2,3,7,1,1,3,4,0,1 42,3,2,9,1,1,3,3,0,1 36,3,3,8,1,1,3,2,0,1 19,4,4,0,1,1,3,3,0,1 38,2,3,6,1,1,3,2,0,1 21,3,3,1,1,0,3,2,0,1 27,2,3,3,1,1,3,4,0,1 45,1,1,8,1,1,2,2,1,1 ... with 3730 rows I want to remove comma (,) in data set. The result like: 24 2 3 3 1 1 2 3 0 1 45 1 3 10 1 1 3 4 0 1 43 2 3 7 1 1 3 4 0 1 42 3 2 9 1 1 3 3 0 1 36 3 3 8 1 1 3 2 0 1 19 4 4 0 1 1 3 3 0 1 38 2 3 6 1 1 3 2 0 1 21 3 3 1 1 0 3 2 0 1 27 2 3 3 1 1 3 4 0 1 45 1 1 8 1 1 2 2 1 1 ... How can I do it. Thanks you for your help. Best regards, Muhammad Subianto __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Remove comma (,) in data set
On Tue, 30 Sep 2003 18:51:52 +0200, Muhammad Subianto [EMAIL PROTECTED] wrote : Dear R-helper, I am new learning R. Now, I have a data set like: 24,2,3,3,1,1,2,3,0,1 45,1,3,10,1,1,3,4,0,1 ... with 3730 rows I want to remove comma (,) in data set. The result like: 24 2 3 3 1 1 2 3 0 1 45 1 3 10 1 1 3 4 0 1 ... How can I do it. Thanks you for your help. I assume you're talking about reading a file with commas, and writing one without. Use one of the read functions (e.g. read.csv, read.table, or scan) which can deal with the commas on input. Then write using write.table with the default separator, a space. You'll likely want non-default choices for the row.names and col.names parameters. Duncan Murdoch __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] subsetting a matrix
Hi, I'm trying to take a set of rows and columns out of a matrix. I hve been using the index aray approach. My overll matrix is X and is 179 x 65. I want to take out 4 columns and 161 rows. Thus I made a 161 x 2 array I and filled it up with the row,col indices. However doing, X[ I ] gives me a vector of the extracted elements. Is there anyway I can coerce this into a 161 x 4 matrix? --- Rajarshi Guha [EMAIL PROTECTED] http://jijo.cjb.net GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE --- Disembowelling takes guts. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] lme vs. aov
Hi, I have a question about using lme and aov for the following dataset. If I understand correctly, using aov with Error term in the formula is equivalent to using lme with default settings, i.e. both assume compound symmetry correlation structure. And I have found that equivalency in the past. However, with the follwing dataset, I got different answers, can anyone explain what happened here? I have 2 differnt response variables x and y in the following dataset, with y, I achieved the equivalency between lme and aov, but with x, I got different p values for the ANOVA table. --- x-c(-0.0649,-0.0923,-0.0623,0.1809,0.0719,0.1017,0.0144,-0.1727,-0.1332,0.0986,0.304,-0.4093,0.2054,0.251,-0.1062,0.3833, 0.0649,0.2908,0.1073,0.0919,0.1167,0.2369,0.306,0.1379) y-c(-0.0649,-0.0923,0.32,0.08,0.0719,0.1017,0.05,-0.1727,-0.1332,0.15,0.304,-0.4093,0.2054,0.251,-0.1062,0.3833,0.0649, 0.2908,0.1073,0.0919,0.1167,0.2369,0.306,0.1379) treat-as.factor(c(1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2)) time-as.factor(c(1,1,1,1,2,2,2,2,3,3,3,3,1,1,1,1,2,2,2,2,3,3,3,3)) sex-as.factor(c('F','F','M','M','F','F','M','M','F','F','M','M','F','F','M','M','F','F','M','M','F','F','M','M')) subject-as.factor(c(rep(1:4,3),rep(5:8,3))) xx-cbind(x=data.frame(x),y=y,treat=treat,time=time,sex=sex,subject=subject) using x as dependable variable xx.lme-lme(x~treat*sex*time,random=~1|subject,xx) xx.aov-aov(x~treat*sex*time+Error(subject),xx) summary(xx.aov) Error: subject Df Sum Sq Mean Sq F value Pr(F) treat 1 0.210769 0.210769 6.8933 0.05846 . sex1 0.005775 0.005775 0.1889 0.68627 treat:sex 1 0.000587 0.000587 0.0192 0.89649 Residuals 4 0.122304 0.030576 --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 Error: Within Df Sum Sq Mean Sq F value Pr(F) time2 0.00102 0.00051 0.0109 0.9891 treat:time 2 0.00998 0.00499 0.1066 0.9002 sex:time2 0.02525 0.01263 0.2696 0.7704 treat:sex:time 2 0.03239 0.01619 0.3458 0.7178 Residuals 8 0.37469 0.04684 anova(xx.lme) numDF denDF F-value p-value (Intercept)1 8 3.719117 0.0899 treat 1 4 5.089022 0.0871 sex1 4 0.139445 0.7278 time 2 8 0.012365 0.9877 treat:sex 1 4 0.014175 0.9110 treat:time 2 8 0.120538 0.8880 sex:time 2 8 0.304878 0.7454 treat:sex:time 2 8 0.391012 0.6886 using y as dependable variable xx.lme2-lme(y~treat*sex*time,random=~1|subject,xx) xx.aov2-aov(y~treat*sex*time+Error(subject),xx) summary(xx.aov2) Error: subject Df Sum Sq Mean Sq F value Pr(F) treat 1 0.147376 0.147376 2.0665 0.2239 sex1 0.000474 0.000474 0.0067 0.9389 treat:sex 1 0.006154 0.006154 0.0863 0.7836 Residuals 4 0.285268 0.071317 Error: Within Df Sum Sq Mean Sq F value Pr(F) time2 0.009140 0.004570 0.1579 0.8565 treat:time 2 0.012598 0.006299 0.2177 0.8090 sex:time2 0.043132 0.021566 0.7453 0.5049 treat:sex:time 2 0.069733 0.034866 1.2050 0.3488 Residuals 8 0.231480 0.028935 anova(xx.lme2) numDF denDF F-value p-value (Intercept)1 8 3.0667809 0.1180 treat 1 4 2.0664919 0.2239 sex1 4 0.0066516 0.9389 time 2 8 0.1579473 0.8565 treat:sex 1 4 0.0862850 0.7836 treat:time 2 8 0.2177028 0.8090 sex:time 2 8 0.7453185 0.5049 treat:sex:time 2 8 1.2049883 0.3488 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] subsetting a matrix
Rajarshi - Why not simply subscript your matrix X to return the rows and columns you want to keep ? For example, new - X[16:176, c(3,5,7,9)] assuming those are the rows and columns you want. See help(Extract). - tom blackwell - u michigan medical school - ann arbor - On Tue, 30 Sep 2003, Rajarshi Guha wrote: I'm trying to take a set of rows and columns out of a matrix. I hve been using the index aray approach. My overll matrix is X and is 179 x 65. I want to take out 4 columns and 161 rows. Thus I made a 161 x 2 array I and filled it up with the row,col indices. However doing, X[ I ] gives me a vector of the extracted elements. Is there anyway I can coerce this into a 161 x 4 matrix? --- Rajarshi Guha [EMAIL PROTECTED] http://jijo.cjb.net GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE --- __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] generic function object
Hi, I would like to know if there is a way to see the code of a generic function? Like when I only type the function name, it prints the source of that function. But I cannot see the code of a generic function, it prints: ... function (object, ...) standardGeneric(normalize) environment: 0x8e9e368 Methods may be defined for arguments: object ... Thanks, Mathieu __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Preserving names from p to f in nlm (was: can't get names from vector in nlm calls)
Perhaps someone else can help you figure out how to preserve the names from argument p to function f in calls to nlm, but I'm now beyond the limits of my knowledge. I'm sorry, but I can't help further with this. Spencer Graves Jeff D. Hamann wrote: I started looking at the R and C code to examine where to change this and found the SEXP do_nlm(SEXP call, SEXP op, SEXP args, SEXP rho) function, but I'm not really sure how to modifiy yet to preserve the variable names, if there are variable names when it gets to that function. Plus I'd have to install lots of new and potentially conflicting tools on my win32 machine and then debug to the code... so i think I'm going to have to find another solution to my problem, which is a drag as the solution I originally thought of (get the names from p vector) would be the best one so far. Jeff. - Original Message - From: Spencer Graves [EMAIL PROTECTED] To: Spencer Graves [EMAIL PROTECTED] Cc: Jeff D. Hamann [EMAIL PROTECTED] Sent: Tuesday, September 30, 2003 5:44 AM Subject: Re: [R] can't get names from vector in nlm calls I've written functions to ask first if the input vector had names. If it didn't, I checked the length and then assigned the names I expected it to have. Then I checked the names. That worked for me. I believe it would be possible to get nlm/optim to preserve the names, as you ask. However, it would not be easy, and it might slow down the code. To check this, I typed nlm and optim at a command prompt and read the code. When I did that, I found that most of the work in both is done via a call to .Internal, which passes control to a compiled function. R is open source, which means you could get the source code and modify it to do what you want. However, that would be difficult, at least for me. hope this helps. spencer graves Jeff D. Hamann wrote: optim give the same results. is it possible to get nlm/optim to preserve the names? - Original Message - From: Spencer Graves [EMAIL PROTECTED] To: Jeff D. Hamann [EMAIL PROTECTED] Sent: Monday, September 29, 2003 8:18 PM Subject: Re: [R] can't get names from vector in nlm calls I have not used nlm, but it may not preserve the names of the starting values in p. hope this helps. spencer graves Jeff D. Hamann wrote: I've been trying to figure out how to get the names of the parameter vector variables when inside the function that nlm calls to return the objective function value: knls - function( theta, eqns, data, fitmethod=OLS, instr=NULL, S=NULL ) { ## print( names( theta ) ) # returns NULL ## get the values of the parameters for( i in 1:length( theta ) ) { val - theta[i] storage.mode( val ) - double assign( names( theta )[i], val ) # gags here cause I can't get the names... } ## resids = eval( lhs ) - eval( rhs ) for( i in length( eqns ) ) { lhs[[i]] - eval( formula( eqns[[i]] )[2] ) rhs[[i]] - eval( formula( eqns[[i]] )[3] ) residi[[i]] - lhs[[i]] - rhs[[i]] r - rbind( r, as.matrix( residi[[i]] ) ) } ## blah, blah, blah knls - obj } print( calling nlstest ) demand2 - q ~ d0 + d1 * p + d2 * d supply2 - q ~ s0 + s1 * p + s2 * f + s3 * a system2 - list( demand2, supply2 ) sv2 - c(d0=3,d2=4,d1=4.234,s0=-2.123,s2=2.123,s3=4.234,s1=0.234) ### call the nlm function to get the estimates... estnew - nlm( knls, sv2, hessian=TRUE, print.level=1, eqns=system2, data=kmenta, fitmethod=OLS ) My question is why can't I simply call names on the vector (sv2) that is passed into the nlm function to get the parameters? Thanks, Jeff. --- Jeff D. Hamann Hamann, Donald and Associates, Inc. PO Box 1421 Corvallis, Oregon USA 97339-1421 (office) 541-754-1428 (cell) 541-740-5988 [EMAIL PROTECTED] www.hamanndonald.com __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] generic function object
getMethods(normalize) should do the trick. Best, Jim James W. MacDonald Affymetrix and cDNA Microarray Core University of Michigan Cancer Center 1500 E. Medical Center Drive 7410 CCGC Ann Arbor MI 48109 734-647-5623 Mathieu Drapeau [EMAIL PROTECTED] 09/30/03 02:14PM Hi, I would like to know if there is a way to see the code of a generic function? Like when I only type the function name, it prints the source of that function. But I cannot see the code of a generic function, it prints: ... function (object, ...) standardGeneric(normalize) environment: 0x8e9e368 Methods may be defined for arguments: object ... Thanks, Mathieu __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] subsetting a matrix
On 30-Sep-03 Rajarshi Guha wrote: Hi, I'm trying to take a set of rows and columns out of a matrix. I hve been using the index aray approach. My overll matrix is X and is 179 x 65. I want to take out 4 columns and 161 rows. Thus I made a 161 x 2 array I and filled it up with the row,col indices. However doing, X[ I ] gives me a vector of the extracted elements. Is there anyway I can coerce this into a 161 x 4 matrix? X[c(list_of_rows),c(list_of_cols)] should do it. E.g. X[c(2,5,7,9),c(3,5,6)] Alternatively you can make index vectors iR (for rows), iC (for cols) which have values TRUE for what you want to select and FALSE for the rest; then X[iR,iC] will also do it. There are other approaches -- you should choose whichever most closely fits in with your criteria for row and column selection. E.g. X[iR,c(3,5,6)] would also do! What it all boils down to is an expression of the form X[rowselector, colselector] Hope this helps, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 167 1972 Date: 30-Sep-03 Time: 19:48:09 -- XFMail -- __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] cluster mgcv update
On Tue, Sep 30, 2003 at 02:04:23PM +0200, Martin Wegmann wrote: You need to add atlas2-base-dev: $ apt-get install atlas2-base-dev I installed atlas2-base-dev and g77 but know I get the error messages pasted below. Both (cluster and mgcv) requires lfrtbegin, but that does not seem to be programm which I can install via apt-get. FWIW this appears to have been in inconsistency between the newest Knoppix version and Debian testing/unstable which Martin was able to solve by grabbing the current gcc, g77 and g++ from Debian unstable. Dirk -- Those are my principles, and if you don't like them... well, I have others. -- Groucho Marx __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] fitdistr, mle's and gamma distribution
Dear R Users, I am trying to obtain a best-fit analytic distribution for a dataset with 11535459 entries. The data range in value from 1 to 3. I use: fitdistr(data, gamma) to obtain mle's for the parameters. I get the following error: Error in optim(start, mylogfn, x = x, hessian = TRUE, ...) : non-finite finite-difference value [1] And the following warnings: NaNs produced in: dgamma(x, shape, scale, log) I have the same problem with the exponential distribution, but the lognormal and weibull distributions don't have this problem. I suspect the problem has to do with: It means that in computing derivatives by finite differencing, one of the values is NA, +Inf or -Inf. Put some print values in your objective function and find out why it is giving a non-finite value. - quote by Prof Ripley from r-help as from the warnings it is clear that some of the values obtained during maximum likelihood computations are NaN. I cannot however print values of the objective function, as in my case it is dgamma which is called by fitdistr, over which I don't have control. Can anyone please point me in the right direction? Lourens -- Lourens Olivier Walters [EMAIL PROTECTED] Computer Science Masters Student University of Cape Town South Africa http://people.cs.uct.ac.za/~lwalters/ __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] subsetting a matrix
(Ted Harding) wrote: On 30-Sep-03 Rajarshi Guha wrote: Hi, I'm trying to take a set of rows and columns out of a matrix. I hve been using the index aray approach. My overll matrix is X and is 179 x 65. I want to take out 4 columns and 161 rows. ... This is documented in An Introduction to R, under the section Arrays and Matricies. There's lots of good stuff in there. From R: help.start() And click on An Introduction to R. The short answer to this particular question: a) negative indicies remove rows or columns. Since you only want to remove 4 columns, I'd use that. b) Since you only want to keep 18 rows, I'd use the numbers of the rows you want to keep. As a toy example, say you wanted to remove columns 51 to 54, and keep the last 18 rows: newX - X[162:179,-(51:54)] There's even more handy stuff in the document mentioned above. cheers Jason -- Indigo Industrial Controls Ltd. http://www.indigoindustrial.co.nz 64-21-343-545 [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Problem with R1.8beta
Hi, I trying to use r.180beta on a XPPro PC with Athlon 2.0 I downloaded the zip file and when I unzipped it using winzip last version I had this message: C:\Program Files\R\rw1080beta\doc\manual\refman.pdf An error occured while trying to copy a file: The source file is corrupted. Anything to do with this or shall I just skip it ? thanks Philippe G [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] fitdistr, mle's and gamma distribution
In my experience, the most likely cause of this problem is that optim may try to test nonpositive values for shape or scale. I avoid this situation by programming the log(likelihood) in terms of log(shape) and log(scale) as follows: gammaLoglik - + function(x, logShape, logScale, negative=TRUE){ + lglk - sum(dgamma(x, shape=exp(logShape), scale=exp(logScale), + log=TRUE)) + if(negative) return(-lglk) else return(lglk) + } tst - rgamma(10, 1) gammaLoglik(tst, 0, 0) [1] 12.29849 Then I then call optim directly to minimize the negative of the log(likelihood). If I've guessed correctly, this should fix the problem. If not, let us know. hope this helps. spencer graves Lourens Olivier Walters wrote: Dear R Users, I am trying to obtain a best-fit analytic distribution for a dataset with 11535459 entries. The data range in value from 1 to 3. I use: fitdistr(data, gamma) to obtain mle's for the parameters. I get the following error: Error in optim(start, mylogfn, x = x, hessian = TRUE, ...) : non-finite finite-difference value [1] And the following warnings: NaNs produced in: dgamma(x, shape, scale, log) I have the same problem with the exponential distribution, but the lognormal and weibull distributions don't have this problem. I suspect the problem has to do with: It means that in computing derivatives by finite differencing, one of the values is NA, +Inf or -Inf. Put some print values in your objective function and find out why it is giving a non-finite value. - quote by Prof Ripley from r-help as from the warnings it is clear that some of the values obtained during maximum likelihood computations are NaN. I cannot however print values of the objective function, as in my case it is dgamma which is called by fitdistr, over which I don't have control. Can anyone please point me in the right direction? Lourens __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] subsetting a matrix
On Tue, 2003-09-30 at 15:51, Jason Turner wrote: (Ted Harding) wrote: On 30-Sep-03 Rajarshi Guha wrote: Hi, I'm trying to take a set of rows and columns out of a matrix. I hve been using the index aray approach. My overll matrix is X and is 179 x 65. I want to take out 4 columns and 161 rows. ... This is documented in An Introduction to R, under the section Arrays and Matricies. There's lots of good stuff in there. From R: help.start() And click on An Introduction to R. The short answer to this particular question: a) negative indicies remove rows or columns. Since you only want to remove 4 columns, I'd use that. b) Since you only want to keep 18 rows, I'd use the numbers of the rows you want to keep. Thanks for all the answers. I had been writing loops and extracting elements - I've been spending too much time in C :-/ --- Rajarshi Guha [EMAIL PROTECTED] http://jijo.cjb.net GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE --- Build a system that even a fool can use and only a fool will want to use it. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] in addition R1.8b install
this problem also occurred later in the installation process: C:\Program Files\R\rw1080beta\doc\manual\refman.pdf C:\Program Files\R\rw1080beta\library\mva\html\loadings.html C:\Program Files\R\rw1080beta\library\ctest\html\fisher.test.html C:\Program Files\R\rw1080beta\library\base\chtml\base.chm C:\Program Files\R\rw1080beta\afm\hvo.afm An error occured while trying to copy a file: The source file is corrupted. however by the end R opened correctly any suggestions ? thanks Philippe [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] in addition R1.8b install
On Tue, 2003-09-30 at 15:00, [EMAIL PROTECTED] wrote: this problem also occurred later in the installation process: C:\Program Files\R\rw1080beta\doc\manual\refman.pdf C:\Program Files\R\rw1080beta\library\mva\html\loadings.html C:\Program Files\R\rw1080beta\library\ctest\html\fisher.test.html C:\Program Files\R\rw1080beta\library\base\chtml\base.chm C:\Program Files\R\rw1080beta\afm\hvo.afm An error occured while trying to copy a file: The source file is corrupted. however by the end R opened correctly any suggestions ? thanks Philippe The first thing to try would be to re-download the ZIP file to rule in/out the possibility that the download was corrupted. HTH, Marc Schwartz __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] in addition R1.8b install
On Tue, 2003-09-30 at 15:35, Marc Schwartz wrote: On Tue, 2003-09-30 at 15:00, [EMAIL PROTECTED] wrote: this problem also occurred later in the installation process: C:\Program Files\R\rw1080beta\doc\manual\refman.pdf C:\Program Files\R\rw1080beta\library\mva\html\loadings.html C:\Program Files\R\rw1080beta\library\ctest\html\fisher.test.html C:\Program Files\R\rw1080beta\library\base\chtml\base.chm C:\Program Files\R\rw1080beta\afm\hvo.afm An error occured while trying to copy a file: The source file is corrupted. however by the end R opened correctly any suggestions ? thanks Philippe The first thing to try would be to re-download the ZIP file to rule in/out the possibility that the download was corrupted. HTH, Marc Schwartz Correction, that should read EXE file... Sorry. Marc __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] fitdistr, mle's and gamma distribution
Spencer Graves's suggestion of using shape and scale parameters on a log scale is a good one. To do specifically what you want (check values for which the objective function is called and see what happens) you can do the following (untested!), which makes a local copy of dgamma that you can mess with: dgamma.old - dgamma dgamma - function(x,shape,rate,...) { d - dgamma.old(x,shape,rate,...) cat(shape,rate,d,\n) return(d) } On Tue, 30 Sep 2003, Lourens Olivier Walters wrote: Dear R Users, I am trying to obtain a best-fit analytic distribution for a dataset with 11535459 entries. The data range in value from 1 to 3. I use: fitdistr(data, gamma) to obtain mle's for the parameters. I get the following error: Error in optim(start, mylogfn, x = x, hessian = TRUE, ...) : non-finite finite-difference value [1] And the following warnings: NaNs produced in: dgamma(x, shape, scale, log) I have the same problem with the exponential distribution, but the lognormal and weibull distributions don't have this problem. I suspect the problem has to do with: It means that in computing derivatives by finite differencing, one of the values is NA, +Inf or -Inf. Put some print values in your objective function and find out why it is giving a non-finite value. - quote by Prof Ripley from r-help as from the warnings it is clear that some of the values obtained during maximum likelihood computations are NaN. I cannot however print values of the objective function, as in my case it is dgamma which is called by fitdistr, over which I don't have control. Can anyone please point me in the right direction? Lourens -- 620B Bartram Hall[EMAIL PROTECTED] Zoology Department, University of Floridahttp://www.zoo.ufl.edu/bolker Box 118525 (ph) 352-392-5697 Gainesville, FL 32611-8525 (fax) 352-392-3704 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] truncated multivariate normal
Please, I would like to know how to generate a truncated multivariate normal distribution k - dimensional,X ~ NT(mu, Sigma), where the elements of X to be non-negative (except the first), and the first dimension is strictly larger than zero. Example: X ~ NT_2(mu, Sigma), where mu=c(0.5, 0.5) and Sigma=c([120, 191], [191,154]), with X_10 and X_2=0 Could anybody help me? Thanks in advanced. Juliana G. Cespedes Mestranda em Estatística e Experimentação Agronômica Departamento de Ciências Exatas - ESALQ/USP São Paulo - Brasil __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] fitdistr, mle's and gamma distribution
PS. 11 MILLION entries?? On Tue, 30 Sep 2003, Ben Bolker wrote: Spencer Graves's suggestion of using shape and scale parameters on a log scale is a good one. To do specifically what you want (check values for which the objective function is called and see what happens) you can do the following (untested!), which makes a local copy of dgamma that you can mess with: dgamma.old - dgamma dgamma - function(x,shape,rate,...) { d - dgamma.old(x,shape,rate,...) cat(shape,rate,d,\n) return(d) } On Tue, 30 Sep 2003, Lourens Olivier Walters wrote: Dear R Users, I am trying to obtain a best-fit analytic distribution for a dataset with 11535459 entries. The data range in value from 1 to 3. I use: fitdistr(data, gamma) to obtain mle's for the parameters. I get the following error: Error in optim(start, mylogfn, x = x, hessian = TRUE, ...) : non-finite finite-difference value [1] And the following warnings: NaNs produced in: dgamma(x, shape, scale, log) I have the same problem with the exponential distribution, but the lognormal and weibull distributions don't have this problem. I suspect the problem has to do with: It means that in computing derivatives by finite differencing, one of the values is NA, +Inf or -Inf. Put some print values in your objective function and find out why it is giving a non-finite value. - quote by Prof Ripley from r-help as from the warnings it is clear that some of the values obtained during maximum likelihood computations are NaN. I cannot however print values of the objective function, as in my case it is dgamma which is called by fitdistr, over which I don't have control. Can anyone please point me in the right direction? Lourens -- 620B Bartram Hall[EMAIL PROTECTED] Zoology Department, University of Floridahttp://www.zoo.ufl.edu/bolker Box 118525 (ph) 352-392-5697 Gainesville, FL 32611-8525 (fax) 352-392-3704 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Re: Help needed: plotting with no device
Thanks to everyone for your help. I decided to see if the session could be recovered if I connected back from the original, local terminal. The local screen was locked by the KDE screensaver. Either my unlocking it, or the passage of time, seems to have got the process unstuck. It happened before I reattached to the screen session from a local terminal. Whew! __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] truncated multivariate normal
Do you mean you want to generate deviates from this distribution or that you want the density function (or distribution function)? mvrnorm in package MASS (library(MASS)) will generate multivariate normal deviates. A brute-force approach would just keep picking values until you get ones in the right quadrant, although with your example (large variance, small mean) that would mean you would be wasting 3/4 of your values -- so there are probably more efficient approaches. Depends how much time you want to spend programming, how many values you want to draw, and how fast your computer is ... Ben On Tue, 30 Sep 2003, Juliana Garcia Cespedes wrote: Please, I would like to know how to generate a truncated multivariate normal distribution k - dimensional,X ~ NT(mu, Sigma), where the elements of X to be non-negative (except the first), and the first dimension is strictly larger than zero. Example: X ~ NT_2(mu, Sigma), where mu=c(0.5, 0.5) and Sigma=c([120, 191], [191,154]), with X_10 and X_2=0 Could anybody help me? Thanks in advanced. Juliana G. Cespedes Mestranda em Estatística e Experimentação Agronômica Departamento de Ciências Exatas - ESALQ/USP São Paulo - Brasil __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help -- 620B Bartram Hall[EMAIL PROTECTED] Zoology Department, University of Floridahttp://www.zoo.ufl.edu/bolker Box 118525 (ph) 352-392-5697 Gainesville, FL 32611-8525 (fax) 352-392-3704 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Help needed: plotting with no device
On Mon, 2003-09-29 at 14:25, Luke Tierney wrote: Look at ?Signal and see if that would help. You may need to rename the appropriate .RData beforehand to be safer. luke For those who follow, note it's actually ?Signals you want. It talks about USR1 and USR2 (as did some other people in this thread). __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] variables
Hi, can someone please help me. I will give a simple example of my problem. p - function() { i - 1 sr - function(){ i-i+3 i- sqrt(i) } cat(i) } This is just an example. My main problem is defining i like a global variable which I can use in the sub- and main functions without any complicated switches. Thanks in advance. cilver = = Sylvie B. Forkusam Eppelheimer Str.52/A2-5-2 69115 Heidelberg, Germany Tel: (0049)-06221/346913 Mobile: 0179-6816276 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Problem with R1.8beta
On Tue, 30 Sep 2003 15:56:03 EDT, you wrote: Hi, I trying to use r.180beta on a XPPro PC with Athlon 2.0 I downloaded the zip file and when I unzipped it using winzip last version I had this message: C:\Program Files\R\rw1080beta\doc\manual\refman.pdf An error occured while trying to copy a file: The source file is corrupted. Anything to do with this or shall I just skip it ? I'd check the md5sum for the file to see whether your download really was corrupted or not. Duncan Murdoch __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] variables
forkusam wrote: Hi, can someone please help me. I will give a simple example of my problem. p - function() { i - 1 sr - function(){ i-i+3 i- sqrt(i) } cat(i) } This is just an example. My main problem is defining i like a global variable which I can use in the sub- and main functions without any complicated switches. Thanks in advance. cilver Within the function p(), it should just work. Try this slight variation of your example: p - function() { i - 1 sr - function(){ i-i+3 i- sqrt(i) i #explicitly return the newly calculated value } cat(sr() returned ,sr(),\n) #now check if i was actually modified outside sr() cat(i = ,i,\n) } When I load this into R... p() sr() returned 2 i = 1 note that i is not visible outside the function p(). It disappears when p() exits. i Error: Object i not found The internal function variables being available to sub-fuctions is an example of lexical scoping, and it's one of the things that makes R so nice to work with. Try demo(scoping) for a very interesting use of lexical scoping. Cheers Jason -- Indigo Industrial Controls Ltd. http://www.indigoindustrial.co.nz 64-21-343-545 [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] R icon for RedHat 9.
Dear R-helpers, I just installed R on a RedHat 9 machine and when I was trying add a launcher on the panel to it, I could not find any R icon in png format. Is there any available? Do I have it and I could not find it in my file hierarchy? Thank you for your help. Carlos J. Gil Bellosta Sigma Consultores Estadísticos http://www.consultoresestadisticos.com __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] R-icon for RH Linux 9.
Dear R helpers, It is the first time I have to install R under Linux (Red Hat 9) and as I was setting up the panels, I could not find any png icon to launch the program. Does it exist and I have overlooked it? Can I get it somewhere? Carlos J. Gil Bellosta Sigma Consultores Estadísticos http://www.consultoresestadisticos.com __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Remove comma (,) in data set
Muhammad Subianto [EMAIL PROTECTED] wrote: I am new learning R. Now, I have a data set like: 24,2,3,3,1,1,2,3,0,1 45,1,3,10,1,1,3,4,0,1 ... with 3730 rows I want to remove comma (,) in data set. The result like: 24 2 3 3 1 1 2 3 0 1 45 1 3 10 1 1 3 4 0 1 ... How can I do it. Thanks you for your help. Assuming your dataset is stored in a flat ascii file, you need not use R for this trivial translation of the character , into a space . From your shell (i.e., if standard shell tools are available on your machine), type the following: cat file1 | tr ,file2 -- Philippe Glaziou Institut Pasteur du Cambodge __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help