Re: [R] effects in ANCOVA
Dear Chuck, thank you very much indeed. I was looking for that and I could not find it. Cheers Tomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Problems in plot.lm with option which=5
[PLease don't send HTML mail: your message was badly formatted on arrival. See the posting guide and the double-spaced mess below.] This _is_ a bug: the author had tried to reorder the factor levels by mean fitted value, but forgot to reorder the residuals (etc) to match. You may have noticed that the added line was not monotone, and it should have been. I've fixed this in R-patched (and documented on the help page what was supposed to happen). On Fri, 17 Nov 2006, Gabriela Cendoya wrote: Hi: I think I found an error in plot.lm with the option which=5, of course I can be wrong , as usually happen, but I had work on it for a while and show it to some other people that work with R, and so far I don't see what I can be interpreting wrong. I also worked over the plot.lm's code and change some lines to get what I call the right plot, if any body is interested I can send the modified code to see what is the problem I think I found and what could be a solution. I´m working with R 2.4.0 on windows XP, and here is a reproducible example, (this example is just to show the problems in the plot and it doesn't make any sense the way I analyzed). set.seed(3) datos -data.frame(fac.A=rep(c(bla,Ur2,pel,arb),each=3), y= c(rnorm(3,sd=0.5),rnorm(9,sd=2))) model1 - lm(y~fac.A,data=datos) plot(model1,which=5) # plot1 # this plot1 show that level arb has less dispersion than the other levels, # But if I do the plot by myself, look: hii - lm.influence(model1, do.coef = FALSE)$hat s1 - sqrt(deviance(model1)/df.residual(model1)) rs - residuals(model1)/(s1 * sqrt(1 - hii)) plot(rs~datos$fac.A) # plot2 # this plot2 show me that level bla is less variable. # also per and Url have some problems but this give you the idea of what I think Is wrong. What I have found in the code, is that for this option (which=5), the labels of the x axis are ordered in a way that the predicted value for the levels are increasing, but when it actually do the plot it doesn't keep that order. Thanks for your time (and sorry for my English) . Gabriela [[alternative HTML version deleted]] -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Gantt chart problem after upgrade to R 2.4.0
John Kane wrote: I am having a problem with a gantt chart since moving to R2.4.0. from 2.3.1 ... Okay, I think I have fixed the problem. I don't yet know why it worked on Windows and not Linux, but this should work on both. I have added another argument to the gantt.chart function and it seems to overcome the problem. Haven't tested it extensively, so I would appreciate any information about bugs that have sprung from the ichor of the one I squashed. There will be another version of plotrix shortly and this will be in it. Jim Watch out for the line breaks that have crept into the code. gantt.chart-function(x=NULL,format=%Y/%m/%d,xlim=NULL,taskcolors=NULL, priority.legend=FALSE,vgridpos=NULL,vgridlab=NULL,vgrid.format=%Y/%m/%d, half.height=0.25,hgrid=FALSE,main=,ylab=) { oldpar-par(no.readonly=TRUE) if(is.null(x)) x-get.gantt.info(format=format) ntasks-length(x$labels) plot.new() charheight-strheight(M,units=inches) maxwidth-max(strwidth(x$labels,units=inches))*1.5 if(is.null(xlim)) xlim=range(c(x$starts,x$ends)) npriorities-max(x$priorities) if(is.null(taskcolors)) taskcolors-color.gradient(c(255,0),c(0,0),c(0,255),npriorities) else { if(length(taskcolors) npriorities) taskcolors-rep(taskcolors,length.out=npriorities) } bottom.margin-ifelse(priority.legend,0.5,0) par(mai=c(bottom.margin,maxwidth,charheight*5,0.1)) par(omi=c(0.1,0.1,0.1,0.1),xaxs=i,yaxs=i) plot(x$starts,1:ntasks,xlim=xlim,ylim=c(0.5,ntasks+0.5), main=,xlab=,ylab=ylab,axes=FALSE,type=n) box() if(nchar(main)) mtext(main,3,2) if(is.null(vgridpos)) tickpos-axis.POSIXct(3,xlim,format=vgrid.format) else tickpos-vgridpos # if no tick labels, use the grid positions if there if(is.null(vgridlab) !is.null(vgridpos)) vgridlab-format.POSIXct(vgridpos,vgrid.format) # if vgridpos wasn't specified, use default axis ticks if(is.null(vgridlab)) axis.POSIXct(3,xlim,format=vgrid.format) else axis(3,at=tickpos,labels=vgridlab) topdown-seq(ntasks,1) axis(2,at=topdown,labels=x$labels,las=2) abline(v=tickpos,col=darkgray,lty=3) for(i in 1:ntasks) { rect(x$starts[i],topdown[i]-half.height, x$ends[i],topdown[i]+half.height, col=taskcolors[x$priorities[i]], border=FALSE) } if(hgrid) abline(h=(topdown[1:(ntasks-1)]+topdown[2:ntasks])/2,col=darkgray,lty=3) if(priority.legend) { par(xpd=TRUE) plim-par(usr) gradient.rect(plim[1],0,plim[1]+(plim[2]-plim[1])/4,0.3,col=taskcolors) text(plim[1],0.2,Priorities ,adj=c(1,0.5)) text(c(plim[1],plim[1]+(plim[2]-plim[1])/4),c(0.4,0.4),c(High,Low)) } par(oldpar) invisible(x) } __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Random sample from log-normal distribution
Dear all R users, Please forgive me if my question is too trivial. Suppose I have two variables, (x,y) which is log-normally distributed with expected value (mu1, mu2) and some variance-covariance matrix. Now I want to draw a random sample of size 1000 from this distribution. Is there any function available to do this? Thanks and regards, Megh __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] (no subject)
Hello, I need help to understand my error in this code... I would like to make a direct sampler... thanks Celine p-matrix(c(1,2,3,2,1,4),3,2,byrow=T) p-p/sum(p) ky-ncol(p) kx-nrow(p) p.vec-as.vector(t(p)) l-rmultinom(1,1,p) l-(t(l)) m-(l%%ky) ifelse (m==0, i-l/ky (j-ky), i-((l/ky)+1) (j-(l %% ky) _ Faites de MSN Search votre page d'accueil: Toutes les réponses en un clic! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] deriv when one term is indexed
This works for me in terms of giving results without error messages except for the confint(dd.plin) which I assume you don't really need anyways. gg - model.matrix(~ Gun/GL - Gun, dd) dd.plin - nls(Lum ~ gg^gamm, dd, start = list(gamm = 2.4), +alg = plinear +) confint(dd.plin) Waiting for profiling to be done... Error in eval(expr, envir, enclos) : (subscript) logical subscript too long B - as.vector(coef(dd.nls0)) st -list(Blev = B[2], beta = B[3:5], gamm = B[1]) dd.nls - nls(Lum ~ Blev + beta[Gun] * GL^gamm, +data = dd, start = st +) confint(dd.nls) Waiting for profiling to be done... 2.5%97.5% Blev -1.612492e-01 2.988386e-02 beta1 6.108282e-06 8.762679e-06 beta2 1.269000e-05 1.792914e-05 beta3 3.844042e-05 5.388546e-05 gamm 2.481102e+00 2.542966e+00 dd.deriv2 - function (Blev, beta, gamm, GL) + { +.expr1 - GL^gamm +.value - Blev + rep(beta, each = 17) * .expr1 +.grad - array(0, c(length(.value), 5), list(NULL, c(Blev, +beta.rouge, beta.vert, beta.bleu, gamm))) +.grad[, Blev] - 1 +.grad[1:17, beta.rouge] - .expr1[1:17] +.grad[18:34, beta.vert] - .expr1[1:17] +.grad[35:51, beta.bleu] - .expr1[1:17] +.grad[, gamm] - ifelse(GL == 0, 0, rep(beta, each = 17) * (.expr1 * + log(GL))) +attr(.value, gradient) - .grad +.value + } dd.nls.d2 - nls(Lum ~ dd.deriv2(Blev, beta, gamm, GL), data = dd, +start = list(Blev = B[2], beta = B[3:5], gamm = B[1])) confint(dd.nls.d2) Waiting for profiling to be done... 2.5%97.5% Blev -1.612492e-01 2.988391e-02 beta1 1.269000e-05 1.792914e-05 beta2 3.844041e-05 5.388546e-05 beta3 6.108281e-06 8.762678e-06 gamm 2.481102e+00 2.542966e+00 R.version.string # XP [1] R version 2.4.0 Patched (2006-10-24 r39722) On 11/18/06, Ken Knoblauch [EMAIL PROTECTED] wrote: Thank you for your rapid response. This is reproducible on my system. Here it is again, with, I hope, sufficient detail to properly document what does not work and what does on my system, But my original question, properly motivated or not, concerns whether there is a way to use or adapt deriv() to work if a term is indexed, as here my term beta is indexed by Gun? In any case, it is puzzling that the error is not reproducible and so I would be curious to track that down, if it is specific to my system. Thank you. Before retrying, I upgraded to the latest patched version (details at the end). The data, again dd Lum GL Gun mBl 0.150 rouge 0.09 0.0715 rouge 0.01 0.1 31 rouge 0.04 0.1947 rouge 0.13 0.4 63 rouge 0.34 0.7379 rouge 0.67 1.2 95 rouge 1.14 1.85111 rouge 1.79 2.91127 rouge 2.85 3.74143 rouge 3.68 5.08159 rouge 5.02 6.43175 rouge 6.37 8.06191 rouge 8 9.84207 rouge 9.78 12 223 rouge 11.94 14.2239 rouge 14.14 16.6255 rouge 16.54 0.1 0 vert0.04 0.1 15 vert0.04 0.1731 vert0.11 0.4647 vert0.4 1.0863 vert1.02 2.2279 vert2.16 3.7495 vert3.68 5.79111 vert5.73 8.36127 vert8.3 11.6143 vert11.54 15.4159 vert15.34 19.9175 vert19.84 24.6191 vert24.54 30.4207 vert30.34 36.1223 vert36.04 43 239 vert42.94 49.9255 vert49.84 0.060 bleu0 0.0615 bleu0 0.0831 bleu0.02 0.1347 bleu0.07 0.2563 bleu0.19 0.4379 bleu0.37 0.6695 bleu0.6 1.02111 bleu0.96 1.46127 bleu1.4 1.93143 bleu1.87 2.49159 bleu2.43 3.2 175 bleu3.14 3.96191 bleu3.9 4.9 207 bleu4.84 5.68223 bleu5.62 6.71239 bleu6.65 7.93255 bleu7.87 ###For initial values - this time using plinear algorithm insted of optim gg - model.matrix(~-1 + Gun/GL, dd)[ , c(4:6)] dd.plin - nls(Lum ~ cbind(rep(1, 51), gg^gamm), data = dd, start = list(gamm = 2.4), alg = plinear ) B - as.vector(coef(dd.plin)) st -list(Blev = B[2], beta = B[3:5], gamm = B[1]) dd.nls - nls(Lum ~ Blev + beta[Gun] * GL^gamm, data = dd, start = st ) confint(dd.plin) Waiting for profiling to be done... Error in eval(expr, envir, enclos) : (subscript) logical subscript too long ### Here is the error that I observe confint(dd.nls) Waiting for profiling to be done... Error in prof$getProfile() : step factor 0.000488281 reduced below
Re: [R] deriv when one term is indexed
I mixed up examples. Here it is again. As with the last one confint(dd.plin) gives an error (which I assume is a problem with confint that needs to be fixed) but other than that it works without issuing errors and I assume you don't need the confint(dd.plin) in any case since dd.plin is just being used to get starting values. gg - model.matrix(~ Gun/GL - Gun, dd) dd.plin - nls(Lum ~ gg^gamm, dd, start = list(gamm = 2.4), +alg = plinear +) confint(dd.plin) Waiting for profiling to be done... Error in eval(expr, envir, enclos) : (subscript) logical subscript too long B - as.vector(coef(dd.plin)) st -list(Blev = B[2], beta = B[3:5], gamm = B[1]) dd.nls - nls(Lum ~ Blev + beta[Gun] * GL^gamm, +data = dd, start = st +) confint(dd.nls) Waiting for profiling to be done... 2.5%97.5% Blev -1.612492e-01 2.988387e-02 beta1 6.108282e-06 8.762679e-06 beta2 1.269000e-05 1.792914e-05 beta3 3.844042e-05 5.388546e-05 gamm 2.481102e+00 2.542966e+00 dd.deriv2 - function (Blev, beta, gamm, GL) + { +.expr1 - GL^gamm +.value - Blev + rep(beta, each = 17) * .expr1 +.grad - array(0, c(length(.value), 5), list(NULL, c(Blev, +beta.rouge, beta.vert, beta.bleu, gamm))) +.grad[, Blev] - 1 +.grad[1:17, beta.rouge] - .expr1[1:17] +.grad[18:34, beta.vert] - .expr1[1:17] +.grad[35:51, beta.bleu] - .expr1[1:17] +.grad[, gamm] - ifelse(GL == 0, 0, rep(beta, each = 17) * (.expr1 * + log(GL))) +attr(.value, gradient) - .grad +.value + } dd.nls.d2 - nls(Lum ~ dd.deriv2(Blev, beta, gamm, GL), data = dd, +start = list(Blev = B[2], beta = B[3:5], gamm = B[1])) confint(dd.nls.d2) Waiting for profiling to be done... 2.5%97.5% Blev -1.612492e-01 2.988391e-02 beta1 1.269000e-05 1.792914e-05 beta2 3.844041e-05 5.388546e-05 beta3 6.108281e-06 8.762678e-06 gamm 2.481102e+00 2.542966e+00 R.version.string # XP [1] R version 2.4.0 Patched (2006-10-24 r39722) On 11/18/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: This works for me in terms of giving results without error messages except for the confint(dd.plin) which I assume you don't really need anyways. gg - model.matrix(~ Gun/GL - Gun, dd) dd.plin - nls(Lum ~ gg^gamm, dd, start = list(gamm = 2.4), +alg = plinear +) confint(dd.plin) Waiting for profiling to be done... Error in eval(expr, envir, enclos) : (subscript) logical subscript too long B - as.vector(coef(dd.nls0)) st -list(Blev = B[2], beta = B[3:5], gamm = B[1]) dd.nls - nls(Lum ~ Blev + beta[Gun] * GL^gamm, +data = dd, start = st +) confint(dd.nls) Waiting for profiling to be done... 2.5%97.5% Blev -1.612492e-01 2.988386e-02 beta1 6.108282e-06 8.762679e-06 beta2 1.269000e-05 1.792914e-05 beta3 3.844042e-05 5.388546e-05 gamm 2.481102e+00 2.542966e+00 dd.deriv2 - function (Blev, beta, gamm, GL) + { +.expr1 - GL^gamm +.value - Blev + rep(beta, each = 17) * .expr1 +.grad - array(0, c(length(.value), 5), list(NULL, c(Blev, +beta.rouge, beta.vert, beta.bleu, gamm))) +.grad[, Blev] - 1 +.grad[1:17, beta.rouge] - .expr1[1:17] +.grad[18:34, beta.vert] - .expr1[1:17] +.grad[35:51, beta.bleu] - .expr1[1:17] +.grad[, gamm] - ifelse(GL == 0, 0, rep(beta, each = 17) * (.expr1 * + log(GL))) +attr(.value, gradient) - .grad +.value + } dd.nls.d2 - nls(Lum ~ dd.deriv2(Blev, beta, gamm, GL), data = dd, +start = list(Blev = B[2], beta = B[3:5], gamm = B[1])) confint(dd.nls.d2) Waiting for profiling to be done... 2.5%97.5% Blev -1.612492e-01 2.988391e-02 beta1 1.269000e-05 1.792914e-05 beta2 3.844041e-05 5.388546e-05 beta3 6.108281e-06 8.762678e-06 gamm 2.481102e+00 2.542966e+00 R.version.string # XP [1] R version 2.4.0 Patched (2006-10-24 r39722) On 11/18/06, Ken Knoblauch [EMAIL PROTECTED] wrote: Thank you for your rapid response. This is reproducible on my system. Here it is again, with, I hope, sufficient detail to properly document what does not work and what does on my system, But my original question, properly motivated or not, concerns whether there is a way to use or adapt deriv() to work if a term is indexed, as here my term beta is indexed by Gun? In any case, it is puzzling that the error is not reproducible and so I would be curious to track that down, if it is specific to my system. Thank you. Before retrying, I upgraded to the latest patched version (details at the end). The data, again dd Lum GL Gun mBl 0.150 rouge 0.09 0.0715 rouge 0.01 0.1 31 rouge 0.04 0.19
Re: [R] Random sample from log-normal distribution
?rlnorm On 11/18/06, Megh Dal [EMAIL PROTECTED] wrote: Dear all R users, Please forgive me if my question is too trivial. Suppose I have two variables, (x,y) which is log-normally distributed with expected value (mu1, mu2) and some variance-covariance matrix. Now I want to draw a random sample of size 1000 from this distribution. Is there any function available to do this? Thanks and regards, Megh __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] (no subject)
I'm not sure what the last line is trying to achieve, but this might be what you want: i - ifelse(m==0, l/ky, l/ky + 1) j - ifelse(m==0,ky, l %% ky) On 18/11/06, Céline Henzelin [EMAIL PROTECTED] wrote: Hello, I need help to understand my error in this code... I would like to make a direct sampler... thanks Celine p-matrix(c(1,2,3,2,1,4),3,2,byrow=T) p-p/sum(p) ky-ncol(p) kx-nrow(p) p.vec-as.vector(t(p)) l-rmultinom(1,1,p) l-(t(l)) m-(l%%ky) ifelse (m==0, i-l/ky (j-ky), i-((l/ky)+1) (j-(l %% ky) _ Faites de MSN Search votre page d'accueil: Toutes les réponses en un clic! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Random sample from log-normal distribution
On Sat, 18 Nov 2006, jim holtman wrote: ?rlnorm Not for a bivariate lognormal, nor specifying via mean and variance (which is not the normal way to specify a univariate lognormal). I think we need clarification of exactly what is meant, but the answer is most likely 'no'. On 11/18/06, Megh Dal [EMAIL PROTECTED] wrote: Dear all R users, Please forgive me if my question is too trivial. Suppose I have two variables, (x,y) which is log-normally distributed with expected value (mu1, mu2) and some variance-covariance matrix. Now I want to draw a random sample of size 1000 from this distribution. Is there any function available to do this? Thanks and regards, Megh __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] .First.lib
Greetings: Im running R version 2.4.0 (2006-10-03) on WindowsXP in a 3 year old DELL box with 2 gig. I have successfully created a zipped package, mh1823_2.1.zip, using R CMD build --binary mh1823. R CMD build --binary automatically adds a file, mh1823, containing .First.lib and its default function definition. I would like to supply my own .First.lib function to create menus when the package is loaded by calling my menu-creator function. It is easy to do after the package is installed from mh1823_2.1.zip, but I want my .First.lib function to be part of mh1823_2.1.zip in the first place. Is there a way that I can use R CMD build --binary, with its zip file output, but substitute my .First.lib function for the default? Thanks for any help. Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Gantt chart problem after upgrade to R 2.4.0
--- Jim Lemon [EMAIL PROTECTED] wrote: John Kane wrote: I am having a problem with a gantt chart since moving to R2.4.0. from 2.3.1 ... Okay, I think I have fixed the problem. I don't yet know why it worked on Windows and not Linux, but this should work on both. Looks pretty good to me. I am getting a date 1820/01/01 rather than just 1820 as I was before but that seems like what I actually requested :). Now I just have to figure out how to handle the formatting. Thank you very much, especially on a weekend. I have added another argument to the gantt.chart function and it seems to overcome the problem. Haven't tested it extensively, so I would appreciate any information about bugs that have sprung from the ichor of the one I squashed. There will be another version of plotrix shortly and this will be in it. Jim Watch out for the line breaks that have crept into the code. I did a straight cut and paste with no problem. gantt.chart-function(x=NULL,format=%Y/%m/%d,xlim=NULL,taskcolors=NULL, priority.legend=FALSE,vgridpos=NULL,vgridlab=NULL,vgrid.format=%Y/%m/%d, half.height=0.25,hgrid=FALSE,main=,ylab=) { oldpar-par(no.readonly=TRUE) if(is.null(x)) x-get.gantt.info(format=format) ntasks-length(x$labels) plot.new() charheight-strheight(M,units=inches) maxwidth-max(strwidth(x$labels,units=inches))*1.5 if(is.null(xlim)) xlim=range(c(x$starts,x$ends)) npriorities-max(x$priorities) if(is.null(taskcolors)) taskcolors-color.gradient(c(255,0),c(0,0),c(0,255),npriorities) else { if(length(taskcolors) npriorities) taskcolors-rep(taskcolors,length.out=npriorities) } bottom.margin-ifelse(priority.legend,0.5,0) par(mai=c(bottom.margin,maxwidth,charheight*5,0.1)) par(omi=c(0.1,0.1,0.1,0.1),xaxs=i,yaxs=i) plot(x$starts,1:ntasks,xlim=xlim,ylim=c(0.5,ntasks+0.5), main=,xlab=,ylab=ylab,axes=FALSE,type=n) box() if(nchar(main)) mtext(main,3,2) if(is.null(vgridpos)) tickpos-axis.POSIXct(3,xlim,format=vgrid.format) else tickpos-vgridpos # if no tick labels, use the grid positions if there if(is.null(vgridlab) !is.null(vgridpos)) vgridlab-format.POSIXct(vgridpos,vgrid.format) # if vgridpos wasn't specified, use default axis ticks if(is.null(vgridlab)) axis.POSIXct(3,xlim,format=vgrid.format) else axis(3,at=tickpos,labels=vgridlab) topdown-seq(ntasks,1) axis(2,at=topdown,labels=x$labels,las=2) abline(v=tickpos,col=darkgray,lty=3) for(i in 1:ntasks) { rect(x$starts[i],topdown[i]-half.height, x$ends[i],topdown[i]+half.height, col=taskcolors[x$priorities[i]], border=FALSE) } if(hgrid) abline(h=(topdown[1:(ntasks-1)]+topdown[2:ntasks])/2,col=darkgray,lty=3) if(priority.legend) { par(xpd=TRUE) plim-par(usr) gradient.rect(plim[1],0,plim[1]+(plim[2]-plim[1])/4,0.3,col=taskcolors) text(plim[1],0.2,Priorities ,adj=c(1,0.5)) text(c(plim[1],plim[1]+(plim[2]-plim[1])/4),c(0.4,0.4),c(High,Low)) } par(oldpar) invisible(x) } __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Gantt chart problem after upgrade to R 2.4.0
--- No No [EMAIL PROTECTED] wrote: I am on ubuntu linux with R 2.4.0 compiled and I get the same picture as with yours with R 2.4.0. Thanks. From another reply it looks like this is a 2.4.0 problem that is solved in 2.4.0-patched and not a Windows vs Linux problem. I upgraded to the patch this morning and the plot looks as lovely as before. Well lovely to me anyway :) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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 sample from log-normal distribution
On 18-Nov-06 Megh Dal wrote: Dear all R users, Please forgive me if my question is too trivial. Suppose I have two variables, (x,y) which is log-normally distributed with expected value (mu1, mu2) and some variance-covariance matrix. Now I want to draw a random sample of size 1000 from this distribution. Is there any function available to do this? Thanks and regards, Megh Browsing around, I have found R code listed at http://www.internal.eawag.ch/~reichert/sysanal.r This lists several functions. One is 'randsamp' which can generate a random sample from either a normal or a lognormal distribution. You may find it useful to extract the lognormal part of the code (which seems to be effectively independent of the normal part of the code), and adapt it to suit your purposes. Caveat: I have not tried this code, but it looks as though it does it correctly -- i.e. you specify the vector of means of the components of the lognormal random vector, the vector of their standard deviations, and the matrix of their correlations (easily derivable from the matrix of their covariances using the SDs), and you get a result with n rows, each row being a sample from the MV lognormal with specified means and covariances. (You can omit the line which calculates the density function using another function 'calc.pdf'). NB: The source should be acknowledged! Hoping this helps, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 18-Nov-06 Time: 17:12:21 -- 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] .First.lib
On Sat, 18 Nov 2006, Charles Annis, P.E. wrote: Greetings: Im running R version 2.4.0 (2006-10-03) on WindowsXP in a 3 year old DELL box with 2 gig. I have successfully created a zipped package, mh1823_2.1.zip, using R CMD build --binary mh1823. R CMD build --binary automatically adds a file, mh1823, containing .First.lib and its default function definition. How does it do that? (I've never seen it do so.) What it is documented to do is to create a binary package with a file mh1823/R/mh1823 which contains code you put in the package sources, so I am pretty sure you defined .First.lib. I would like to supply my own .First.lib function to create menus when the package is loaded by calling my menu-creator function. It is easy to do after the package is installed from mh1823_2.1.zip, but I want my .First.lib function to be part of mh1823_2.1.zip in the first place. Is there a way that I can use R CMD build --binary, with its zip file output, but substitute my .First.lib function for the default? All packages that I am aware of on CRAN which use compiled code have their own .First.lib or .onLoad, normally in file R/zzz.R. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] lattice layout multiple pages
Dear all, Using lattice I would like to print a conditionnal plot of 32 panels in a limited number of panels (eg 4) in each of several pages: xyplot(pds~time|Idnid,data=croispond3,layout=c(4,4)) This works well in principle, but the pages are printed without any possibility of stopping the printing process before each next page. I have tried par(ask=T) before the xyplot command line but it does not work for some reasons. Also I would like to print those pages to a device (eg using win.metafile(filename = myfile)), but I wonder how to manage not to make each page file created overwritten by the next one in this context. Thanks in advance for any hint, Patrick __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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 integrate function
Hi there. Thanks for your time in advance. I am using R 2.2.0 and OS: Windows XP. My final goal is to calculate 1/2*integral of (f1(x)^1/2-f2(x)^(1/2))^2dx (Latex codes: $\frac{1}{2}\int^{{\infty}}_{\infty} (\sqrt{f_1(x)}-\sqrt{f_2(x)})^2dx $.) where f1(x) and f2(x) are two marginal densities. My problem: I have the following R codes using adapt package. Although adapt function is mainly designed for more than 2 dimensions, the manual says it will also call up integrate if the number of dimension equals one. I feed in the data x1 and x2 and bandwidths h1 and h2. These codes worked well when my final goal was to take double integrals. integrand - function(x) { # x input is evaluation point for x1 and x2, a 2x1 vector x1.eval - x[1] x2.eval - x[2] # n is the number of observations n - length(x1) # x1 and x2 are the vectors read from data.dat # Compute the marginal densities f.x1 - sum(dnorm((x1.eval-x1)/h1))/(n*h1) f.x2 - sum(dnorm((x2.eval-x2)/h2))/(n*h2) # Return the integrand # return((sqrt(f.x1)-sqrt(f.x2))**2) } estimate-0.5*adapt(1, lo=lo.default, up=up.default, minpts=minpts.default, maxpts=maxpts.default, functn=integrand, eps=eps.default, x1, x2,h1,h2)$value But when I used it for one-dimension, it failed. Some of my colleagues suggested getting rid of x2.eval in the integrand because it is only one integral. But after I changed it, it still didn't work. R gave the error msg: evaluation of function gave a result of wrong length I am not a frequent R user..although I looked up the mailing list for a while and there were few postings asking similar questions, I can't still figure out why my codes won't work. Any help will be appreciated. Le - ~~ Le Wang, Ph.D Population Center University of Minnesota __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] sorry for repeated msgs
Hi there, Sorry for the repeated msgs. I set my option to receive my own email, but it didn't seem to work. So, I didn't realize my previous posts actually got through. Le - ~~~ Le Wang, Ph.D Population Center University of Minnesota __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] .First.lib
Thank you Professor Ripley. I don't have compiled code and do not have a namespace, which is required (I understand) to use onLoad. The package is of moderate size, however with about 100 R functions. I know that I could emulate the technique used by Rcmdr, but had hoped to use R CMD build --binary. Should I just declare a namespace and use onLoad, or is there a mechanism to use my own .First.lib? Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Saturday, November 18, 2006 12:53 PM To: Charles Annis, P.E. Cc: r-help@stat.math.ethz.ch Subject: Re: [R] .First.lib On Sat, 18 Nov 2006, Charles Annis, P.E. wrote: Greetings: I'm running R version 2.4.0 (2006-10-03) on WindowsXP in a 3 year old DELL box with 2 gig. I have successfully created a zipped package, mh1823_2.1.zip, using R CMD build --binary mh1823. R CMD build --binary automatically adds a file, mh1823, containing .First.lib and its default function definition. How does it do that? (I've never seen it do so.) What it is documented to do is to create a binary package with a file mh1823/R/mh1823 which contains code you put in the package sources, so I am pretty sure you defined .First.lib. I would like to supply my own .First.lib function to create menus when the package is loaded by calling my menu-creator function. It is easy to do after the package is installed from mh1823_2.1.zip, but I want my .First.lib function to be part of mh1823_2.1.zip in the first place. Is there a way that I can use R CMD build --binary, with its zip file output, but substitute my .First.lib function for the default? All packages that I am aware of on CRAN which use compiled code have their own .First.lib or .onLoad, normally in file R/zzz.R. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Multinomial sampling WAS: Re: (no subject)
Celine, The posting guide directs you to Use an informative subject line (not something like `question'). Doing so will increase the probability of getting an informative response. You need to spend a more time with the help pages and with An Introduction to R. -- Specifically for the help page ?Logic you needed to know that The longer form evaluates left to right examining only the first element of each vector (referring to the behavior of ), which I suspect is much different than you assumed. As for this help page: ?rmultinom Using rmultinom( 1 , 1, p) %% 2 suggests you didn't understand the returned value. -- For An Introduction to R see section 5.1 where it explains what it means to order the elements of a matrix in column major order For example, using your construction of the matrix 'p': as.vector( p ) [1] 0.07692308 0.23076923 0.07692308 0.15384615 0.15384615 0.30769231 is probably not what you expected. -- Ordinarily, you might benefit from following the advice of the posting guide, which you are asked to consult before posting. However, I see that the suggestion there to * Do help.search(keyword) Fails miserably when I tried help.search(sample) to direct me to the function named 'sample', which I think solves your problem, which I guess is to return the row and column location of the '1' in a multinomial sample from a two-way table of probabilities with N = 1. If my guess was correct, then you want something like this: which(array(seq(along=p),dim(p))==sample(length(p),1,prob=p), arr.ind=TRUE) row col [1,] 2 1 see ?which ?sample ?seq for further details. HTH, Chuck On Sat, 18 Nov 2006, David Barron wrote: I'm not sure what the last line is trying to achieve, but this might be what you want: i - ifelse(m==0, l/ky, l/ky + 1) j - ifelse(m==0,ky, l %% ky) On 18/11/06, C?line Henzelin [EMAIL PROTECTED] wrote: Hello, I need help to understand my error in this code... I would like to make a direct sampler... thanks Celine p-matrix(c(1,2,3,2,1,4),3,2,byrow=T) p-p/sum(p) ky-ncol(p) kx-nrow(p) p.vec-as.vector(t(p)) l-rmultinom(1,1,p) l-(t(l)) m-(l%%ky) ifelse (m==0, i-l/ky (j-ky), i-((l/ky)+1) (j-(l %% ky) _ Faites de MSN Search votre page d'accueil: Toutes les r?ponses en un clic! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:[EMAIL PROTECTED] UC San Diego http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego 92093-0717 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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 sample from log-normal distribution
Dear all R users, Please forgive me if my question is too trivial. Suppose I have two variables, (x,y) which is log-normally distributed with expected value (mu1, mu2) and some variance-covariance matrix. Now I want to draw a random sample of size 1000 from this distribution. Is there any function available to do this? Thanks and regards, Megh If what you really want is a bivariate lognormal, you can generate first a bivariate normal sample (X,Y) with the function rmvnorm in package mvtnorm. Then exp(X,Y) will be multivariate lognormal. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] .First.lib
Perseverance, I guess, is the answer. Thank you exceedingly Professor Ripley for your help. Things do look awfully simple on this side of success. At your suggestion (after several false starts) I defined a .First.lib function within a file named zzz.R and built with R CMD build --binary, loaded the new package and there were my new menus. Thanks again. Sheepishly, Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Charles Annis, P.E. Sent: Saturday, November 18, 2006 1:54 PM To: 'Prof Brian Ripley' Cc: r-help@stat.math.ethz.ch Subject: Re: [R] .First.lib Thank you Professor Ripley. I don't have compiled code and do not have a namespace, which is required (I understand) to use onLoad. The package is of moderate size, however with about 100 R functions. I know that I could emulate the technique used by Rcmdr, but had hoped to use R CMD build --binary. Should I just declare a namespace and use onLoad, or is there a mechanism to use my own .First.lib? Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Saturday, November 18, 2006 12:53 PM To: Charles Annis, P.E. Cc: r-help@stat.math.ethz.ch Subject: Re: [R] .First.lib On Sat, 18 Nov 2006, Charles Annis, P.E. wrote: Greetings: I'm running R version 2.4.0 (2006-10-03) on WindowsXP in a 3 year old DELL box with 2 gig. I have successfully created a zipped package, mh1823_2.1.zip, using R CMD build --binary mh1823. R CMD build --binary automatically adds a file, mh1823, containing .First.lib and its default function definition. How does it do that? (I've never seen it do so.) What it is documented to do is to create a binary package with a file mh1823/R/mh1823 which contains code you put in the package sources, so I am pretty sure you defined .First.lib. I would like to supply my own .First.lib function to create menus when the package is loaded by calling my menu-creator function. It is easy to do after the package is installed from mh1823_2.1.zip, but I want my .First.lib function to be part of mh1823_2.1.zip in the first place. Is there a way that I can use R CMD build --binary, with its zip file output, but substitute my .First.lib function for the default? All packages that I am aware of on CRAN which use compiled code have their own .First.lib or .onLoad, normally in file R/zzz.R. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Questions regarding integrate function
Hello, your integrand needs to be a function which accepts a numeric vector as first argument and returns a vector of the same length (see ?integrate). Your function does not fulfill this requirement. Hence, you have to rewrite your function or use sapply, apply or friends; something like newintegrand - function(x) sapply(x, integrand) By the way you use a very old R version and I would recommend to update to R 2.4.0. hth Matthias Le Wang schrieb: Hi there. Thanks for your time in advance. I am using R 2.2.0 and OS: Windows XP. My final goal is to calculate 1/2*integral of (f1(x)^1/2-f2(x)^(1/2))^2dx (Latex codes: $\frac{1}{2}\int^{{\infty}}_{\infty} (\sqrt{f_1(x)}-\sqrt{f_2(x)})^2dx $.) where f1(x) and f2(x) are two marginal densities. My problem: I have the following R codes using adapt package. Although adapt function is mainly designed for more than 2 dimensions, the manual says it will also call up integrate if the number of dimension equals one. I feed in the data x1 and x2 and bandwidths h1 and h2. These codes worked well when my final goal was to take double integrals. integrand - function(x) { # x input is evaluation point for x1 and x2, a 2x1 vector x1.eval - x[1] x2.eval - x[2] # n is the number of observations n - length(x1) # x1 and x2 are the vectors read from data.dat # Compute the marginal densities f.x1 - sum(dnorm((x1.eval-x1)/h1))/(n*h1) f.x2 - sum(dnorm((x2.eval-x2)/h2))/(n*h2) # Return the integrand # return((sqrt(f.x1)-sqrt(f.x2))**2) } estimate-0.5*adapt(1, lo=lo.default, up=up.default, minpts=minpts.default, maxpts=maxpts.default, functn=integrand, eps=eps.default, x1, x2,h1,h2)$value But when I used it for one-dimension, it failed. Some of my colleagues suggested getting rid of x2.eval in the integrand because it is only one integral. But after I changed it, it still didn't work. R gave the error msg: evaluation of function gave a result of wrong length I am not a frequent R user..although I looked up the mailing list for a while and there were few postings asking similar questions, I can't still figure out why my codes won't work. Any help will be appreciated. Le - ~~ Le Wang, Ph.D Population Center University of Minnesota __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dr. rer. nat. Matthias Kohl E-Mail: [EMAIL PROTECTED] Home: www.stamats.de __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Gantt chart problem after upgrade to R 2.4.0
It is working on linux fine now. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Trellis Plot Labels
On 11/17/06, Deepayan Sarkar [EMAIL PROTECTED] wrote: On 11/17/06, Turgut Durduran [EMAIL PROTECTED] wrote: On 11/17/06, Turgut Durduran [EMAIL PROTECTED] wrote: Hello everyone, I am ploting a groupeddata object with formula: formula(mydatausegroup) BF ~ HO | ID/Infar/Day Using this command: plot(na.omit(mydatausegroup), displayLevel=2,layout=c(10,2),aspect=2) This trellis plot does almost what I want and produces a 10x2 trellis plot, each panel is labeled as ID/Infar where infarct is either 1 or 0. And in each panel, it plots BF vs HO for each Day. However, the days are labeled simply as 1,2,3,4 instead of their actual values (ranging from 1 to 8). This just mapped for each ID the 1 st measurement, 2nd measurement, 3rd measurement, 4th measurement. This seems to be intended behaviour, and the responsible function is collapse.groupedData (which is not very transparent to me). How can I get this trellis plot to use 8 different colors and label them correct? I don't see a documented way, so you'll probably need to modify collapse.groupedData I should have added: it's of course fairly easy if you use xyplot directly. 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.
Re: [R] Gantt chart problem after upgrade to R 2.4.0
--- [EMAIL PROTECTED] wrote: This is interesting. I am on Win2000 running R version 2.4.0 Patched (2006-11-15 r39915) and plotrix 2.1.5. I get the plot that scaled a little differently that the 2.3.1 example but the dates look fine. My fault there. I simply copied the metafile and sized it in a WP before exporting to PDF. I ran the original code posted by John cane with no changes (copy and paste). I used the windows device and did Save As... to save the PDF file. I agree. It seems to work perfectly with R-2.4.0 Patched. I had not realized that there was a Patch version out already but as soon, as I upgraded, the gantt looked fine. However one serous complaint : Kane not cane Thanks a lot. This saves a lot of time and trouble. Here is the code: require(plotrix) Ymd.format - %Y/%m/%d Ymd - function(x){ as.POSIXct(strptime(x, format=Ymd.format))} gantt.info - list( labels=c(Dickens, Doyle,Kipling, Poe), starts=Ymd(c(1824/01/01, 1850/01/01, 1865/01/01, 1815/11/01)), ends=Ymd(c(1901/01/01, 1922/01/01, 1935/01/01, 1867/01/01)), priorities =c(1,2,2,4)) gantt.chart(gantt.info,main=Writers, xlim=as.POSIXct(c(1810/01/01,1940/01/01))) Here is the result: (See attached file: plot.pdf) Cheers, Andy __ Andy Jaworski 518-1-01 Process Laboratory 3M Corporate Research Laboratory - E-mail: [EMAIL PROTECTED] Tel: (651) 733-6092 Fax: (651) 736-3122 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] deriv when one term is indexed
I don't know why I get a different result than you do, though I'll play around with it some and check the code to see if I can figure out what is going on, on my end. I will add that by transforming GL so that it spans the interval [0, 1] instead of [0, 255], the correlations among the parameters decreased, also evidenced in the plot and the pairs plots of the profile object, but this didn't change whether these functions worked for me on the model when i did not add derivative information. But, this is a bit of a diversion, since we haven't yet addressed the question to which my Subject heading refers and remains the question for which I'm most seeking an answer, direction or guidance, and that is whether there would be a way to adapt the deriv and deriv3 functions to deal with formulas that have an indexed term as in the one in my situation, i.e., Lum ~ Blev + beta[Gun] * GL^gamm Any ideas on that? Thank you. ken Gabor Grothendieck wrote: I mixed up examples. Here it is again. As with the last one confint(dd.plin) gives an error (which I assume is a problem with confint that needs to be fixed) but other than that it works without issuing errors and I assume you don't need the confint(dd.plin) in any case since dd.plin is just being used to get starting values. gg - model.matrix(~ Gun/GL - Gun, dd) dd.plin - nls(Lum ~ gg^gamm, dd, start = list(gamm = 2.4), +alg = plinear +) confint(dd.plin) Waiting for profiling to be done... Error in eval(expr, envir, enclos) : (subscript) logical subscript too long B - as.vector(coef(dd.plin)) st -list(Blev = B[2], beta = B[3:5], gamm = B[1]) dd.nls - nls(Lum ~ Blev + beta[Gun] * GL^gamm, +data = dd, start = st +) confint(dd.nls) Waiting for profiling to be done... 2.5%97.5% Blev -1.612492e-01 2.988387e-02 beta1 6.108282e-06 8.762679e-06 beta2 1.269000e-05 1.792914e-05 beta3 3.844042e-05 5.388546e-05 gamm 2.481102e+00 2.542966e+00 dd.deriv2 - function (Blev, beta, gamm, GL) + { +.expr1 - GL^gamm +.value - Blev + rep(beta, each = 17) * .expr1 +.grad - array(0, c(length(.value), 5), list(NULL, c(Blev, +beta.rouge, beta.vert, beta.bleu, gamm))) +.grad[, Blev] - 1 +.grad[1:17, beta.rouge] - .expr1[1:17] +.grad[18:34, beta.vert] - .expr1[1:17] +.grad[35:51, beta.bleu] - .expr1[1:17] +.grad[, gamm] - ifelse(GL == 0, 0, rep(beta, each = 17) * (.expr1 * + log(GL))) +attr(.value, gradient) - .grad +.value + } dd.nls.d2 - nls(Lum ~ dd.deriv2(Blev, beta, gamm, GL), data = dd, +start = list(Blev = B[2], beta = B[3:5], gamm = B[1])) confint(dd.nls.d2) Waiting for profiling to be done... 2.5%97.5% Blev -1.612492e-01 2.988391e-02 beta1 1.269000e-05 1.792914e-05 beta2 3.844041e-05 5.388546e-05 beta3 6.108281e-06 8.762678e-06 gamm 2.481102e+00 2.542966e+00 R.version.string # XP [1] R version 2.4.0 Patched (2006-10-24 r39722) On 11/18/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: This works for me in terms of giving results without error messages except for the confint(dd.plin) which I assume you don't really need anyways. gg - model.matrix(~ Gun/GL - Gun, dd) dd.plin - nls(Lum ~ gg^gamm, dd, start = list(gamm = 2.4), +alg = plinear +) confint(dd.plin) Waiting for profiling to be done... Error in eval(expr, envir, enclos) : (subscript) logical subscript too long B - as.vector(coef(dd.nls0)) st -list(Blev = B[2], beta = B[3:5], gamm = B[1]) dd.nls - nls(Lum ~ Blev + beta[Gun] * GL^gamm, +data = dd, start = st +) confint(dd.nls) Waiting for profiling to be done... 2.5%97.5% Blev -1.612492e-01 2.988386e-02 beta1 6.108282e-06 8.762679e-06 beta2 1.269000e-05 1.792914e-05 beta3 3.844042e-05 5.388546e-05 gamm 2.481102e+00 2.542966e+00 dd.deriv2 - function (Blev, beta, gamm, GL) + { +.expr1 - GL^gamm +.value - Blev + rep(beta, each = 17) * .expr1 +.grad - array(0, c(length(.value), 5), list(NULL, c(Blev, +beta.rouge, beta.vert, beta.bleu, gamm))) +.grad[, Blev] - 1 +.grad[1:17, beta.rouge] - .expr1[1:17] +.grad[18:34, beta.vert] - .expr1[1:17] +.grad[35:51, beta.bleu] - .expr1[1:17] +.grad[, gamm] - ifelse(GL == 0, 0, rep(beta, each = 17) * (.expr1 * + log(GL))) +attr(.value, gradient) - .grad +.value + } dd.nls.d2 - nls(Lum ~ dd.deriv2(Blev, beta, gamm, GL), data = dd, +start = list(Blev = B[2], beta = B[3:5], gamm = B[1])) confint(dd.nls.d2) Waiting for profiling to be done... 2.5%97.5% Blev -1.612492e-01 2.988391e-02 beta1 1.269000e-05 1.792914e-05 beta2
Re: [R] lattice layout multiple pages
On 11/18/06, Patrick Giraudoux [EMAIL PROTECTED] wrote: Dear all, Using lattice I would like to print a conditionnal plot of 32 panels in a limited number of panels (eg 4) in each of several pages: xyplot(pds~time|Idnid,data=croispond3,layout=c(4,4)) This works well in principle, but the pages are printed without any possibility of stopping the printing process before each next page. I have tried par(ask=T) before the xyplot command line but it does not work for some reasons. You need the grid equivalent, grid::grid.prompt(TRUE) (and FALSE to restore). I'm toying with the idea of making par(ask=TRUE) work as well. Also I would like to print those pages to a device (eg using win.metafile(filename = myfile)), but I wonder how to manage not to make each page file created overwritten by the next one in this context. Don't know about win.metafile (have you tried it? Does it really overwrite previous pages?), but pdf etc have options (described in their help page) to produce either a single multi-page files or multiple single-page files. -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.
Re: [R] gzfile with multiple entries in the archive
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Apologies for entering this late, but last week was extremely busy. I hadn't realized that you would implement something so quickly and I could have saved you some time. I was in the process of adding facilities for gzipped tar files in the Rcompression package. A new version (0.3-0) is available from the www.omegahat.org respositories www.omegahat.org/R for source and Windows. This uses code from the zlib-1.2.3 contrib/ directory to do the extraction and table of contents. So it should be pretty quick. And it allows for event-driven programming with callback functions, and has hints for avoiding vector resizing issues which make it considerably faster. D. John James wrote: Following suggestions from Prof. Ripley and several others to use gzfile, here's rough code that will unzip a tgz into your working directory and return a list of the files. (It doesn't warn you that it is overwriting files!) The magic numbers refer to the current tar header specification; the block sizes etc. are arbitrary. It is inefficient in that it re-reads the file from the start for every file. I couldn't get the file pointer to stay and change the readBin mode back from 'character' to 'raw' although the reverse is used! Is there a setting I've missed? Also, is there a better way to do the convert(..) function? All criticisms gratefully received, especially being pointed to an existing function. John James Mango Solutions unzip - function(x, archiveDirectory = '.', zipExtension='tgz', block=5, maxBlocks=100, maxCountFiles=100) { # Example # unzip('test.tgz') convert - function(oct= 2, oldRoot=8, newRoot=10) { if((newRoot==16)) return(structure(convert(oct, oldRoot, 10), class='hexmode')) if(newRoot10) return(simpleError('WIP')) if(class(oct)=='hexmode') { oct - unclass(oct) if(newRoot==10) return(oct) oldRoot - 10 return(simpleError('WIP')) } oct - as.numeric(oct) ret - 0 oldPower - 1 while(oct 0.1){ newoct - floor(oct / newRoot) rem - oct - newoct * newRoot ret - rem * oldPower + ret oldPower - oldPower * oldRoot oct - newoct } if(newRoot==16) ret - structure(ret, class = 'hexmode') ret } listOfFiles - list() theArchives - list.files(archiveDirectory, pattern = zipExtension) if(length(grep(x, theArchives))==0) return(simpleError(paste('No archive matching *', x, '*.', zipExtension, ' found'))) what - paste(archiveDirectory, theArchives[grep(x, theArchives)], sep=.Platform$file.sep) tmp - tempfile() nextBlockStartsAt - readUpTo - countFiles - mu - safety - 0 zz - gzfile(what, 'rb') ww - file(tmp, 'wb') on.exit(unlink(tmp)) while(length(mu)0) { if(safety maxBlocks) { return(simpleError(paste('Archive File too large'))) } safety - safety + 1 mu - readBin(zz, 'raw', block) writeBin(mu, ww) } close(zz) close(ww) while(countFiles maxCountFiles){ countFiles - countFiles + 1 zz - file(tmp, 'rb') stuff - readBin(zz, 'raw', n=nextBlockStartsAt) header - readBin(zz, character(), n=100) header - header[nchar(header)0][c(1,5)] close(zz) if(any(is.na(header))) { break; } listOfFiles[[countFiles]] - header[1] zz - file(tmp, 'rb') body - readBin(zz, 'raw', n = 512 + nextBlockStartsAt + convert(header[2])) writeBin(body[-c(1:(512 + nextBlockStartsAt))], header[1]) readUpTo - 512 + nextBlockStartsAt + convert(header[2]) nextBlockStartsAt - (readUpTo%/%512 + 1) * 512 close(zz) } listOfFiles } -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: 14 November 2006 15:18 To: John James Cc: r-help@stat.math.ethz.ch Subject: Re: [R] gzfile with multiple entries in the archive On Tue, 14 Nov 2006, John James wrote: If I open a tgz archive with gzfile and then parse it using readLines I miss the initial line of each member of the archive - and also the name of the file although the archive otherwise complete (but useless!). You can use a gzfile connection to read the underlying .tar file, but that is not a text file and you will need to
[R] Ryacas not working properly
Dear All I have just installed the package Ryacas, but getting the following: library(Ryacas) Loading required package: XML yacas(1/2 * 3/4) [1] Starting Yacas! Error in socketConnection(host = 127.0.0.1, port = 9734, server = FALSE, : unable to open connection In addition: Warning message: 127.0.0.1:9734 cannot be opened /usr/lib/R/library/Ryacas/yacdir/R.ys(1) : File not found I am using Fedora Core 6 (Linux), R 2.4.0 and Yacas 1.0.62. Any ideas? Thanks in advance, Paul __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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 on adding reference line?
Dear Ruser, I use abline() function to add the reference line successfully, but i can't display the values corresponding to the reference line on the x/y axis, anybody knows how to display it? *My simulated programs:* y-rnorm(50) plot(x,y) abline(v=0.5) *#my question is how to display x=0.5 in the x axis?* Thanks in advance. -- With Kind Regards, oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [***] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 [EMAIL PROTECTED] Dept. of Epidemiology,school of public health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 [***] oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [[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] Ryacas not working properly
Checkout the INSTALLATION - UNIX and TROUBLESHOOTING sections of the home page: http://code.google.com/p/ryacas/ On 11/18/06, Paul Smith [EMAIL PROTECTED] wrote: Dear All I have just installed the package Ryacas, but getting the following: library(Ryacas) Loading required package: XML yacas(1/2 * 3/4) [1] Starting Yacas! Error in socketConnection(host = 127.0.0.1, port = 9734, server = FALSE, : unable to open connection In addition: Warning message: 127.0.0.1:9734 cannot be opened /usr/lib/R/library/Ryacas/yacdir/R.ys(1) : File not found I am using Fedora Core 6 (Linux), R 2.4.0 and Yacas 1.0.62. Any ideas? Thanks in advance, Paul __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] questions on adding reference line?
Try: axis(1, 0.5, tick = TRUE) On 11/18/06, zhijie zhang [EMAIL PROTECTED] wrote: Dear Ruser, I use abline() function to add the reference line successfully, but i can't display the values corresponding to the reference line on the x/y axis, anybody knows how to display it? *My simulated programs:* y-rnorm(50) plot(x,y) abline(v=0.5) *#my question is how to display x=0.5 in the x axis?* Thanks in advance. -- With Kind Regards, oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [***] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 [EMAIL PROTECTED] Dept. of Epidemiology,school of public health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 [***] oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [[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.