Re: [R] FTP download from ftp.sec.gov
Gabor Grothendieck wrote: On Windows XP it worked for me on both 2.4.1 and 2.5.0. I did notice that on 2.4.1 it says using Synchronous WinInet calls but does not say this on 2.5.0. See below for the two transcripts. ftp - ftp://anonymous:[EMAIL PROTECTED]/edgar/full-index/company.idx download.file(url=ftp, destfile=test.txt) trying URL 'ftp://anonymous:[EMAIL PROTECTED]/edgar/full-index/company.idx' using Synchronous WinInet calls opened URL downloaded 33930Kb This appears to be highly system dependent. Works for me on my home machine using Fedora 6, but not on the office machine running SUSE 10. I wouldn't be surprised if firewall configuration plays a part. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] number of levels for a factor
On 1 Mar 2007 at 12:17, Aimin Yan wrote: Date sent: Thu, 01 Mar 2007 12:17:09 -0600 To: r-help@stat.math.ethz.ch From: Aimin Yan [EMAIL PROTECTED] Subject:[R] number of levels for a factor I have temp list which have 19 data.frame I want to get number of levels for pr in the first dat.frame I do this like this: temp[[1]]$pr just has 1A24 after I do nlevels(temp[[1]]$pr) I expect to get 1, but I get 19 anyone know why? Hi help page for [.factor tells you that using subsetting results in A factor with the same set of levels as x unless drop=TRUE. I presume your list resulted from some splitting operation and that original set of levels was preserved. HTH Petr tail(temp[[1]]$pr) [1] 1A24 1A24 1A24 1A24 1A24 1A24 19 Levels: 1A24 1A57 1A5J 1A6X 1AB7 1AF8 1AFI 1AGG 1AH9 1AHL 1AJ3 1AJW ... 1AZK nlevels(temp[[1]]$pr) [1] 19 Aimin __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] mixing symbols and rectangles in legend()
Hello, I try to mix symbols and coloured rectangles in a legend: plot(10,10) legend(top, c(text,text2), pch=c(21,22), fill=c(red,green), + pt.bg=black) On the resulting graph, the symbol is not centered upon the coloured rectangle. Is there a way to adjust their relative position, so that they are centered? Looking through ?legend has not helped me (but I might have missed the line where it is explained)... [R version 2.4.0 (2006-10-03) on linux] Thanks for any help. Best regards, -- Nicolas Mazziotta The contents of this e-mail, including any attachments, are ...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] label histogram question
Hi in your case I would use for loop (although common practice i to distract from their use :-), maybe together with main and axes options. Or probably lattice histogram could be used too. HTH Petr On 1 Mar 2007 at 22:17, Aimin Yan wrote: Date sent: Thu, 01 Mar 2007 22:17:26 -0600 To: r-help@stat.math.ethz.ch From: Aimin Yan [EMAIL PROTECTED] Subject:[R] label histogram question Dear R list: I have a data like this head(data.19.pr.2) prAveSd M#Re Aa 1 1A24 57.66 33.50 20 ALA_1 ALA 2 1A24 72.16 19.75 20 GLN_2 GLN 3 1A24 103.52 8.64 20 TYR_3 TYR 4 1A24 38.67 15.51 20 GLU_4 GLU 5 1A24 54.56 16.43 20 ASP_5 ASP 6 1A24 999.00 0.00 20 GLY_6 GLY levels(data.19.pr.2$Aa) [1] ALA ARG ASN ASP CYS GLN GLU GLY HIS ILE LEU LYS MET PHE PRO SER THR TRP TYR VAL I want to do histogram for Sd grouped by 20 levels of Aa, and put 20 histograms in one page. I use this code to do job par(mfrow=c(4,5)) tapply(data.19.pr.2$Sd,data.19.pr.2$Aa,hist) I get all 20 histogram in one page,but main label of each histogram is labeled by Histogram of X[[1]] and xlab is labeled by X[[1]]. I want to change these labels using 20 levels of Aa . it look like this: Histogram of ALA Does anyone know how to code these? Aimin __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Reformulated matrices dimensions limitation problem
First I wanted to thank both Marc Schwartz Greg Snow and for their reply. Then I needed to add a level of complexity to the problem. I would be able to create the biggest possible matrix. In other way does it exist a method to ask smthing like the following : max number of rows for a matrix if column=x? Thank you -- Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom http://click.libero.it/infostrada2marz07 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with faster optimization for large parameter problem
Hello all, I have a large parameter problem with the following very simple likelihood function: fn-function(param) { x1-param[1:n] g1-param[(n+1):(2*n)] beta-param[(2*n+1):(2*n+k)] sigma2-param[2*n+k+1]^2 meang1sp-mean(g1[sp]) mu-beta%*%matrix(x1,1,n)-(g1[sp]-meang1sp)%*%matrix(g1,1,n) return(sum((ydc-mu)^2)/(2*sigma2) + n*k*log(sqrt(sigma2)) + mean(x1)^2 + mean(g1)^2 + 1000*(x1[1]x1[n])) } There's nothing special here -- it's just plain old OLS, except all the variables on the right hand side are parameters (only the variable ydc is observed). I have no problems getting this to recover parameter estimates from data I myself have generated for smaller problems (e.g. where ydc is a k=500 by n=50 matrix and there are 601 parameters). But the target problem with real data will be k=6000 by n=400 with 6801 parameters. I am currently using optim(method=BFGS) but it is slow. I can get good starting values for x1 and g1 with some svd techniques, and these help me generate the starting values for the betas via lm(). I then use optim() on a modified likelihood function to find g1,x1,sigma2 while holding beta fixed and then use optim() again to find beta while holding the other variables fixed. But eventually, I have to run optim on the unmodified likelihood function above and it is very slow, taking several days for large problems. I have also tried metrop() in mcmc, but I find this needs to be very close to the mode of the likelihood to be efficient (in fact, MCMCpack's metropolis function calls optim first and even requires it to invert the hessian before even starting the metropolis algorithm, unless we can provide our own covariance matrix). I will probably use metrop() to generate standard errors once I find a mode In the mean time, I can't help thinking that there is some easy way to make this much faster than I am currently doing, especially since the likelihood is normal. I am sure I have missed something obvious so I'd very much appreciate any advice you could give on packages in R or code that might help. Thanks! james -- James H. Fowler, Associate Professor web: http://jhfowler.ucsd.edu Department of Political Scienceemail: [EMAIL PROTECTED] University of California, San Diegophone: (858) 534-6807 Social Sciences Building 383, #0521fax: (858) 534-7130 9500 Gilman Drive, La Jolla, CA 92093 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reformulated matrices dimensions limitation problem
Hi creating a biggest possible matrix does not automaticaly mean you can do some computation with it. So the size will depend partly on what you want to do with it. I presume that you do not want only to create a matrix just for pleasure to be able to. Cheers Petr On 2 Mar 2007 at 10:15, Bruno C. wrote: Date sent: Fri, 2 Mar 2007 10:15:33 +0100 From: Bruno C. [EMAIL PROTECTED] To: r-help [EMAIL PROTECTED] Subject:[R] Reformulated matrices dimensions limitation problem First I wanted to thank both Marc Schwartz Greg Snow and for their reply. Then I needed to add a level of complexity to the problem. I would be able to create the biggest possible matrix. In other way does it exist a method to ask smthing like the following : max number of rows for a matrix if column=x? Thank you -- Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom http://click.libero.it/infostrada2marz07 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Dice dissimilarity output and 'phylo' function in R
Dear All, I get some problems using the 'phylo' and dissimilarity functions in R. I converted an output from 'hclust' into an order of phylo so as to be able to use the 'consensus' function on it. Each time I submit the consensus codes, my computer hangs. When I tried to see what the contents of the object converted into order phylo is, I get the message Phylogenetic tree with 0 tips and 7 internal nodes. Tip labels: NULL Rooted; includes branch lengths. So I guess this explains why the consensus function does not work. Another thing I noticed in the output from the 'dissimilarity' function is that when I compared the distances computed in R with that from NTSYS or SAS, for example dice and jaccard coefficients I realised that the dice distances are very different while the jaccard distances are the same with those from these other softwares. The codes I used for a small example are shown below: samptest4- scan (file = samp-test4.txt) samptest4- matrix(data = samptest4,nrow=8, ncol=4, byrow=T) library(MASS) library(arules) library(ape) #CFI- numeric (M) CFI - function(ctree) { (ctree$Nnode -1)/(length(ctree$tip.label) - 2) } #calculation of dissimilarities construction of trees# #Calc Jacc disimi# disjacc - dissimilarity(samptest4, y=NULL,method=jaccard) #Calc Dice disimi# disdice - dissimilarity(samptest4, y=NULL,method=dice) #Construct Jacc dendro# tjacc- hclust(disjacc, method = average) tjaccphylo- as.phylo(tjacc) #Construct Dice dendro# tdice- hclust(disdice, method = average) tdicephylo- as.phylo(tdice) pdf (file = paste(TJD4, .pdf, sep = )) par(mfrow = c(1,2)) plot (tjacc, hang = -1) plot (tdice, hang = -1) dev.off() #Construct consensus tree# ctree-consensus(tdicephylo,tjaccphylo) plot(ctree) CFI(ctree) I will appreciate any help in solving these problems. Thank you and best regards, Taiwo Don't pick lemons. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] hpush not allowed
Hi, I've get the following on both strider and frodo: frodo{hb}: hpush -v Sorry, user hb is not allowed to execute '/usr/local/bin/hpush -v' as upush on frodo.Berkeley.EDU. Strange, because it worked when we set it up Thursday. Thxs Henrik __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] hpush not allowed
[that one went to the wrong [EMAIL PROTECTED] sorry about that. /Henrik] On 3/2/07, Henrik Bengtsson [EMAIL PROTECTED] wrote: Hi, I've get the following on both strider and frodo: frodo{hb}: hpush -v Sorry, user hb is not allowed to execute '/usr/local/bin/hpush -v' as upush on frodo.Berkeley.EDU. Strange, because it worked when we set it up Thursday. Thxs Henrik __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] plot of 2 time series with very different values
Hi R-Users, I am trying to plot two time series in the same plot, but they measure different things and hence one has values around 1-9 (Use=c(7,8, 6, 2, 3)), and the other one around 20-100 (Resitance=c(80, 100, 95, 35, 28)). I have thought of plotting both in the same graph but with two axes, one from 1 to 9 and the other from 20 to 100. To do so, I needed to do a regression for corrsepondence (1 goes to 20 and 9 goes to 100); the code to produce the graph would be: plot(1996:2000, xlim=c(1996, 2000),ylab=Resistence, ylim=c(20,100), type=n, xlab=Date) lines(1996:2000, c(80, 100, 95, 35, 28), col=1) axis(side=4, at=c(20,30,40,50,60,70,80,90,100), labels=c(1:9)) lines(1996:2000, lsfit(c(1,9),c(20,100))$coef[1]+ lsfit(c(1,9),c(20,100))$coef[2]*c(7,8,6, 2, 3), col=2) legend(1998.5, 90, legend=c(Resistence, Use), fill=c(1,2)) However, I suspect there are better ways to do so, and I would like to know one because I have to do that many times. Thanks a lot in advance, Berta __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] vectorized dmvnorm
Dear List, Is there an R-function that computes vectorized densities of the multivariate normal distribution, ie vectorized in x, mean and sigma? That is, a function that takes eg: x - matrix(0,3,2) y - matrix(1:6,3)-3 sig - array(c(1,0,0,1,1,0.1,0.1,1,1,0.3,0.3,1),c(2,2,3)) x [,1] [,2] [1,]00 [2,]00 [3,]00 y [,1] [,2] [1,] -21 [2,] -12 [3,]03 sig , , 1 [,1] [,2] [1,]10 [2,]01 , , 2 [,1] [,2] [1,] 1.0 0.1 [2,] 0.1 1.0 , , 3 [,1] [,2] [1,] 1.0 0.3 [2,] 0.3 1.0 and then returns a vector with elements: dmvnorm(x[i,],y[i,],sig[,,i]) And/or is there another efficient of computing these without using loops: for(i in 1:3) print(dmvnorm(x[i,],y[i,],sig[,,i])) best, Ingmar Visser __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] barplot2, gap.barplot
Marc A. Rohling wrote: Hello, I try to handle a simple bar-plot, but it turns out to be not as simple as I thought. ... As you can see, because of the 4th bar (value 45), the other bars look a little bit tiny: there is too much white-space. What I need to handle this problem is a function to insert a gap. I tried to use gap.barplot, but unfortunately, it cannot handle any of the parameters I need from the barplot2-function. After days of missing effort, I am sick of this problem. Is there a solution? Hi Marc1, As Marc2 said, the use of discontinuous axes in plots is a contentious one. No, I did not try to make gap.barplot compatible with barplot2 as the two seem to have different aims. gap.barplot is one solution to the troublesome issue of the outlier. What I would suggest as a one-off solution (to the horror of some) is to subtract, say, 25 from the outlier value, do the barplot, then: par(xpd=TRUE) axis.break(2,21,style=gap) text(barpos[4],24,48.6) I realize that your plot is more complex (I don't have gplots, etc. installed so I can't reproduce it at the moment), but that might give you something with which to work. Jim __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot of 2 time series with very different values
Hi I use a function plot.yy which i designed for convenieant plotting on 2 y axes for myself (see code below). You can modify its internals to suit your needs easily but this will give you something quite close. plot.yy(1996:2000, c(80, 100, 95, 35, 28), c(7,8,6, 2, 3), xlim=c(1996, 2000), yylab=c(Resistence,Use), xlab=Date, pch=c(NA,NA), linky=T) HTH Petr On 2 Mar 2007 at 11:54, Berta wrote: From: Berta [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Date sent: Fri, 2 Mar 2007 11:54:57 +0100 Organization: bioef Subject:[R] plot of 2 time series with very different values Hi R-Users, I am trying to plot two time series in the same plot, but they measure different things and hence one has values around 1-9 (Use=c(7,8, 6, 2, 3)), and the other one around 20-100 (Resitance=c(80, 100, 95, 35, 28)). I have thought of plotting both in the same graph but with two axes, one from 1 to 9 and the other from 20 to 100. To do so, I needed to do a regression for corrsepondence (1 goes to 20 and 9 goes to 100); the code to produce the graph would be: plot(1996:2000, xlim=c(1996, 2000),ylab=Resistence, ylim=c(20,100), type=n, xlab=Date) lines(1996:2000, c(80, 100, 95, 35, 28), col=1) axis(side=4, at=c(20,30,40,50,60,70,80,90,100), labels=c(1:9)) lines(1996:2000, lsfit(c(1,9),c(20,100))$coef[1]+ lsfit(c(1,9),c(20,100))$coef[2]*c(7,8,6, 2, 3), col=2) legend(1998.5, 90, legend=c(Resistence, Use), fill=c(1,2)) However, I suspect there are better ways to do so, and I would like to know one because I have to do that many times. Thanks a lot in advance, Berta __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Here is the code, all parameters are easily understood except of rect, which will was designed for a plotting a rectangle and you can ignore it completely. plot.yy-function(x,yright,yleft, yleftlim=NULL, yrightlim = NULL, xlab = NULL ,yylab=c(,), pch=c(1,2),col=c(1,2), linky=F, smooth=0, lwds=1, length=10, format=%d/%m, rect=NULL, type=p,...) { par(mar=c(5,4,4,2),oma=c(0,0,0,3)) plot(x, yright, ylim=yrightlim, axes=F,ylab=, xlab=xlab, pch=pch[1],col=col[1], type=type, ...) if (!is.null(rect)) rect(x[rect[1]],rect[2],cas.osa[rect[3]],rect[4], col=grey) points(x, yright, ylim=yrightlim, ylab=, xlab=xlab, pch=pch[1],col=col[1], ...) axis(4,pretty(range(yright,na.rm=T),10),col=col[1]) if (linky) lines(x,yright,col=col[1], ...) if (smooth!=0) lines(supsmu(x,yright,span=smooth),col=col[1], lwd=lwds, ...) if(yylab[1]==) mtext(deparse(substitute(yright)),side=4,outer=T,line=1, col=col[1], ...) else mtext(yylab[1],side=4,outer=T,line=1, col=col[1], ...) par(new=T) plot(x,yleft, ylim=yleftlim, ylab=, axes=F ,xlab=xlab, pch=pch[2],col=col[2], ...) box() axis(2,pretty(range(yleft,na.rm=T),10),col=col[2], col.axis=col[2]) if (!inherits(x,c(Date,POSIXt))) axis(1,pretty(range(x,na.rm=T),10)) else { l-length(x) axis(1,at=x[seq(1,l,length=length)],labels=format(as.POSIXct(x[seq(1,l ,length=length)]),format=format)) } if(yylab[2]==) mtext(deparse(substitute(yleft)),side=2,line=2, col=col[2], ...) else mtext(yylab[2],side=2,line=2, col=col[2], ...) if (linky) lines(x,yleft,col=col[2], lty=2, ...) if (smooth!=0) lines(supsmu(x,yleft,span=smooth),col=col[2], lty=2, lwd=lwds, ...) } Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot of 2 time series with very different values
Thank you so much Petr, it is exaclty what I was looking for!! Berta. Hi I use a function plot.yy which i designed for convenieant plotting on 2 y axes for myself (see code below). You can modify its internals to suit your needs easily but this will give you something quite close. plot.yy(1996:2000, c(80, 100, 95, 35, 28), c(7,8,6, 2, 3), xlim=c(1996, 2000), yylab=c(Resistence,Use), xlab=Date, pch=c(NA,NA), linky=T) HTH Petr On 2 Mar 2007 at 11:54, Berta wrote: From: Berta [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Date sent: Fri, 2 Mar 2007 11:54:57 +0100 Organization: bioef Subject:[R] plot of 2 time series with very different values Hi R-Users, I am trying to plot two time series in the same plot, but they measure different things and hence one has values around 1-9 (Use=c(7,8, 6, 2, 3)), and the other one around 20-100 (Resitance=c(80, 100, 95, 35, 28)). I have thought of plotting both in the same graph but with two axes, one from 1 to 9 and the other from 20 to 100. To do so, I needed to do a regression for corrsepondence (1 goes to 20 and 9 goes to 100); the code to produce the graph would be: plot(1996:2000, xlim=c(1996, 2000),ylab=Resistence, ylim=c(20,100), type=n, xlab=Date) lines(1996:2000, c(80, 100, 95, 35, 28), col=1) axis(side=4, at=c(20,30,40,50,60,70,80,90,100), labels=c(1:9)) lines(1996:2000, lsfit(c(1,9),c(20,100))$coef[1]+ lsfit(c(1,9),c(20,100))$coef[2]*c(7,8,6, 2, 3), col=2) legend(1998.5, 90, legend=c(Resistence, Use), fill=c(1,2)) However, I suspect there are better ways to do so, and I would like to know one because I have to do that many times. Thanks a lot in advance, Berta __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Here is the code, all parameters are easily understood except of rect, which will was designed for a plotting a rectangle and you can ignore it completely. plot.yy-function(x,yright,yleft, yleftlim=NULL, yrightlim = NULL, xlab = NULL ,yylab=c(,), pch=c(1,2),col=c(1,2), linky=F, smooth=0, lwds=1, length=10, format=%d/%m, rect=NULL, type=p,...) { par(mar=c(5,4,4,2),oma=c(0,0,0,3)) plot(x, yright, ylim=yrightlim, axes=F,ylab=, xlab=xlab, pch=pch[1],col=col[1], type=type, ...) if (!is.null(rect)) rect(x[rect[1]],rect[2],cas.osa[rect[3]],rect[4], col=grey) points(x, yright, ylim=yrightlim, ylab=, xlab=xlab, pch=pch[1],col=col[1], ...) axis(4,pretty(range(yright,na.rm=T),10),col=col[1]) if (linky) lines(x,yright,col=col[1], ...) if (smooth!=0) lines(supsmu(x,yright,span=smooth),col=col[1], lwd=lwds, ...) if(yylab[1]==) mtext(deparse(substitute(yright)),side=4,outer=T,line=1, col=col[1], ...) else mtext(yylab[1],side=4,outer=T,line=1, col=col[1], ...) par(new=T) plot(x,yleft, ylim=yleftlim, ylab=, axes=F ,xlab=xlab, pch=pch[2],col=col[2], ...) box() axis(2,pretty(range(yleft,na.rm=T),10),col=col[2], col.axis=col[2]) if (!inherits(x,c(Date,POSIXt))) axis(1,pretty(range(x,na.rm=T),10)) else { l-length(x) axis(1,at=x[seq(1,l,length=length)],labels=format(as.POSIXct(x[seq(1,l ,length=length)]),format=format)) } if(yylab[2]==) mtext(deparse(substitute(yleft)),side=2,line=2, col=col[2], ...) else mtext(yylab[2],side=2,line=2, col=col[2], ...) if (linky) lines(x,yleft,col=col[2], lty=2, ...) if (smooth!=0) lines(supsmu(x,yleft,span=smooth),col=col[2], lty=2, lwd=lwds, ...) } Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] vectorized dmvnorm
On Fri, 2 Mar 2007 12:08:20 +0100, Ingmar Visser wrote: IV Dear List, IV Is there an R-function that computes vectorized densities of the IV multivariate normal distribution, ie vectorized in x, mean and sigma? IV IV That is, a function that takes eg: IV IV x - matrix(0,3,2) IV y - matrix(1:6,3)-3 IV sig - array(c(1,0,0,1,1,0.1,0.1,1,1,0.3,0.3,1),c(2,2,3)) IV IV x IV [,1] [,2] IV [1,]00 IV [2,]00 IV [3,]00 IV y IV [,1] [,2] IV [1,] -21 IV [2,] -12 IV [3,]03 IV sig IV , , 1 IV IV [,1] [,2] IV [1,]10 IV [2,]01 IV IV , , 2 IV IV [,1] [,2] IV [1,] 1.0 0.1 IV [2,] 0.1 1.0 IV IV , , 3 IV IV [,1] [,2] IV [1,] 1.0 0.3 IV [2,] 0.3 1.0 IV IV and then returns a vector with elements: IV IV dmvnorm(x[i,],y[i,],sig[,,i]) IV IV And/or is there another efficient of computing these without using IV loops: IV for(i in 1:3) print(dmvnorm(x[i,],y[i,],sig[,,i])) IV a partial answer: dmnorm() in package mnormt is vectorized for x, not for mean and covariance; dmvnorm() in package mvtnorm works similarly -- Adelchi Azzalini [EMAIL PROTECTED] Dipart.Scienze Statistiche, Università di Padova, Italia tel. +39 049 8274147, http://azzalini.stat.unipd.it/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reformulated matrices dimensions limitation problem
You are right. and I am aware of that. This is what I need to do: load a regression model load the bigget posible matrix do prediction on this matrix the first and 3rd step will not need to much memory... and I would really appreciate this degree of introspection from R: it would be great if there would be a package that could simulate the amount of memory needed from a process But I don't pretend that much, this is why I am asking only about a function able to build a matrix matrix, with size based on memory available... Hi creating a biggest possible matrix does not automaticaly mean you can do some computation with it. So the size will depend partly on what you want to do with it. I presume that you do not want only to create a matrix just for pleasure to be able to. Cheers Petr On 2 Mar 2007 at 10:15, Bruno C. wrote: Date sent:Fri, 2 Mar 2007 10:15:33 +0100 From: Bruno C. [EMAIL PROTECTED] To: r-help [EMAIL PROTECTED] Subject: [R] Reformulated matrices dimensions limitation problem First I wanted to thank both Marc Schwartz Greg Snow and for their reply. Then I needed to add a level of complexity to the problem. I would be able to create the biggest possible matrix. In other way does it exist a method to ask smthing like the following : max number of rows for a matrix if column=x? Thank you -- Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom http://click.libero.it/infostrada2marz07 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] -- Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom http://click.libero.it/infostrada2marz07 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error in length of vector ?
Hi, I'm having a weird result with the length() function: a [... omited ...] [9994] NA2003-12-03 16:37:00 2002-06-26 18:43:00 [9997] 2005-07-04 04:00:00 2007-02-16 22:09:00 2007-02-24 15:49:00 [1] NA length(LastModified) [1] 9 length(c(LastModified)) [1] 9 I was expecting to get 1 as an answer. I'm trying to bind two vector, and I keep getting the error - number of rows of result is not a multiple of vector length. Thus I tested length and got this value. Any hint? Thanks in advance, Sérgio Nunes __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] FTP download from ftp.sec.gov
Thanks to everyone for trying it out. I guess the part that surprises me is that I currently download a file from a different FTP site every night with no problem. I have also downloaded from web sites with no problem. Buy now that I know the R code is okay I can look into other fixes for the problems. Thanks again, Roger -Original Message- From: Peter Dalgaard [mailto:[EMAIL PROTECTED] Sent: Friday, March 02, 2007 3:17 AM To: Gabor Grothendieck Cc: Bos, Roger; r-help@stat.math.ethz.ch Subject: Re: [R] FTP download from ftp.sec.gov Gabor Grothendieck wrote: On Windows XP it worked for me on both 2.4.1 and 2.5.0. I did notice that on 2.4.1 it says using Synchronous WinInet calls but does not say this on 2.5.0. See below for the two transcripts. ftp - ftp://anonymous:[EMAIL PROTECTED]/edgar/full-index/company.idx download.file(url=ftp, destfile=test.txt) trying URL 'ftp://anonymous:[EMAIL PROTECTED]/edgar/full-index/company.idx' using Synchronous WinInet calls opened URL downloaded 33930Kb This appears to be highly system dependent. Works for me on my home machine using Fedora 6, but not on the office machine running SUSE 10. I wouldn't be surprised if firewall configuration plays a part. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ** * This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No right to confidential or privileged treatment of this message is waived or lost by any error in transmission. If you have received this message in error, please immediately notify the sender by e-mail, delete the message and all copies from your system and destroy any hard copies. You must not, directly or indirectly, use, disclose, distribute, print or copy any part of this message if you are not the intended recipient. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error in length of vector ?
Hi you stepped on a difference between POSIXct and POSIXlt Details There are two basic classes of date/times. Class POSIXct represents the (signed) number of seconds since the beginning of 1970 as a ***numeric vector***. Class POSIXlt is a ***named list*** of vectors representing so you need to change your POSIXlt - named list to POSIXct by as.POSIXct(your vector) HTH Petr Maybe it could be useful to give some kind of warning into the help page of strptime e.g. Be aware of length of an objects created by strptime as POSIXlt class. It is always 9. See Details section of DateTimeClasses. On 2 Mar 2007 at 12:33, Sérgio Nunes wrote: Date sent: Fri, 2 Mar 2007 12:33:46 + From: Sérgio Nunes [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] Error in length of vector ? Hi, I'm having a weird result with the length() function: a [... omited ...] [9994] NA2003-12-03 16:37:00 2002-06-26 18:43:00 [9997] 2005-07-04 04:00:00 2007-02-16 22:09:00 2007-02-24 15:49:00 [1] NA length(LastModified) [1] 9 length(c(LastModified)) [1] 9 I was expecting to get 1 as an answer. I'm trying to bind two vector, and I keep getting the error - number of rows of result is not a multiple of vector length. Thus I tested length and got this value. Any hint? Thanks in advance, Sérgio Nunes __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reformulated matrices dimensions limitation problem
Did you consider biglm package. I did not use it myself but from its description it can be used for linear models on objects that do not fit into memory. HTH Petr On 2 Mar 2007 at 13:12, Bruno C. wrote: Date sent: Fri, 2 Mar 2007 13:12:07 +0100 From: Bruno C. [EMAIL PROTECTED] To: petr.pikal [EMAIL PROTECTED] Copies to: r-help [EMAIL PROTECTED] Subject:Re: [R] Reformulated matrices dimensions limitation problem You are right. and I am aware of that. This is what I need to do: load a regression model load the bigget posible matrix do prediction on this matrix the first and 3rd step will not need to much memory... and I would really appreciate this degree of introspection from R: it would be great if there would be a package that could simulate the amount of memory needed from a process But I don't pretend that much, this is why I am asking only about a function able to build a matrix matrix, with size based on memory available... Hi creating a biggest possible matrix does not automaticaly mean you can do some computation with it. So the size will depend partly on what you want to do with it. I presume that you do not want only to create a matrix just for pleasure to be able to. Cheers Petr On 2 Mar 2007 at 10:15, Bruno C. wrote: Date sent: Fri, 2 Mar 2007 10:15:33 +0100 From: Bruno C. [EMAIL PROTECTED] To: r-help [EMAIL PROTECTED] Subject:[R] Reformulated matrices dimensions limitation problem First I wanted to thank both Marc Schwartz Greg Snow and for their reply. Then I needed to add a level of complexity to the problem. I would be able to create the biggest possible matrix. In other way does it exist a method to ask smthing like the following : max number of rows for a matrix if column=x? Thank you -- Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom http://click.libero.it/infostrada2marz07 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] -- Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom http://click.libero.it/infostrada2marz07 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error in length of vector ?
Thanks. Using as.POSIXct() worked fine, length = 1. Basically I cannot have a column of POSIXlt values in a matrix? Sérgio Nunes On 3/2/07, Petr Pikal [EMAIL PROTECTED] wrote: Hi you stepped on a difference between POSIXct and POSIXlt Details There are two basic classes of date/times. Class POSIXct represents the (signed) number of seconds since the beginning of 1970 as a ***numeric vector***. Class POSIXlt is a ***named list*** of vectors representing so you need to change your POSIXlt - named list to POSIXct by as.POSIXct(your vector) HTH Petr Maybe it could be useful to give some kind of warning into the help page of strptime e.g. Be aware of length of an objects created by strptime as POSIXlt class. It is always 9. See Details section of DateTimeClasses. On 2 Mar 2007 at 12:33, Sérgio Nunes wrote: Date sent: Fri, 2 Mar 2007 12:33:46 + From: Sérgio Nunes [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] Error in length of vector ? Hi, I'm having a weird result with the length() function: a [... omited ...] [9994] NA2003-12-03 16:37:00 2002-06-26 18:43:00 [9997] 2005-07-04 04:00:00 2007-02-16 22:09:00 2007-02-24 15:49:00 [1] NA length(LastModified) [1] 9 length(c(LastModified)) [1] 9 I was expecting to get 1 as an answer. I'm trying to bind two vector, and I keep getting the error - number of rows of result is not a multiple of vector length. Thus I tested length and got this value. Any hint? Thanks in advance, Sérgio Nunes __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Using R for devices trial
Hi Cody, I would point you to the presentation by Sue Bell at least year's ASA meeting available here: http://www.fda.gov/Cder/Offices/Biostatistics/Bell.pdf. I can't speak for CDRH, but at CDER we are making some progress towards the level of comfort with the use of R as a valid software tool. Specifically, 1. R was granted approval by our IT folks for use on our government PC's (2 years in the making to get this). 2. An R course is in development for FDA reviewers to use R for review of clinical trial data. 3. This Monday at the 1st FDA/DIA Spring Meeting I will be offering a tutorial on Statistical Graphics with R for Clinical Trial Data. 4. An increasing effort to pigeon-tail R to ongoing projects to show proof by example that R can be trusted when used properly. So from the regulatory side, progress is being made, but there still do exist those who have some discomfort with the use of an open-source tool for data analysis. Someday hopefully that too will be changed. HTH, -Mat Disclaimer: The views expressed are those of the author and must not be taken to represent policy or guidance on behalf of the Food and Drug Administration. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Thursday, March 01, 2007 5:43 PM To: [EMAIL PROTECTED] Subject: [R] Using R for devices trial I would like to use R for submissions to FDA/CDRH (the medical device company I work for currently uses only SAS). Previous postings to the list regarding R and 21 CFR 11 compliance have been very helpful. However, reluctance to using open source software for statistical analyses and reporting remains high here at my company. Has anyone used R for an official submission to FDA/CDRH? It would be most helpful if I could tell our group that others have been able to use R for this purpose. Regards, Cody Hamilton Staff Biostatistician Edwards Lifesciences __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] PROC TABULATE with R
Yes, anyway there is some opensource GUIs for doing that, especially jpivot. In fact, my idea consists in extracting datas from an OLAP cube with MDX or XMLA or JOLAP queries, from an existing OLAP server, as it is currently possible with some software like SAS or SPSS. Regards, Laurent 2007/3/1, David Meyer [EMAIL PROTECTED]: You can also have a look at structable() in vcd, especially the indexing functions. The problem with OLAP in R is, that you will have to create sth. like a hierarchical factor to handle rollup/drilldown correctly. And you will have to decide whether it's purely memory-based (fast calculations, but memory limit), or you do it using data bases / SQL (slow). And finally, you will need some simple GUI to provide interactive use (doing OLAP using command-line functions is not really OLAP). Best, David - Hi ! with apply or tapply-like functions, is it possible to create multidimensional cubes with R ? Like with SAS and its function PROC TABULATE or OLAP ? Is there some functions or modules to access OLAP databases with R ? My idea is to create a package for that, since XMLA and JOLAP specifications should able us to do so ! -- Dr. David Meyer Department of Information Systems and Operations Vienna University of Economics and Business Administration Augasse 2-6, A-1090 Wien, Austria, Europe Tel: +43-1-313 36 4393 Fax: +43-1-313 36 90 4393 HP: http://wi.wu-wien.ac.at/~meyer/ -- «À attendre que l'herbe pousse, le boeuf meurt de faim» «Le boeuf» @http://www.le-valdo.com [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reformulated matrices dimensions limitation problem
bigml is for generalized regression model. I need to use lars ans svm. Anway I am perfectly able to train my model: my training matrix is not so big. The big matrix is the test one then I can split it by rows into several matrices without affecting the results. The point is that I wanted to split it in an elegant way, mainimizing the needed submatrices wrt memory. But I have the impression I am asking R too much :D Did you consider biglm package. I did not use it myself but from its description it can be used for linear models on objects that do not fit into memory. HTH Petr On 2 Mar 2007 at 13:12, Bruno C. wrote: Date sent:Fri, 2 Mar 2007 13:12:07 +0100 From: Bruno C. [EMAIL PROTECTED] To: petr.pikal [EMAIL PROTECTED] Copies to:r-help [EMAIL PROTECTED] Subject: Re: [R] Reformulated matrices dimensions limitation problem You are right. and I am aware of that. This is what I need to do: load a regression model load the bigget posible matrix do prediction on this matrix the first and 3rd step will not need to much memory... and I would really appreciate this degree of introspection from R: it would be great if there would be a package that could simulate the amount of memory needed from a process But I don't pretend that much, this is why I am asking only about a function able to build a matrix matrix, with size based on memory available... Hi creating a biggest possible matrix does not automaticaly mean you can do some computation with it. So the size will depend partly on what you want to do with it. I presume that you do not want only to create a matrix just for pleasure to be able to. Cheers Petr On 2 Mar 2007 at 10:15, Bruno C. wrote: Date sent:Fri, 2 Mar 2007 10:15:33 +0100 From: Bruno C. [EMAIL PROTECTED] To: r-help [EMAIL PROTECTED] Subject: [R] Reformulated matrices dimensions limitation problem First I wanted to thank both Marc Schwartz Greg Snow and for their reply. Then I needed to add a level of complexity to the problem. I would be able to create the biggest possible matrix. In other way does it exist a method to ask smthing like the following : max number of rows for a matrix if column=x? Thank you -- Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom http://click.libero.it/infostrada2marz07 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] -- Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom http://click.libero.it/infostrada2marz07 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] -- Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom http://click.libero.it/infostrada2marz07 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] function with Multiple Output
my.fun=function(vector, index){ a=fun.a(vector, index) b=fun.b(vector, index) return(list(a=a, b=b)) } On 3/1/07, Claudio Isella [EMAIL PROTECTED] wrote: Dear R user, I have a simple question for you: I have created a global function that evoke other subsidiary functions. when I run the global function I want to store the outcomes of the of each subsidiary function into a variables. an examples my.fun=function(vector, index){ a=fun.a(vector, index) b=fun.b(vector, index) } if i use return() I can only retrive one single results. what can I do to store the outcome of the two function in differnt enviroment variables? -- Claudio __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error in length of vector ?
On 2 Mar 2007 at 13:22, Sérgio Nunes wrote: Date sent: Fri, 2 Mar 2007 13:22:43 + From: Sérgio Nunes [EMAIL PROTECTED] To: Petr Pikal [EMAIL PROTECTED] Copies to: r-help@stat.math.ethz.ch Subject:Re: [R] Error in length of vector ? Thanks. Using as.POSIXct() worked fine, length = 1. Basically I cannot have a column of POSIXlt values in a matrix? No, it has different length as it is a ***named list*** see e.g. Last.Modified[[1]] if it is POSIXlt class. Petr Sérgio Nunes On 3/2/07, Petr Pikal [EMAIL PROTECTED] wrote: Hi you stepped on a difference between POSIXct and POSIXlt Details There are two basic classes of date/times. Class POSIXct represents the (signed) number of seconds since the beginning of 1970 as a ***numeric vector***. Class POSIXlt is a ***named list*** of vectors representing so you need to change your POSIXlt - named list to POSIXct by as.POSIXct(your vector) HTH Petr Maybe it could be useful to give some kind of warning into the help page of strptime e.g. Be aware of length of an objects created by strptime as POSIXlt class. It is always 9. See Details section of DateTimeClasses. On 2 Mar 2007 at 12:33, Sérgio Nunes wrote: Date sent: Fri, 2 Mar 2007 12:33:46 + From: Sérgio Nunes [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] Error in length of vector ? Hi, I'm having a weird result with the length() function: a [... omited ...] [9994] NA2003-12-03 16:37:00 2002-06-26 18:43:00 [9997] 2005-07-04 04:00:00 2007-02-16 22:09:00 2007-02-24 15:49:00 [1] NA length(LastModified) [1] 9 length(c(LastModified)) [1] 9 I was expecting to get 1 as an answer. I'm trying to bind two vector, and I keep getting the error - number of rows of result is not a multiple of vector length. Thus I tested length and got this value. Any hint? Thanks in advance, Sérgio Nunes __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reformulated matrices dimensions limitation problem
I believe that due to memory management the size of biggest possible matrix can change. But I probably am not the persou who can explain it correctly. Petr On 2 Mar 2007 at 14:40, Bruno C. wrote: Date sent: Fri, 2 Mar 2007 14:40:18 +0100 From: Bruno C. [EMAIL PROTECTED] To: petr.pikal [EMAIL PROTECTED] Copies to: r-help [EMAIL PROTECTED] Subject:Re: [R] Reformulated matrices dimensions limitation problem bigml is for generalized regression model. I need to use lars ans svm. Anway I am perfectly able to train my model: my training matrix is not so big. The big matrix is the test one then I can split it by rows into several matrices without affecting the results. The point is that I wanted to split it in an elegant way, mainimizing the needed submatrices wrt memory. But I have the impression I am asking R too much :D Did you consider biglm package. I did not use it myself but from its description it can be used for linear models on objects that do not fit into memory. HTH Petr On 2 Mar 2007 at 13:12, Bruno C. wrote: Date sent: Fri, 2 Mar 2007 13:12:07 +0100 From: Bruno C. [EMAIL PROTECTED] To: petr.pikal [EMAIL PROTECTED] Copies to: r-help [EMAIL PROTECTED] Subject:Re: [R] Reformulated matrices dimensions limitation problem You are right. and I am aware of that. This is what I need to do: load a regression model load the bigget posible matrix do prediction on this matrix the first and 3rd step will not need to much memory... and I would really appreciate this degree of introspection from R: it would be great if there would be a package that could simulate the amount of memory needed from a process But I don't pretend that much, this is why I am asking only about a function able to build a matrix matrix, with size based on memory available... Hi creating a biggest possible matrix does not automaticaly mean you can do some computation with it. So the size will depend partly on what you want to do with it. I presume that you do not want only to create a matrix just for pleasure to be able to. Cheers Petr On 2 Mar 2007 at 10:15, Bruno C. wrote: Date sent: Fri, 2 Mar 2007 10:15:33 +0100 From: Bruno C. [EMAIL PROTECTED] To: r-help [EMAIL PROTECTED] Subject:[R] Reformulated matrices dimensions limitation problem First I wanted to thank both Marc Schwartz Greg Snow and for their reply. Then I needed to add a level of complexity to the problem. I would be able to create the biggest possible matrix. In other way does it exist a method to ask smthing like the following : max number of rows for a matrix if column=x? Thank you -- Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom http://click.libero.it/infostrada2marz07 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] -- Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom http://click.libero.it/infostrada2marz07 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] -- Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom http://click.libero.it/infostrada2marz07 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] question about xtable and Hmisc
Richard M. Heiberger wrote: Also, if x is a data frame, latex(x) contains the row numbers. Can I get rid of them here as well? I think you are asking for the rowname=NULL argument. latex(x, rowname=NULL) See ?latex to confirm if that is what you are looking for. Rich __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Yes - that is exactly what I wanted. thanks, Steve __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] lattice: clipping data, not plot margins
I am plotting subsets of my data, using ylim. This works fine, but the outer margin line widths of the plot are thin, due to clipping. If I include trellis.par.set(clip=list(panel = off)) then the outer margin line widths are fine, but the outlying data is visible. Is there any way of achieving both correct margin line widths and clipping of outlying data? Thanks, Dan Bebber info: Windows XP, R 2.4.1., lattice 0.14-16 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] LIMMA contrast.matrix
Dear R-Help, I am using the LIMMA User's Guide 5 January 2007 PDF version. For the example show in Section 7.4 DIRECT TWO-COLOR DESIGNS (pgs. 33-34), I could not grasp the rationale in developing the contrast.matrix with these R statements ( indicates the R command prompt): contrast.matrix - cbind(CD8-CD4=c(1,0),DN-CD4=c(0,1),CD8-DN=c(1,-1)) How do we get that numbers (1,0)(0,1) and (1,-1)? This knowledge is critical to develop the correct contrasts. I would like to extend properly this concept to my experiments. Thank you very much. Roger PS. To avoid you going to the LIMMA User's Guide. I show below the indicated example and R commands used. Please see below. Roger L. Vallejo, Ph.D. Computational Biologist Geneticist U.S. Department of Agriculture, ARS National Center for Cool Cold Water Aquaculture 11861 Leetown Road Kearneysville, WV 25430 Voice:(304) 724-8340 Ext. 2141 Email: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] targets SlideNumber FileName Cy3 Cy5 ml12med 12 ml12med.spot CD4 CD8 ml13med 13 ml13med.spot CD8 CD4 ml14med 14 ml14med.spot DN CD8 ml15med 15 ml15med.spot CD8 DN ml16med 16 ml16med.spot CD4 DN ml17med 17 ml17med.spot DN CD4 design - modelMatrix(targets, ref=CD4) Found unique target names: CD4 CD8 DN design CD8 DN ml12med 1 0 ml13med -1 0 ml14med 1 -1 ml15med -1 1 ml16med 0 1 ml17med 0 -1 fit - lmFit(MA, design, ndups=2) contrast.matrix - cbind(CD8-CD4=c(1,0),DN-CD4=c(0,1),CD8-DN=c(1,-1)) rownames(contrast.matrix) - colnames(design) contrast.matrix CD8-CD4 DN-CD4 CD8-DN CD8 1 0 1 DN 0 1 -1 *** [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] extracting data from zoo series
Dear List, Sorry if I'm overlooking something simple here but I have gotten a bit tangled. I am trying to print the next five values(with their dates), which occur after a certain condition is met. I have a series of data in zoo format, call it A. From this series I have created a subset (also in zoo format) based on a certain condition, call this series B. I want to use the dates from B as an index, so as each of these dates occur in A, the succeeding five rows from A after this date are printed out. Any help would be most appreciated. Regards, Alfonso Sammassimo Melbourne, Victoria __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with faster optimization for large parameter problem
Hi James, There are a few things that immediately come to my mind that you could try: 1. Profile your code using Rprof to detect which steps are the most time-consuming. 2. In your likelihood function you can make the code a bit more faster by using outer instead of %*%. 3. Using conjugate-gradient type methods in optim might be a better option since you are dealing with thousands of parameters and BFGS could use up a lot of memory working with a large Hessian matrix. CG methods use much less storage and memory than quasi-Newton methods. The main caveat here is that the CG methods generally have slower convergence than QN type methods, unless you can precondition the problem. Hope this is helpful, Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of James Fowler Sent: Friday, March 02, 2007 4:34 AM To: r-help@stat.math.ethz.ch Subject: [R] Help with faster optimization for large parameter problem Hello all, I have a large parameter problem with the following very simple likelihood function: fn-function(param) { x1-param[1:n] g1-param[(n+1):(2*n)] beta-param[(2*n+1):(2*n+k)] sigma2-param[2*n+k+1]^2 meang1sp-mean(g1[sp]) mu-beta%*%matrix(x1,1,n)-(g1[sp]-meang1sp)%*%matrix(g1,1,n) return(sum((ydc-mu)^2)/(2*sigma2) + n*k*log(sqrt(sigma2)) + mean(x1)^2 + mean(g1)^2 + 1000*(x1[1]x1[n])) } There's nothing special here -- it's just plain old OLS, except all the variables on the right hand side are parameters (only the variable ydc is observed). I have no problems getting this to recover parameter estimates from data I myself have generated for smaller problems (e.g. where ydc is a k=500 by n=50 matrix and there are 601 parameters). But the target problem with real data will be k=6000 by n=400 with 6801 parameters. I am currently using optim(method=BFGS) but it is slow. I can get good starting values for x1 and g1 with some svd techniques, and these help me generate the starting values for the betas via lm(). I then use optim() on a modified likelihood function to find g1,x1,sigma2 while holding beta fixed and then use optim() again to find beta while holding the other variables fixed. But eventually, I have to run optim on the unmodified likelihood function above and it is very slow, taking several days for large problems. I have also tried metrop() in mcmc, but I find this needs to be very close to the mode of the likelihood to be efficient (in fact, MCMCpack's metropolis function calls optim first and even requires it to invert the hessian before even starting the metropolis algorithm, unless we can provide our own covariance matrix). I will probably use metrop() to generate standard errors once I find a mode In the mean time, I can't help thinking that there is some easy way to make this much faster than I am currently doing, especially since the likelihood is normal. I am sure I have missed something obvious so I'd very much appreciate any advice you could give on packages in R or code that might help. Thanks! james -- James H. Fowler, Associate Professor web: http://jhfowler.ucsd.edu Department of Political Scienceemail: [EMAIL PROTECTED] University of California, San Diegophone: (858) 534-6807 Social Sciences Building 383, #0521fax: (858) 534-7130 9500 Gilman Drive, La Jolla, CA 92093 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [friday topic]: what exactly is statistical computing
Dear List, on www.r-project.org, the title says 'The R Project for Statistical Computing'. but what exactly is the definition of statistical computing? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] barplot2, gap.barplot
3. Depending on the nature of your data, if the extreme value is representative of an important marked difference relative to the other values, then I don't particularly find the 'look' of the plot to be overly problematic. It does appropriately emphasize the large difference. On the other hand, you might want to consider using a log scale on the y axis as an alternative to an axis gap. This would be a reasonable approach to plotting values that have a notable difference in range. If you do this, note that you would need to ensure that all y values are 0 (ie. y axis range minimum, lower bounds of CI's, etc.) since: log10(0) [1] -Inf Of course, you can't do this with a bar plot, because bars should be anchored at 0. Hadley __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Account Completed
Thank you for inquiring about your mortgage rate. Feel free to visit our Hassle-FreeQuote website so we can review more specific information in order to reduce your current rate. The process takes less than a minute to complete. We're happy to have this chance to save you even more money. *Current Rates: 3.81 - 4.92 *Average savings: $3,000 - $12,000 per year Hassle-FreeQuotes© Secure Website---siloids.com __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] from function to its name?
Hi, I can get from a string to a function with this name: f1 - function(x){ mean(x) } do.call(f1,list{1:4}) get(f1) etc... But how do I get from a function to its name? funcVec - c(f1,median) funcVec [[1]] function(x){ mean(x) } str(funcVec) List of 2 $ :function (x) ..- attr(*, source)= chr function(x){ mean(x) } $ :function (x, ...) deparse(funcVec[1]) [1] list(function (x) { mean(x) [4] }) thank you very much ido __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot of 2 time series with very different values
There is an example in the example section of plotting two time series on the same plot with different left hand and right hand scales here: library(zoo) ?plot.zoo On 3/2/07, Berta [EMAIL PROTECTED] wrote: Hi R-Users, I am trying to plot two time series in the same plot, but they measure different things and hence one has values around 1-9 (Use=c(7,8, 6, 2, 3)), and the other one around 20-100 (Resitance=c(80, 100, 95, 35, 28)). I have thought of plotting both in the same graph but with two axes, one from 1 to 9 and the other from 20 to 100. To do so, I needed to do a regression for corrsepondence (1 goes to 20 and 9 goes to 100); the code to produce the graph would be: plot(1996:2000, xlim=c(1996, 2000),ylab=Resistence, ylim=c(20,100), type=n, xlab=Date) lines(1996:2000, c(80, 100, 95, 35, 28), col=1) axis(side=4, at=c(20,30,40,50,60,70,80,90,100), labels=c(1:9)) lines(1996:2000, lsfit(c(1,9),c(20,100))$coef[1]+ lsfit(c(1,9),c(20,100))$coef[2]*c(7,8,6, 2, 3), col=2) legend(1998.5, 90, legend=c(Resistence, Use), fill=c(1,2)) However, I suspect there are better ways to do so, and I would like to know one because I have to do that many times. Thanks a lot in advance, Berta __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lattice: clipping data, not plot margins
On 3/2/07, Dan Bebber [EMAIL PROTECTED] wrote: I am plotting subsets of my data, using ylim. This works fine, but the outer margin line widths of the plot are thin, due to clipping. If I include trellis.par.set(clip=list(panel = off)) then the outer margin line widths are fine, but the outlying data is visible. Is there any way of achieving both correct margin line widths and clipping of outlying data? Why not subset your data? (Of course if you are overlaying statistical transformations, eg. a smoother, this will affect those displays as well) Hadley __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] from function to its name?
On Mar 2, 2007, at 9:42 AM, Ido M. Tamir wrote: Hi, I can get from a string to a function with this name: f1 - function(x){ mean(x) } do.call(f1,list{1:4}) get(f1) etc... But how do I get from a function to its name? funcVec - c(f1,median) funcVec [[1]] function(x){ mean(x) } I suppose you could do: funcVec but that's probably not what you want ;). Can you do this with any object in R? In what situation will you be wanting this name? I mean, how would you be given this object, but not know its name in advance? If it is passed as an argument in a function or something, then what would you consider to be its name? I.e. I don't really see where you would reasonably want to do something like this, without there being another way around it. Btw, perhaps this does what you want: as.character(quote(f)) Haris Skiadas Department of Mathematics and Computer Science Hanover College __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reformulated matrices dimensions limitation problem
On 3/2/07, Bruno C. [EMAIL PROTECTED] wrote: bigml is for generalized regression model. I need to use lars ans svm. Anway I am perfectly able to train my model: my training matrix is not so big. The big matrix is the test one then I can split it by rows into several matrices without affecting the results. The point is that I wanted to split it in an elegant way, mainimizing the needed submatrices wrt memory. But I have the impression I am asking R too much :D Design an experiment. Start with a small matrix and keep increasing until it gets too big. You will want to control for other factors like what other objects are in memory. I don't think this is particularly more elegant than splitting the matrix into pieces that you know will fit into memory. And will certainly take much more time. Hadley __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error in length of vector ?
Suggest you review the help desk article on dates in R News 4/1. It mentions that POSIXlt objects are lists with 9 components and other facts about date objects in R. On 3/2/07, Sérgio Nunes [EMAIL PROTECTED] wrote: Hi, I'm having a weird result with the length() function: a [... omited ...] [9994] NA2003-12-03 16:37:00 2002-06-26 18:43:00 [9997] 2005-07-04 04:00:00 2007-02-16 22:09:00 2007-02-24 15:49:00 [1] NA length(LastModified) [1] 9 length(c(LastModified)) [1] 9 I was expecting to get 1 as an answer. I'm trying to bind two vector, and I keep getting the error - number of rows of result is not a multiple of vector length. Thus I tested length and got this value. Any hint? Thanks in advance, Sérgio Nunes __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Double-banger function names: preferences and suggestions
On Thu, Mar 01, 2007 at 10:31:08AM -0700, Jason Barnhart wrote: Definitely not #2. Prefer #1 but #3 is ok as well. Definitely not #1. Prefer #2 but #3 is ok as well. there is nothing like unanimous agreement :-) but in earnest: I don't think #1 is good on the already mentioned grounds that it masks the difference between a method call and a simple function name. I don't think a function name such as plot.mydata would be reasonable: is this a method call for plotting objects of class `mdyata' or is it some other function call (probably plotting my data)? in browsing through source code this is at least an unnecessary nuisance having to check this point. Thanks for contributing and inquiring. - Original Message - From: hadley wickham [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, February 25, 2007 7:44 AM Subject: [R] Double-banger function names: preferences and suggestions What do you prefer/recommend for double-banger function names: 1 scale.colour 2 scale_colour 3 scaleColour 1 is more R-like, but conflicts with S3. 2 is a modern version of number 1, but not many packages use it. Number 3 is more java-like. (I like number 2 best) Any suggestions? Thanks, Hadley __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [friday topic]: what exactly is statistical computing
This means it comes with substantial statistical routines built-in. You could just as well use VBA or Java for your programming language, but with those you would have to write pretty much any stat routine you need. With R, since it is a 'statistical computing' language, you know that most of what you need has already been programmed, tested(?), and is ready to use. I have seen you on this list for a while. You already know all this. I am not sure why you are asking this question. Roger -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Wensui Liu Sent: Friday, March 02, 2007 9:43 AM To: r-help@stat.math.ethz.ch Subject: [R] [friday topic]: what exactly is statistical computing Dear List, on www.r-project.org, the title says 'The R Project for Statistical Computing'. but what exactly is the definition of statistical computing? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ** * This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No right to confidential or privileged treatment of this message is waived or lost by any error in transmission. If you have received this message in error, please immediately notify the sender by e-mail, delete the message and all copies from your system and destroy any hard copies. You must not, directly or indirectly, use, disclose, distribute, print or copy any part of this message if you are not the intended recipient. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] from function to its name?
On Fri, Mar 02, 2007 at 03:42:46PM +0100, Ido M. Tamir wrote: Hi, I can get from a string to a function with this name: f1 - function(x){ mean(x) } do.call(f1,list{1:4}) get(f1) etc... But how do I get from a function to its name? funcVec - c(f1,median) funcVec [[1]] function(x){ mean(x) } str(funcVec) List of 2 $ :function (x) ..- attr(*, source)= chr function(x){ mean(x) } $ :function (x, ...) deparse(funcVec[1]) [1] list(function (x) { mean(x) [4] }) for any symbol/name deparse(substitute(f1)) yields the string representation, but this won't give you f1 for deparse(substitute(funcVec[1])). but rather the string funcVec[1]. if you actually want to access funcVec components via strings denoting the components, maybe you simply could use funcVec - list(f1 = f1, median = median) and access these via funcVec[[f1]] which would enable using a string variable holding the name: dum = f1 funcVec[[dum]] hth joerg __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] barplot2, gap.barplot
On Fri, 2007-03-02 at 08:53 -0600, hadley wickham wrote: 3. Depending on the nature of your data, if the extreme value is representative of an important marked difference relative to the other values, then I don't particularly find the 'look' of the plot to be overly problematic. It does appropriately emphasize the large difference. On the other hand, you might want to consider using a log scale on the y axis as an alternative to an axis gap. This would be a reasonable approach to plotting values that have a notable difference in range. If you do this, note that you would need to ensure that all y values are 0 (ie. y axis range minimum, lower bounds of CI's, etc.) since: log10(0) [1] -Inf Of course, you can't do this with a bar plot, because bars should be anchored at 0. Both barplot() and barplot2() support log scaling for both x and y axes. In both functions, the default axis minimum for the 'height' axis (y by default, x if 'horizontal = TRUE') will be 0.9 * min(height) to avert log10(0) related issues. Errors will be issued otherwise if any values of 'height' are = 0 or 'ylim'/'xlim' args are similarly set. Using a function that Martin had posted some time ago, to nicely format the axis labels: axTexpr - function(side, at = axTicks(side, axp=axp, usr=usr, log=log), axp = NULL, usr = NULL, log = NULL) { ## Purpose: Do a 10^k labeling instead of a ek ## this auxiliary should return 'at' and 'label' (expression) ## -- ## Arguments: as for axTicks() ## -- ## Author: Martin Maechler, Date: 7 May 2004, 18:01 eT - floor(log10(abs(at)))# at == 0 case is dealt with below mT - at / 10^eT ss - lapply(seq(along = at), function(i) if(at[i] == 0) quote(0) else substitute(A %*% 10^E, list(A=mT[i], E=eT[i]))) do.call(expression, ss) } x - 10 ^ (0:10) barplot(x, log = y, yaxt = n) axis(2, at = x, labels = axTexpr(2), las = 2) box() HTH, Marc __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] barplot2, gap.barplot
On 3/2/07, Marc Schwartz [EMAIL PROTECTED] wrote: On Fri, 2007-03-02 at 08:53 -0600, hadley wickham wrote: 3. Depending on the nature of your data, if the extreme value is representative of an important marked difference relative to the other values, then I don't particularly find the 'look' of the plot to be overly problematic. It does appropriately emphasize the large difference. On the other hand, you might want to consider using a log scale on the y axis as an alternative to an axis gap. This would be a reasonable approach to plotting values that have a notable difference in range. If you do this, note that you would need to ensure that all y values are 0 (ie. y axis range minimum, lower bounds of CI's, etc.) since: log10(0) [1] -Inf Of course, you can't do this with a bar plot, because bars should be anchored at 0. Both barplot() and barplot2() support log scaling for both x and y axes. In both functions, the default axis minimum for the 'height' axis (y by default, x if 'horizontal = TRUE') will be 0.9 * min(height) to avert log10(0) related issues. Errors will be issued otherwise if any values of 'height' are = 0 or 'ylim'/'xlim' args are similarly set. I think that's a pretty bad idea - in a bar plot you are comparing the ratio of heights of the bars, not the absolute heights. It's the same reason it's a bad idea to have a bar graph with a non-0 y-axis - it's misleading. Hadley __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] RE-Row-wise two sample T-test on subsets of a matrix
hello all thanks a lot for the info, I just actually needed to remove that comma in my command line what i had typed in was t.test(temp.matrix[,1:11],temp.matrix[,12:22],paired=TRUE) what i needed to do was t.test(temp.matrix[1:11],temp.matrix[12:22],paired=TRUE) thanks Petr, saw your comment later. nameeta __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] barplot with different color combination for each bar
Hi, I'd like to construct a somewhat unusual barplot. In barplot I use beside=F as I'd like to have stacked bars. The height of each bar is always the same. Information in my plot is coded in the color of the bar. I therefore need to be able so assign a different combination (or order) of colors to each individual stacked bar. In the example below, the combination of colors for my plot is generated by X, Q, color and cols. These colors are supposed to fill the stacked bars with the height of H. However, only the first column of cols is used for all columns of H as barplot only allows me to assign one vector for the color scheme of the entire barplot. Does anybody know a way how I can assign each bar a potentially unique color combination? Thanks for your help! Kim X - seq(1:6) Q- matrix(sample(X, 60, replace = T), nrow=6, byrow = T) H - matrix(rep(1,60), nrow=6, byrow=T) color - c(blue, orange, gold, indianred, skyblue4, lightblue) cols - ifelse( (Q ==1) , color[1], ifelse( (Q ==2), color[2], ifelse( (Q ==3) , color[3], ifelse( (Q ==4), color[4], ifelse( (Q ==5) , color[5], color[6] ) ) ) ) ) barplot( H, col=cols, width = c(0.1), xlim = c(0,3), beside=F ) __ Kim Milferstedt University of Illinois at Urbana-Champaign Department of Civil and Environmental Engineering 4125 Newmark Civil Engineering Laboratory 205 North Mathews Avenue MC-250 Urbana, IL 61801 USA phone: (001) 217 333-9663 fax: (001) 217 333-6968 email: [EMAIL PROTECTED] http://cee.uiuc.edu/research/morgenroth __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] extracting data from zoo series
Please read the last line of every message to r-help and follow it when posting. You ought to have provided small examples for A and B and the result. The following lists every row in z that is at a date in zs or is up to 4 rows later: library(zoo) z - zoo(matrix(101:148, 24), 2001:2024) zs - z[c(1, 3, 10)] z[unique(c(sapply(match(time(zs), time(z)), seq, length = 5)))] On 3/1/07, Alfonso Sammassimo [EMAIL PROTECTED] wrote: Dear List, Sorry if I'm overlooking something simple here but I have gotten a bit tangled. I am trying to print the next five values(with their dates), which occur after a certain condition is met. I have a series of data in zoo format, call it A. From this series I have created a subset (also in zoo format) based on a certain condition, call this series B. I want to use the dates from B as an index, so as each of these dates occur in A, the succeeding five rows from A after this date are printed out. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] RE-Row-wise two sample T-test on subsets of a matrix
whoops. forgot to mention the apply command. so this is what I exactly typed in fun5-function(m){as.numeric(t.test(m[1:11],m[12:22])[[1]])} abc-apply(temp.matrix,1,fun5) temp.matrix or course being my 196002*22 matrix and then I got the t-test rowwise for my two groups. It's just that previously I had the extra commas in my function. Post doc in lab helped me. Syntax always worries me. nameeta Original message Date: Fri, 2 Mar 2007 11:28:26 -0500 From: Leeds, Mark (IED) [EMAIL PROTECTED] Subject: RE: [R] RE-Row-wise two sample T-test on subsets of a matrix To: Nameeta Lobo [EMAIL PROTECTED] wow, so it didn't even need a call to apply. t.test must be vectorized. interesting. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nameeta Lobo Sent: Friday, March 02, 2007 11:09 AM To: r-help@stat.math.ethz.ch Subject: [R] RE-Row-wise two sample T-test on subsets of a matrix hello all thanks a lot for the info, I just actually needed to remove that comma in my command line what i had typed in was t.test(temp.matrix[,1:11],temp.matrix[,12:22],paired=TRUE) what i needed to do was t.test(temp.matrix[1:11],temp.matrix[12:22],paired=TRUE) thanks Petr, saw your comment later. nameeta __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This is not an offer (or solicitation of an offer) to buy/sell the securities/instruments mentioned or an official confirmation. Morgan Stanley may deal as principal in or own or act as market maker for securities/instruments mentioned or may advise the issuers. This is not research and is not from MS Research but it may refer to a research analyst/research report. Unless indicated, these views are the author's and may differ from those of Morgan Stanley research or others in the Firm. We do not represent this is accurate or complete and we may not update this. Past performance is not indicative of future returns. For additional information, research reports and important disclosures, contact me or see https://secure.ms.com/servlet/cls. You should not use e-mail to request, authorize or effect the purchase or sale of any security or instrument, to send transfer instructions, or to effect any other transactions. We cannot guarantee that any such requests received via e-mail will be processed in a timely manner. This communication is solely for the addressee(s) and may contain confidential information. We do not waive confidentiality by mistransmission. Contact me if you do not wish to receive these communications. In the UK, this communication is directed in the UK to those persons who are market counterparties or intermediate customers (as defined in the UK Financial Services Authority's rules). __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] from function to its name?
Charilaos Skiadas wrote: On Mar 2, 2007, at 9:42 AM, Ido M. Tamir wrote: But how do I get from a function to its name? Can you do this with any object in R? In what situation will you be wanting this name? I mean, how would you be given this object, but not know its name in advance? If it is passed as an argument in a function or something, then what would you consider to be its name? I.e. I don't really see where you would reasonably want to do something like this, without there being another way around it. I wanted to pass a vector of functions as an argument to a function to do some calculations and put the results in a list where each list entry has the name of the function. I thought I could either pass a vector of function names as character, then retrieve the functions etc... Or do the opposite, pass the functions and then retrieve the names, but this seems not to be possible it occurred to me, hence my question. thanks ido __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lattice: clipping data, not plot margins
On 3/2/07, Dan Bebber [EMAIL PROTECTED] wrote: I am plotting subsets of my data, using ylim. This works fine, but the outer margin line widths of the plot are thin, due to clipping. If I include trellis.par.set(clip=list(panel = off)) then the outer margin line widths are fine, but the outlying data is visible. Is there any way of achieving both correct margin line widths and clipping of outlying data? I believe this behaviour has already been changed in the svn sources of lattice (i.e. the boundaries are not clipped). There hasn't been a release since then, but I'll try to make one within a week or two. Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Matrix looping
Hi all, I am having a problem getting my fucntion to work correctly. Here is my problem. I have three ages: Nage-c(1,2,3) I have an weight matrix: Wt-c( 0.04952867, 0.23808432, 0.34263880) I have an age schedule of maturity: Mat-c(0,1,1) where 0 is not mature, and 1 is mature I have a vulnerability schedule: Vul-c(0,1,1) I have an survivorship schedule: Survship-c(1,0.4,0.16) I also have leading parameters R0-130.66; recK-3.068; a-5.48; b-0.0282; S-0.4 I have annual catches for 100 years, ct-runif(100,5,20) Now I want a matrix of 100 years x 3 ages yr-c(1:100) Nt-matrix(0,nrow=length(yr)+1),ncol=length(Nage)) Now the first row of my matrix needs to be the product of R0 and Survship, no problem Nt[1,]-Ro*Survship I also need to create a new vector of egg production so Eggs-vector();Eggs[1]-sum(Mat*Nt[1,]) I also calculate the vulnerable biomass for each year so VulBio-vector();VulBio[1]-sum(Wt*Vul*Nt[1,]) Now I calculate the exploitation Ut-min(0.99,ct[1]/VulBio[1]) For (i in 1:length(Nt[,1])){ Now I need to calculate the first column of values where; Nt[i+1,1]-a*Eggs[i]/(1+b*Eggs[i]) Eggs[i+1]-sum(Mat*Nt[i+1,] VulBio[i+1]-sum(Wt*Vul*Nt[i+1,]) Ut[i+1]-min(0.99,ct[i+1]/VulBio[i+1]) Now here is the rub, I need to calculate the rest of the matrix based on the previous years values for the previous age, but I don't want to overwrite the first column or first row. Nt[i+1,i+1]-Nt[i,i]*S*(1-Ut[i]*Vul[i] gives the diagonal. How do I fill the matrix without overwriting colum and row 1? Cameron Guenther, Ph.D. 100 8th Ave. SE St. Petersburg, Fl 33701 727-896-8626 ext. 4305 [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] random uniform sample of points on an ellipsoid (e.g. WG
OK, I stand corrected, my previous post generated a point on an ellipsoid as a proyection of an uniform random point in a sphere. now, to generate a random point in a sphere I generate an uniform on one axis and an uniform angle in the second, since the sphere has the property that the perifery of all slices of equal thickness parallel to an equator have equal surface. So, if I devide an oblate ellipsoid, like a geoid, in slices parallel to the equator, I can easily compute the surface area of the slices lower - 0 upper - pi/2 a - 1 b - 1.001 e - sqrt(1-a^2/b^2) # # area revolution # fun3 - function(t,az,bz){ 2 * pi * bz * sin(t) * sqrt(az^2 * sin(t)^2 + bz^2 * cos(t)^2) } are3 - integrate(fun3,lower,upper,az=a, bz=b) are3 s - 2 * pi *(a*a + b*b*atanh(e)/e) print(s/2) so the integration works ok on the semi-ellipsoid, Now I devide it in 100 slices # v - rep(0,100) for(i in 1:100){ l - (i-1)*pi/200 u - i*pi/200 v[i] - integrate(fun3,lower=l, upper=u, az=a, bz = b)$value } print(sum(v)) #[1] 6.291565 s/2 #[1] 6.29157 w - cumsum(v) w - w/w[100] # now I choose a slice at random proportional to its area and a point in the latitude axis the longitude is random 0-2pi. # x - runif(1) xx - max(which(w x)) lat - (xx+runif(1)) * pi / 200 lon - 2 * runif(1) * pi # cat(lat*180/pi,lon*180/pi) # This point should be 'approximately' at random on the surface of the ellipsoid (revolution oblate). The error in the distribution of the point versus perfectly random is 'only' in the determination of latitude where I interpolate within a slice with a, straight line ' xx + runif(1) ' instead of following the curve. Taking 1000 slices instead of 100 obviously reduces this error to almost nothing, but not zero. Am I correct this time? Heberto Ghezzo McGill University Montreal - Canada __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] from function to its name?
Ido M. Tamir [EMAIL PROTECTED] writes: I wanted to pass a vector of functions as an argument to a function to do some calculations and put the results in a list where each list entry has the name of the function. I thought I could either pass a vector of function names as character, then retrieve the functions etc... Or do the opposite, pass the functions and then retrieve the names, but this seems not to be possible it occurred to me, hence my question. Functions don't have to have names, by which I mean that the definition doesn't have to be bound to a symbol. If your function takes a list of functions then: yourFunc(theFuncs=list(function(x) x + 1)) You could force the list to have names and use them. Or you could force function names to be passed in (your other idea). + 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 and provide commented, minimal, self-contained, reproducible code.
[R] Problem with user defined split function in Rpart
Dear all, I'm trying to manage with user defined split function in rpart. I (hope) correctly defined three functions (eval, split, init) I need. I tested these function by executing them step by step and they work correctly. When I try to build the tree by the rpart command (by specifying method= the list of the my three functions) I get no errors but the tree I obtain contains only the root ! I tried in different ways to understand the reason why the tree does not grow up but I had not success ... The only strange thing I observed is that the CP parameter in summary.rpart is negative CP nsplit rel error 1 -1.011038 0 1 Where does the problem lie ? Thank you for any helpful suggestion. Paolo Radaelli Paolo Radaelli Dipartimento di Metodi Quantitativi per le Scienze Economiche ed Aziendali Facoltà di Economia Università degli Studi di Milano-Bicocca P.zza dell'Ateneo Nuovo, 1 20126 Milano Italy e-mail [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] from function to its name?
Seth is, of course, correct, but perhaps the following may help: ## function that takes a function as an argument foo - function(f,x)list(deparse(substitute(f)),f(x)) ## Value is a list of length 2; first component is a character string giving the name of the funtion; second component is the result of applying the function to the x argument. ##pass in the name (UNquoted) of the function as the first argument ## This works because the evaluator looks up the function that the symbol is bound to in the usual way foo(mean, 1:5) [[1]] [1] mean [[2]] [1] 3 ## pass in an unnamed function as the first argument foo(function(y)sum(y)/length(y), 1:5) [[1]] [1] function(y) sum(y)/length(y) [[2]] [1] 3 ## the following gives an error since the first argument is a character string, not a name/symbol: foo(f=mean, 1:5) Error in foo(f = mean, 1:5) : could not find function f Cheers, Bert Gunter Genentech Nonclinical Statistics South San Francisco, CA 94404 650-467-7374 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Seth Falcon Sent: Friday, March 02, 2007 9:18 AM To: r-help@stat.math.ethz.ch Subject: Re: [R] from function to its name? Ido M. Tamir [EMAIL PROTECTED] writes: I wanted to pass a vector of functions as an argument to a function to do some calculations and put the results in a list where each list entry has the name of the function. I thought I could either pass a vector of function names as character, then retrieve the functions etc... Or do the opposite, pass the functions and then retrieve the names, but this seems not to be possible it occurred to me, hence my question. Functions don't have to have names, by which I mean that the definition doesn't have to be bound to a symbol. If your function takes a list of functions then: yourFunc(theFuncs=list(function(x) x + 1)) You could force the list to have names and use them. Or you could force function names to be passed in (your other idea). + 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 and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] plot with fixed axis proportion
I want to plot something (eg a circle) with a fixed ratio of the x and y axis, or (even better) with a fixed size when I print it. Output should then be a circle (actually it'll be someting more complicated) with radius 5cm and not an ellipse. I'm _sure_ this is not new, but after looking 45min for a solution, I post here... Thanks for help 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] random uniform sample of points on an ellipsoid (e.g. WG
Alberto == Alberto Vieira Ferreira Monteiro [EMAIL PROTECTED] writes: Alberto I guess this sample is required for some practical Alberto application, say a simulation for something done over the Alberto Earth. Then, I also guess that the sample does not have to be Alberto _absolutely_ exact, but a reasonable approximation can do Alberto it. And the ellipsoid is a rotation ellipsoid. Alberto This is my suggestion: Alberto (1) Divide the Ellipsoid by latitudes in _n_ horizontal Alberto slices in such a way that each slice can be considered Alberto almost spherical. Of course here lies the problem: Alberto depending on the purpose of the simulation, _n_ would be so Alberto big as to make it impractical Alberto (2) Compute the area of each slice (there are formulas for Alberto that, whose error is not very big - again, we rely on the Alberto purpose of the simulation) Alberto (3) Chose a random slice based on weight = area Alberto (4) Chose the random latitude by a uniform from the minimum Alberto to the maximum latitude (a much better approximation would Alberto give higher weight to the latitude closer to the equator) Alberto (5) lon = 2 pi runif(1) # :-) Alberto Now the question is: do you know the formulas to compute the Alberto area in (2)? I know these formulas exist, I learned them in Alberto the last century, but I can't remember them and I don't know Alberto how to find them. This is essentially the approach I (and my local helpers) have taken. With garden-variety calculus, we have derived a function t(z) that maps equal area over the oblate ellipsoid. We select t from a uniform distribution and then find the corresponding z dimension. The expression is quite hairy, but apparently analytically correct (I haven't found any errors yet), if possibly unstable numerically. The derivative with respect to z of area on the ellipsoid at a plane of latitude intersecting at a height z above the equator, where the ellipsoid has been scaled such that a is the polar radius and the equatorial radius is 1, is: dA/dz = 2 * pi * f where f = sqrt((z^2 * (1 - a^2))/a^4 + 1) You find the function t(z) such that dA/dt is constant. Then you select from a uniform distribution and then find the value of z that corresponds. -- Russell Senior ``I have nine fingers; you have ten.'' [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] from function to its name?
Check out: https://stat.ethz.ch/pipermail/r-help/2006-October/114431.html On 3/2/07, Ido M. Tamir [EMAIL PROTECTED] wrote: Charilaos Skiadas wrote: On Mar 2, 2007, at 9:42 AM, Ido M. Tamir wrote: But how do I get from a function to its name? Can you do this with any object in R? In what situation will you be wanting this name? I mean, how would you be given this object, but not know its name in advance? If it is passed as an argument in a function or something, then what would you consider to be its name? I.e. I don't really see where you would reasonably want to do something like this, without there being another way around it. I wanted to pass a vector of functions as an argument to a function to do some calculations and put the results in a list where each list entry has the name of the function. I thought I could either pass a vector of function names as character, then retrieve the functions etc... Or do the opposite, pass the functions and then retrieve the names, but this seems not to be possible it occurred to me, hence my question. thanks ido __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] random uniform sample of points on an ellipsoid (e.g. WG
Russell Senior wrote: This is essentially the approach I (and my local helpers) have taken. With garden-variety calculus, we have derived a function t(z) that maps equal area over the oblate ellipsoid. We select t from a uniform distribution and then find the corresponding z dimension. The expression is quite hairy, but apparently analytically correct (I haven't found any errors yet), if possibly unstable numerically. Hmmm... I have just thought about something. The ellipsoid is almost a sphere, so every formula for the sphere should map into a formula for the ellipsoid that can be expressed as a power series in the eccentricity or the oblateness. Since these parameters are small, most of these series will converge very fast, and it might be possible to do most transformations with them. So, you could have a fast and accurate series that would generate the random latitudes. The derivative with respect to z of area on the ellipsoid at a plane of latitude intersecting at a height z above the equator, where the ellipsoid has been scaled such that a is the polar radius and the equatorial radius is 1, is: dA/dz = 2 * pi * f where f = sqrt((z^2 * (1 - a^2))/a^4 + 1) You find the function t(z) such that dA/dt is constant. Then you select from a uniform distribution and then find the value of z that corresponds. Yikes! I can't read a formula in ascii notation :-P Let's parametrize the ellipsoid by the corresponding sphere, using coordinates lats (latitude of the corresponding sphere) and lon. So: x = a cos(lats) cos(lon) y = a cos(lats) sin(lon) z = b sin(lats) But then the surface are between lats and lats + dl will require a little bit of calculus... Russell Senior ``I have nine fingers; you have ten.'' So do Frodo, Sauron and brazilian president Lula :-) Alberto Monteiro __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot with fixed axis proportion
See the aspect argument, asp, in ?plot.default . Also eqscplot in MASS. On 3/2/07, Thomas Steiner [EMAIL PROTECTED] wrote: I want to plot something (eg a circle) with a fixed ratio of the x and y axis, or (even better) with a fixed size when I print it. Output should then be a circle (actually it'll be someting more complicated) with radius 5cm and not an ellipse. I'm _sure_ this is not new, but after looking 45min for a solution, I post here... Thanks for help 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 and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [friday topic]: what exactly is statistical computing
Thanks for your insight, Roger. Actually, my question is not related to R only. statistical computing is a popular topic recently. However, when I check its meaning on wikipedia/google, I couldn't find it. another reason why I asked is related to myself. I am very interested in this area and maintaining a blog in this topic. however, when asked what 'statistical computing' is, I am not able to give a well-verbalized answer. On 3/2/07, Bos, Roger [EMAIL PROTECTED] wrote: This means it comes with substantial statistical routines built-in. You could just as well use VBA or Java for your programming language, but with those you would have to write pretty much any stat routine you need. With R, since it is a 'statistical computing' language, you know that most of what you need has already been programmed, tested(?), and is ready to use. I have seen you on this list for a while. You already know all this. I am not sure why you are asking this question. Roger -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Wensui Liu Sent: Friday, March 02, 2007 9:43 AM To: r-help@stat.math.ethz.ch Subject: [R] [friday topic]: what exactly is statistical computing Dear List, on www.r-project.org, the title says 'The R Project for Statistical Computing'. but what exactly is the definition of statistical computing? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ** * This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No right to confidential or privileged treatment of this message is waived or lost by any error in transmission. If you have received this message in error, please immediately notify the sender by e-mail, delete the message and all copies from your system and destroy any hard copies. You must not, directly or indirectly, use, disclose, distribute, print or copy any part of this message if you are not the intended recipient. ** -- WenSui Liu A lousy statistician who happens to know a little programming (http://spaces.msn.com/statcompute/blog) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] lme problem : extra parameters
Hello: Below is a toy logistic regression problem. When I wrote my own code, Newton-Raphson converged in three iterations using both the gradient and the Hessian and the starting values given below. But I can't get nlm() to work! I would much appreciate any help. x [1] 10.2 7.7 5.1 3.8 2.6 y [1] 9 8 3 2 1 n [1] 10 9 6 8 10 derfs4=function(b,x,y,n) { b0 = b[1] b1 = b[2] c=b0+b1*x d=exp(c) p=d/(1+d) e=d/(1+d)^2 f = -sum(log(choose(n,y))-n*log(1+d)+y*c) attr(f,gradient)=c(-sum(y-n*p),-sum(x*(y-n*p))) attr(f,hessian)=matrix(c(sum(n*e),sum(n*x*e),sum(n*x*e),sum(n*x^2*e)),2,2) return(f) } nlm(derfs4,c(-3.9,.64),hessian=T,print.level=2,x=x,y=y,n=n) Error in choose(n, y) : argument n is missing, with no default I tried a variety of other ways too. When I got it to work it did not converge in 100 iterations ;rather like the fgh example given on the lme help page. Mervyn [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] barplot2, gap.barplot
On Fri, 2007-03-02 at 10:07 -0600, hadley wickham wrote: On 3/2/07, Marc Schwartz [EMAIL PROTECTED] wrote: On Fri, 2007-03-02 at 08:53 -0600, hadley wickham wrote: 3. Depending on the nature of your data, if the extreme value is representative of an important marked difference relative to the other values, then I don't particularly find the 'look' of the plot to be overly problematic. It does appropriately emphasize the large difference. On the other hand, you might want to consider using a log scale on the y axis as an alternative to an axis gap. This would be a reasonable approach to plotting values that have a notable difference in range. If you do this, note that you would need to ensure that all y values are 0 (ie. y axis range minimum, lower bounds of CI's, etc.) since: log10(0) [1] -Inf Of course, you can't do this with a bar plot, because bars should be anchored at 0. Both barplot() and barplot2() support log scaling for both x and y axes. In both functions, the default axis minimum for the 'height' axis (y by default, x if 'horizontal = TRUE') will be 0.9 * min(height) to avert log10(0) related issues. Errors will be issued otherwise if any values of 'height' are = 0 or 'ylim'/'xlim' args are similarly set. I think that's a pretty bad idea - in a bar plot you are comparing the ratio of heights of the bars, not the absolute heights. It's the same reason it's a bad idea to have a bar graph with a non-0 y-axis - it's misleading. Hadley, I might note that even lattice will do this, arguably easier than barplot[2](): library(lattice) x - 10 ^ (0:10) barchart(x ~ 0:10, horizontal = FALSE, scales = list(y = list(log = 10))) Is it the right thing to do? I'll leave that for others to debate. I have stronger feelings on the 'gapped axis' issue. I don't tend to use bar plots too much myself any longer and it all depends upon the audience. There have been requests for log scales on barplots on the R lists going back several years, which is one of the reasons that I wrote barplot2() some years ago. It was also one of my first exercises in gaining a lower level understanding of R's graphics models. The 'log' and 'add' arguments and related code from barplot2() were then included in R's barplot() in version 2.2.0, I believe by Paul. HTH, Marc __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reformulated matrices dimensions limitation problem
I don't have anything in front of me but just to make sure everyone knows thee are 2 rfp's out there right now from sea grant. 1 is a speceduc climate change and the other the normal RFP. I think the proopal would fit in either Perhaps that is the discrepency in amounts? --- Mark Herzog PhD Program Director San Francisco Bay Research, Wetlands Division PRBO Conservation Science (415) 893-7677 x308 (office) [EMAIL PROTECTED] -Original Message- From: Petr Pikal [EMAIL PROTECTED] Date: Fri, 02 Mar 2007 15:22:06 To:Bruno C. [EMAIL PROTECTED], r-help [EMAIL PROTECTED] Subject: Re: [R] Reformulated matrices dimensions limitation problem I believe that due to memory management the size of biggest possible matrix can change. But I probably am not the persou who can explain it correctly. Petr On 2 Mar 2007 at 14:40, Bruno C. wrote: Date sent: Fri, 2 Mar 2007 14:40:18 +0100 From: Bruno C. [EMAIL PROTECTED] To: petr.pikal [EMAIL PROTECTED] Copies to: r-help [EMAIL PROTECTED] Subject:Re: [R] Reformulated matrices dimensions limitation problem bigml is for generalized regression model. I need to use lars ans svm. Anway I am perfectly able to train my model: my training matrix is not so big. The big matrix is the test one then I can split it by rows into several matrices without affecting the results. The point is that I wanted to split it in an elegant way, mainimizing the needed submatrices wrt memory. But I have the impression I am asking R too much :D Did you consider biglm package. I did not use it myself but from its description it can be used for linear models on objects that do not fit into memory. HTH Petr On 2 Mar 2007 at 13:12, Bruno C. wrote: Date sent: Fri, 2 Mar 2007 13:12:07 +0100 From: Bruno C. [EMAIL PROTECTED] To: petr.pikal [EMAIL PROTECTED] Copies to: r-help [EMAIL PROTECTED] Subject:Re: [R] Reformulated matrices dimensions limitation problem You are right. and I am aware of that. This is what I need to do: load a regression model load the bigget posible matrix do prediction on this matrix the first and 3rd step will not need to much memory... and I would really appreciate this degree of introspection from R: it would be great if there would be a package that could simulate the amount of memory needed from a process But I don't pretend that much, this is why I am asking only about a function able to build a matrix matrix, with size based on memory available... Hi creating a biggest possible matrix does not automaticaly mean you can do some computation with it. So the size will depend partly on what you want to do with it. I presume that you do not want only to create a matrix just for pleasure to be able to. Cheers Petr On 2 Mar 2007 at 10:15, Bruno C. wrote: Date sent: Fri, 2 Mar 2007 10:15:33 +0100 From: Bruno C. [EMAIL PROTECTED] To: r-help [EMAIL PROTECTED] Subject:[R] Reformulated matrices dimensions limitation problem First I wanted to thank both Marc Schwartz Greg Snow and for their reply. Then I needed to add a level of complexity to the problem. I would be able to create the biggest possible matrix. In other way does it exist a method to ask smthing like the following : max number of rows for a matrix if column=x? Thank you -- Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom http://click.libero.it/infostrada2marz07 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] -- Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom http://click.libero.it/infostrada2marz07 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] -- Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom
Re: [R] plot with fixed axis proportion
Your question can be interpreted a couple of ways, Gabor gave you the answer to one of those interpretations. Another interpretation of your question makes it the same as one that was asked earlier in the week with the subject: PLotting R graphics/symbols without user x-y scaling, looking at that question and the replies to it should help if that is the correct interpretation of your question. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Thomas Steiner Sent: Friday, March 02, 2007 10:49 AM To: r-help@stat.math.ethz.ch Subject: [R] plot with fixed axis proportion I want to plot something (eg a circle) with a fixed ratio of the x and y axis, or (even better) with a fixed size when I print it. Output should then be a circle (actually it'll be someting more complicated) with radius 5cm and not an ellipse. I'm _sure_ this is not new, but after looking 45min for a solution, I post here... Thanks for help 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 and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [friday topic]: what exactly is statistical computing
This is indeed a Friday topic. I think I understand the difficulty that Wensui has. I teach two classes, each with the phrase statistical computing in the title, and yet they cover completely different topics. -roger Wensui Liu wrote: Thanks for your insight, Roger. Actually, my question is not related to R only. statistical computing is a popular topic recently. However, when I check its meaning on wikipedia/google, I couldn't find it. another reason why I asked is related to myself. I am very interested in this area and maintaining a blog in this topic. however, when asked what 'statistical computing' is, I am not able to give a well-verbalized answer. On 3/2/07, Bos, Roger [EMAIL PROTECTED] wrote: This means it comes with substantial statistical routines built-in. You could just as well use VBA or Java for your programming language, but with those you would have to write pretty much any stat routine you need. With R, since it is a 'statistical computing' language, you know that most of what you need has already been programmed, tested(?), and is ready to use. I have seen you on this list for a while. You already know all this. I am not sure why you are asking this question. Roger -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Wensui Liu Sent: Friday, March 02, 2007 9:43 AM To: r-help@stat.math.ethz.ch Subject: [R] [friday topic]: what exactly is statistical computing Dear List, on www.r-project.org, the title says 'The R Project for Statistical Computing'. but what exactly is the definition of statistical computing? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ** * This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No right to confidential or privileged treatment of this message is waived or lost by any error in transmission. If you have received this message in error, please immediately notify the sender by e-mail, delete the message and all copies from your system and destroy any hard copies. You must not, directly or indirectly, use, disclose, distribute, print or copy any part of this message if you are not the intended recipient. ** -- Roger D. Peng | http://www.biostat.jhsph.edu/~rpeng/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Using R for devices trial
Mat, Thank you for the update and for the link. I look forward to (hopefully) using R for future FDA submissions. Regards, -Cody Soukup, Mat [EMAIL PROTECTED] hs.govTo [EMAIL PROTECTED], 03/02/2007 05:28 [EMAIL PROTECTED] AM cc Subject RE: [R] Using R for devices trial Hi Cody, I would point you to the presentation by Sue Bell at least year's ASA meeting available here: http://www.fda.gov/Cder/Offices/Biostatistics/Bell.pdf. I can't speak for CDRH, but at CDER we are making some progress towards the level of comfort with the use of R as a valid software tool. Specifically, 1. R was granted approval by our IT folks for use on our government PC's (2 years in the making to get this). 2. An R course is in development for FDA reviewers to use R for review of clinical trial data. 3. This Monday at the 1st FDA/DIA Spring Meeting I will be offering a tutorial on Statistical Graphics with R for Clinical Trial Data. 4. An increasing effort to pigeon-tail R to ongoing projects to show proof by example that R can be trusted when used properly. So from the regulatory side, progress is being made, but there still do exist those who have some discomfort with the use of an open-source tool for data analysis. Someday hopefully that too will be changed. HTH, -Mat Disclaimer: The views expressed are those of the author and must not be taken to represent policy or guidance on behalf of the Food and Drug Administration. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Thursday, March 01, 2007 5:43 PM To: [EMAIL PROTECTED] Subject: [R] Using R for devices trial I would like to use R for submissions to FDA/CDRH (the medical device company I work for currently uses only SAS). Previous postings to the list regarding R and 21 CFR 11 compliance have been very helpful. However, reluctance to using open source software for statistical analyses and reporting remains high here at my company. Has anyone used R for an official submission to FDA/CDRH? It would be most helpful if I could tell our group that others have been able to use R for this purpose. Regards, Cody Hamilton Staff Biostatistician Edwards Lifesciences __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] add mean, sd, number of observation in each panel for lattice histogram
__ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R: ARIMA forecasting
Dear all, I just have a short question regarding the forecasting of ARIMA models with external regressors. I tried to program a ARX(1) model arx.mod - arima(reihe.lern, order = c(1, 0, 0), seasonal = list(order = c(0, 0, 0), period = 52), xreg = lern.design, include.mean = TRUE) for which I need to estimate the next (105th) value. Xreg=lern.design is - at this time - 104 rows long. I tried to use the following function: predict(arx.mod, n.ahead = 1, newxreg=lern.design[105,]) Here, lern.design is 105 rows long, same number of columns. Now the problem is the following error: Error in predict.Arima(arx.mod, n.ahead = 1, newxreg = lern.design[105, : 'xreg' and 'newxreg' have different numbers of columns If I use the total new lern.design matrix with the external regressor information (105 rows), R estimates every observation and the 105th is no longer correct (I recalculated is manually). What can I do? I just need the forecasted value for the 105th observation so that I can add this to my data and create a new one-step forecast. Thanks for your help! Kind regards Malte Rüsing __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Using R for devices trial
Mat, Thank you for the update and for the link. I look forward to (hopefully) using R for future FDA submissions. Regards, -Cody Soukup, Mat [EMAIL PROTECTED] hs.govTo [EMAIL PROTECTED], 03/02/2007 05:28 [EMAIL PROTECTED] AM cc Subject RE: [R] Using R for devices trial Hi Cody, I would point you to the presentation by Sue Bell at least year's ASA meeting available here: http://www.fda.gov/Cder/Offices/Biostatistics/Bell.pdf. I can't speak for CDRH, but at CDER we are making some progress towards the level of comfort with the use of R as a valid software tool. Specifically, 1. R was granted approval by our IT folks for use on our government PC's (2 years in the making to get this). 2. An R course is in development for FDA reviewers to use R for review of clinical trial data. 3. This Monday at the 1st FDA/DIA Spring Meeting I will be offering a tutorial on Statistical Graphics with R for Clinical Trial Data. 4. An increasing effort to pigeon-tail R to ongoing projects to show proof by example that R can be trusted when used properly. So from the regulatory side, progress is being made, but there still do exist those who have some discomfort with the use of an open-source tool for data analysis. Someday hopefully that too will be changed. HTH, -Mat Disclaimer: The views expressed are those of the author and must not be taken to represent policy or guidance on behalf of the Food and Drug Administration. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Thursday, March 01, 2007 5:43 PM To: [EMAIL PROTECTED] Subject: [R] Using R for devices trial I would like to use R for submissions to FDA/CDRH (the medical device company I work for currently uses only SAS). Previous postings to the list regarding R and 21 CFR 11 compliance have been very helpful. However, reluctance to using open source software for statistical analyses and reporting remains high here at my company. Has anyone used R for an official submission to FDA/CDRH? It would be most helpful if I could tell our group that others have been able to use R for this purpose. Regards, Cody Hamilton Staff Biostatistician Edwards Lifesciences __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [friday topic]: what exactly is statistical computing
Statistical computing perhaps is not so much a single topic as a family of related topics (a la Wittgenstein) that share a lot in common but perhaps very little is common to all. For example, 1. Statistical computing in contrast to statistical theory. 6. Statistical computing as a supplement to statistical theory. 2. Statistical computing as gaining insight through data visualization 3. Statistical computing for asymptotic analyses 4. Statistical computing for approximations to unknown distributions 5. Statistical computing for teaching demonstrations 7. Statistical computing for assessing behavior of statistics. and so on. Joe -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Roger D. Peng Sent: Friday, March 02, 2007 1:07 PM To: Wensui Liu Cc: r-help@stat.math.ethz.ch; Bos, Roger Subject: Re: [R] [friday topic]: what exactly is statistical computing This is indeed a Friday topic. I think I understand the difficulty that Wensui has. I teach two classes, each with the phrase statistical computing in the title, and yet they cover completely different topics. -roger Wensui Liu wrote: Thanks for your insight, Roger. Actually, my question is not related to R only. statistical computing is a popular topic recently. However, when I check its meaning on wikipedia/google, I couldn't find it. another reason why I asked is related to myself. I am very interested in this area and maintaining a blog in this topic. however, when asked what 'statistical computing' is, I am not able to give a well-verbalized answer. On 3/2/07, Bos, Roger [EMAIL PROTECTED] wrote: This means it comes with substantial statistical routines built-in. You could just as well use VBA or Java for your programming language, but with those you would have to write pretty much any stat routine you need. With R, since it is a 'statistical computing' language, you know that most of what you need has already been programmed, tested(?), and is ready to use. I have seen you on this list for a while. You already know all this. I am not sure why you are asking this question. Roger -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Wensui Liu Sent: Friday, March 02, 2007 9:43 AM To: r-help@stat.math.ethz.ch Subject: [R] [friday topic]: what exactly is statistical computing Dear List, on www.r-project.org, the title says 'The R Project for Statistical Computing'. but what exactly is the definition of statistical computing? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. * * * This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No right to confidential or privileged treatment of this message is waived or lost by any error in transmission. If you have received this message in error, please immediately notify the sender by e-mail, delete the message and all copies from your system and destroy any hard copies. You must not, directly or indirectly, use, disclose, distribute, print or copy any part of this message if you are not the intended recipient. * * -- Roger D. Peng | http://www.biostat.jhsph.edu/~rpeng/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [friday topic]: what exactly is statistical computing
Wensui Liu writes: but what exactly is the definition of statistical computing? In my world, statistical computing is using computers for statistical calculation and data management. By using computers I mean using computers for their greatest strengths, and by that I mean programming them to do exactly what I need. Joel -- Joel J. Adamson Biostatistician Pediatric Psychopharmacology Research Unit Massachusetts General Hospital Boston, MA 02114 (617) 643-1432 (303) 880-3109 The information transmitted in this electronic communication is intended only for the person or entity to whom it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this information in error, please contact the Compliance HelpLine at 800-856-1983 and properly dispose of this information. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [friday topic]: what exactly is statistical computing
Bos, Roger writes: I have seen you on this list for a while. You already know all this. I am not sure why you are asking this question. Roger I think [friday topic] means fun discussion. I agree with your main comment Roger; I often think about the power of straight-up languages like C, Java, etc., and wonder Why do we need so many statistical packages, much less totally awesome ones like S? It would be a pain to have to program everything from scratch, and having something like R eases the communication routes. Joel -- Joel J. Adamson Biostatistician Pediatric Psychopharmacology Research Unit Massachusetts General Hospital Boston, MA 02114 (617) 643-1432 (303) 880-3109 The information transmitted in this electronic communication is intended only for the person or entity to whom it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this information in error, please contact the Compliance HelpLine at 800-856-1983 and properly dispose of this information. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] nlm() problem : extra parameters
Hello: Below is a toy logistic regression problem. When I wrote my own code, Newton-Raphson converged in three iterations using both the gradient and the Hessian and the starting values given below. But I can't get nlm() to work! I would much appreciate any help. x [1] 10.2 7.7 5.1 3.8 2.6 y [1] 9 8 3 2 1 n [1] 10 9 6 8 10 derfs4=function(b,x,y,n) { b0 = b[1] b1 = b[2] c=b0+b1*x d=exp(c) p=d/(1+d) e=d/(1+d)^2 f = -sum(log(choose(n,y))-n*log(1+d)+y*c) attr(f,gradient)=c(-sum(y-n*p),-sum(x*(y-n*p))) attr(f,hessian)=matrix(c(sum(n*e),sum(n*x*e),sum(n*x*e),sum(n*x^2*e)),2,2) return(f) } nlm(derfs4,c(-3.9,.64),hessian=T,print.level=2,x=x,y=y,n=n) Error in choose(n, y) : argument n is missing, with no default I tried a variety of other ways too. When I got it to work it did not converge in 100 iterations ;rather like the fgh example given on the lme help page. Mervyn [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] sampling random groups with all observations in the group
Hi I have a panel dataset with large number of groups and differing number of observations for each group. I want to randomly select say, 20% of the groups or 200 groups, but along with all observations from the selcted groups (with the corresponding data). I guess it is possible to generate a random sample from the groups ids and then match that with the entire dataset to have the intended dataset, but it sounds cumbersome and possibly there is an easier way to do this? checked the package 'sampling' or command 'sample', but they cant do exactly the same thing. I was wondering if someone on this list will be able to share his/her knowldege? Thanks in advance, Zia ** Zia Wadud PhD Student Centre for Transport Studies Department of Civil and Environmental Engineering Imperial College London London SW7 2AZ Tel +44 (0) 207 594 6055 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] barplot2, gap.barplot
On 3/2/07, Marc Schwartz [EMAIL PROTECTED] wrote: On Fri, 2007-03-02 at 10:07 -0600, hadley wickham wrote: On 3/2/07, Marc Schwartz [EMAIL PROTECTED] wrote: On Fri, 2007-03-02 at 08:53 -0600, hadley wickham wrote: 3. Depending on the nature of your data, if the extreme value is representative of an important marked difference relative to the other values, then I don't particularly find the 'look' of the plot to be overly problematic. It does appropriately emphasize the large difference. On the other hand, you might want to consider using a log scale on the y axis as an alternative to an axis gap. This would be a reasonable approach to plotting values that have a notable difference in range. If you do this, note that you would need to ensure that all y values are 0 (ie. y axis range minimum, lower bounds of CI's, etc.) since: log10(0) [1] -Inf Of course, you can't do this with a bar plot, because bars should be anchored at 0. Both barplot() and barplot2() support log scaling for both x and y axes. In both functions, the default axis minimum for the 'height' axis (y by default, x if 'horizontal = TRUE') will be 0.9 * min(height) to avert log10(0) related issues. Errors will be issued otherwise if any values of 'height' are = 0 or 'ylim'/'xlim' args are similarly set. I think that's a pretty bad idea - in a bar plot you are comparing the ratio of heights of the bars, not the absolute heights. It's the same reason it's a bad idea to have a bar graph with a non-0 y-axis - it's misleading. Hadley, I might note that even lattice will do this, arguably easier than barplot[2](): library(lattice) x - 10 ^ (0:10) barchart(x ~ 0:10, horizontal = FALSE, scales = list(y = list(log = 10))) Is it the right thing to do? I'll leave that for others to debate. I have stronger feelings on the 'gapped axis' issue. I think this is up there with double and gapped axes. Although it's much easier to resolve - just use a dot plot instead (which is generally a pretty good rule whenever you want to use a bar plot) There have been requests for log scales on barplots on the R lists going back several years, which is one of the reasons that I wrote barplot2() some years ago. It was also one of my first exercises in gaining a lower level understanding of R's graphics models. People are always asking for things they don't really want! ;) I (obviously) have pretty strong feelings about graphics - I don't think you should be able to create meaningless (in some sense) graphics. Hadley __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Fwd: Re: [friday topic]: what exactly is statistical computing
This is a very fascinating discussion topic. I find I run into some fundamental differences in interpretation of the phrase statistical computing. I think of it as writing programs or functions, such as R or packages in R, and of understanding the numerical analysis behind these functions. I exclude USING computer programs, such as R, for data analysis from my definition of statistical computing. I see that as doing statistics. I have had students, some sent by other faculty members, in my class on statistical computing thinking they were going to learn how to do statistical analysis using the computer. There was a clash of expectations between what they thought they were taking and what I had in the syllabus. Rich Original message Date: Fri, 2 Mar 2007 13:25:59 -0600 From: Lucke, Joseph F [EMAIL PROTECTED] Subject: Re: [R] [friday topic]: what exactly is statistical computing To: Roger D. Peng [EMAIL PROTECTED], Wensui Liu [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch, Bos, Roger [EMAIL PROTECTED] Statistical computing perhaps is not so much a single topic as a family of related topics (a la Wittgenstein) that share a lot in common but perhaps very little is common to all. For example, 1. Statistical computing in contrast to statistical theory. 6. Statistical computing as a supplement to statistical theory. 2. Statistical computing as gaining insight through data visualization 3. Statistical computing for asymptotic analyses 4. Statistical computing for approximations to unknown distributions 5. Statistical computing for teaching demonstrations 7. Statistical computing for assessing behavior of statistics. and so on. Joe __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] nlm() problem : extra parameters
Change the name of n to something else. Also please using spacing in your code for readability. x - c(10.2, 7.7, 5.1, 3.8, 2.6) y - c(9, 8, 3, 2, 1) n. - c(10, 9, 6, 8, 10) derfs4 - function(b, x, y, n.) + { + b0 - b[1] + b1 - b[2] + c=b0 +b1 * x + d - exp(c) + p= d/(1+d) + e - d/(1+d)^2 + f - - sum(log(choose(n., y)) - n. * log(1 + d) + y * c) + attr(f, gradient) - c(- sum(y - n. * p), -sum(x * (y - n. * p))) + attr(f, hessian) - matrix(c(sum(n. * e), sum(n. * x * e), + sum(n. * x * e), sum(n. * x^2 * e)), 2, 2) + return(f) + } nlm(derfs4, c(-3.9, 0.64), hessian = TRUE, x = x, y = y, n. = n.) $minimum [1] 5.746945 $estimate [1] -3.5380638 0.6505037 $gradient [1] -0.031425476 -0.006637742 $hessian [,1] [,2] [1,] 5.963954 31.15266 [2,] 31.152658 192.53408 $code [1] 4 $iterations [1] 100 On 3/2/07, Mervyn G Marasinghe [EMAIL PROTECTED] wrote: Hello: Below is a toy logistic regression problem. When I wrote my own code, Newton-Raphson converged in three iterations using both the gradient and the Hessian and the starting values given below. But I can't get nlm() to work! I would much appreciate any help. x [1] 10.2 7.7 5.1 3.8 2.6 y [1] 9 8 3 2 1 n [1] 10 9 6 8 10 derfs4=function(b,x,y,n) { b0 = b[1] b1 = b[2] c=b0+b1*x d=exp(c) p=d/(1+d) e=d/(1+d)^2 f = -sum(log(choose(n,y))-n*log(1+d)+y*c) attr(f,gradient)=c(-sum(y-n*p),-sum(x*(y-n*p))) attr(f,hessian)=matrix(c(sum(n*e),sum(n*x*e),sum(n*x*e),sum(n*x^2*e)),2,2) return(f) } nlm(derfs4,c(-3.9,.64),hessian=T,print.level=2,x=x,y=y,n=n) Error in choose(n, y) : argument n is missing, with no default I tried a variety of other ways too. When I got it to work it did not converge in 100 iterations ;rather like the fgh example given on the lme help page. Mervyn [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sampling random groups with all observations in the group
Wadud, Zia wrote: Hi I have a panel dataset with large number of groups and differing number of observations for each group. I want to randomly select say, 20% of the groups or 200 groups, but along with all observations from the selcted groups (with the corresponding data). I guess it is possible to generate a random sample from the groups ids and then match that with the entire dataset to have the intended dataset, but it sounds cumbersome and possibly there is an easier way to do this? checked the package 'sampling' or command 'sample', but they cant do exactly the same thing. I was wondering if someone on this list will be able to share his/her knowldege? How about something like this? df - data.frame(GROUP = rep(1:5, c(2,3,4,2,2)), Y = runif(13)) # Sample Two of the Five Groups subset(df, GROUP %in% with(df, sample(unique(GROUP), 2))) Thanks in advance, Zia ** Zia Wadud PhD Student Centre for Transport Studies Department of Civil and Environmental Engineering Imperial College London London SW7 2AZ Tel +44 (0) 207 594 6055 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] nlm() problem : extra parameters
Here's a partial answer to your question. The argument ``n'' is getting lost because it ``matches'' one of the formal arguments to nlm, namely ``ndigit''. If you change the argument list of ``derfs4'' to ``b,x,y,size'' (and replace references to ``n'' in the body of derfs4 by references to ``size'') then nlm() will work (?) --- but it seems to take 337 iterations, r.t. 3 (!!!) to converge. No idea what the problem is. cheers, Rolf Turner ===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+=== Original message: Mervyn G Marasinghe wrote: Below is a toy logistic regression problem. When I wrote my own code, Newton-Raphson converged in three iterations using both the gradient and the Hessian and the starting values given below. But I can't get nlm() to work! I would much appreciate any help. x [1] 10.2 7.7 5.1 3.8 2.6 y [1] 9 8 3 2 1 n [1] 10 9 6 8 10 derfs4=function(b,x,y,n) { b0 = b[1] b1 = b[2] c=b0+b1*x d=exp(c) p=d/(1+d) e=d/(1+d)^2 f = -sum(log(choose(n,y))-n*log(1+d)+y*c) attr(f,gradient)=c(-sum(y-n*p),-sum(x*(y-n*p))) attr(f,hessian)=matrix(c(sum(n*e),sum(n*x*e),sum(n*x*e),sum(n*x^2*e)),2,2) return(f) } nlm(derfs4,c(-3.9,.64),hessian=T,print.level=2,x=x,y=y,n=n) Error in choose(n, y) : argument n is missing, with no default I tried a variety of other ways too. When I got it to work it did not converge in 100 iterations ;rather like the fgh example given on the lme help page. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] barplot2, gap.barplot
On Fri, 2007-03-02 at 14:57 -0600, hadley wickham wrote: On 3/2/07, Marc Schwartz [EMAIL PROTECTED] wrote: On Fri, 2007-03-02 at 10:07 -0600, hadley wickham wrote: On 3/2/07, Marc Schwartz [EMAIL PROTECTED] wrote: On Fri, 2007-03-02 at 08:53 -0600, hadley wickham wrote: 3. Depending on the nature of your data, if the extreme value is representative of an important marked difference relative to the other values, then I don't particularly find the 'look' of the plot to be overly problematic. It does appropriately emphasize the large difference. On the other hand, you might want to consider using a log scale on the y axis as an alternative to an axis gap. This would be a reasonable approach to plotting values that have a notable difference in range. If you do this, note that you would need to ensure that all y values are 0 (ie. y axis range minimum, lower bounds of CI's, etc.) since: log10(0) [1] -Inf Of course, you can't do this with a bar plot, because bars should be anchored at 0. Both barplot() and barplot2() support log scaling for both x and y axes. In both functions, the default axis minimum for the 'height' axis (y by default, x if 'horizontal = TRUE') will be 0.9 * min(height) to avert log10(0) related issues. Errors will be issued otherwise if any values of 'height' are = 0 or 'ylim'/'xlim' args are similarly set. I think that's a pretty bad idea - in a bar plot you are comparing the ratio of heights of the bars, not the absolute heights. It's the same reason it's a bad idea to have a bar graph with a non-0 y-axis - it's misleading. Hadley, I might note that even lattice will do this, arguably easier than barplot[2](): library(lattice) x - 10 ^ (0:10) barchart(x ~ 0:10, horizontal = FALSE, scales = list(y = list(log = 10))) Is it the right thing to do? I'll leave that for others to debate. I have stronger feelings on the 'gapped axis' issue. I think this is up there with double and gapped axes. Although it's much easier to resolve - just use a dot plot instead (which is generally a pretty good rule whenever you want to use a bar plot) Indeed. Beyond Tufte and Cleveland, a while back I had been doing some searches on related matters and happened to come across this article by Naomi Robbins: http://www.b-eye-network.com/newsletters/ben/2468 You may find the graphics somewhat familiar looking... There have been requests for log scales on barplots on the R lists going back several years, which is one of the reasons that I wrote barplot2() some years ago. It was also one of my first exercises in gaining a lower level understanding of R's graphics models. People are always asking for things they don't really want! ;) Quite... :-) I (obviously) have pretty strong feelings about graphics - I don't think you should be able to create meaningless (in some sense) graphics. But, how do you really feel? ;-) Regards, Marc __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sampling random groups with all observations in the group
One possibility is to use split to create a list with each of your groups as an element, sample from the list, then combine back into a data frame. For example: mydata - data.frame(group=sample(LETTERS[1:5], 100, replace=TRUE), + x= 1:100, y= rnorm(100) ) head(mydata) group x y 1 B 1 -1.1709539 2 A 2 0.2438249 3 C 3 -1.9079472 4 E 4 0.6155387 5 E 5 -1.0671110 6 C 6 0.8109344 mydata2 - split(mydata, mydata$group) mysamp - sample(5,2) mydata3 - do.call('rbind',mydata2[mysamp]) summary(mydata3) groupx y A: 0 Min. : 3.00 Min. :-1.9079 B: 0 1st Qu.:18.75 1st Qu.:-0.9798 C:17 Median :46.50 Median :-0.4309 D:19 Mean :45.19 Mean :-0.2333 E: 0 3rd Qu.:68.25 3rd Qu.: 0.4351 Max. :97.00 Max. : 3.0469 Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Wadud, Zia Sent: Friday, March 02, 2007 1:12 PM To: r-help@stat.math.ethz.ch Subject: [R] sampling random groups with all observations in the group Hi I have a panel dataset with large number of groups and differing number of observations for each group. I want to randomly select say, 20% of the groups or 200 groups, but along with all observations from the selcted groups (with the corresponding data). I guess it is possible to generate a random sample from the groups ids and then match that with the entire dataset to have the intended dataset, but it sounds cumbersome and possibly there is an easier way to do this? checked the package 'sampling' or command 'sample', but they cant do exactly the same thing. I was wondering if someone on this list will be able to share his/her knowldege? Thanks in advance, Zia ** Zia Wadud PhD Student Centre for Transport Studies Department of Civil and Environmental Engineering Imperial College London London SW7 2AZ Tel +44 (0) 207 594 6055 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sampling random groups with all observations in the group
Chuck Cleland wrote: Wadud, Zia wrote: Hi I have a panel dataset with large number of groups and differing number of observations for each group. I want to randomly select say, 20% of the groups or 200 groups, but along with all observations from the selcted groups (with the corresponding data). I guess it is possible to generate a random sample from the groups ids and then match that with the entire dataset to have the intended dataset, but it sounds cumbersome and possibly there is an easier way to do this? checked the package 'sampling' or command 'sample', but they cant do exactly the same thing. I was wondering if someone on this list will be able to share his/her knowldege? How about something like this? df - data.frame(GROUP = rep(1:5, c(2,3,4,2,2)), Y = runif(13)) # Sample Two of the Five Groups subset(df, GROUP %in% with(df, sample(unique(GROUP), 2))) The with() part can be dropped too. subset(df, GROUP %in% sample(unique(GROUP), 2)) Thanks in advance, Zia ** Zia Wadud PhD Student Centre for Transport Studies Department of Civil and Environmental Engineering Imperial College London London SW7 2AZ Tel +44 (0) 207 594 6055 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Questions regarding biplot
Hi, I am using biplot (in package stats) to visualize the results of some PCA analyses. When I use scale=0 in the biplot function, it draws X (PC1) and Y (PC2) axes, with the scales multiplied by sqrt(N), where N is the sample size. Is there a way to change these scales so that the actual values of PC1 and PC2 are shown, instead of multiplication by sqrt(n)? Also, how can I plot the points in biplot with different colors or symbols corresponding to a grouping variable, instead of sample row number? Thanks for any suggestions. Best, Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] significant anova but no distinct groups ?
Dear all, I am studying a dataset using the aov() function. The independant variable 'cds' is a factor() with 8 levels and here is the result in studying the dependant variable 'rta' with aov() : summary(aov(rta ~ cds)) Df Sum Sq Mean Sq F value Pr(F) cds 7 0.34713 0.04959 2.3807 0.02777 Residuals 92 1.91635 0.02083 The dependant variable 'rta' is normally distributed and variances are homogeneous. But when studying the result with TukeyHSD, no differences in 'rta' are seen among groups of 'cds' : TukeyHSD(aov(rta ~ cds), which=cds) Tukey multiple comparisons of means 95% family-wise confidence level Fit: aov(formula = rta ~ cds) $cds difflwrupr p adj 1-0 -0.1046092796 -0.4331100 0.22389141 0.9751178 2-0 0.0359991860 -0.1371359 0.20913425 0.9980970 3-0 0.0261665235 -0.1348524 0.18718540 0.9996165 4-0 0.0004502442 -0.1805448 0.18144531 1.000 5-0 -0.1438949939 -0.3104752 0.02268526 0.1422670 [...] 7-5 0.0621598639 -0.1027595 0.22707926 0.9386170 7-6 0.0256519274 -0.1757408 0.22704465 0.248 I tried a pairwise.t.test (holm correction) which also was not able to detect differences in 'rta' among groups of 'cds' I've never been confronted to such a situation before : is it just a problem of power of the /a posteriori/ tests used ? Do I miss something important in basic stats or in R ? How to highlight differences among 'cds' groups seen with aov() ? Any help appreciated Thanks in advance, Fred J. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reading text file not table
Sorry just one more question, Patrick Burns wrote: as part of your alternative plan. But I don't think you would need to write a file and read it back in again. Yea So I tried to use the connection but that doesn't work. How can I read the object back in with read.csv, or at very least get it into a matrix seperated by comma? Thanks PB __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] significant anova but no distinct groups ?
The pairwise tests compare only pairs of means. Plot the means themselves. Chances are you will see some clustering of groups, or a visible contrast of several groups. Rich __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] significant anova but no distinct groups ?
Frederic, You're performing 8*7/2 = 28 multiple comparisons controlling the FWE at the .05 level. Using a Bonferroni's adjustment (admittedly more conservative than the Holm's or Tukey's approach), that's testing each comparison at the .05/28 = 0.0018 level. With only 100 observations spread over 8 levels, you won't have much power to detect a difference. Regards, -Cody Frederic Jean [EMAIL PROTECTED] iv-brest.fr To Sent by: [EMAIL PROTECTED] [EMAIL PROTECTED] cc at.math.ethz.ch Subject [R] significant anova but no 03/02/2007 01:52 distinct groups ? PM Dear all, I am studying a dataset using the aov() function. The independant variable 'cds' is a factor() with 8 levels and here is the result in studying the dependant variable 'rta' with aov() : summary(aov(rta ~ cds)) Df Sum Sq Mean Sq F value Pr(F) cds 7 0.34713 0.04959 2.3807 0.02777 Residuals 92 1.91635 0.02083 The dependant variable 'rta' is normally distributed and variances are homogeneous. But when studying the result with TukeyHSD, no differences in 'rta' are seen among groups of 'cds' : TukeyHSD(aov(rta ~ cds), which=cds) Tukey multiple comparisons of means 95% family-wise confidence level Fit: aov(formula = rta ~ cds) $cds difflwrupr p adj 1-0 -0.1046092796 -0.4331100 0.22389141 0.9751178 2-0 0.0359991860 -0.1371359 0.20913425 0.9980970 3-0 0.0261665235 -0.1348524 0.18718540 0.9996165 4-0 0.0004502442 -0.1805448 0.18144531 1.000 5-0 -0.1438949939 -0.3104752 0.02268526 0.1422670 [...] 7-5 0.0621598639 -0.1027595 0.22707926 0.9386170 7-6 0.0256519274 -0.1757408 0.22704465 0.248 I tried a pairwise.t.test (holm correction) which also was not able to detect differences in 'rta' among groups of 'cds' I've never been confronted to such a situation before : is it just a problem of power of the /a posteriori/ tests used ? Do I miss something important in basic stats or in R ? How to highlight differences among 'cds' groups seen with aov() ? Any help appreciated Thanks in advance, Fred J. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Horvitz Thompson Variance
I am performing linear regression R and would like to incorporate sampling weights. Does any one know how to obtain Horvitz-Thompson variance estimates when performing linear regression? Thank you for your help. -- View this message in context: http://www.nabble.com/Horvitz-Thompson-Variance-tf3336348.html#a9278653 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Mitools and lmer
Hey there I am estimating a multilevel model using lmer. I have 5 imputed datasets so I am using mitools to pool the estimates from the 5 datasets. Everything seems to work until I try to use MIcombine to produced pooled estimates. Does anyone have any suggestions? The betas and the standard errors were extracted with no problem so everything seems to work smoothly up until that point. Program #Read data data.dir-system.file(dta,package=mitools) files.imp-imputationList(lapply(list.files(data.dir, pattern=imp.\\.dta, full=TRUE), read.dta)) #estimate model over each imputed dataset model0-with(files.imp,lmer( erq2tnc ~1+trt2+nash+wash+male+coh2+coh3+(1 | sitebeth))) #extract betas and standard errors betas-MIextract(model0,fun=coef) vars-MIextract(model0,fun=vcov) #Combine the results summary(MIcombine(betas,vars)) Error in cbar + results[[i]] : non-numeric argument to binary operator Error in summary(MIcombine(betas, vars)) : error in evaluating the argument 'object' in selecting a method for function 'summary' Thanks Beth [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fwd: Re: [friday topic]: what exactly is statistical com
On 02-Mar-07 Richard M. Heiberger wrote: This is a very fascinating discussion topic. I find I run into some fundamental differences in interpretation of the phrase statistical computing. I think of it as writing programs or functions, such as R or packages in R, and of understanding the numerical analysis behind these functions. I exclude USING computer programs, such as R, for data analysis from my definition of statistical computing. I see that as doing statistics. I have had students, some sent by other faculty members, in my class on statistical computing thinking they were going to learn how to do statistical analysis using the computer. There was a clash of expectations between what they thought they were taking and what I had in the syllabus. It is indeed a fascinating topic, and I agree with the implications of Richard's views above. Though computing machinery (from Brunsvigas with manual crank-handles upwards) has been used for doing the computations of statistics since the year dot, statistical computing (in my view of it) did not begin to develop until much later. I think the first developments which could be recognised as statistical cmputing (as opposed to using computers to do statistics) were the pioneering GENSTAT and GLIM (1973-4, though developed over some years previously). Possibly what characterised them for this was the fact that their programming language was recognisably statistical in flavour, and the commands triggered computational procedures in which statistical algorithms were implemented. Then, as the science of computer programming developed, and became more generalised, with structures, methods and all the rest, so these concepts were implemented for statistics. The result of a computation was a data-structure, which could be recognised by any method that was capable of dealing with It's perhaps hard to say when S was actually born: perhaps passage to the outside world began with its port to UNIX in 1979, though it was conceived around 1975. But it must be acknowledged that in its adaptation of advanced (for the time) programming methods to statistics was a breakthrough in statistical computing. A quite early simple instance of this kind of programming was SPIDA (Statistical Program for Interactive Data Analysis) which was developed prior to 1988 -- since Dan Lunn Don McNeil issued a SPIDA User's Manual in 1988 (and perhaps grew out of NcNeil's approaches described in his 1977 book Interactive Data Analysis: A Practical Primer), followed by the book Computer-Interactive Data Aanalysis A.D. Lunn and D.R. McNeil (Wiley 1991) (with a couple of 5.25 DOS floppies with the SPIDA software) which I remember using with pleasure! So I see this confluence of the evolution of computational concepts and techniques through the 1970's and 80's, with the development of statistical modelling techniques and their implementation in software, as the core of statistical computing. Best wishes to all, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 02-Mar-07 Time: 22:53:33 -- XFMail -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reading text file not table
Is this what you want to do? x - 1,2,3,4 + 5,6,7,8 + 9,0,1,2 + 3,4,5,6 read.csv(textConnection(x), header=FALSE) V1 V2 V3 V4 1 1 2 3 4 2 5 6 7 8 3 9 0 1 2 4 3 4 5 6 On 3/2/07, H. Paul Benton [EMAIL PROTECTED] wrote: Sorry just one more question, Patrick Burns wrote: as part of your alternative plan. But I don't think you would need to write a file and read it back in again. Yea So I tried to use the connection but that doesn't work. How can I read the object back in with read.csv, or at very least get it into a matrix seperated by comma? Thanks PB __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fwd: Re: [friday topic]: what exactly is statistical com
Ted: I agree with what you and Richard have to say on this topic but disagree with your time frame. I would like to believe that rudiments of what we call statistical computing today started long before the mid-seventies. Most probably it goes back to the mid-fifties. There is a book that is long out of print Statistical Computation edited by Milton and Nelder (a copy of which I am privileged to possess) of the proceedings of a meeting held at the University of Wisconsin in April 1969. The list of contributors read like a who's who of statistical computing. To name a few: Box, Chambers, Dixon, Golub, Hartley, Hemmerle, Kruskal, Massey, Nelder, Wilkinson etc.. I know for a fact they have been doing research on statistical computing for a while before 1969! I am also pretty sure that the work on BMD programs at UCLA by Dixon and Jennrich preceded Genstat and Glim by many years because they were working on it in the mid-sixties. And they weren't using software; they were writing them. Just my bit. Take care. Mervyn At 04:53 PM 3/2/2007, you wrote: On 02-Mar-07 Richard M. Heiberger wrote: This is a very fascinating discussion topic. I find I run into some fundamental differences in interpretation of the phrase statistical computing. I think of it as writing programs or functions, such as R or packages in R, and of understanding the numerical analysis behind these functions. I exclude USING computer programs, such as R, for data analysis from my definition of statistical computing. I see that as doing statistics. I have had students, some sent by other faculty members, in my class on statistical computing thinking they were going to learn how to do statistical analysis using the computer. There was a clash of expectations between what they thought they were taking and what I had in the syllabus. It is indeed a fascinating topic, and I agree with the implications of Richard's views above. Though computing machinery (from Brunsvigas with manual crank-handles upwards) has been used for doing the computations of statistics since the year dot, statistical computing (in my view of it) did not begin to develop until much later. I think the first developments which could be recognised as statistical cmputing (as opposed to using computers to do statistics) were the pioneering GENSTAT and GLIM (1973-4, though developed over some years previously). Possibly what characterised them for this was the fact that their programming language was recognisably statistical in flavour, and the commands triggered computational procedures in which statistical algorithms were implemented. Then, as the science of computer programming developed, and became more generalised, with structures, methods and all the rest, so these concepts were implemented for statistics. The result of a computation was a data-structure, which could be recognised by any method that was capable of dealing with It's perhaps hard to say when S was actually born: perhaps passage to the outside world began with its port to UNIX in 1979, though it was conceived around 1975. But it must be acknowledged that in its adaptation of advanced (for the time) programming methods to statistics was a breakthrough in statistical computing. A quite early simple instance of this kind of programming was SPIDA (Statistical Program for Interactive Data Analysis) which was developed prior to 1988 -- since Dan Lunn Don McNeil issued a SPIDA User's Manual in 1988 (and perhaps grew out of NcNeil's approaches described in his 1977 book Interactive Data Analysis: A Practical Primer), followed by the book Computer-Interactive Data Aanalysis A.D. Lunn and D.R. McNeil (Wiley 1991) (with a couple of 5.25 DOS floppies with the SPIDA software) which I remember using with pleasure! So I see this confluence of the evolution of computational concepts and techniques through the 1970's and 80's, with the development of statistical modelling techniques and their implementation in software, as the core of statistical computing. Best wishes to all, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 02-Mar-07 Time: 22:53:33 -- XFMail -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] significant anova but no distinct groups ?
You can use the LSD.test or waller.test of the package agricolae that less conservatives than tukey. From: [EMAIL PROTECTED] on behalf of Frederic Jean Sent: Fri 3/2/2007 4:52 PM To: [EMAIL PROTECTED] Subject: [R] significant anova but no distinct groups ? Dear all, I am studying a dataset using the aov() function. The independant variable 'cds' is a factor() with 8 levels and here is the result in studying the dependant variable 'rta' with aov() : summary(aov(rta ~ cds)) Df Sum Sq Mean Sq F value Pr(F) cds 7 0.34713 0.04959 2.3807 0.02777 Residuals 92 1.91635 0.02083 The dependant variable 'rta' is normally distributed and variances are homogeneous. But when studying the result with TukeyHSD, no differences in 'rta' are seen among groups of 'cds' : TukeyHSD(aov(rta ~ cds), which=cds) Tukey multiple comparisons of means 95% family-wise confidence level Fit: aov(formula = rta ~ cds) $cds difflwrupr p adj 1-0 -0.1046092796 -0.4331100 0.22389141 0.9751178 2-0 0.0359991860 -0.1371359 0.20913425 0.9980970 3-0 0.0261665235 -0.1348524 0.18718540 0.9996165 4-0 0.0004502442 -0.1805448 0.18144531 1.000 5-0 -0.1438949939 -0.3104752 0.02268526 0.1422670 [...] 7-5 0.0621598639 -0.1027595 0.22707926 0.9386170 7-6 0.0256519274 -0.1757408 0.22704465 0.248 I tried a pairwise.t.test (holm correction) which also was not able to detect differences in 'rta' among groups of 'cds' I've never been confronted to such a situation before : is it just a problem of power of the /a posteriori/ tests used ? Do I miss something important in basic stats or in R ? How to highlight differences among 'cds' groups seen with aov() ? Any help appreciated Thanks in advance, Fred J. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reading text file not table
__ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fwd: Re: [friday topic]: what exactly is statistical com
On 3/2/07, Ted Harding [EMAIL PROTECTED] wrote: I think the first developments which could be recognised as statistical cmputing (as opposed to using computers to do statistics) were the pioneering GENSTAT and GLIM (1973-4, though developed over some years previously). Possibly what characterised them for this was the fact that their programming language was recognisably statistical in flavour, and the commands triggered computational procedures in which statistical algorithms were implemented. There were also many people using APL for statistical computing in that time frame. Then, as the science of computer programming developed, and became more generalised, with structures, methods and all the rest, so these concepts were implemented for statistics. The result of a computation was a data-structure, which could be recognised by any method that was capable of dealing with It's perhaps hard to say when S was actually born: perhaps passage to the outside world began with its port to UNIX in 1979, though it was conceived around 1975. But it must be acknowledged that in its adaptation of advanced (for the time) programming methods to statistics was a breakthrough in statistical computing. A quite early simple instance of this kind of programming was SPIDA (Statistical Program for Interactive Data Analysis) which was developed prior to 1988 -- since Dan Lunn Don McNeil issued a SPIDA User's Manual in 1988 (and perhaps grew out of NcNeil's approaches described in his 1977 book Interactive Data Analysis: A Practical Primer), followed by the book Computer-Interactive Data Aanalysis A.D. Lunn and D.R. McNeil (Wiley 1991) (with a couple of 5.25 DOS floppies with the SPIDA software) McNeil's earlier book used APL. Around the same time frame, i.e. late seventies, David Donoho at Princeton http://www.ims.nus.edu.sg/imprints/interviews/DavidDonoho.pdf developed ISP possibly along with Peter Bloomfield. I think this pre-dated S but was somewhat S-like in that it: - was written in C using yacc - ran on UNIX - was interactive and had builtin regression and other stat routines - eventually made its way to hundreds of universities (though it was ultimately displaced by S) which I remember using with pleasure! So I see this confluence of the evolution of computational concepts and techniques through the 1970's and 80's, with the development of statistical modelling techniques and their implementation in software, as the core of statistical computing. A few other points. There was an ASA section on statistical computing in the 70's: http://www.statcomputing.org/officers/1970s.html and getting back to the subject heading of this thread, one of the Chairs wrote a book called Statistical Computing published in 1980 (which I own): http://www.amazon.ca/Statistical-Computing-William-J-Kennedy/dp/0824768981 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] package installation for windows vista
Hi guys, How to install selected packages for R 2.4.1 under windows vista? Thanks a lot. JP [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.