[R] ordering boxplots according to median
Dear R-users, Does anyone knows how I can order my serie of boxplots from lowest to highest median (which is much better for visualization purposes). thanks in advance, willem [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] ordering boxplots according to median
Willem, use the at= argument, and feed it the rank of the medians eg require(MASS) data(iris) boxplot(iris$Sepal.Width ~ iris$Species) # Not ordered boxplot(iris$Sepal.Width ~ iris$Species, at=rank(tapply(iris$Sepal.Width, iris$Species, median))) # Ordered I hope that this helps, Andrew On Wed, Mar 22, 2006 at 09:59:09AM +0100, Talloen, Willem [PRDBE] wrote: Dear R-users, Does anyone knows how I can order my serie of boxplots from lowest to highest median (which is much better for visualization purposes). thanks in advance, willem [[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 -- Andrew Robinson Department of Mathematics and StatisticsTel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 Email: [EMAIL PROTECTED] http://www.ms.unimelb.edu.au __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] ordering boxplots according to median
boxplot(count~spray, InsectSprays) spray2 - with(InsectSprays, factor(spray, levels=levels(spray)[order(tapply(count,spray,median))])) boxplot(count~spray2, InsectSprays) Talloen, Willem [PRDBE] a écrit : Dear R-users, Does anyone knows how I can order my serie of boxplots from lowest to highest median (which is much better for visualization purposes). thanks in advance, willem [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Classifying time series by shape over time
Hi, turnpoints() in library(pastecs) determines if the succession of peaks and pits is random, or not. I think that the hypothesis here is little bit stronger: it should fit a Gaussian. I just think a little bit to this problem, and I don't get a simple solution. Here is what I got, but this is subject certainly to many criticisms (feel free to do so!). The idea is to draw the cumulative distribution of the hits and fit it with a logistic curve. Then, predicted hits are back calculated (knowind that the logistic curve is symmetrical around 'xmid'), and the observed and predicted distributions of the hits are compared using a Kolmogorv-Smirnov goodness-of-fit test: # Enter example data id1 - data.frame( dates = as.Date(c(2004-12-01, 2005-01-01, 2005-02-01, 2005-03-01, 2005-04-01, 2005-05-01, 2005-06-01, 2005-07-01, 2005-08-01, 2005-09-01, 2005-10-01, 2005-11-01, 2005-12-01)), hits = c(3, 4, 10, 6, 35, 14, 33, 13, 3, 9, 8, 4, 3)) id2 - data.frame( dates = as.Date(c(2001-01-01, 2001-02-01, 2001-03-01, 2001-04-01, 2001-05-01, 2001-06-01, 2001-07-01, 2001-08-01, 2001-09-01, 2001-10-01, 2001-11-01, 2001-12-01, 2002-01-01, 2002-02-01, 2002-03-01, 2002-04-01, 2002-05-01, 2002-06-01, 2002-07-01, 2002-08-01, 2002-09-01, 2002-10-01, 2002-11-01, 2002-12-01, 2003-01-01, 2003-02-01, 2003-03-01)), hits = c(6, 5, 5, 6, 2, 5, 1, 6, 4, 10, 0, 3, 6, 5, 1, 2, 4, 4, 0, 1, 0, 2, 2, 2, 2, 3, 7)) # How does it look like? plot(id1$dates, id1$hits, type = l) plot(id2$dates, id2$hits, type = l) # Cumsum of hits and fit models id1$datenum - as.numeric(id1$dates) id1$cumhits - cumsum(id1$hits) id1.fit - nls(cumhits ~ SSlogis(datenum, Asym, xmid, scal), data = id1) summary(id1.fit) plot(id1$dates, id1$cumhits) lines(id1$dates, predict(id1.fit)) id2$datenum - as.numeric(id2$dates) id2$cumhits - cumsum(id2$hits) id2.fit - nls(cumhits ~ SSlogis(datenum, Asym, xmid, scal), data = id2) summary(id2.fit) plot(id2$dates, id2$cumhits) lines(id2$dates, predict(id2.fit)) # Get xmid and recalculate predicted values for hits xmid1 - coef(id1.fit)[xmid] id1$hitspred - predict(id1.fit, newdata = data.frame(datenum = xmid1 - abs(id1$datenum - xmid1))) plot(id1$dates, id1$hits, ylim = range(c(id1$hits, id1$hitspred))) lines(id1$dates, id1$hitspred) xmid2 - coef(id2.fit)[xmid] id2$hitspred - predict(id2.fit, newdata = data.frame(datenum = xmid2 - abs(id2$datenum - xmid2))) plot(id2$dates, id2$hits, ylim = range(c(id2$hits, id2$hitspred))) lines(id2$dates, id2$hitspred) # A two samples Kolmogorov-Smirnov test of goodness-of-fit ks.test(id1$hits, id1$hitspred) # H0 not rejected ks.test(id2$hits, id2$hitspred) # H0 rejected Best, Philippe Grosjean Kjetil Brinchmann Halvorsen wrote: Andreas Neumann wrote: Dear all, I have hundreds of thousands of univariate time series of the form: character seriesid, vector of Date, vector of integer (some exemplary data is at the end of the mail) I am trying to find the ones which somehow have a shape over time that looks like the histogramm of a (skewed) normal distribution: hist(rnorm(200,10,2)) The mean is not interesting, i.e. it does not matter if the first nonzero observation happens in the 2. or the 40. month of observation. So all that matters is: They should start sometime, the hits per month increase, at some point they decrease and then they more or less disappear. Short Example (hits at consecutive months (Dates omitted)): 1. series: 0 0 0 2 5 8 20 42 30 19 6 1 0 0 0- Good 2. series: 0 3 8 9 20 6 0 3 25 67 7 1 0 4 60 20 10 0 4 - Bad Series 1 would be an ideal case of what I am looking for. Graphical inspection would be easy but is not an option due to the huge amount of series. Does function turnpoints)= in package pastecs help_ Kjetil Questions: 1. Which (if at all) of the many packages that handle time series is appropriate for my problem? 2. Which general approach seems to be the most straightforward and best supported by R? - Is there a way to test the time series directly (preferably)? - Or do I need to type-cast them as some kind of histogram data and then test against the pdf of e.g. a normal distribution (but how)? - Or something totally different? Thank you for your time, Andreas Neumann Data Examples (id1 is good, id2 is bad): id1 dates hits 1 2004-12-01 3 2 2005-01-01 4 3 2005-02-0110 4 2005-03-01 6 5 2005-04-0135 6 2005-05-0114 7 2005-06-0133 8 2005-07-0113 9 2005-08-01 3 10 2005-09-01 9 11 2005-10-01 8 12 2005-11-01 4 13 2005-12-01 3 id2 dates hits 1 2001-01-01 6 2 2001-02-01 5 3 2001-03-01 5 4 2001-04-01 6 5 2001-05-01 2 6 2001-06-01 5 7 2001-07-01 1 8
[R] post hoc comparison following with multcomp?
Dear R community, I would like to check differences between treatment (Trait) following a glm. From R help list, I tried in the following way using the multcom library. Please, is it a correct manner to do post hoc comparison with the data below. Thank you in advance. Sincerely * tabp-read.delim(ponteM1.txt)* * tabp* Trait totponte 1 T 10 2 T 11 3 T 11 4 T9 5 T7 6 T7 7 T9 8 T 12 9 T9 10 T 10 11 M9 12 M 10 13 M8 14 M8 15 M 10 16 M8 17 M8 18 M9 19 M 11 20 M7 21 F8 22 F8 23 F5 24 F9 25 F5 26 F7 27 F5 28 F7 29 F6 30 F3 * attach(tabp)* * glm1-glm(totponte~Trait,family=poisson)* ** * anova(glm1,test=F)* Model: poisson, link: log Response: totponte Terms added sequentially (first to last) Df Deviance Resid. Df Resid. Dev F Pr(F) NULL 2916.3879 Trait 2 7.177027 9.2109 3.5885 0.02764 * * * * library(multcomp)* * (coefglm1-coef(glm1))* (Intercept) TraitM TraitT 1.8405496 0.3342021 0.4107422 * (vc.trait-vcov(glm1))* (Intercept) TraitM TraitT (Intercept) 0.01587301 -0.01587301 -0.01587301 TraitM -0.01587301 0.02723665 0.01587301 TraitT -0.01587301 0.01587301 0.02639933 * (CM-contrMat(table(tabp$Trait),type=Tukey))* F M T M-F -1 1 0 T-F -1 0 1 T-M 0 -1 1 * * * csimint(coefglm1,df=27,covm=vc.trait,cmatrix=CM)* Simultaneous confidence intervals: user-defined contrasts 95 % confidence intervals Estimate 2.5 % 97.5 % M-F -1.506 -2.177 -0.836 T-F -1.430 -2.097 -0.763 T-M0.077 -0.286 0.439 --- Michaël COEURDASSIER, PhD Department of Environmental Biology UsC INRA EA3184MRT Institute for Environmental Sciences and Technology University of Franche-Comte Place Leclerc 25030 Besançon cedex FRANCE Tel : +33 (0)381 665 741 Fax : +33 (0)381 665 797 [EMAIL PROTECTED]: [EMAIL PROTECTED] http://lbe.univ-fcomte.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
[R] gray level values
Hello. I have a matrix whit n1 rows and n2 columns called example. If I do image(example), R shows me an image with 480x480 pixels. How can I obtain the gray level of the pixel of row i and column j? Thanks, Arnau. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] mixed ordinal logistic regression
Dear Colleagues, I hope to know how ordinal logistic regression with a mixed model is made in R. We (My colleague and I) are studying the behavior of a beetle. The attraction of beetles to a stimulus are recorded: the response is Slow, Mid, or Fast. They are based on the time after the presentation of the stimulus to the beetles. Because we do not observe the behavior continuously but do record the number of beetles near the stimulus at the pre-determined two timings. The beetles that are near the stimulus at the 1st timing are Fast. Those that come to 'near the stimulus' between the first and second timings are Mid. Those that do not come to 'near the stimulus' till the second timing are Slow. The response variable is an ordinal one. We applied 3 treatments (say, A, B and C) for groups of the beetles. We had several groups for each of the treatments. A group of beetles was reared in a container. I think the difference among groups under a given treatment is random-effect, while the difference among the treatments is fixed-effect. So , I hope to know the information on ordinal logistic regression in a mixed model in R. ** **Kasuya, Eiiti **Department of Biology, **Faculty of Sciences, **Kyushu University, **Hakozaki, **Hukuoka,812-8581(postal code) **Japan **telephone 092-642-2624 or 092-642-2623 **facsimile 092-642-2645 ** __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Use of the index of a for loop to assign values to the rows of a series of variables
Dear All, It is difficult to summarize the question in few words. So, please, look at the following example. Thanks in advance, domenico -- rm(list = ls()) posfix=1:5* 10 for(i in posfix) assign(paste(matX.,i,sep=),matrix(0,3,2)) ls() [1] i matX.10 matX.20 matX.30 matX.40 matX.50 posfix AT THIS STEP I HAVE 5 MATRIX OF ZEROS (3 ROWS PER 2 COLUMNS) NOW I WOULD LIKE TO ASSIGN TO A ROW OF THE 5 MATRICES A VALUE RELATED TO THE INDEX OF A FOR LOOP for(i in 1:length(posfix)) assign(paste(matX.,posfix[i],[,i,,],sep=),i) ls() [1] i matX.10 matX.10[1,] matX.20 matX.20[2,] [6] matX.30 matX.30[3,] matX.40 matX.40[4,] matX.50 [11] matX.50[5,] posfix ?? WHY IT DOES NOT ASSIGN THE VALUE TO THE ROWS OF THE PRE-INITIALIZED VARIABLES. WHERE IS MY ERROR? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] R package for computing state path using Viterbi algorithm
Dear list, This question is about Hidden Markov Model. Given a transition matrix, an emission matrix and a sequence of observed symbols (actually, nucleotide sequences, A, T, C and G), I hope to predict the sequence of state by Viterbi algorithm. I searched R repository for related packages. msm package has function viterbi.msm (as well as very good document), but it only works for continuous-time condition. Other two HMM related packages, hmm.discnp and repeats, however, does not have such a function (similar to hmmviterbi() function in MatLab). Is there an R package that implements such a function? Thanks, Wuming __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Sheather Jones Plug-In Bandwidth
Dear All, Is there a way to find bandwidths for Normal, and Triangular Kernels using Sheather Jones plug-in method. If not, is there a way we could convert the bandwidth obtained by the default( I assume that the default is standard normal) in hcj(x,...) to other kernels. I appreciate your help. Thanks Durai - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Sweave in png
Hello list, Here is a problem I had. I write this to the list in case the solution I found would be useful to anyone else. I had to Sweave document including pixmap pictures, which are very heavy when converted into pdf pictures. In practice, this eventually led to very heavy pdf, sometimes impossible to read. So the first solution I found was to save pictures in png, when too heavy in pdf : ### in a .rnw document ### % here is an invisible chunck to create a picture fig =FALSE,echo=FALSE= png(filename='figs/myPic.png') @ % next, R code to generate picture fig=FALSE,echo=TRUE= ... @ % then, close the device. Hidden, again fig =FALSE,echo=FALSE= dev.off() @ % and then, include it as a picture \includegraphics{figs/myPic.png} ### end of the example ### I found that quite heavy, though, when more than one such figure were needed in my document. So I adapted the Sweave driver 'RweaveLatex' in order to allow to generate png pictures instead of ps or pdf, when using a pdf-oriented compiler (such as pdflatex). I just have to source the new driver (RweaveInPng), then call it when Sweaving. Then for example, I simply use: ### rnw document ### % a single chunck containing R code to generate the picture fig=TRUE,pdf=FALSE,png=TRUE= ... @ The driver, which is only a slight modification of RweaveLatex, can generate ps, pdf or png figures; it was tested on Ubuntu64, Debian, several Windows systems and macOS X partforms with no detected problem. Does someone find this useful, or were there better solutions I missed? Regards, Thibaut Jombart . -- ## Thibaut JOMBART CNRS UMR 5558 - Laboratoire de Biométrie et Biologie Evolutive Universite Lyon 1 43 bd du 11 novembre 1918 69622 Villeurbanne Cedex Tél. : 04.72.43.29.35 Fax : 04.72.43.13.88 [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Use of the index of a for loop to assign values to the rows of a series of variables
On Wed, 22 Mar 2006, Domenico Vistocco wrote: Dear All, It is difficult to summarize the question in few words. So, please, look at the following example. Thanks in advance, domenico -- rm(list = ls()) posfix=1:5* 10 for(i in posfix) assign(paste(matX.,i,sep=),matrix(0,3,2)) ls() [1] i matX.10 matX.20 matX.30 matX.40 matX.50 posfix AT THIS STEP I HAVE 5 MATRIX OF ZEROS (3 ROWS PER 2 COLUMNS) NOW I WOULD LIKE TO ASSIGN TO A ROW OF THE 5 MATRICES A VALUE RELATED TO THE INDEX OF A FOR LOOP Don't do that. Make matX a list of matrices, so that matX.10 is matX[[1]], matX.20 is matX[[2]]. for(i in 1:length(posfix)) assign(paste(matX.,posfix[i],[,i,,],sep=),i) ls() [1] i matX.10 matX.10[1,] matX.20 matX.20[2,] [6] matX.30 matX.30[3,] matX.40 matX.40[4,] matX.50 [11] matX.50[5,] posfix ?? WHY IT DOES NOT ASSIGN THE VALUE TO THE ROWS OF THE PRE-INITIALIZED VARIABLES. WHERE IS MY ERROR? The help page for assign says 'assign' does not dispatch assignment methods, so it cannot be used to set elements of vectors, names, attributes, etc. There is a solution using eval and substitute, but you really don't want to go there. -thomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Use of the index of a for loop to assign values to the rows of a series of variables
Hi Domenico, If I understand correctly, you are missing a step. See also ?get Something like this should do what you want: for(i in 1:length(posfix)) { matname - paste(matX.,posfix[i], sep=) # store the filename currently needed thismat - get(matname) # get the matrix matching that filename # do whatever assignment you'd like assign(matname, thismat) # copy thismat back into matname } -- Sarah Goslee USDA-ARS [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] An lme model that works in old R.2.1.1 but not always in R.2.2.0 - why?
Following lme model runs fine in general under R.2.1.1 but only for 9 out of my 11 response variables under R.2.2.0. model for one of my response variables: lme(Yresp~F1fix,random=list(const=pdBlocked(list(~F2mix-1,~Ass:F1fix-1,~F3mix-1,~F1fix:F3mix-1,~F2mix:F3mix-1),pdClass=pdIdent))) Yresp is my response variable, F1fix is a fixed effect factor whereas F2mix and F3mix are random effect factors. const is set to rep(1,dim(Ycont)[1]). The strange thing is that if an intercept is omitted (F1fix-1) the R.2.2.0 also runs a 100 %. It's the same model, just with another parameterization?? Niels Sommer __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Use of the index of a for loop to assign values to the ro ws of a series of variables
1. The matrices are only 3x2. In your loop you'd be assigning rows 4 and 5 in the last two iterations. Are you sure that's what you want? 2. The reason it ``didn't work'' is because assign() takes the first argument as the name of the object to create, literally, instead of evaluating it. 3. You probably ought to be working with a list. E.g.: m - replicate(5, matrix(0, 5, 2), simplify=FALSE) names(m) - paste(MAT, 1:5 * 10, sep=) for (i in 1:length(m)) m[[i]][i, ] - i Andy ps: Please try not to use all caps: It's the equivalent of shouting on top of your lungs. Not exactly the thing to do when you're asking for help. From: Domenico Vistocco Dear All, It is difficult to summarize the question in few words. So, please, look at the following example. Thanks in advance, domenico -- -- -- rm(list = ls()) posfix=1:5* 10 for(i in posfix) assign(paste(matX.,i,sep=),matrix(0,3,2)) ls() [1] i matX.10 matX.20 matX.30 matX.40 matX.50 posfix AT THIS STEP I HAVE 5 MATRIX OF ZEROS (3 ROWS PER 2 COLUMNS) NOW I WOULD LIKE TO ASSIGN TO A ROW OF THE 5 MATRICES A VALUE RELATED TO THE INDEX OF A FOR LOOP for(i in 1:length(posfix)) assign(paste(matX.,posfix[i],[,i,,],sep=),i) ls() [1] i matX.10 matX.10[1,] matX.20 matX.20[2,] [6] matX.30 matX.30[3,] matX.40 matX.40[4,] matX.50 [11] matX.50[5,] posfix ?? WHY IT DOES NOT ASSIGN THE VALUE TO THE ROWS OF THE PRE-INITIALIZED VARIABLES. WHERE IS MY ERROR? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R package for computing state path using Viterbi algorithm
Wuming, Have a look at the depmix package that implements the viterbi algorithm for hidden markov models (in discrete time). The function to use is posterior(...). The package includes a manual with a number of examples. Hth, Ingmar From: Wuming Gong [EMAIL PROTECTED] Date: Wed, 22 Mar 2006 23:18:54 +0800 To: r-help@stat.math.ethz.ch Subject: [R] R package for computing state path using Viterbi algorithm Dear list, This question is about Hidden Markov Model. Given a transition matrix, an emission matrix and a sequence of observed symbols (actually, nucleotide sequences, A, T, C and G), I hope to predict the sequence of state by Viterbi algorithm. I searched R repository for related packages. msm package has function viterbi.msm (as well as very good document), but it only works for continuous-time condition. Other two HMM related packages, hmm.discnp and repeats, however, does not have such a function (similar to hmmviterbi() function in MatLab). Is there an R package that implements such a function? Thanks, Wuming __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] setting argument defaults in setMethod
Hi, I want to set a default value in a method of a generic function. This seems as though it should be possible. From R help on setMethod... Method definitions can have default expressions for arguments. If those arguments are then missing in the call to the generic function, the default expression in the method is used. If the method definition has no default for the argument, then the expression (if any) supplied in the definition of the generic function itself is used. But note that this expression will be evaluated in the environment defined by the method. So, I try this... setGeneric(test,function(x,y){standardGeneric(test)}) setMethod(test,numeric, function(x,y=FALSE){ browser() } ) test(5) Called from: test(5) Browse[1] x [1] 5 Browse[1] y Error: argument y is missing, with no default Why doesn't it find the default setting of y? If instead I define the generic as... setGeneric(test1,function(x,...){standardGeneric(test1)}) setMethod(test1,numeric, function(x,y=FALSE){ browser() } ) test1(5) Called from: .local(x, ...) Browse[1] x [1] 5 Browse[1] y [1] FALSE In this case I can access the default value of y because it is not an argument to the generic function. However, this seems to contradict the help. The help implies that the default does not need to be missing from the generic. In fact, it states that only if the default value is missing from the method will the default be retrieved from generic function. If the help is correct, then why doesn't the code in the for test above work? If the help is wrong, then how does one set defaults in methods? Thanks, Steve [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Is it possible to model with Laplace's error distribution?
As you haven't gotten a reply, I'll make an attempt; but caveat emptor! Hopefully others will correct my errors. The Laplace distribution is double exponential with heavy tails and for which the sample median, not the mean, is the mle for the location parameter. In the more general linear modeling context, this suggests you might be interested in quantile regression, for which Roger Koenker's quantreg package is the place to go. However, I doubt that the lmer package can deal with this in the mixed model context, as special algorithms are required. Doug Bates or others should correct me if I'm wrong on this. HTH. And again, caveat emptor. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Petar Milin Sent: Tuesday, March 21, 2006 2:42 PM To: R-HELP Subject: [R] Is it possible to model with Laplace's error distribution? Hello! My question is stated in the Subject: Is it possible to model with Laplace's error distribution? For example, lmer() function have few families of functions, like binomial etc., but not Laplace. Is there any other package that would allow for Laplace? Or is there a way to give user-defined family? Sincerely, P. Milin __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] setting argument defaults in setMethod
Steven Lacey [EMAIL PROTECTED] writes: I want to set a default value in a method of a generic function. This seems as though it should be possible. From R help on setMethod... So, I try this... setGeneric(test,function(x,y){standardGeneric(test)}) setMethod(test,numeric, function(x,y=FALSE){ browser() } ) I think you have to actually specify a default value in the definition of the generic (I don't claim this makes any sense). That value won't get used as long as you specify a default in the method. setGeneric(foo, function(x, y=1) standardGeneric(foo)) setMethod(foo, signature(x=character), function(x, y=world) cat(x, y, \n)) foo(hello) setMethod(foo, signature(x=character), function(x, y) cat(x, y, \n)) foo(hello) + seth __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] ordering boxplots according to median
Use reorder # boxplot with increasing order of medians s2-with(InsectSprays,reorder(spray,count,median)) with(InsectSprays,boxplot(count~s2)) # boxplot with decreasing order of medians s2-with(InsectSprays,reorder(spray,-count,median)) with(InsectSprays,boxplot(count~s2)) John Talloen, Willem wrote-- Dear R-users, Does anyone knows how I can order my serie of boxplots from lowest to highest median (which is much better for visualization purposes). thanks in advance, willem -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] build R on windows
I narrowed down the problem to the socketConnection call within the package that I was trying to build. The build package process seems to evaluate initialize function, which is where socketConnection invoked in the package. example code: socketConnection(localhost, ) So, if there is no server listening on the localhost, port , then the build process will hang until N seconds (specify by timeout value) has passed. With a very large timeout value, the process can look like it's hanging and never returns. I then experiment with firewall settings on Windows, thinking it might have some clues to what was happening. It turned out that firewall has no effect when the client is a Windows box, and server resides on a Linux box or a Windows box. By no effect, I mean socketConnection to a host and non-listening port will only return after timeout value has expired. However, firewall has effect when the client is a Linux box, and the server resides on a Windows box. With firewall on, socketConnection will return after timeout value expired. With firewall off, socketConnection returns almost immediately. What about if both client and server are Linux boxes. As it turned out, socketConnection also returns immediately, even if no one is listening to the port. Is there any workaround to this, besides setting timeout value to a very small value? Since this timeout value also controls the timeout on receiving data, therefore we would like to make it as large as possible. Regards, Jennifer Duncan Murdoch wrote: On 3/21/2006 6:14 PM, Jennifer Lai wrote: Hi, I'm not sure if this question has been answered before, but when I execute command Rcmd INSTALL --build nws to build an R package on Windows, the build process got stucked on the save image step. Here is the snapshot of the build process, --- Making package nws adding build stamp to DESCRIPTION installing NAMESPACE file and metadata installing R files save images The build process never returns unless I Ctrl-C out of it. I also tried with removing SaveImage option from the DESCRIPTION file. This time, the build process got stucked at lazy loading step. I then set LazyLoad option to no in the DESCRIPTION file, this allows the build process to generate a zip file. However, when I load the library in R command console by typing library(nws), the command just hung trying to load the library. Here is the content of the description file, Package: nws Title: R functions for NetWorkSpaces and Sleigh Version: 1.3.0 License: GPL Version 2 or later Depends: R (=2.1), methods SaveImage: true URL: http://nws-r.sourceforge.net Is there any subtlety between building R packages in Linux and Windows? I can build and load this package under Linux. But can't figure out what's causing the hang on Windows and how to debug the problem. Has anyone ran into similar problem before, and steps you took to debug the problem? I very much appreciate any help you can provide. Thanks! The main subtlety is that on Windows you need to install most of the tools yourself. Read the instructions in the R Installation and Administration manual, and follow them exactly. A common error is not to put the R tools first in the PATH; then Windows finds the wrong commands, and things go wrong. I don't know what debugging tools are available, other than editing the scripts to print things out as they go along. The scripts are normally installed in the RHOME/bin directory. Duncan Murdoch 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
Re: [R] An lme model that works in old R.2.1.1 but not always in R.2.2.0 - why?
On 3/22/06, Niels A. Sommer [EMAIL PROTECTED] wrote: Following lme model runs fine in general under R.2.1.1 but only for 9 out of my 11 response variables under R.2.2.0. model for one of my response variables: lme(Yresp~F1fix,random=list(const=pdBlocked(list(~F2mix-1,~Ass:F1fix-1,~F3mix-1,~F1fix:F3mix-1,~F2mix:F3mix-1),pdClass=pdIdent))) Yresp is my response variable, F1fix is a fixed effect factor whereas F2mix and F3mix are random effect factors. const is set to rep(1,dim(Ycont)[1]). The strange thing is that if an intercept is omitted (F1fix-1) the R.2.2.0 also runs a 100 %. It's the same model, just with another parameterization?? The first thing to do in such a case is to request verbose output from the optimizer by adding control = list(msVerbose = TRUE) to your call to lme. One thing that changed for lme between R-2.1.1 and R-2.2.0 is that the default optimizer is now nlminb. Previously it was optim. With a model of that complexity you may well find that you are not getting convergence either in R-2.1.1 or in R-2.2.0. It is just that you are learning about it in R-2.2.0 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] install local packages
Hello all, I'm trying to install the local package under window system. Two ways I've tried: 1. using the menupackages install package(s) from local zip files My .zip file is mclust.zip. But it shows Errors which are: Error in gzfile(file,r): unable to open connection In addition: Warning messages: 1.error -1 in extracting from zip file 2.cannot open compressed file 'mclust/DESCRIPTION' 2. using function install.packages. the command I use is install.packages(mclust.zip,D:\sfu\BC project\clustering project\stuff from Jeffrey\flowCytometryClustering,repos=NULL,destdir=C:\Program Files\R\rw2011\library) But error is object mclust.zip not found. Could you please help me how I can install the local packages? Thanks a lot! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] calculate difference of consecutive cells in vector
Hi in dataframe I want to subtract the next value in the list from the former one to get this: name var1 output a 9506 b 515512 c1027453 so I subtract: table$var1[2]-table$var1[1] and write it into table$output[1] etc.. I did this with: for (i in 1:(length(table$var1)){ table$output[i] - table$var1[i+1]-table$var1[i] } it works but it get extremely slow for a large table. I bet there is a better way to do this in R with sapply or something similiar, but I couldn't figure out how. I'd apprechiate any idea Thanks! Max -- Feel free mit GMX FreeMail! Monat für Monat 10 FreeSMS inklusive! http://www.gmx.net __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] calculate difference of consecutive cells in vector
Try my.data$output - diff(my.data$var1) -Christos -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Max Kauer Sent: Wednesday, March 22, 2006 3:36 PM To: r-help@stat.math.ethz.ch Subject: [R] calculate difference of consecutive cells in vector Hi in dataframe I want to subtract the next value in the list from the former one to get this: name var1 output a 9506 b 515512 c1027453 so I subtract: table$var1[2]-table$var1[1] and write it into table$output[1] etc.. I did this with: for (i in 1:(length(table$var1)){ table$output[i] - table$var1[i+1]-table$var1[i] } it works but it get extremely slow for a large table. I bet there is a better way to do this in R with sapply or something similiar, but I couldn't figure out how. I'd apprechiate any idea Thanks! Max -- Feel free mit GMX FreeMail! Monat f|r Monat 10 FreeSMS inklusive! http://www.gmx.net __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Fixed legend in vcd/mosaicplot
Dieter, there is no way of fixing the range of the residuals yet, we will add sth. like a ylim argument to legend_foo(). Thanks for pointing this out, David PS: there is no mosaicplot() function in vcd, but a mosaic() ... -- Dr. David Meyer Department of Information Systems and Operations Vienna University of Economics and Business Administration Augasse 2-6, A-1090 Wien, Austria, Europe Fax: +43-1-313 36x746 Tel: +43-1-313 36x4393 HP: http://wi.wu-wien.ac.at/~meyer/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] New 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
[R] generating multivariate autocorrelated time series
Hello expeRts, for an application in hydrology I need to generate multivariate (log)normally distributed time series with given auto- and cross-correlations. While this is simple for the univariate case (e.g. with conditional normal sampling) it seems to be not so trivial for multivariate time series (according to papers available about this topic). An example: I have several (e.g. 3) time series (which are, of course, *correlated* measurements in reality): z - ts(matrix(rnorm(300), 100, 3), start=c(1961, 1), frequency=12) and I want to get the vector for the next time step(s): z[n+1, 1:3] respecting the autocorrelations from that matrix up to a given lag value: a - acf(z, lag=2) My question: Does anybody know about a solution (function, package, example etc...) available in R? Thanks a lot! Thomas P. --- http://tu-dresden.de/Members/thomas.petzoldt __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] a question related to clustering
Hello all, I have a fundamental question to ask related to clustering. As you know, when we do statistic analysis, such as t-test, or anova, we like to log transform our data to make it normally distributed. My question is shall we use signal intensity of affy chips to cluster or use log transformed data. The Dendrogram profiles are certainly different when comparing two type of the data. Thanks, AG [[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