[R] Confindence interval for Levenberg-Marquardt fit
Dear all, I would like to use the Levenberg-Marquardt algorithm for non-linear least-squares regression using function nls.lm. Can anybody help me to find a a way to compute confidence intervals on the fitted parameters as it is possible for nls (using confint.nls, which does not work for nls.lm)? Thank you for your help Michael __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Confindence interval for Levenberg-Marquardt fit
Thank you, sorry, I forgot to mention that nls.lm is in package minpack.lm. It's use is motivated by the wish of a colleague to reproduce a result from some publication. But if I understand you correctly, use of the methods implemented in nls or optim is preferred? Prof Brian Ripley wrote: Well, the algorithm used does not affect the confidence interval (provided it works correctly), but what is nls.ml (presumably in some package you have not mentioned) and why would I want to use an old-fashioned algorithm? You could start nls at the solution you got from nls.ml and use confint() on that. On Wed, 21 Feb 2007, Michael Dondrup wrote: Dear all, I would like to use the Levenberg-Marquardt algorithm for non-linear least-squares regression using function nls.lm. Can anybody help me to find a a way to compute confidence intervals on the fitted parameters as it is possible for nls (using confint.nls, which does not work for nls.lm)? Thank you for your help Michael __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] variation on vioplot?
Hi Karin, I think it's just setting horizontal to FALSE. vioplot(normal,uniform,horizontal=FALSE) For the axis: How about this: vioplot(normal, uniform) axis(2, pos=1.5) sometimes the second axis might overlap, so try this one too: ylim - range(normal, uniform) par(mfrow=c(1,2), bty='n') vioplot(normal, ylim=ylim,names=c('normal')) vioplot(uniform, ylim=ylim, names=c('uniform')) btw: library(vioplot) works for me Hope this helps Michael Michael Dondrup [EMAIL PROTECTED] writes: Hi Karin, I would like to help with this, but it's not completely clear to me what your vioplots look or should look like. Could you post a little reproducible code example to the list, and then specify what should be different? OK. Adapted from the vioplot example: source(vioplot.R) uniform-runif(2000,-4,4) normal-rnorm(2000,0,3) vioplot(normal,uniform,horizontal=TRUE) Now these two are positioned one on top of the other. I would like to have them next to each other, if possible. I would then like the scale underneath to be duplicated so that there is one scale underneath each of them. Karin __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] how to plot additional function into pairwise scatterplots?
Harald, for your specific problem (add main diagonal) for example: abline.points - function (x,y,...) { points(x, y, ...); abline(0,1) } pairs(USJudgeRatings[1:5], panel = abline.points, cex = 1.5 ) example(pairs) has nicer examples. Regards Michael Am Tuesday 16 May 2006 10:46 schrieb Harald Stepputtis: Hello, I am new to R and want to use it for some statistical tests. Before the tests, I want to visualize my data with pairwise scatterplots using pairs(myData). To analyse it by eye, I would like to draw the function f(x)=y into each of the scatterplot panels. Unfortunately I get lost when I try to figure it out by reading help(pairs). Can anyone help me or point me to a nice tutorial about graphics? Regards, Harald __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] data input strategy - lots of csv files
Hi, if you would use a list, to collect (append) all your data.frames from read.csv, you don't have to compute variable names like a1...a66, just iterate over contents of the list. By using function dir, you can read all files in a directory in a loop. Michael Am Thursday 11 May 2006 10:03 schrieb Sean O'Riordain: Good morning, I have currently 63 .csv files most of which have lines which look like 01/06/05,23445 Though some files have two numbers beside each date. There are missing values, and currently the longest file has 318 rows. (merge() is losing the head and doing runaway memory allocation - but thats another question - I'm still trying to pin that issue down and make a small repeatable example) Currently I'm reading in these files with lines like a1 - read.csv(daft_file_name_1.csv,header=F) ... a63 - read.csv(another_silly_filename_63.csv,header=F) and then i'm naming the columns in these like... names(a1)[2] - silly column name ... names(a63)[2] - daft column name then trying to merge()... atot - merge(a1, a2, all=T) and then using language manipulation to loop atot - merge(atot, a3, all=T) ... atot - merge(atot, a63, all=T) etc... followed by more language manipulation for() { rm(a1) } etc... i.e. for (i in 2:63) { atot - merge(atot, eval(parse(text=paste(a, i, sep=))), all=T) # eval(parse(text=paste(a,i,[1] - NULL,sep=))) cat(i is , i, gc(), \n) # now delete these 63 temporary objects... # e.g. should look like rm(a33) eval(parse(text=paste(rm(a,i,), sep=))) } eventually getting a dataframe with the first column being the date, and the subsequent 63 columns being the data... with missing values coded as NA... so my question is... is there a better strategy for reading in lots of small files (only a few kbytes each) like that which are timeseries with missing data... which doesn't go through the above awkwardness (and language manipulation) but still ends up with a nice data.frame with NA values correctly coded etc. Many thanks, Sean O'Riordain __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] export
Hi, how about round() ? best On Monday 08 May 2006 12:36 Søren Højsgaard wrote: One way is to use the sprintf-function which returns strings, and then write these strings in a file. But it is kludgy and there must be better ways... Best Søren -Oprindelig meddelelse- Fra: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] På vegne af Andrea Toreti Sendt: 8. maj 2006 12:26 Til: R Emne: [R] export I have a problem with the export of a simulated matrix (nrow=1000, ncol=492). I want to obtain a .txt file with fixed format data (five character for example). I've tried to use the instructions: options(digits=5) followed by write.table(...), but the .txt file reports always the data with different lenght, whereas the matrix in R gives right result (i.e. the elements have the same lenght). Could you help me? Thanks Andrea Toreti [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] persp plot increasing 'x' and 'y' values expected
Hi, yes, your x and y are increasing but the (x,y) coordinates are not unique. Looks like some measurements are redundant in your input. Michael hello, i do the following in order to get an persp-plot x-c(2,2,2,2,2,2,3,3,3,3) y-c(41,41,83,83,124,166,208,208,208,208) z-c(90366,90366,92240,92240,92240,96473,100995,100995,100995,100995) x-data$x y-data$y z-matrix(data$z,length(y),length(x)) persp(x,y,z, col=gray) but i always get the error message increasing 'x' and 'y' values expected, but i think my data values are already increasing, what is wrong? best regards andreas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] persp plot increasing 'x' and 'y' values expected
Hi, of course it can't because the number of unique values is different. You need a unique _combination_ of x,y and hopefully you don't have different z values for any such a pair. try: xyz - unique(cbind(x,y,z)) persp(xyz) If you still get the err, then you had different measurements for the same point. Cheers Am Tuesday 25 April 2006 12:24 schrieb [EMAIL PROTECTED]: hi peter, thank you for your advice. ok, i see the problem, but if i do x-unique(data$x) y-unique(data$y) z-matrix(unique(data$z),length(y),length(x)) it also doesn't work. i want to do a plot, where i can see, how x and y influences z. P Ehlers wrote: [EMAIL PROTECTED] wrote: hello, i do the following in order to get an persp-plot x-c(2,2,2,2,2,2,3,3,3,3) y-c(41,41,83,83,124,166,208,208,208,208) z-c(90366,90366,92240,92240,92240,96473,100995,100995,100995,100995) x-data$x y-data$y z-matrix(data$z,length(y),length(x)) persp(x,y,z, col=gray) but i always get the error message increasing 'x' and 'y' values expected, but i think my data values are already increasing, what is wrong? I'm not sure what your data$x, data$y, data$z are (but I can guess). Why do you think that your x is *increasing*? Is x[i+1] x[i]? Does diff(x) yield only positive values? What kind of a perspective plot do you expect? You seem to have only 5 unique points. Peter Ehlers best regards andreas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] persp plot increasing 'x' and 'y' values expected
Hi, of course it can't because the number of unique values is different. You need a unique _combination_ of x,y and hopefully you don't have different z values for any such a pair. try: xyz - unique(cbind(x,y,z)) persp(xyz) If you still get the err, then you had different measurements for the same point. Cheers Am Tuesday 25 April 2006 12:24 schrieb [EMAIL PROTECTED]: hi peter, thank you for your advice. ok, i see the problem, but if i do x-unique(data$x) y-unique(data$y) z-matrix(unique(data$z),length(y),length(x)) it also doesn't work. i want to do a plot, where i can see, how x and y influences z. P Ehlers wrote: [EMAIL PROTECTED] wrote: hello, i do the following in order to get an persp-plot x-c(2,2,2,2,2,2,3,3,3,3) y-c(41,41,83,83,124,166,208,208,208,208) z-c(90366,90366,92240,92240,92240,96473,100995,100995,100995,100995) x-data$x y-data$y z-matrix(data$z,length(y),length(x)) persp(x,y,z, col=gray) but i always get the error message increasing 'x' and 'y' values expected, but i think my data values are already increasing, what is wrong? I'm not sure what your data$x, data$y, data$z are (but I can guess). Why do you think that your x is *increasing*? Is x[i+1] x[i]? Does diff(x) yield only positive values? What kind of a perspective plot do you expect? You seem to have only 5 unique points. Peter Ehlers best regards andreas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] persp plot increasing 'x' and 'y' values expected
Hmm, well, of course this is tested, and it produces a plot, but not the correct one ;) Sorry, that was too quick Am Tuesday 25 April 2006 12:51 schrieb Duncan Murdoch: On 4/25/2006 6:23 AM, Michael Dondrup wrote: Hi, of course it can't because the number of unique values is different. You need a unique _combination_ of x,y and hopefully you don't have different z values for any such a pair. try: xyz - unique(cbind(x,y,z)) persp(xyz) If you still get the err, then you had different measurements for the same point. I think you and Andreas want scatterplot3d (from a contributed package of the same name), not persp. Persp takes very data in a very particular format. See the man page. In general, it's a good idea to test your suggestions before posting them. Yours wouldn't work, because x, y and z *must not* be the same length in persp. Duncan Murdoch Am Tuesday 25 April 2006 12:24 schrieb [EMAIL PROTECTED]: hi peter, thank you for your advice. ok, i see the problem, but if i do x-unique(data$x) y-unique(data$y) z-matrix(unique(data$z),length(y),length(x)) it also doesn't work. i want to do a plot, where i can see, how x and y influences z. P Ehlers wrote: [EMAIL PROTECTED] wrote: hello, i do the following in order to get an persp-plot x-c(2,2,2,2,2,2,3,3,3,3) y-c(41,41,83,83,124,166,208,208,208,208) z-c(90366,90366,92240,92240,92240,96473,100995,100995,100995,100995) x-data$x y-data$y z-matrix(data$z,length(y),length(x)) persp(x,y,z, col=gray) but i always get the error message increasing 'x' and 'y' values expected, but i think my data values are already increasing, what is wrong? I'm not sure what your data$x, data$y, data$z are (but I can guess). Why do you think that your x is *increasing*? Is x[i+1] x[i]? Does diff(x) yield only positive values? What kind of a perspective plot do you expect? You seem to have only 5 unique points. Peter Ehlers best regards andreas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] plot control
Hi, it's not quite clear to me, what you are trying to accomplish with this. You are referring to quantiles (you means quartiles in your case?, see ?quantile ). So, are you trying to compare theoretical quantiles of a distribution to the empirical quantiles? Or are you just trying to split the left axes into 4 ticks? For the first case, try something like: y - rnorm(100) y.right.axisticks - quantile(y) y.left.ticks - qnorm(c(0.25,0.5,0.75)) #makes no sense to compare with # theor. quantiles of uniform distribution, right? ;) plot(y,yaxt='n') axis(2,at=y.left.ticks,labels=round(y.left.ticks,3)) axis(4,at=y.right.axisticks,labels=round(y.right.axisticks,3)) or for the latter: yrange - range(y) y.left.ticks - seq(yrange[1], yrange[2], (yrange[2] - yrange[1])/4) plot(y,yaxt='n') axis(2,at=y.left.ticks,labels=round(y.left.ticks,3)) axis(4,at=y.right.axisticks,labels=round(y.right.axisticks,3)) is that, what you thought of? see also: ?qqplot for another way to compare quantiles cheers Am Monday 24 April 2006 08:53 schrieb Alexander Nervedi: Dear R gurus, I'd like to plot a distribution with the tickmarks always at the quantiles of the y-axis, as opposed to the quantiles of the distribution I am plotting. plot seems to place these ticks based on some calculations that I cant see (?plot doesnt show the innards of plot). Below is some functional code, but the tick marks are placed unattractively since I am referencing the quantiles of the distribution. I'd ideally like the tickmarks to be able to reference fixed points on the y-axis and the show the associted values. I'd be very grateful for ideas, suggestion and leads. - alex. # some code y1-rnorm(100) y2-runif(100) x -1:100 l -length(y1) mat-scale(cbind(y1,y2)) plot(x, mat[,1], col = blue, yaxt = n, ylab=) axis(2, at = sort(mat[,1])[c(0.25*l,0.5*l,0.75*l)], labels = round(sort(y1)[c(0.25*l, 0.5*l,0.75*l)],2)) points(x, mat[,2], col = red) axis(4, at = sort(mat[,2])[c(0.25*l,0.4*l,0.75*l)], labels = round(sort(y2)[c(0.25*l, 0.5*l,0.75*l)],2)) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Dealing with missing values in HeatMap generation
Hi, 'g' must be a numeric matrix and obviously it's not (suspect it's character?). If 'g' is numeric in your example depends on how you read data into 'filedata' and this step is missing in your code (maybe you just forgot to use read.table?). See ?read.table for that, and use argument colClasses if required. Am Friday 07 April 2006 17:01 schrieb Himanshu Ardawatia: Hi, I want to generate a heatmap for my data (in a matrix). However, the data has some missing values (represented as blank). I get the following errors (with the blanks and with blanks replaced by NA and including the option rm.na = TURE): filename = input_heatmap.txt g - as.matrix(filedata) fg - rainbow(nrow(g), start=0, end=.3) gg - rainbow(ncol(g), start=0, end=.3) hg - heatmap(g, col = cm.colors(256), scale=column,na.rm = TRUE, + RowSideColors = fg, ColSideColors = gg, margin=c(5,10), + xlab = Average per Species, ylab= Pathways, + main = heatmap(Ka/Ks Average Data per Species, ..., scale = \column\)) Error in heatmap(g, col = cm.colors(256), scale = column, na.rm = TRUE, : 'x' must be a numeric matrix Is there anyway to deal with it? Second question: What is the basis for generation of the dendrogram (over the heatmap) in the heatmap? Is it simple hierarchical clustering? Thanks in advance Himanshu __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to generate a list of lists recursively (for bayesm)
Hi Moritz, you need to initialize your lists somehow, before you can use them (hence the error) like: regdata1 - regdata2 - list() [some for loops] I believe it might be cleaner to use c() to concat the lists, as your code seems to add lists at the end, than to assign to list elements which do not actually exist. Cheers Am Tuesday 28 March 2006 14:39 schrieb [EMAIL PROTECTED]: thanx for the reply. Sk is a 1067*300 matrix att is a 300*15 matrix attq8 is a 300*17 matrix regdata1 and regdata2 are meant to become my 2 lists of lists by this procedure - I actually do not know if they should be initialized in any other way as lists of lists and how to do this. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html