[R] The old question: R vs MATLAB vs Mathematica vs ...
Hi, This question seems to be old, however I am asking it from a different point of view. R introduces itself as a 'statistical' language and environment. There are many discussions about comparing R to MATLAB or mathematica (or other similar software). It seems to me that these other software have a broader range of applications. For example, in Mathematica one can solve a partial differential equation numberically or do image processing, or, one can connect a data acquisition card to MATLAB to acquire data from a measurement and analyse the results. - Does R already provide such facilities? - Was R design to be merely a statistical tool or was it designed with an idea of a general mathematical tool in mind? - If the answer to the above is no, can R already be extended to include the missing features simply by extra packages or does it need some rational changes to support these features? _ Windows Live Messenger has arrived. Click here to download it for free! __ 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] call c function in R
Hi, I need to call a c funtion in R.I created the Dll in Visual C++. And In R , I used the dyn(path) no erro. Then when I call .c (function m=name , parameter) it always says the c entry point product not in load table I really need your help. Many thanks Gao [[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] Mute script
How are you running this 'script'? If you use source(), you do need to explicitly print or use the 'print.eval' argument. If you use R CMD BATCH or similar (which is what most people mean by running a script), you do get autoprinting. On Sun, 15 Oct 2006, Alexandre Aguiar wrote: Hi, I tried to run the following script with R 2.4.0. The data stuff is commented out because data are already in memory. #db - read.csv(normais.csv, sep=;, quote=, header=T) sink(normais-chi.txt, append=T, type = output, split=T) #sink(normais-chi.txt, append=T) table(db$agua, db$mBerg) chisq.test(db$agua, db$mBerg, correct=F) print(table(db$agua, db$mBerg)) print(chisq.test(db$agua, db$mBerg, correct=F)) # here there are several other table/chisq.test pairs sink() #rm(db) By introducing syntax errors in the script error messages will appear but normal output won't neither at screen nor at the sink file. On the other hand, by inserting print commands I get both screen and file outputs. Is it necessary to use the print command in every line? In interactive mode the simple command will produce the proper output. Or do I have a configuration problem? Haven't found the answer elsewhere in teh Net. If as I suspect you used source() the answer is both on the help page and in the archives of this list. -- 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] Execution halting of lmer on UNIX when no problem on windows
See ?try ?tryCatch FAQ 7.32 This is not a Windows/UNIX difference as you suppose, but an interactive/batch difference. You could also look into using options(error=). On Sun, 15 Oct 2006, Toby Gardner wrote: Dear R-users, I have a frustrating problem that I am hoping has a simple fix. I am running a series of lmer models from the lme4 package of the general form: model-lmer(y~x1 + x2 . + xn + (1|site),data=dataframe,family=poisson,method=Laplace,control=list(usePQL=FALSE,msVerbose=TRUE)) where the same model is executed multiple times on a bootstrapped dataframe. For each bootstrapped model run the resulting model object is used to return the AIC (and models are then compared using a bootstrapped weight - frequency of runs a given model had the lowest AIC). This works just fine when running interactively on my windows machine (so there is nothing the matter with the code, hence I have not bored you with the details here) however when I submit the job as a batch to a UNIX system it usually (but not always) fails and the execution is halted after an error message is produced: Error in objective (.par,...): Leading minor of order 1 in downdated X'X is not positive definite In addition: There were 12 warnings (use warnings() to see them) Error in logLik(model) : no applicable method for logLik Execution halted On windows when the execution of a single model run fails to estimate the logLik (an unstable model...) R just continues past the error and still runs to the end of the script (i.e. runs through all the bootstraps), and I can then inspect the output and any errors at the end. My question, then is when using UNIX on batch mode, how can I get the job to NOT halt it's execution on the production of an unstable model (not positive definite) and continue running? If the models are not bootstrapped then the script is executed without any problem in UNIX (so the script is successfuly submitted as a batch job), so it seems that some of the bootstrap runs are producing unstable models in rare instances, but just one is sufficient to halt the execution of the script. I am running R.2.3.1 on both Windows and UNIX, Many thanks in advance, Toby Gardner School of Environmental Sciences University of East Anglia Norwich, NR4 7TJ United Kingdom Email: [EMAIL PROTECTED] Website: www.uea.ac.uk/~e387495 [[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. -- 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] Generate a random bistochastic matrix
Please, I would like to generate a random bistochastic matrix, that is a squared matrix of non-negative numbers with each row and each column sum to 1, for example : .2.3.5 .6.3.1 .2 .4 .4 I don't know of to code this. Do you have any idea ? Thanks Florent Bresson ___ Demandez à ceux qui savent sur Yahoo! Questions/Réponses __ 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] Fill a matrix with vectors of different lengths
Hello, how can I best fill a (fixed) matrix with vectors of varying lengths by column, setting the superfluous elements to zero? Here is my code: v-(1,1,2,3,4,6) binc-function(x){ l-sum(x)+1 y-c(1,rep(0,l-1)) for (i in x) y-y+c(rep(0,i),y)[1:l] } mat-matrix(0, nrow=sum(v)+1, ncol=length(v)) for (i in 1:length(v)) mat[,i]=mat[,i]+binc(v[1:i]) the expression in the for-loop produces an error since mat[,i] and binc(v[1:i]) are of unequal lengths, except on the last iteration. Thanks in advance, Serguei -- ___ Austrian Institute of Economic Research (WIFO) Name: Serguei Kaniovski P.O.Box 91 Tel.: +43-1-7982601-231 Arsenal Objekt 20 Fax: +43-1-7989386 1103 Vienna, Austria Mail: [EMAIL PROTECTED] http://www.wifo.ac.at/Serguei.Kaniovski __ 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] Fill a matrix with vectors of different lengths
you can try something like the following: out - lapply(1:length(v), function(i) binc(v[1:i])) nout - max(sapply(out, length)) sapply(out, function(x) c(x, rep(0, nout - length(x I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Serguei Kaniovski [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Monday, October 16, 2006 10:27 AM Subject: [R] Fill a matrix with vectors of different lengths Hello, how can I best fill a (fixed) matrix with vectors of varying lengths by column, setting the superfluous elements to zero? Here is my code: v-(1,1,2,3,4,6) binc-function(x){ l-sum(x)+1 y-c(1,rep(0,l-1)) for (i in x) y-y+c(rep(0,i),y)[1:l] } mat-matrix(0, nrow=sum(v)+1, ncol=length(v)) for (i in 1:length(v)) mat[,i]=mat[,i]+binc(v[1:i]) the expression in the for-loop produces an error since mat[,i] and binc(v[1:i]) are of unequal lengths, except on the last iteration. Thanks in advance, Serguei -- ___ Austrian Institute of Economic Research (WIFO) Name: Serguei Kaniovski P.O.Box 91 Tel.: +43-1-7982601-231 Arsenal Objekt 20 Fax: +43-1-7989386 1103 Vienna, Austria Mail: [EMAIL PROTECTED] http://www.wifo.ac.at/Serguei.Kaniovski __ 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. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ 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] Fill a matrix with vectors of different lengths
for (i in 1:length(v)) { bi - binc(v[1:i]) mat[1:length(bi),i]=mat[1:length(bi),i]+bi } On 16/10/06, Serguei Kaniovski [EMAIL PROTECTED] wrote: Hello, how can I best fill a (fixed) matrix with vectors of varying lengths by column, setting the superfluous elements to zero? Here is my code: v-(1,1,2,3,4,6) binc-function(x){ l-sum(x)+1 y-c(1,rep(0,l-1)) for (i in x) y-y+c(rep(0,i),y)[1:l] } mat-matrix(0, nrow=sum(v)+1, ncol=length(v)) for (i in 1:length(v)) mat[,i]=mat[,i]+binc(v[1:i]) the expression in the for-loop produces an error since mat[,i] and binc(v[1:i]) are of unequal lengths, except on the last iteration. Thanks in advance, Serguei -- ___ Austrian Institute of Economic Research (WIFO) Name: Serguei Kaniovski P.O.Box 91 Tel.: +43-1-7982601-231 Arsenal Objekt 20 Fax: +43-1-7989386 1103 Vienna, Austria Mail: [EMAIL PROTECTED] http://www.wifo.ac.at/Serguei.Kaniovski __ 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] Sweave, R and complex latex projects
On Sat, 14 Oct 2006 23:00:27 +0100, Mark Wardle (MW) wrote: Hello all, I've been able to use R very successfully to run simple statistics and generate the plots I require. I've been evaluating Sweave, and have hit upon a small problem that I don't seem to be able to workaround. Sweave runs very well for single file latex documents, but I have a complex thesis made up of several parts and chapters. These are arranged with a master latex file and subdirectories with \include-ed latex fragments representing those parts/chapters, and I don't seem to be able to get Sweave to work properly. I've tried a number of approaches, including converting the master document into a Snw file itself, or even generating chapters manually chapter by chapter using Sweave and then \includeing the result into the master tex file. Unfortunately for the latter attempt, the the latex generated doesn't prepend the required path to the filename, and so latex looks for the pdfs and tex files in the wrong place - it looks in the root directory (where the master tex file is located) rather than the chapter subdirectory where all the files have been generated. I hope I'm not missing something obviously documented, but I can't see it in the Sweave docs. Is there an option to prepend a pathname to the filename of Sweave generated TeX and PDF documents? Yes, simply set prefix.string to a path, not only a filename. E.g., \SweaveOpts{prefix.string=figs/myfile} will place all figures in subdir figs (you have to create the directory first manually) and call the separate files myfile-XXX where XXX is number or name of the chunk. Do people use Sweave for complex multi-file latex projects, and what is the best approach? I'm almost tempted to keep R and Latex separate, and continue to run a R script to generate all of the dynamic tables/charts which are then \inputed, but I was rather attracted to the whole Sweave approach. I personally mostly use Makefiles as suggested by Deepayan. In addition there is \SweaveInput{} which works similar to Latex's own \input{} command. There currently is no equivalent of \include{}. HTH, Fritz -- --- Prof. Dr. Friedrich Leisch Institut für Statistik Tel: (+49 89) 2180 3165 Ludwig-Maximilians-Universität Fax: (+49 89) 2180 5308 Ludwigstraße 33 D-80539 München http://www.stat.uni-muenchen.de/~leisch __ 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] Sweave, R and complex latex projects
On Sat, 14 Oct 2006 16:04:50 -0700, Deepayan Sarkar (DS) wrote: %.tex: %.Rnw echo library(tools); Sweave('$') | ${R_PROG} --vanilla --silent Note that we now have R CMD Sweave (new in R 2.4.0) for this purpose. Best, Fritz __ 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] set linetype with plotCI
Sorry, the plot_linetypes[1] is a debugging leftover. It's plot_linetypes[graph_idx] in my actual code ... And plot_linetypes is just the sequence 1,2,3,4... etc plotCI( x = xvals.f[sorted], y = yvals.f[sorted], xlim = c(xmin, xmax), ylim = c(ymin, ymax), pch = plot_symbols[graph_idx], type = b, lty = plot_linetypes[1], col = plot_colors[graph_idx], barcol = plot_colors[graph_idx], uiw = NA, xlab = , ylab = , add = (plot_cnt 0) ) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] set linetype with plotCI
You could look at the plotCI function in the plotrix package, which has a separate parameter for setting the linetype of the error bars. (An additional benefit is that it works with R 2.4.0 -- gplots seems not to have been updated, or at least the windows binary hasn't, and still includes a now defunct feature.) On 16/10/06, JeeBee [EMAIL PROTECTED] wrote: Sorry, the plot_linetypes[1] is a debugging leftover. It's plot_linetypes[graph_idx] in my actual code ... And plot_linetypes is just the sequence 1,2,3,4... etc plotCI( x = xvals.f[sorted], y = yvals.f[sorted], xlim = c(xmin, xmax), ylim = c(ymin, ymax), pch = plot_symbols[graph_idx], type = b, lty = plot_linetypes[1], col = plot_colors[graph_idx], barcol = plot_colors[graph_idx], uiw = NA, xlab = , ylab = , add = (plot_cnt 0) ) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html 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] call c function in R
On 10/15/2006 11:24 PM, lan gao wrote: Hi, I need to call a c funtion in R.I created the Dll in Visual C++. And In R , I used the dyn(path) no erro. Then when I call .c (function m=name , parameter) it always says the c entry point product not in load table Check that the entry point you specified was really exported: VC++ should provide some tool for this. Show us your R code. If it was really .c (function m=name , parameter) then it wouldn't have given that error. Show us the real error. I really need your help. Read the posting guide, and follow the instructions there, and you'll get better help. Duncan Murdoch Many thanks Gao [[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] set linetype with plotCI
Thanks, I tried using plotCI in the plotrix library. This, however, gives me the below error. CODE:: cat(x = ); print(xvals.f[sorted]) cat(y = ); print(yvals.f[sorted]) cat(pch = ); print(plot_symbols[graph_idx]) cat(lty = ); print(plot_linetypes[graph_idx]) cat(col = ); print(plot_colors[graph_idx]) print(paste(graph_idx =, graph_idx, and plot_cnt =, plot_cnt)) plotCI( x = xvals.f[sorted], y = yvals.f[sorted], xlim = c(xmin, xmax), ylim = c(ymin, ymax), pch = plot_symbols[graph_idx], type = b, lty = plot_linetypes[graph_idx], col = plot_colors[graph_idx], barcol = plot_colors[graph_idx], uiw = NA, xlab = , ylab = , add = (plot_cnt 0) ) print(plotCI succeeeded...) OUTPUT:: x = [1] 160 160 160 160 160 160 160 160 160 160 320 320 320 320 320 320 320 320 320 [20] 480 480 480 480 480 480 480 480 480 640 640 640 640 640 640 640 640 800 800 [39] 800 800 800 800 800 800 800 960 960 960 960 960 960 960 960 960 y = [1] 0.062263829 0.062263829 0.062263829 0.062263829 0.062263829 0.062263829 [7] 0.062263829 0.062263829 0.062263829 0.062263829 0.029483948 0.029483948 [13] 0.029483948 0.029483948 0.029483948 0.029483948 0.029483948 0.029483948 [19] 0.029483948 0.018035707 0.018035707 0.018035707 0.018035707 0.018035707 [25] 0.018035707 0.018035707 0.018035707 0.018035707 0.009895540 0.009895540 [31] 0.009895540 0.009895540 0.009895540 0.009895540 0.009895540 0.009895540 [37] 0.008534913 0.008534913 0.008534913 0.008534913 0.008534913 0.008534913 [43] 0.008534913 0.008534913 0.008534913 0.007301515 0.007301515 0.007301515 [49] 0.007301515 0.007301515 0.007301515 0.007301515 0.007301515 0.007301515 pch = [1] 0 lty = [1] 1 col = [1] #FF [1] graph_idx = 1 and plot_cnt = 0 Error in plot.default(c(160, 160, 160, 160, 160, 160, 160, 160, 160, 160, : formal argument type matched by multiple actual arguments __ 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] set linetype with plotCI
Looking at the source code for plotCI, I see that it calls plot with type specified as n when the error bars are not being added to an existing plot, so you cannot use the type argument in a call to plotCI. If you want to add lines as well as points, I think you will have to use lines(x,y,type=b,lty = plot_linetypes[graph_idx]) in addition to plotCI, or amend the plotCI function to your own specifications. On 16/10/06, JeeBee [EMAIL PROTECTED] wrote: Thanks, I tried using plotCI in the plotrix library. This, however, gives me the below error. CODE:: cat(x = ); print(xvals.f[sorted]) cat(y = ); print(yvals.f[sorted]) cat(pch = ); print(plot_symbols[graph_idx]) cat(lty = ); print(plot_linetypes[graph_idx]) cat(col = ); print(plot_colors[graph_idx]) print(paste(graph_idx =, graph_idx, and plot_cnt =, plot_cnt)) plotCI( x = xvals.f[sorted], y = yvals.f[sorted], xlim = c(xmin, xmax), ylim = c(ymin, ymax), pch = plot_symbols[graph_idx], type = b, lty = plot_linetypes[graph_idx], col = plot_colors[graph_idx], barcol = plot_colors[graph_idx], uiw = NA, xlab = , ylab = , add = (plot_cnt 0) ) print(plotCI succeeeded...) OUTPUT:: x = [1] 160 160 160 160 160 160 160 160 160 160 320 320 320 320 320 320 320 320 320 [20] 480 480 480 480 480 480 480 480 480 640 640 640 640 640 640 640 640 800 800 [39] 800 800 800 800 800 800 800 960 960 960 960 960 960 960 960 960 y = [1] 0.062263829 0.062263829 0.062263829 0.062263829 0.062263829 0.062263829 [7] 0.062263829 0.062263829 0.062263829 0.062263829 0.029483948 0.029483948 [13] 0.029483948 0.029483948 0.029483948 0.029483948 0.029483948 0.029483948 [19] 0.029483948 0.018035707 0.018035707 0.018035707 0.018035707 0.018035707 [25] 0.018035707 0.018035707 0.018035707 0.018035707 0.009895540 0.009895540 [31] 0.009895540 0.009895540 0.009895540 0.009895540 0.009895540 0.009895540 [37] 0.008534913 0.008534913 0.008534913 0.008534913 0.008534913 0.008534913 [43] 0.008534913 0.008534913 0.008534913 0.007301515 0.007301515 0.007301515 [49] 0.007301515 0.007301515 0.007301515 0.007301515 0.007301515 0.007301515 pch = [1] 0 lty = [1] 1 col = [1] #FF [1] graph_idx = 1 and plot_cnt = 0 Error in plot.default(c(160, 160, 160, 160, 160, 160, 160, 160, 160, 160, : formal argument type matched by multiple actual arguments __ 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] set linetype with plotCI
Great, why didn't I think of that. Thanks :) If you want to add lines as well as points, I think you will have to use lines(x,y,type=b,lty = plot_linetypes[graph_idx]) in addition to plotCI, __ 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] linear mixed effects models with breakpoints
Hi folks I have some data to which I've been fitting linear mixed effects models. I am currently using a lme model in the nlme package, with terms for random effects due to repeated measures on individuals and the corCAR1 serial correlation structure. However, there is some suggestion in the data (and from theory) that a breakpoint (change point) model may be more appropriate. Scott, Norman and Berger's lmeChgPt model seems to go some way to fitting the requirements for such a model but does not incorporate, as I understand it, a serial correlation structure. Is anyone aware of a model fitting procedure that incorporates the correlation structures of the lme models in a breakpoint model? Kind regards, Ewan Wakefield British Antarctic Survey, High Cross, Madingley Road, Cambridge CB3 OET Tel. +44 (0) 1223 221215 E-mail: [EMAIL PROTECTED] Website: antarctica.ac.uk -- This message (and any attachments) is for the recipient only...{{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.
[R] NULL or NA for missing function arguments?
Hi, I am troubled by the use of NULL or NA to indicate missing/non-specified function arguments. In the R code that I have looked at, it seems that both forms are used (NULL seems to be used more often though). Sometimes both variants are in the same declaration, e.g. format.default - function(x, trim = FALSE, digits = NULL, nsmall = 0, justify = c(left, right, centre, none), width = NULL, na.encode = TRUE, scientific = NA, big.mark = , big.interval = 3, small.mark = , small.interval = 5, decimal.mark = ., zero.print = NULL, ...) Is there a right way? And if both forms are used, how do I know which one is right? Thanks a lot and best regards, Hans-Peter __ 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] Generate a random bistochastic matrix
bistochastic.3x3 - function() { B - matrix(0, 3, 3) ## 2 df tmp.1 - runif(3) B[1,] - tmp.1/sum(tmp.1) ## 1 df tmp.2 - runif(2) B[2:3, 1] - (1-B[1,1]) * tmp.2/sum(tmp.2) ## 1 df B[2, 2] - runif(1, max=min(1-B[1,2], 1-B[2,1])) ## Fill in the rest B[2,3] - 1-sum(B[2, 1:2]) B[3,2] - 1-sum(B[1:2, 2]) B[3,3] - 1-sum(B[1:2, 3]) B } B - bistochastic.3x3() apply(B, 1, sum) apply(B, 2, sum) To extend this to larger than 3x3 requires the same kind of conditional generation of alternating rows and columns of the matrix. The hard part is the extension of the two-way conditioning I illustrated in the B[2, 2] line. 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] NULL or NA for missing function arguments?
There is also a third way, namely use the missing function in the code: f - function(x) if (missing(x)) print(missing) else print(x) f() On 10/16/06, Hans-Peter [EMAIL PROTECTED] wrote: Hi, I am troubled by the use of NULL or NA to indicate missing/non-specified function arguments. In the R code that I have looked at, it seems that both forms are used (NULL seems to be used more often though). Sometimes both variants are in the same declaration, e.g. format.default - function(x, trim = FALSE, digits = NULL, nsmall = 0, justify = c(left, right, centre, none), width = NULL, na.encode = TRUE, scientific = NA, big.mark = , big.interval = 3, small.mark = , small.interval = 5, decimal.mark = ., zero.print = NULL, ...) Is there a right way? And if both forms are used, how do I know which one is right? Thanks a lot and best regards, Hans-Peter __ 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] grep function with patterns list...
Dear R-users, is there a way to pass a list of patterns to the grep function? I vaguely remember something with %in% operator... Thanks, Stéphane. -- La science a certes quelques magnifiques réussites à son actif mais à tout prendre, je préfère de loin être heureux plutôt qu'avoir raison. D. Adams -- AGC website http://www.genoscope.cns.fr/agc Stéphane CRUVEILLER Ph. D. Genoscope - Centre National de Séquencage Atelier de Génomique Comparative 2, Rue Gaston Cremieux CP 5706 91057 Evry Cedex - France Phone: +33 (0)1 60 87 84 58 Fax: +33 (0)1 60 87 25 14 [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] grep function with patterns list...
Try this: grep(b|c|d, letters, value = TRUE) [1] b c d On 10/16/06, Stéphane CRUVEILLER [EMAIL PROTECTED] wrote: Dear R-users, is there a way to pass a list of patterns to the grep function? I vaguely remember something with %in% operator... Thanks, Stéphane. -- La science a certes quelques magnifiques réussites à son actif mais à tout prendre, je préfère de loin être heureux plutôt qu'avoir raison. D. Adams -- AGC website http://www.genoscope.cns.fr/agc Stéphane CRUVEILLER Ph. D. Genoscope - Centre National de Séquencage Atelier de Génomique Comparative 2, Rue Gaston Cremieux CP 5706 91057 Evry Cedex - France Phone: +33 (0)1 60 87 84 58 Fax: +33 (0)1 60 87 25 14 [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-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] NULL or NA for missing function arguments?
On 10/16/2006 8:47 AM, Hans-Peter wrote: Hi, I am troubled by the use of NULL or NA to indicate missing/non-specified function arguments. In the R code that I have looked at, it seems that both forms are used (NULL seems to be used more often though). Sometimes both variants are in the same declaration, e.g. format.default - function(x, trim = FALSE, digits = NULL, nsmall = 0, justify = c(left, right, centre, none), width = NULL, na.encode = TRUE, scientific = NA, big.mark = , big.interval = 3, small.mark = , small.interval = 5, decimal.mark = ., zero.print = NULL, ...) Is there a right way? And if both forms are used, how do I know which one is right? As Gabor said, the third way is to give no default, but test missing() in the code. There are differences between the options, but I don't think there's a single right way. Some differences: If you want to allow a vector of parameters, some of which are missing and some are not, then you'd probably want NA, so that something like c(1,2,NA) was possible. The length of NA is 1, but the length of NULL is 0, so it would be harder to expand NULL to the same length as x. Taking the length of a truly missing parameter, or trying to change it, will trigger an error. That is, rep(param, length(x)) will work for NA, but not the others. It's also convenient to declare an error if length(scientific) != 1. Using NULL or NA is a little clearer to a user who just takes a quick look at the function header, rather than carefully reading the man page, to find what parameters are needed. NA is logical, NULL is NULL. So in format.default, there could be a test is.logical(scientific) which will default to TRUE. So generally my advice would be: - Be consistent with similar existing functions. - Choose what you think will be convenient in current and predicted future versions of your function. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] grep function with patterns list...
Thx for the hint, but what would I have used if b,c and d were values of a dataframe for instance? Stéphane. Gabor Grothendieck a écrit : Try this: grep(b|c|d, letters, value = TRUE) [1] b c d On 10/16/06, Stéphane CRUVEILLER [EMAIL PROTECTED] wrote: Dear R-users, is there a way to pass a list of patterns to the grep function? I vaguely remember something with %in% operator... Thanks, Stéphane. -- La science a certes quelques magnifiques réussites à son actif mais à tout prendre, je préfère de loin être heureux plutôt qu'avoir raison. D. Adams -- AGC website http://www.genoscope.cns.fr/agc Stéphane CRUVEILLER Ph. D. Genoscope - Centre National de Séquencage Atelier de Génomique Comparative 2, Rue Gaston Cremieux CP 5706 91057 Evry Cedex - France Phone: +33 (0)1 60 87 84 58 Fax: +33 (0)1 60 87 25 14 [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. -- La science a certes quelques magnifiques réussites à son actif mais à tout prendre, je préfère de loin être heureux plutôt qu'avoir raison. D. Adams -- AGC website http://www.genoscope.cns.fr/agc Stéphane CRUVEILLER Ph. D. Genoscope - Centre National de Séquencage Atelier de Génomique Comparative 2, Rue Gaston Cremieux CP 5706 91057 Evry Cedex - France Phone: +33 (0)1 60 87 84 58 Fax: +33 (0)1 60 87 25 14 [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] help with plot()
Hi, I am new to R and I have been trying it out. I ran into a problem with the plot() function. Below is my code: d - read.table(c:/test/sp.txt,header=0) spval - d[,2] plot(spval,type=l) Warning messages: 1: graphical parameter type is obsolete in: plot.window(xlim, ylim, log, asp, ...) 2: graphical parameter type is obsolete in: axis(side, at, labels, tick, line, pos, outer, font, lty, lwd, 3: graphical parameter type is obsolete in: title(main, sub, xlab, ylab, line, outer, ...) 4: graphical parameter type is obsolete in: axis(side, at, labels, tick, line, pos, outer, font, lty, lwd, I tried to plot a line graph from a text file with two columns. Some how R won't plot the data as lines, and it kept giving me the same warning: type is obsolete. What does this mean? Am I doing something wrong, or is the parameter really obsolete, or do I need install some package? Thanks, Tom [[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] Sweave, R and complex latex projects
On 16 October 2006 at 11:28, Friedrich Leisch wrote: | On Sat, 14 Oct 2006 16:04:50 -0700, | Deepayan Sarkar (DS) wrote: | | | |%.tex: %.Rnw |echo library(tools); Sweave('$') | ${R_PROG} --vanilla --silent | | Note that we now have R CMD Sweave (new in R 2.4.0) for this purpose. It would have been nice if that followed convention and responded to --help as suggested by 'R --help': [EMAIL PROTECTED]:~$ R --help | tail -5 Please use 'R CMD command --help' to obtain further information about the usage of 'command'. Report bugs to [EMAIL PROTECTED]. [EMAIL PROTECTED]:~$ yet what we get is an error: [EMAIL PROTECTED]:~$ R CMD Sweave --help library(utils); Sweave(--help) Writing to file --help.tex Processing code chunks ... Error in SweaveReadFile(file, syntax) : no Sweave file with name '--help' found Execution halted [EMAIL PROTECTED]:~$ On the other hand: [EMAIL PROTECTED]:~$ R CMD INSTALL --help | head -2 Usage: R CMD INSTALL [options] pkgs [EMAIL PROTECTED]:~$ R --version R version 2.4.0 (2006-10-03) Copyright (C) 2006 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under the terms of the GNU General Public License. For more information about these matters, see http://www.gnu.org/copyleft/gpl.html. [EMAIL PROTECTED]:~$ Dirk -- Hell, there are no rules here - we're trying to accomplish something. -- Thomas A. Edison __ 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] grep function with patterns list...
Ooops sorry for html tags... Just forgot to edit the message before sending it... So back to my question: Thx for the hint, but what would I have used if b,c and d were values of a dataframe for instance? X is for instance a dataframe: X Mypatterns 1 pattern1 2 pattern2 3 pattern3 Y is another dataframe. If I do: grep(X$Mypatterns,Y) this will take into account only the first pattern... I could use a loop but I vaguely remember an elegant trick that combined grep and %in%. Stéphane. __ 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] grep function with patterns list...
DF - data.frame(pat = letters[1:3]) grep(paste(DF$pat, collapse = |), letters, value = TRUE) [1] a b c On 10/16/06, Stéphane CRUVEILLER [EMAIL PROTECTED] wrote: Ooops sorry for html tags... Just forgot to edit the message before sending it... So back to my question: Thx for the hint, but what would I have used if b,c and d were values of a dataframe for instance? X is for instance a dataframe: X Mypatterns 1 pattern1 2 pattern2 3 pattern3 Y is another dataframe. If I do: grep(X$Mypatterns,Y) this will take into account only the first pattern... I could use a loop but I vaguely remember an elegant trick that combined grep and %in%. Stéphane. __ 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 : Generate a random bistochastic matrix
Thanks, I tried someting like this, but computation takes times for large matrices btransf-function(y,X=length(y)^4){ N-length(y) bm-matrix(rep(1/N,N^2),N,N) for(j in 1:X){ coord-sample(1:N,4,replace=T) d- runif(1,0,min(bm[coord[1],coord[2]],bm[coord[3],coord[4]])) bm[coord[1],coord[2]]-bm[coord[1],coord[2]]-d bm[coord[3],coord[4]]-bm[coord[3],coord[4]]-d bm[coord[1],coord[4]]-bm[coord[1],coord[4]]+d bm[coord[2],coord[3]]-bm[coord[2],coord[3]]+d} y.btransf-bm%*%y y.btransf-y.btransf+(mean(y)-mean(y.btransf)) as.vector(y.btransf)} the fonction is designed to perform a mean-preserving transformation of a vector. - Message d'origine De : Richard M. Heiberger [EMAIL PROTECTED] À : Florent Bresson [EMAIL PROTECTED]; r-help@stat.math.ethz.ch Envoyé le : Lundi, 16 Octobre 2006, 14h58mn 13s Objet : Re: [R] Generate a random bistochastic matrix bistochastic.3x3 - function() { B - matrix(0, 3, 3) ## 2 df tmp.1 - runif(3) B[1,] - tmp.1/sum(tmp.1) ## 1 df tmp.2 - runif(2) B[2:3, 1] - (1-B[1,1]) * tmp.2/sum(tmp.2) ## 1 df B[2, 2] - runif(1, max=min(1-B[1,2], 1-B[2,1])) ## Fill in the rest B[2,3] - 1-sum(B[2, 1:2]) B[3,2] - 1-sum(B[1:2, 2]) B[3,3] - 1-sum(B[1:2, 3]) B } B - bistochastic.3x3() apply(B, 1, sum) apply(B, 2, sum) To extend this to larger than 3x3 requires the same kind of conditional generation of alternating rows and columns of the matrix. The hard part is the extension of the two-way conditioning I illustrated in the B[2, 2] line. 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] help with plot()
It's possible the problem is with your data; could you provide some sample data with which we can reproduce the error? On 16/10/06, tom soyer [EMAIL PROTECTED] wrote: Hi, I am new to R and I have been trying it out. I ran into a problem with the plot() function. Below is my code: d - read.table(c:/test/sp.txt,header=0) spval - d[,2] plot(spval,type=l) Warning messages: 1: graphical parameter type is obsolete in: plot.window(xlim, ylim, log, asp, ...) 2: graphical parameter type is obsolete in: axis(side, at, labels, tick, line, pos, outer, font, lty, lwd, 3: graphical parameter type is obsolete in: title(main, sub, xlab, ylab, line, outer, ...) 4: graphical parameter type is obsolete in: axis(side, at, labels, tick, line, pos, outer, font, lty, lwd, I tried to plot a line graph from a text file with two columns. Some how R won't plot the data as lines, and it kept giving me the same warning: type is obsolete. What does this mean? Am I doing something wrong, or is the parameter really obsolete, or do I need install some package? Thanks, Tom [[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. -- = 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] help with plot()
On 10/16/2006 9:44 AM, tom soyer wrote: Hi, I am new to R and I have been trying it out. I ran into a problem with the plot() function. Below is my code: d - read.table(c:/test/sp.txt,header=0) spval - d[,2] plot(spval,type=l) Warning messages: 1: graphical parameter type is obsolete in: plot.window(xlim, ylim, log, asp, ...) 2: graphical parameter type is obsolete in: axis(side, at, labels, tick, line, pos, outer, font, lty, lwd, 3: graphical parameter type is obsolete in: title(main, sub, xlab, ylab, line, outer, ...) 4: graphical parameter type is obsolete in: axis(side, at, labels, tick, line, pos, outer, font, lty, lwd, I tried to plot a line graph from a text file with two columns. Some how R won't plot the data as lines, and it kept giving me the same warning: type is obsolete. What does this mean? Am I doing something wrong, or is the parameter really obsolete, or do I need install some package? I wouldn't expect to see those messages, but you don't tell us what version of R you're using, on what platform, and don't tell us what spval looks like. I'm guessing that spval is a factor. Plotting a factor will plot a bar plot of the counts of the levels; it doesn't make sense to ask for type=l. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] The old question: R vs MATLAB vs Mathematica vs ...
Ali - saveez at hotmail.com writes: R introduces itself as a 'statistical' language and environment. There are many discussions about comparing R to MATLAB or mathematica (or other similar software). It seems to me that these other software have a broader range of applications. For example, in Mathematica one can solve a partial differential equation numberically or do image processing, or, one can connect a data acquisition card to MATLAB to acquire data from a measurement and analyse the results. - Does R already provide such facilities? some ... RSiteSearch(image analysis) http://finzi.psych.upenn.edu/R/Rhelp02a/archive/69200.html RSiteSearch(PDE) -- suggests not much in the way of numeric PDE solutions RSiteSearch(data acquisition) -- suggests not much (but see http://finzi.psych.upenn.edu/R/Rhelp02a/archive/81317.html ) - Was R design to be merely a statistical tool or was it designed with an idea of a general mathematical tool in mind? It was designed as a language and environment for statistical computing and graphics. However, since it provides interfaces to routines written in other languages (Tcl/Tk, C, Fortran, ...) and other programs (databases, GIS, etc.), it can do lots of other things. - If the answer to the above is no, can R already be extended to include the missing features simply by extra packages yes. or does it need some rational [???] changes to support these features? no. You should think about why you want to extend R in these ways. If you already have access to Mathematica/MATLAB and are happy with their capabilities, you should just use them. Perhaps you can't afford them; are there other free/open tools that do what you want? If so, you should think about using them, or perhaps writing interfaces between them and R. cheers Ben Bolker __ 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 : Generate a random bistochastic matrix
I am sorry, I can't figure out what your function is doing. Why do you have N^4 in the argument? A matrix should have N rows and N columns, that is, it should have length N^2. The function returns a vector, not a matrix. There is no example of its use. I am guessing that your function somewhere uses a bistochastic matrix as an intermediate calculation. I recommend isolating the bistochastic matrix function from the larger function that you have constructed. 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] overlapping intervals
Here is a more general way that looks for the transitions: series1-cbind(Start=c(10,21,40,300),End=c(20,26,70,350)) series2-cbind(Start=c(25,60,210,500),End=c(40,100,400,1000)) x - rbind(series1, series2) # create +1 for start and -1 for end x.s - rbind(cbind(x[,1], 1), cbind(x[,2], -1)) #sort by start times x.s - x.s[order(x.s[,1]),] # cumsum is a count of the transitions x.s - cbind(x.s, cumsum(x.s[,2])) # c(1,2) is start and c(-1,1) is the end of an overlap cbind(x.s[x.s[,2] == 1 x.s[,3] == 2, 1], x.s[x.s[,2] == -1 x.s[,3] == 1, 1]) [,1] [,2] [1,] 25 26 [2,] 40 40 [3,] 60 70 [4,] 300 350 On 10/15/06, Giovanni Coppola [EMAIL PROTECTED] wrote: Hello everybody, I have two series of intervals, and I'd like to output the shared regions. For example: series1-cbind(Start=c(10,21,40,300),End=c(20,26,70,350)) series2-cbind(Start=c(25,60,210,500),End=c(40,100,400,1000)) series1 Start End [1,]10 20 [2,]21 26 [3,]40 70 [4,] 300 350 series2 Start End [1,]25 40 [2,]60 100 [3,] 210 400 [4,] 500 1000 I'd like to have something like this as result: shared Start End [1,]25 26 [2,]60 70 [3,] 300 350 I found this post, but the solution finds the regions shared across all the intervals. http://finzi.psych.upenn.edu/R/Rhelp02a/archive/59594.html Can anybody help me with this? Thanks Giovanni __ 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? __ 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] The old question: R vs MATLAB vs...: image analysis
For image analysis and general image processing in R, please check EBImage from bioconductor (www.bioconductor.org). Best, Oleg Ben Bolker wrote: Ali - saveez at hotmail.com writes: R introduces itself as a 'statistical' language and environment. There are many discussions about comparing R to MATLAB or mathematica (or other similar software). It seems to me that these other software have a broader range of applications. For example, in Mathematica one can solve a partial differential equation numberically or do image processing, or, one can connect a data acquisition card to MATLAB to acquire data from a measurement and analyse the results. - Does R already provide such facilities? some ... RSiteSearch(image analysis) http://finzi.psych.upenn.edu/R/Rhelp02a/archive/69200.html RSiteSearch(PDE) -- suggests not much in the way of numeric PDE solutions RSiteSearch(data acquisition) -- suggests not much (but see http://finzi.psych.upenn.edu/R/Rhelp02a/archive/81317.html ) - Was R design to be merely a statistical tool or was it designed with an idea of a general mathematical tool in mind? It was designed as a language and environment for statistical computing and graphics. However, since it provides interfaces to routines written in other languages (Tcl/Tk, C, Fortran, ...) and other programs (databases, GIS, etc.), it can do lots of other things. - If the answer to the above is no, can R already be extended to include the missing features simply by extra packages yes. or does it need some rational [???] changes to support these features? no. You should think about why you want to extend R in these ways. If you already have access to Mathematica/MATLAB and are happy with their capabilities, you should just use them. Perhaps you can't afford them; are there other free/open tools that do what you want? If so, you should think about using them, or perhaps writing interfaces between them and R. cheers Ben Bolker __ 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 Oleg Sklyar * EBI/EMBL, Cambridge CB10 1SD, England * +44-1223-494466 __ 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] Lmer, heteroscedasticity and permutation
Hi everybody, I'm trying to analyse a set of data with a non-normal response, 2 fixed effects and 1 nested random effect with strong heteroscedasticity in the model. I planned to use the function lmer : lmer(resp~var1*var2 + (1|rand)) and then use permutations based on the t-statistic given by lmer to get p-values. 1/ Is it a correct way to obtain p-values for my variables ? 2/ I read somewhere that lme is more adequate when heteroscedasticity is strong. Do I have to use lme instead of lmer ? 3/ It is possible to fit a glm in lmer using family= Is it possible to use it in spite of hard heteroscedasticity ? 4/ A last question concerning SAS. My model appears to not converge in SAS, indicating a structure in the variance. Is it implying something in lmer or lme ? Many Thanks -- Alan Juilland -- Alan Juilland – PhD Student Department of Ecology and Evolution Biophore, University of Lausanne 1015 Dorigny Switzerland Tel : ++41 21 692 41 74 Fax : +41 21 692 41 65 __ 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] Generate a random bistochastic matrix
you can try something like the following: B - 10 N - 5 mats - r2dtable(B, rep(1, N), rep(1, N)) out - matrix(0, N, N) for(i in 1:length(mats)) out - out + mats[[i]] out - out / B out colSums(out) rowSums(out) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Florent Bresson [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Monday, October 16, 2006 10:22 AM Subject: [R] Generate a random bistochastic matrix Please, I would like to generate a random bistochastic matrix, that is a squared matrix of non-negative numbers with each row and each column sum to 1, for example : .2.3.5 .6.3.1 .2 .4 .4 I don't know of to code this. Do you have any idea ? Thanks Florent Bresson ___ __ 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. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ 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 : Generate a random bistochastic matrix
A simpler approach --- as in similar problems --- is to use an iterative solution which works quite fast for any 'n'. Interestingly, the number of necessary iterations seems to *decrease* for increasing 'n' : bistochMat - function(n, tol = 1e-7, maxit = 1000) { ## Purpose: Random bistochastic *square* matrix (M_{ij}): ## M_{ij} = 0; sum_i M_{ij} = sum_j M_{ij} = 1 (for all i, j) ## -- ## Arguments: n: (n * n) matrix dimension; ## -- ## Author: Martin Maechler, Date: 16 Oct 2006, 14:47 stopifnot(maxit = 1, tol = 0) M - matrix(runif(n*n), n,n) for(i in 1:maxit) { M - M / outer((rM - rowSums(M)), (cM - colSums(M))) * sum(rM) / n if(all(abs(c(rM,cM) - 1) tol)) break } ## cat(needed, i, iterations\n) ## or rather attr(M, iter) - i M } attr(M - bistochMat(70), iter) ## typically: ## [1] 8 attr(M - bistochMat(10), iter) ## - 13, 16, 15, 17, ... set.seed(101) ; attr(M - bistochMat(10), iter) ## 15 set.seed(101) ; attr(M - bistochMat(10, tol = 1e-15), iter)## 32 Initially, I tried to solve the general [ n x m ] case. It seems that needs a slightly smarter bias correction instead of just 'sum(M) / n'. If someone figures that out, please post your solution! Regards, Martin Maechler, ETH Zurich __ 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] generate random numbers that sum up to 1
So, Alberto, you didn't see my post? If Y has d independent components that are gamma distributed with common rate and shapes A_1, A_2, ..., A_d, then X, given by the components of Y divided by their sum has distribution Dirichlet(A_1, A_2, ..., A_d). If you want Uniform on the d-simplex, then use A_1 = A_2 = ... = A_d = 1 (just as Duncan said) original message: Duncan Murdoch's definition is _the_ only one that I know. X is Uniform on A means E phi(X) = \int_A phi(x) dx / \int_A dx, so that the probability density is equal to 1/ \int_A dx everwhere on the set A. By the way, another way to simulate X ~ Dirichlet(A1, A2, ..., Ad) is to generate d independent gamma variables having equal rate parameter (doesn't matter, so why not 1) and shape parameters A1, A2, ..., Ad Then the vector of components divided by their sum is the desired Dirichlet: n - 10 d - 3 # for three numbers that add to one ( the unit simplex in R^3) A - rep(1, 3) # for uniform X - matrix(0, n, d) for (k in 1:3) X[,k] - rgamma(n, shape=A[k], rate=1) S - X %*% rep(1, d) Y - X/S Present example will simulate n independant 3 vectors, each having non-negative components summing to 1, and having a distribution assigning equal mass to every possible value. Changing d and the components of A will provide an arbitrary Dirichlet on the unit simplex in R^d Grant Izmirlian NCI Duncan Murdoch wrote Another definition of uniform is to have equal density for all possible vectors; the Dirichlet distribution with parameters (1,1,1) would give you that. __ 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 : Re : Generate a random bistochastic matrix
Yes, you're right. In fact, it's just an adaptation of a matlab command and the author advises using N^4 replications that's why it's the default in the function. The bistochastic matrix is not my subject of interest, but I need it to perform some random tranformation of a vector of incomes. Florent Bresson - Message d'origine De : Richard M. Heiberger [EMAIL PROTECTED] À : Florent Bresson [EMAIL PROTECTED]; r-help@stat.math.ethz.ch Envoyé le : Lundi, 16 Octobre 2006, 16h23mn 39s Objet : Re: Re : [R] Generate a random bistochastic matrix I am sorry, I can't figure out what your function is doing. Why do you have N^4 in the argument? A matrix should have N rows and N columns, that is, it should have length N^2. The function returns a vector, not a matrix. There is no example of its use. I am guessing that your function somewhere uses a bistochastic matrix as an intermediate calculation. I recommend isolating the bistochastic matrix function from the larger function that you have constructed. 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] Re : Generate a random bistochastic matrix
Thanks, I think it's a shrewd solution, but the problem is that it cannot generate every N*N bistochastic matrix and every cell tends to 1/N as B tends to infinity Florent Bresson - Message d'origine De : Dimitris Rizopoulos [EMAIL PROTECTED] À : Florent Bresson [EMAIL PROTECTED] Cc : r-help@stat.math.ethz.ch Envoyé le : Lundi, 16 Octobre 2006, 16h35mn 02s Objet : Re: [R] Generate a random bistochastic matrix you can try something like the following: B - 10 N - 5 mats - r2dtable(B, rep(1, N), rep(1, N)) out - matrix(0, N, N) for(i in 1:length(mats)) out - out + mats[[i]] out - out / B out colSums(out) rowSums(out) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Florent Bresson [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Monday, October 16, 2006 10:22 AM Subject: [R] Generate a random bistochastic matrix Please, I would like to generate a random bistochastic matrix, that is a squared matrix of non-negative numbers with each row and each column sum to 1, for example : .2.3.5 .6.3.1 .2 .4 .4 I don't know of to code this. Do you have any idea ? Thanks Florent Bresson ___ __ 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. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ 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 : Re : Generate a random bistochastic matrix
Thanks, it's perfect for my needs. - Message d'origine De : Martin Maechler [EMAIL PROTECTED] À : Florent Bresson [EMAIL PROTECTED] Cc : Richard M. Heiberger [EMAIL PROTECTED]; r-help@stat.math.ethz.ch Envoyé le : Lundi, 16 Octobre 2006, 16h29mn 47s Objet : Re: [R] Re : Generate a random bistochastic matrix A simpler approach --- as in similar problems --- is to use an iterative solution which works quite fast for any 'n'. Interestingly, the number of necessary iterations seems to *decrease* for increasing 'n' : bistochMat - function(n, tol = 1e-7, maxit = 1000) { ## Purpose: Random bistochastic *square* matrix (M_{ij}): ##M_{ij} = 0; sum_i M_{ij} = sum_j M_{ij} = 1 (for all i, j) ## -- ## Arguments: n: (n * n) matrix dimension; ## -- ## Author: Martin Maechler, Date: 16 Oct 2006, 14:47 stopifnot(maxit = 1, tol = 0) M - matrix(runif(n*n), n,n) for(i in 1:maxit) { M - M / outer((rM - rowSums(M)), (cM - colSums(M))) * sum(rM) / n if(all(abs(c(rM,cM) - 1) tol)) break } ## cat(needed, i, iterations\n) ## or rather attr(M, iter) - i M } attr(M - bistochMat(70), iter) ## typically: ## [1] 8 attr(M - bistochMat(10), iter) ## - 13, 16, 15, 17, ... set.seed(101) ; attr(M - bistochMat(10), iter) ## 15 set.seed(101) ; attr(M - bistochMat(10, tol = 1e-15), iter)## 32 Initially, I tried to solve the general [ n x m ] case. It seems that needs a slightly smarter bias correction instead of just 'sum(M) / n'. If someone figures that out, please post your solution! Regards, Martin Maechler, ETH Zurich __ 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] generate random numbers that sum up to 1
Grant Izmirlian wrote: So, Alberto, you didn't see my post? I think I didn't - but you are demanding too much from my memory; I can hardly remember what I saw yesterday! If Y has d independent components that are gamma distributed with common rate and shapes A_1, A_2, ..., A_d, then X, given by the components of Y divided by their sum has distribution Dirichlet(A_1, A_2, ..., A_d). If you want Uniform on the d-simplex, then use A_1 = A_2 = ... = A_d = 1 (just as Duncan said) The problem is that I wasn't aware that this was the Dirichlet distribution [R does not have this distribution, AFAIK, but I should have consulted the Borg of All Wisdom, the Wikipedia]. 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.
[R] Install RMySQL with R 2.4.0
I just installed RMySQL 0.5-9 with R 2.4.0 on Windows XP and got the following error message when trying to run a script with RMySQL: Error in library(RMySQL) : 'RMySQL' is not a valid package -- installed 2.0.0? Any ideas? Thanks, Frank __ 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 plot()
Hi David and Duncan, Thanks for the reply. I am using R-2.4.0 for windows. All I am trying to do is follow an online tutorial ( http://www.onlamp.com/pub/a/onlamp/2005/11/17/r_for_statistics.html) step by step. spval is just an array of numbers. I also tried using type=1 instead of l, but got same warning message and the same bar graph. Are there any packages that I should have installed? I haven't installed any contributed package, only the base distribution. Thanks, Tom On 10/16/06, David Barron [EMAIL PROTECTED] wrote: It's possible the problem is with your data; could you provide some sample data with which we can reproduce the error? On 16/10/06, tom soyer [EMAIL PROTECTED] wrote: Hi, I am new to R and I have been trying it out. I ran into a problem with the plot() function. Below is my code: d - read.table(c:/test/sp.txt,header=0) spval - d[,2] plot(spval,type=l) Warning messages: 1: graphical parameter type is obsolete in: plot.window(xlim, ylim, log, asp, ...) 2: graphical parameter type is obsolete in: axis(side, at, labels, tick, line, pos, outer, font, lty, lwd, 3: graphical parameter type is obsolete in: title(main, sub, xlab, ylab, line, outer, ...) 4: graphical parameter type is obsolete in: axis(side, at, labels, tick, line, pos, outer, font, lty, lwd, I tried to plot a line graph from a text file with two columns. Some how R won't plot the data as lines, and it kept giving me the same warning: type is obsolete. What does this mean? Am I doing something wrong, or is the parameter really obsolete, or do I need install some package? Thanks, Tom [[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. -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP [[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] Re : Generate a random bistochastic matrix
I don't think this idea has been suggested yet: (1) Form all n! n x n permutation matrices, say M_1, ..., M_K, K = n!. (2) Generate K independent uniform variates x_1, ..., x_k. (3) Renormalize these to sum to 1, x - x/sum(x) (4) Form the convex combination M = x_1*M_1 + ... + x_K*M_K M is a ``random'' doubly stochastic matrix. The point is that the set of all doubly stochastic matrices is a convex set in n^2-dimensional space, and the extreme points are the permutation matrices. I.e. the set of all doubly stochastic matrices is the convex hull of the the permuation matrices. The resulting M will *not* be uniformly distributed on this convex hull. If you want a uniform distribution something more is required. It might be possible to effect uniformity of the distribution, but my guess is that it would be a hard problem. cheers, Rolf Turner [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] Interval pls
RSiteSearch(interval pls) produced 7 hits for me just now. I didn't study all of them carefully, but I doubt if any one of them have exactly what you want. One could also search for pls with ordered factors, but I didn't try that. However, I doubt if it would be excessively difficult to write a wrapper for appropriate functions in the 'pls' packages to do what you want. With the 'interval' variables as a potentially explanatory variable rather than a response variable, one could start by replacing ordered factors by contrasts, then adjusting the coding for intermediate levels iteratively until either (a) intermediate levels were collapsed because the model would otherwise reverse them or (b) the coefficients of nonlinear terms were all zero. Something similar could be done if an 'interval' variable was a response variable, with the goal of maximizing R2. Something similar could be done using the 'sem' package, but the 'sem' function seems to require a moment or covariance matrix as an input, which might make the wrapper somewhat more complex, I think. With 'sem' one could adjust the levels for an ordered response variable to minimize BIC, rather than maximizing R2. This latter seems to me to be somewhat more satisfying and solid theoretically, but others may not agree. Of course, whatever I did in this regard, I'd want to also accompany the effort with a more careful literature search. Hope this helps. Spencer Graves Dirk De Becker wrote: Hey R-helpers, Does anybody know of an implementation of interval PLS in R? Thx, Dirk __ 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 : Re : Generate a random bistochastic matrix
Yes, I would like every generated matrix to be drawn from a uniform distribution. Martin Maechler's solution was interesting but when I compute the product of the obtained matrix with any N-vector Y, the resulting vector is most of the time quite close to a vector like mean(Y)*rep(1,N). Florent Bresson - Message d'origine De : Rolf Turner [EMAIL PROTECTED] À : [EMAIL PROTECTED] Cc : r-help@stat.math.ethz.ch Envoyé le : Lundi, 16 Octobre 2006, 17h50mn 24s Objet : Re: [R] Re : Generate a random bistochastic matrix I don't think this idea has been suggested yet: (1) Form all n! n x n permutation matrices, say M_1, ..., M_K, K = n!. (2) Generate K independent uniform variates x_1, ..., x_k. (3) Renormalize these to sum to 1, x - x/sum(x) (4) Form the convex combination M = x_1*M_1 + ... + x_K*M_K M is a ``random'' doubly stochastic matrix. The point is that the set of all doubly stochastic matrices is a convex set in n^2-dimensional space, and the extreme points are the permutation matrices. I.e. the set of all doubly stochastic matrices is the convex hull of the the permuation matrices. The resulting M will *not* be uniformly distributed on this convex hull. If you want a uniform distribution something more is required. It might be possible to effect uniformity of the distribution, but my guess is that it would be a hard problem. cheers, Rolf Turner [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] help with plot()
Tom, If your text file, 'sp.txt' contains the headers used on that web page, then your read.table() function call is incorrect. Your call below presently has 'header = 0'. Use TRUE/FALSE for easier reading of code. The tutorial seems to be inconsistent with that. If your text file contains the 'Date' and 'SP500' column headers, then your SP500 data column is going to be read in as a character variable, as R will see the first entry of 'SP500' as a character value, not as a column header. This column in turn, will be coerced to a factor, resulting in the errors you are seeing, as plot.factor() will be used. You should be using: d - read.table(c:/test/sp.txt, header = TRUE) Use: str(d) to review the current structure of your data frame. That should give you some hints. HTH, Marc Schwartz On Mon, 2006-10-16 at 10:54 -0500, tom soyer wrote: Hi David and Duncan, Thanks for the reply. I am using R-2.4.0 for windows. All I am trying to do is follow an online tutorial ( http://www.onlamp.com/pub/a/onlamp/2005/11/17/r_for_statistics.html) step by step. spval is just an array of numbers. I also tried using type=1 instead of l, but got same warning message and the same bar graph. Are there any packages that I should have installed? I haven't installed any contributed package, only the base distribution. Thanks, Tom On 10/16/06, David Barron [EMAIL PROTECTED] wrote: It's possible the problem is with your data; could you provide some sample data with which we can reproduce the error? On 16/10/06, tom soyer [EMAIL PROTECTED] wrote: Hi, I am new to R and I have been trying it out. I ran into a problem with the plot() function. Below is my code: d - read.table(c:/test/sp.txt,header=0) spval - d[,2] plot(spval,type=l) Warning messages: 1: graphical parameter type is obsolete in: plot.window(xlim, ylim, log, asp, ...) 2: graphical parameter type is obsolete in: axis(side, at, labels, tick, line, pos, outer, font, lty, lwd, 3: graphical parameter type is obsolete in: title(main, sub, xlab, ylab, line, outer, ...) 4: graphical parameter type is obsolete in: axis(side, at, labels, tick, line, pos, outer, font, lty, lwd, I tried to plot a line graph from a text file with two columns. Some how R won't plot the data as lines, and it kept giving me the same warning: type is obsolete. What does this mean? Am I doing something wrong, or is the parameter really obsolete, or do I need install some package? Thanks, Tom __ 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 : Generate a random bistochastic matrix
On 10/16/2006 11:50 AM, Rolf Turner wrote: I don't think this idea has been suggested yet: (1) Form all n! n x n permutation matrices, say M_1, ..., M_K, K = n!. (2) Generate K independent uniform variates x_1, ..., x_k. (3) Renormalize these to sum to 1, x - x/sum(x) (4) Form the convex combination M = x_1*M_1 + ... + x_K*M_K M is a ``random'' doubly stochastic matrix. The point is that the set of all doubly stochastic matrices is a convex set in n^2-dimensional space, and the extreme points are the permutation matrices. I.e. the set of all doubly stochastic matrices is the convex hull of the the permuation matrices. The resulting M will *not* be uniformly distributed on this convex hull. If you want a uniform distribution something more is required. It might be possible to effect uniformity of the distribution, but my guess is that it would be a hard problem. But using your solution a Markov chain converging to the uniform distribution would be easy: Start at a bistochastic matrix X, e.g. at a permutation matrix drawn at random, or at constant 1/n, or whatever. Choose a direction D at random by drawing two permutation matrices and taking the difference. Calculate the range of scalar lambda such that X + lambda*D remains stochastic (no negatives, no values greater than 1). Draw lambda uniformly on this range, and move there. This is a hit-and-run sampler. I suspect it would mix pretty rapidly. I'd guess a Propp-Wilson perfect version would be fairly easy to put together. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sweave, R and complex latex projects
Friedrich Leisch wrote: On Sat, 14 Oct 2006 23:00:27 +0100, Mark Wardle (MW) wrote: Hello all, ... Yes, simply set prefix.string to a path, not only a filename. E.g., ... Many thanks for everyone's help on this (both on and off list). Working perfectly now! Now I just need help with ! Only joking, although it will only be a matter of time! Best wishes, Mark __ 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] lda
I'm trying to do a linear discriminant analysis on a dataset of three classes (Affinities), using the MASS library: data.frame2 - na.omit(data.frame1) data.ld = lda(AFFINITY ~ ., data.frame2, prior = c(1,1,1)/3) Error in var(x - group.means[g, ]) : missing observations in cov/cor What does this error message mean and how can I get rid of it? Thanks! Pieter __ 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] MLE Methods
Greetings Forum, I am new to R and and writing in hopes of getting some help. Our MLE results from a home grown software do not match with that of R. We are using a censored sample and will really appreciate if you could give us any pointers as to which MLE method is used in R... to my knowledge there are different flavors of MLE used. Thanks in Advance... - Get your email and more, right on the new Yahoo.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] overlapping intervals
If speed is an issue as in large scale (e.g. genomic) problems, then findInterval is very helpful. See http://finzi.psych.upenn.edu/R/Rhelp02a/archive/60815.html for an example. On Sun, 15 Oct 2006, jim holtman wrote: Not the most efficient and requires integer values (maybe less than 1M). My results show an additional overlap at 40 - start end were the same -- does this count? If not, just delete rows that are the same in both columns. series1-cbind(Start=c(10,21,40,300),End=c(20,26,70,350)) series2-cbind(Start=c(25,60,210,500),End=c(40,100,400,1000)) x1 - x2 - logical(max(series1, series2)) # vector FALSE x1[unlist(mapply(seq, series1[,1], series1[,2]))] - TRUE x2[unlist(mapply(seq, series2[,1], series2[,2]))] - TRUE r - rle(x1 x2) # determine overlaps offset - cumsum(r$lengths) (z - cbind(offset[r$values] - r$lengths[r$values] + 1, offset[r$values])) [,1] [,2] [1,] 25 26 [2,] 40 40 [3,] 60 70 [4,] 300 350 # if you don't like dups for overlaps (@40) z[z[,1] != z[,2],] [,1] [,2] [1,] 25 26 [2,] 60 70 [3,] 300 350 On 10/15/06, Giovanni Coppola [EMAIL PROTECTED] wrote: Hello everybody, I have two series of intervals, and I'd like to output the shared regions. For example: series1-cbind(Start=c(10,21,40,300),End=c(20,26,70,350)) series2-cbind(Start=c(25,60,210,500),End=c(40,100,400,1000)) series1 Start End [1,]10 20 [2,]21 26 [3,]40 70 [4,] 300 350 series2 Start End [1,]25 40 [2,]60 100 [3,] 210 400 [4,] 500 1000 I'd like to have something like this as result: shared Start End [1,]25 26 [2,]60 70 [3,] 300 350 I found this post, but the solution finds the regions shared across all the intervals. http://finzi.psych.upenn.edu/R/Rhelp02a/archive/59594.html Can anybody help me with this? Thanks Giovanni __ 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? __ 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] NULL or NA for missing function arguments?
2006/10/16, Duncan Murdoch [EMAIL PROTECTED]: As Gabor said, the third way is to give no default, but test missing() in the code. I forgot this one, thank you. In my case it is probably not suited as I just pass the arguments to a C (Pascal) function and do the checking there. [explanations snipped] So generally my advice would be: - Be consistent with similar existing functions. - Choose what you think will be convenient in current and predicted future versions of your function. Ok, thank you. - Until now I always used NA but will (apart from your advice) prefer NULL from now on. In C (Pascal) code NULL is also easier to check than NA* Thanks again and best regards, Hans-Peter Suter -- * function riIsNull( _s: pSExp ): aRBoolean; cdecl; vs. function IsNaScalar( _x: pSExp ): boolean; begin result:= (riLength( _x ) = 1) and (riTypeOf( _x ) in [setLglSxp, setRealSxp]) and (rIsNa( riReal( riCoerceVector( _x, setRealSxp ) )[0] ) 0); end; __ 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] NULL or NA for missing function arguments?
On 10/16/06, Hans-Peter [EMAIL PROTECTED] wrote: 2006/10/16, Duncan Murdoch [EMAIL PROTECTED]: As Gabor said, the third way is to give no default, but test missing() in the code. I forgot this one, thank you. In my case it is probably not suited as I just pass the arguments to a C (Pascal) function and do the checking there. The R interface need not be identical to the C or Pascal interface. Its pretty easy to convert making use of the fact that a nonexistent else leg returns NULL: f - function(x) { x - if (!missing(x)) x; x } f() # NULL __ 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] plots: layout + subtitles
Hello, I want to create a figure that consists of a collection of 16 graphs on 4 rows. I am using nf - layout(matrix(seq(1,16), 4,4, byrow=TRUE), respect=TRUE) boxplot(... to create the layout of my 16 graphs. It works really well. However, I'd like to add sub-titles that would apply to each row of 4 graphs. More specifically, I'd like to have something like: subtitle 1 (centered) graph 1 graph 2 graph 3 graph 4 subtitle 2 (centered) graph 5 graph 6 graph 7 graph 8 subtitle 3 (centered) graph 9 graph 10 graph 11 graph 12 subtitle 4 (centered) graph 13 graph 14 graph 15 graph 16 in the same figure, to be saved as a ps file. Can somebody help? I hope this question is not redundant, but I have not found information on this on the R mailing lists. I use R 2.3.1 on Linux FC5. Thank you in advance. Marie-Pierre Sylvestre PhD student, McGill University __ 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] Misunderstanding escape (backslash)
Forgive my ignorance, but shouldn't '\\' be converted into '\' in my string? In my output (below), you can see that '\\' remains '\\'. term = mother\'s day term [1] mother's day term = mother\\\'s day term [1] mother\\'s day --- should be mother\'s day Thanks, Frank __ 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
Hello everyone: I am using the following code to draw my barplot but it has two problems. BL-c(1.97,8.04,2.54,10.53,4.85,1.73) LR-c(0.85,0.86,8.33,04.18,6.26,2.40) Q-c(0.00,0.00,1.92,01.92,4.48,0.00) cols - ifelse(Q!=0, orange, green) Graph- barplot(LR, main='LR Value',col=cols, border='black', space=0.05, width=(BL), xlab='Length', ylab='LR block',mar=c(5,1,4,2)) axis(1, at=Graph, sprintf('%0.2f',BL)) mtext(1, at=Graph, text=ifelse(Q!=0, sprintf('%0.2f',Q), ), line=2) mtext(1, at=par('usr')[1], text='BL', line=1) mtext(1, at=par('usr')[1], text='Var', line=2) abline(h=3.84,col='blue') abline(h=6.64,col='red') text(31,3.84,expression(paste(alpha==5,%)),pos=3) text(31,6.64,expression(paste(alpha==1,%)),pos=3) 1) I don't know how to specify the margins. I have written it in the code but it is not working. 2) I want the value of alph=5% at the right end of the line but it is almost in the left side and sometimes in the right side when I use the same code for drawing another barplot. I appreciate any comments about these problems. Thanks, Mohsen [[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] grep function with patterns list...
Hi Stephane, Stéphane CRUVEILLER scruveil at genoscope.cns.fr writes: is there a way to pass a list of patterns to the grep function? I vaguely remember something with %in% operator... I think you are looking for the %in% and %nin% which are part of Design package, and also in Hmisc library. You have to install and load these packages to access these functions. Anupam. __ 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] Misunderstanding escape (backslash)
On 10/16/06, Frank McCown [EMAIL PROTECTED] wrote: Forgive my ignorance, but shouldn't '\\' be converted into '\' in my string? In my output (below), you can see that '\\' remains '\\'. term = mother\'s day term [1] mother's day term = mother\\\'s day term [1] mother\\'s day --- should be mother\'s day I think this is just a matter of interpetation of the output: strsplit(mother\\'s day, NULL)[[1]] [1] m o t h e r \\ ' s d a y cat(mother\\'s day, \n) mother\'s day nchar(mother\\'s day) [1] 13 __ 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 plot()
Thanks Marc. I followed your suggestion and I got R to plot the correct graph! You are absolutely correct about R switching automatically from plot() to plot.factor(). I had no idea that it would do that. It looks like having the header is very important in R. Appreciate your help very much. On 10/16/06, Marc Schwartz [EMAIL PROTECTED] wrote: Tom, If your text file, 'sp.txt' contains the headers used on that web page, then your read.table() function call is incorrect. Your call below presently has 'header = 0'. Use TRUE/FALSE for easier reading of code. The tutorial seems to be inconsistent with that. If your text file contains the 'Date' and 'SP500' column headers, then your SP500 data column is going to be read in as a character variable, as R will see the first entry of 'SP500' as a character value, not as a column header. This column in turn, will be coerced to a factor, resulting in the errors you are seeing, as plot.factor() will be used. You should be using: d - read.table(c:/test/sp.txt, header = TRUE) Use: str(d) to review the current structure of your data frame. That should give you some hints. HTH, Marc Schwartz On Mon, 2006-10-16 at 10:54 -0500, tom soyer wrote: Hi David and Duncan, Thanks for the reply. I am using R-2.4.0 for windows. All I am trying to do is follow an online tutorial ( http://www.onlamp.com/pub/a/onlamp/2005/11/17/r_for_statistics.html) step by step. spval is just an array of numbers. I also tried using type=1 instead of l, but got same warning message and the same bar graph. Are there any packages that I should have installed? I haven't installed any contributed package, only the base distribution. Thanks, Tom On 10/16/06, David Barron [EMAIL PROTECTED] wrote: It's possible the problem is with your data; could you provide some sample data with which we can reproduce the error? On 16/10/06, tom soyer [EMAIL PROTECTED] wrote: Hi, I am new to R and I have been trying it out. I ran into a problem with the plot() function. Below is my code: d - read.table(c:/test/sp.txt,header=0) spval - d[,2] plot(spval,type=l) Warning messages: 1: graphical parameter type is obsolete in: plot.window(xlim, ylim, log, asp, ...) 2: graphical parameter type is obsolete in: axis(side, at, labels, tick, line, pos, outer, font, lty, lwd, 3: graphical parameter type is obsolete in: title(main, sub, xlab, ylab, line, outer, ...) 4: graphical parameter type is obsolete in: axis(side, at, labels, tick, line, pos, outer, font, lty, lwd, I tried to plot a line graph from a text file with two columns. Some how R won't plot the data as lines, and it kept giving me the same warning: type is obsolete. What does this mean? Am I doing something wrong, or is the parameter really obsolete, or do I need install some package? Thanks, Tom [[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] Misunderstanding escape (backslash)
Gabor Grothendieck [EMAIL PROTECTED] writes: On 10/16/06, Frank McCown [EMAIL PROTECTED] wrote: Forgive my ignorance, but shouldn't '\\' be converted into '\' in my string? In my output (below), you can see that '\\' remains '\\'. term = mother\'s day term [1] mother's day term = mother\\\'s day term [1] mother\\'s day --- should be mother\'s day I think this is just a matter of interpetation of the output: strsplit(mother\\'s day, NULL)[[1]] [1] m o t h e r \\ ' s d a y cat(mother\\'s day, \n) mother\'s day nchar(mother\\'s day) [1] 13 And check out the new FAQ 7.37 http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-does-backslash-behave-strangely-inside-strings_003f -- 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.
[R] generate random numbers that sum up to 1
I found another method to generate this, in the Borg of all Wisdom: http://en.wikipedia.org/wiki/Simplex Alberto Monteiro --- Section Random Sampling: The second method [[the first method is based on the Dirichlet distribution -- avfm]] to generate a random point on the unit simplex is based on the order statistics of the uniform distribution on the unit interval, and was popularized by Horst Kraemer. The algorithm is as follows: Set p0 = 0 and pK=1. Generate K-1 uniform random draws pi from the open interval (0,1). Sort into ascending order the K+1 points p0, ..., pK. The K coordinates t1, ..., tK of the final point on the unit simplex are given by ti=pi-pi-1. It has been pointed out by Smith and Tromble that the second method is technically only valid if none of the differences pi-p(i-1) are equal to zero. In practice, it is sufficient to merely re-run the algorithm to generate a new set of points if this happens. __ 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] Misunderstanding escape (backslash)
And check out the new FAQ 7.37 http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-does-backslash-behave-strangely-inside-strings_003f Thanks, guys, for the help. Frank __ 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] glm cannot find valid starting values
At 16:12 15/10/2006, Ronaldo ReisJunior wrote: Em Sábado 14 Outubro 2006 11:15, Gabor Grothendieck escreveu: Try using OLS starting values: glm(Y~X,family=gaussian(link=log), start = coef(lm(Y~X))) Ok, using a starting value the model work. But, sometimes ago it work without any starting values. Why now I need a starting values? Since this involves a prediction about how a computer will work in the future I would have thought the quote from Samuel Goldwyn in your .sig was helpful. More seriously I think you need to give more detail about when it worked for those more expert than me to tell you what happened. Thanks Ronaldo -- Nunca faça previsões, especialmente sobre o futuro. -- Samuel Goldwyn -- Prof. Ronaldo Reis Júnior | .''`. UNIMONTES/Depto. Biologia Geral/Lab. Ecologia Evolutiva | : :' : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil | `- Fone: (38) 3229-8190 | [EMAIL PROTECTED] | ICQ#: 5692561 | LinuxUser#: 205366 Michael Dewey http://www.aghmed.fsnet.co.uk __ 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] How to solve for parameter in likelihood?
Hi, I want to calculate, for any likelihood function, the value(s) of the parameter of interest that makes the likelihood equal to 1/8-th of the value of the likelihood at the maximum. Say, with the following toy example with a binomial distribution and with interest in p: p-seq(0.01,0.99,by=0.001) n=113 y=28 llbin-y*log(p)+(n-y)*log(1-p) #log-likelihood lbin-exp(llbin) #likelihood rlbin-mat.or.vec(length(p),nc=1) #relative-likelihood for (i in 1:length(p)) { rlbin[i]-lbin[i]/max(lbin) } How do I obtain the value of p such that rlbin=0.125? It doesn't seem to me that I can do this using solve. I can do this rlbinp-cbind(rlbin,p) rlbinp and actually look at the two values of p that make the rlbin go down to 0.125*max(rlbin), but there must be another way. The corresponding function in Octave (and Matlab) is fzero. Thanks in advance, Rubén __ 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] plots: layout + subtitles
Hi Marie-Pierre Sylvestre wrote: Hello, I want to create a figure that consists of a collection of 16 graphs on 4 rows. I am using nf - layout(matrix(seq(1,16), 4,4, byrow=TRUE), respect=TRUE) boxplot(... to create the layout of my 16 graphs. It works really well. However, I'd like to add sub-titles that would apply to each row of 4 graphs. More specifically, I'd like to have something like: subtitle 1 (centered) graph 1 graph 2 graph 3 graph 4 subtitle 2 (centered) graph 5 graph 6 graph 7 graph 8 subtitle 3 (centered) graph 9 graph 10 graph 11 graph 12 subtitle 4 (centered) graph 13 graph 14 graph 15 graph 16 in the same figure, to be saved as a ps file. How about ... lmat - rbind(c(0, 17, 17, 0), 1:4, c(0, 18, 18, 0), 5:8, c(0, 19, 19, 0), 9:12, c(0, 20, 20, 0), 13:16) layout(lmat, respect=TRUE, widths=rep(5, 4), heights=rep(c(1, 5), 4)) # layout.show(20) opar - par(cex=0.5, mar=c(4, 4, 1, 1)) for (i in 1:16) plot(i) par(mar=rep(0, 4)) for (i in 1:4) { plot.new() text(0.5, 0.5, paste(Sub-title, i)) } par(opar) Can somebody help? I hope this question is not redundant, but I have not found information on this on the R mailing lists. I use R 2.3.1 on Linux FC5. Thank you in advance. Marie-Pierre Sylvestre PhD student, McGill University __ 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 Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 [EMAIL PROTECTED] http://www.stat.auckland.ac.nz/~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.
Re: [R] MLE Methods
nand kumar nksathyar at yahoo.com writes: Greetings Forum, I am new to R and and writing in hopes of getting some help. Our MLE results from a home grown software do not match with that of R. We are using a censored sample and will really appreciate if you could give us any pointers as to which MLE method is used in R... to my knowledge there are different flavors of MLE used. We need more information. There are a huge variety of functions in R that, in one way or another, calculate maximum likelihood estimates (e.g. lm, glm, survReg, lmer, ...) using many different numerical algorithms appropriate for the specific problem. As the posting guide says, please construct the simplest possible reproducible example, showing how you estimate the MLE in R, and explain something about how your home grown software works; otherwise there is no way to answer your question. Ben Bolker __ 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] [R-pkgs] New package Ryacas
Hello, First, I would like to congratulations for very cool package! It's very nice idea!... Secondly, Is there a way to send R'objects (variables) to yacas and make symbolic operations?? for example: d - diag(3) a - A yacas( d * a ) Thanks, Cleber Borges Gabor Grothendieck wrote: Ryacas is an R interface to the free yacas computer algebra system. Ryacas allows one to send R expressions, unprocessed yacas strings and certain other R objects to a separate yacas process from R and get back the result. It also has facilities for manipulating yacas strings and R expressions destined for yacas processing. It can be used for exact arithmetic, symbolic math, ASCII pretty printing and translating R to TeX. Online info. For overview, pointers to additional information, installation instructions and a sample session see: http://code.google.com/p/ryacas/ The vignettes can be viewed online here: http://ryacas.googlecode.com/svn/trunk/inst/doc/Ryacas.pdf http://ryacas.googlecode.com/svn/trunk/inst/doc/Ryacas-Sym.pdf More. Once Ryacas is installed, pointers to additional information can be found with these R commands: library(Ryacas) package?Ryacas --- __ 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] BarPlot
Specify margins using par(mar=c(5,1,4,2)) before the call to barplot. You won't be able to see the vertical axis labels with those settings, though. On 16/10/06, Mohsen Jafarikia [EMAIL PROTECTED] wrote: Hello everyone: I am using the following code to draw my barplot but it has two problems. BL-c(1.97,8.04,2.54,10.53,4.85,1.73) LR-c(0.85,0.86,8.33,04.18,6.26,2.40) Q-c(0.00,0.00,1.92,01.92,4.48,0.00) cols - ifelse(Q!=0, orange, green) Graph- barplot(LR, main='LR Value',col=cols, border='black', space=0.05, width=(BL), xlab='Length', ylab='LR block',mar=c(5,1,4,2)) axis(1, at=Graph, sprintf('%0.2f',BL)) mtext(1, at=Graph, text=ifelse(Q!=0, sprintf('%0.2f',Q), ), line=2) mtext(1, at=par('usr')[1], text='BL', line=1) mtext(1, at=par('usr')[1], text='Var', line=2) abline(h=3.84,col='blue') abline(h=6.64,col='red') text(31,3.84,expression(paste(alpha==5,%)),pos=3) text(31,6.64,expression(paste(alpha==1,%)),pos=3) 1) I don't know how to specify the margins. I have written it in the code but it is not working. 2) I want the value of alph=5% at the right end of the line but it is almost in the left side and sometimes in the right side when I use the same code for drawing another barplot. I appreciate any comments about these problems. Thanks, Mohsen [[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. -- = 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] NULL or NA for missing function arguments?
On 10/16/2006 5:06 PM, Brahm, David wrote: Hans-Peter [EMAIL PROTECTED] wrote: I am troubled by the use of NULL or NA to indicate missing/non-specified function arguments. I suggest using NULL for arguments which are vectors or lists of unspecified length, and NA for scalars (arguments whose length should always be one, such as na.rm). I rarely use missing arguments, as they are harder to pass down to other functions. To be a little more precise: they are easy to pass down, but hard to do anything else with. For example: f - function(x) if (missing(x)) print(missing!) else print(x) g - function(x) f(x) h - function(x) { y - x; f(y) } g() [1] missing! h() Error in h() : argument x is missing, with no default Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [R-pkgs] New package Ryacas
Its pretty limited right now but you can do this: library(Ryacas) d - List(List(1, 0, 0), List(0, 1, 0), List(0, 0, 1)) a - Sym(a) a * d expression(list(list(a, 0, 0), list(0, a, 0), list(0, 0, a))) PrettyForm(%) /\ | ( a ) ( 0 ) ( 0 ) | || | ( 0 ) ( a ) ( 0 ) | || | ( 0 ) ( 0 ) ( a ) | \/ The ASCII representation of the matrix will look correct in R although its possible that the email process munges it up so it may not look right when you receive this. Also there are also matrix examples on the home page, in the Ryacas vignette and in the Ryacas-Sym vignette. Note that by mistake the vignette labelled Ryacas-Sym in the package itself is actually a copy of the Ryacas vignette so to see the actual Ryacas-Sym vignette currently one must look at the one in the source repository: http://ryacas.googlecode.com/svn/trunk/inst/doc/Ryacas-Sym.pdf On 10/16/06, Cleber N. Borges [EMAIL PROTECTED] wrote: Hello, First, I would like to congratulations for very cool package! It's very nice idea!... Secondly, Is there a way to send R'objects (variables) to yacas and make symbolic operations?? for example: d - diag(3) a - A yacas( d * a ) Thanks, Cleber Borges Gabor Grothendieck wrote: Ryacas is an R interface to the free yacas computer algebra system. Ryacas allows one to send R expressions, unprocessed yacas strings and certain other R objects to a separate yacas process from R and get back the result. It also has facilities for manipulating yacas strings and R expressions destined for yacas processing. It can be used for exact arithmetic, symbolic math, ASCII pretty printing and translating R to TeX. Online info. For overview, pointers to additional information, installation instructions and a sample session see: http://code.google.com/p/ryacas/ The vignettes can be viewed online here: http://ryacas.googlecode.com/svn/trunk/inst/doc/Ryacas.pdf http://ryacas.googlecode.com/svn/trunk/inst/doc/Ryacas-Sym.pdf More. Once Ryacas is installed, pointers to additional information can be found with these R commands: library(Ryacas) package?Ryacas --- __ 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] Re : Generate a random bistochastic matrix
Martin, I don't think that a doubly stochastic matrix can be obtained from an arbitrary positive rectangular matrix. There is a theorem by Sinkhorn (Am Math Month 1967) on the diagonal equivalence of matrices with prescribed row and column sums. It shows that given a positive matrix A(m x n), there is a unique matrix DAE (where D and E are m x m and n x n diagonal matrices) with rows, k*r_i (i = 1, ..., m), and column sums, c_j (j=1,...,n) such that k = \sum_j c_j / \sum_i r_i. Therefore, the alternative row and column normalization algorithm (same as the iterative proportional fitting algorithm for contingency tables) will alternate between row and column sums being unity, while the other sum alternates between k and 1/k. Here is a slight modification of your algorithm for the rectangular case: bistochMat.rect - function(m,n, tol = 1e-7, maxit = 1000) { ## Purpose: Random bistochastic *square* matrix (M_{ij}): ## M_{ij} = 0; sum_i M_{ij} = sum_j M_{ij} = 1 (for all i, j) ## -- ## Arguments: n: (n * n) matrix dimension; ## -- ## Author: Martin Maechler, Date: 16 Oct 2006, 14:47 stopifnot(maxit = 1, tol = 0) M - matrix(runif(m*n), m,n) for(i in 1:maxit) { rM - rowSum(M) M - M / rep((rM),n) cM - colSum(M) M - M / rep((cM),each=m) if(all(abs(c(rM,cM) - 1) tol)) break } ## cat(needed, i, iterations\n) ## or rather attr(M, iter) - i M } Using this algorithm we get for an 8 x 4 matrix, for example, we get: M - bistochMat.rect(8,4) apply(M,1,sum) [1] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 apply(M,2,sum) [1] 1 1 1 1 Clearly the algorithm didn't converge according to your convergence criterion, but the row sums oscillate between 1 and 0.5, and the column sums oscillate between 2 and 1, respectively. It is interesting to note that the above algorithm converges if we use the infinity norm, instead of the 1-norm, to scale the rows and columns, i.e. we divide rows and columns by their maxima. 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 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Martin Maechler Sent: Monday, October 16, 2006 10:30 AM To: Florent Bresson Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Re : Generate a random bistochastic matrix A simpler approach --- as in similar problems --- is to use an iterative solution which works quite fast for any 'n'. Interestingly, the number of necessary iterations seems to *decrease* for increasing 'n' : bistochMat - function(n, tol = 1e-7, maxit = 1000) { ## Purpose: Random bistochastic *square* matrix (M_{ij}): ## M_{ij} = 0; sum_i M_{ij} = sum_j M_{ij} = 1 (for all i, j) ## -- ## Arguments: n: (n * n) matrix dimension; ## -- ## Author: Martin Maechler, Date: 16 Oct 2006, 14:47 stopifnot(maxit = 1, tol = 0) M - matrix(runif(n*n), n,n) for(i in 1:maxit) { M - M / outer((rM - rowSums(M)), (cM - colSums(M))) * sum(rM) / n if(all(abs(c(rM,cM) - 1) tol)) break } ## cat(needed, i, iterations\n) ## or rather attr(M, iter) - i M } attr(M - bistochMat(70), iter) ## typically: ## [1] 8 attr(M - bistochMat(10), iter) ## - 13, 16, 15, 17, ... set.seed(101) ; attr(M - bistochMat(10), iter) ## 15 set.seed(101) ; attr(M - bistochMat(10, tol = 1e-15), iter)## 32 Initially, I tried to solve the general [ n x m ] case. It seems that needs a slightly smarter bias correction instead of just 'sum(M) / n'. If someone figures that out, please post your solution! Regards, Martin Maechler, ETH Zurich __ 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] extracting nested variances from lme4 model
Dear Doug Frank: Thanks for the reply, Doug. First a comment, then another question for you, Doug, if you have time: 1. COMMENT: Here's an ugly hack that would seem to answer Frank's question using 'lmer': (vt - with(dtf, tapply(x, trth, sd))) (vr - vt[2]/vt[1]) mod1b - lmer(x~trth+(1|rtr)+(I(vt[1]*(1+vr*trth))-1|cs), data=dtf) Now put this is a loop over a range of values for 'vr' and pick the one that maximizes 'logLik' (or minimizes AIC or BIC); it should be fairly close if not identical to this initial estimate. 2. ANOTHER QUESTION: Can the desired model be fit using 'lme', with crossed random effects, and we want separate variance estimates for the random effect 'cs' for each level of the fixed effect 'trth'? I previously suggested chapters 4 and 5 in Pinheiro and Bates (2000). However, even with the scripts ch04.R and ch05.R in ~library\nlme\scripts, it might take me a while to figure out how to do it (and even answer the question of whether it can). Thanks again. Spencer Graves Douglas Bates wrote: On 10/15/06, Douglas Bates [EMAIL PROTECTED] wrote: On 10/14/06, Spencer Graves [EMAIL PROTECTED] wrote: You want to estimate a different 'cs' variance for each level of 'trth', as indicated by the following summary from your 'fake data set': tapply(dtf$x, dtf$trth, sd) FALSE TRUE 1.532251 8.378206 Since var(x[trth]) var(x[!trth]), I thought that the following should produce this: mod1.-lmer( x ~ (1|rtr)+ (trth|cs) , data=dtf) Unfortunately, this generates an error for me: Error in lmer(x ~ (1 | rtr) + (trth | cs), data = dtf) : the leading minor of order 1 is not positive definite I do not understand this error, and I don't have other ideas about how to get around it using 'lmer'. Hmm. It's an interesting problem. I can tell you where the error message originates but I can't yet tell you why. The error message originates when Cholesky decompositions of the variance-covariance matrices for the random effects are generated at the initial estimates. It looks as if one of the model matrices is not being formed correctly for some reason. I will need to do more debugging. OK, I have worked out why the error occurs and will upload lme4_0.9975-4, which fixes this problem and also has some speedups when fitting generalized linear mixed models. Just for the record, I had assumed that the cholmod_aat function in the CHOLMOD sparse matrix library (the function cholmod_aat calculates AA' from a sparse matrix A) returned a matrix in which the columns are sorted in increasing order of the rows. That is not always correct but the situation is easily remedied. (The typical way to sort the columns in sparse matrices is to take the transpose of the transpose, which had me confused when I first saw it in some of Tim Davis's code. It turns out that a side effect of this operation is to sort the columns in increasing order of the rows.) With this patched lme4 package the model Spencer proposed can be fit but the variance-covariance matrix of the two-dimensional random effects for the cs factor is singular because of the design (the level of trth is constant within each level of cs). I'm not sure how to specify the desired model in lmer. (fm2 - lmer(x ~(1|rtr) + (trth|cs), dtf)) Linear mixed-effects model fit by REML Formula: x ~ (1 | rtr) + (trth | cs) Data: dtf AIC BIC logLik MLdeviance REMLdeviance 252.5 260.9 -121.2 244.8242.5 Random effects: Groups NameVariance Std.Dev. Corr cs (Intercept) 1.9127 1.3830 trthTRUE24.1627 4.9156 1.000 rtr (Intercept) 1.9128 1.3830 Residual 18.5278 4.3044 number of obs: 40, groups: cs, 10; rtr, 4 Fixed effects: Estimate Std. Error t value (Intercept) -0.2128 1.2723 -0.1673 Warning message: nlminb returned message false convergence (8) in: `LMEoptimize-`(`*tmp*`, value = list(maxIter = 200, tolerance = 1.49011611938477e-08, It seems to me that 'lme' in library(nlme) should also be able to handle this problem, but 'lme' is designed for nested factors, and your 'rtr' and 'cs' are crossed. If it were my problem, I think I'd study ch. 4 and possibly ch. 5 of Pinheiro and Bates (2000) Mixed-Effects Models in S and S-Plus (Springer) on 'pdMat' and 'corrStruct' classes, because I believe those may support models with crossed random effects like in your example AND might also support estimating different variance components for different levels of a fixed effect like 'trth' in your example. If we are lucky, someone else might educate us both. I'm sorry I couldn't answer your question, but I hope these comments might help in some way. Spencer Graves Frank Samuelson wrote: I have a model: mod1-lmer( x ~ (1|rtr)+
[R] BarPlot Color
Hello everyone, In the following program, I have specified if 'Q!=0', bar color is 'orange' and if is '0.0', color is green. Now I want to have different colors for 'Q'. For example: If 'Q=0.0' then color is green If 'Q=1.92' then color is blue If 'Q=4.48' then color is red I also want an indicator in the bottom of the graph which tells me what is every color. Can anybody tell me how I can do this? Thanks, Mohsen pdf('Test.pdf') BL-c(1.97,8.04,2.54,10.53,4.85,1.73) LR-c(0.85,0.86,8.33,04.18,6.26,2.40) Q-c(0.00,0.00,1.92,01.92,4.48,0.00) cols - ifelse(Q!=0, orange, green) Graph- barplot(LR, col=cols, width=(BL)) axis(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.
Re: [R] [R-pkgs] New package Ryacas
Here is a slightly shorter way to do it although it involves passing a yacas string directly: yacas(a * Identity(3)) expression(list(list(a, 0, 0), list(0, a, 0), list(0, 0, a))) PrettyForm(%) /\ | ( a ) ( 0 ) ( 0 ) | || | ( 0 ) ( a ) ( 0 ) | || | ( 0 ) ( 0 ) ( a ) | \/ On 10/16/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: Its pretty limited right now but you can do this: library(Ryacas) d - List(List(1, 0, 0), List(0, 1, 0), List(0, 0, 1)) a - Sym(a) a * d expression(list(list(a, 0, 0), list(0, a, 0), list(0, 0, a))) PrettyForm(%) /\ | ( a ) ( 0 ) ( 0 ) | || | ( 0 ) ( a ) ( 0 ) | || | ( 0 ) ( 0 ) ( a ) | \/ The ASCII representation of the matrix will look correct in R although its possible that the email process munges it up so it may not look right when you receive this. Also there are also matrix examples on the home page, in the Ryacas vignette and in the Ryacas-Sym vignette. Note that by mistake the vignette labelled Ryacas-Sym in the package itself is actually a copy of the Ryacas vignette so to see the actual Ryacas-Sym vignette currently one must look at the one in the source repository: http://ryacas.googlecode.com/svn/trunk/inst/doc/Ryacas-Sym.pdf On 10/16/06, Cleber N. Borges [EMAIL PROTECTED] wrote: Hello, First, I would like to congratulations for very cool package! It's very nice idea!... Secondly, Is there a way to send R'objects (variables) to yacas and make symbolic operations?? for example: d - diag(3) a - A yacas( d * a ) Thanks, Cleber Borges Gabor Grothendieck wrote: Ryacas is an R interface to the free yacas computer algebra system. Ryacas allows one to send R expressions, unprocessed yacas strings and certain other R objects to a separate yacas process from R and get back the result. It also has facilities for manipulating yacas strings and R expressions destined for yacas processing. It can be used for exact arithmetic, symbolic math, ASCII pretty printing and translating R to TeX. Online info. For overview, pointers to additional information, installation instructions and a sample session see: http://code.google.com/p/ryacas/ The vignettes can be viewed online here: http://ryacas.googlecode.com/svn/trunk/inst/doc/Ryacas.pdf http://ryacas.googlecode.com/svn/trunk/inst/doc/Ryacas-Sym.pdf More. Once Ryacas is installed, pointers to additional information can be found with these R commands: library(Ryacas) package?Ryacas --- __ 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] New package Ryacas
Hello Gabor I try these example, but I obtain some errors. *First example* yacas(a * Identity(3)) expression(list(list(a, 0, 0), list(0, a, 0), list(0, 0, a))) it's ok , but the next command: PrettyForm(%) Error in PrettyForm(%) : no applicable method for PrettyForm If I make a little modification ( set a variable in YACAS), I obtain right behavior. yacas(TEST := a * Identity(3)) expression(list(list(a, 0, 0), list(0, a, 0), list(0, 0, a))) yacas(PrettyForm(TEST)) /\ | ( a ) ( 0 ) ( 0 ) | || | ( 0 ) ( a ) ( 0 ) | || | ( 0 ) ( 0 ) ( a ) | \/ I make a test for all example in Ryacas.pdf and all works for me! :-) *Second example* d - List(List(1, 0, 0), List(0, 1, 0), List(0, 0, 1)) Error in List(1, 0, 0) : no applicable method for List d - yacas( List(List(1, 0, 0), List(0, 1, 0), List(0, 0, 1)) ) d expression(list(list(1, 0, 0), list(0, 1, 0), list(0, 0, 1))) GUESS: When I use the commands whitout yackas() statement, the error raise up. a - Sym(a) a * d a * list( list( 1 , 0 , 0 ) , list( 0 , 1 , 0 ) , list( 0 , 0 , 1 ) ) PrettyForm(%) Error in PrettyForm(%) : no applicable method for PrettyForm yacas(PrettyForm(%)) a * list( list( 1 , 0 , 0 ) , list( 0 , 1 , 0 ) , list( 0 , 0 , 1 ) ) Thanks for your attention! Cleber Borges Here is a slightly shorter way to do it although it involves passing a yacas string directly: yacas(a * Identity(3)) expression(list(list(a, 0, 0), list(0, a, 0), list(0, 0, a))) PrettyForm(%) /\ | ( a ) ( 0 ) ( 0 ) | || | ( 0 ) ( a ) ( 0 ) | || | ( 0 ) ( 0 ) ( a ) | \/ On 10/16/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: Its pretty limited right now but you can do this: library(Ryacas) d - List(List(1, 0, 0), List(0, 1, 0), List(0, 0, 1)) a - Sym(a) a * d expression(list(list(a, 0, 0), list(0, a, 0), list(0, 0, a))) PrettyForm(%) /\ | ( a ) ( 0 ) ( 0 ) | || | ( 0 ) ( a ) ( 0 ) | || | ( 0 ) ( 0 ) ( a ) | \/ The ASCII representation of the matrix will look correct in R although its possible that the email process munges it up so it may not look right when you receive this. Also there are also matrix examples on the home page, in the Ryacas vignette and in the Ryacas-Sym vignette. Note that by mistake the vignette labelled Ryacas-Sym in the package itself is actually a copy of the Ryacas vignette so to see the actual Ryacas-Sym vignette currently one must look at the one in the source repository: http://ryacas.googlecode.com/svn/trunk/inst/doc/Ryacas-Sym.pdf On 10/16/06, Cleber N. Borges [EMAIL PROTECTED] wrote: Hello, First, I would like to congratulations for very cool package! It's very nice idea!... Secondly, Is there a way to send R'objects (variables) to yacas and make symbolic operations?? for example: d - diag(3) a - A yacas( d * a ) Thanks, Cleber Borges __ 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] tcltk crashes with bad color with text widget
Hello I have been playing with tcl/tk in R 2.4.0 on windows XP and have managed to crash R by supplying tcl/tk with an incorrect color. Is this a bug? is there a way for me to test the color to see if it is a valid tcl/tk color, to avoid this? tt=tktoplevel() tklabel(parent=tt, text=hello world, foreground=reed) Error in structure(.External(dotTclObjv, objv, PACKAGE = tcltk), class = tclObj) : [tcl] unknown color name reed. An error is displayed as one would expect, however when I try tktext(parent=tt, foreground=blaaack) R crashes, rather than displaying an error as tklabel did. This, however, does not happen on my FreeBSD machine, which displays an error similar to the one for tklabel and does not crash. Thanks for any help, Alex Couture-Beil __ 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] New package Ryacas
On 10/16/06, Cleber N.Borges [EMAIL PROTECTED] wrote: Hello Gabor I try these example, but I obtain some errors. *First example* yacas(a * Identity(3)) expression(list(list(a, 0, 0), list(0, a, 0), list(0, 0, a))) it's ok , but the next command: PrettyForm(%) Error in PrettyForm(%) : no applicable method for PrettyForm Bug. Seems 0.2-2 is missing a PrettyForm.default method. Try adding the PrettyForm.default - line shown before the rest: PrettyForm.default - PrettyForm.Sym d - List(List(Sym(1), 0, 0), List(Sym(0), 1, 0), List(Sym(0), 0, 1)) a - Sym(a) a * d PrettyForm(%) If I make a little modification ( set a variable in YACAS), I obtain right behavior. yacas(TEST := a * Identity(3)) expression(list(list(a, 0, 0), list(0, a, 0), list(0, 0, a))) yacas(PrettyForm(TEST)) /\ | ( a ) ( 0 ) ( 0 ) | || | ( 0 ) ( a ) ( 0 ) | || | ( 0 ) ( 0 ) ( a ) | \/ I make a test for all example in Ryacas.pdf and all works for me! :-) *Second example* d - List(List(1, 0, 0), List(0, 1, 0), List(0, 0, 1)) Error in List(1, 0, 0) : no applicable method for List Similar problem. Try issuing this statement: List.default - List.Sym before running the rest. d - yacas( List(List(1, 0, 0), List(0, 1, 0), List(0, 0, 1)) ) d expression(list(list(1, 0, 0), list(0, 1, 0), list(0, 0, 1))) GUESS: When I use the commands whitout yackas() statement, the error raise up. a - Sym(a) a * d a * list( list( 1 , 0 , 0 ) , list( 0 , 1 , 0 ) , list( 0 , 0 , 1 ) ) PrettyForm(%) Error in PrettyForm(%) : no applicable method for PrettyForm yacas(PrettyForm(%)) a * list( list( 1 , 0 , 0 ) , list( 0 , 1 , 0 ) , list( 0 , 0 , 1 ) ) Thanks for your attention! Cleber Borges Here is a slightly shorter way to do it although it involves passing a yacas string directly: yacas(a * Identity(3)) expression(list(list(a, 0, 0), list(0, a, 0), list(0, 0, a))) PrettyForm(%) /\ | ( a ) ( 0 ) ( 0 ) | || | ( 0 ) ( a ) ( 0 ) | || | ( 0 ) ( 0 ) ( a ) | \/ On 10/16/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: Its pretty limited right now but you can do this: library(Ryacas) d - List(List(1, 0, 0), List(0, 1, 0), List(0, 0, 1)) a - Sym(a) a * d expression(list(list(a, 0, 0), list(0, a, 0), list(0, 0, a))) PrettyForm(%) /\ | ( a ) ( 0 ) ( 0 ) | || | ( 0 ) ( a ) ( 0 ) | || | ( 0 ) ( 0 ) ( a ) | \/ The ASCII representation of the matrix will look correct in R although its possible that the email process munges it up so it may not look right when you receive this. Also there are also matrix examples on the home page, in the Ryacas vignette and in the Ryacas-Sym vignette. Note that by mistake the vignette labelled Ryacas-Sym in the package itself is actually a copy of the Ryacas vignette so to see the actual Ryacas-Sym vignette currently one must look at the one in the source repository: http://ryacas.googlecode.com/svn/trunk/inst/doc/Ryacas-Sym.pdf On 10/16/06, Cleber N. Borges [EMAIL PROTECTED] wrote: Hello, First, I would like to congratulations for very cool package! It's very nice idea!... Secondly, Is there a way to send R'objects (variables) to yacas and make symbolic operations?? for example: d - diag(3) a - A yacas( d * a ) Thanks, Cleber Borges ___ O Yahoo! está de cara nova. Venha conferir! http://br.yahoo.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] Variance of fitted value in lm
Hi, I am wondering if a linear model lm(y~ x1+x2) calculates the variance of a fitted value. Thank you Li __ 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] About compositional data analysis
The compositional data xi=(x_i1,x_i2,...,x_in), for each fixed i , xij0, and sum(xij)=1; I want to compare the mean( u_i) of several groups i.e. H0: u_1=u_2=...=u_N or H0: u_11=u_21=...=u_N1 Are there any ANOVA tpye tools to do this work in R? Thanks, WEN S Q [[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] New package Ryacas
Hi Gabor, I'm running Quantian (Debian) inside a VMware virtual machine, on a Windows XP host. I installed the latest version of yacas from the source tarball. I remembered to ./configure --enable-server to allow server connections. make and make install worked ok, after some fiddling. I checked that the yacas server option worked, by doing yacas --server , and then telnet'ing to 127.0.0.1 to check. It worked fine. I installed Ryacas. I then tried it out and got the following error: library(Ryacas) Loading required package: XML yacas('Integrate(x)x;') [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 Accepting requests from port 9734 I tried again (stubborn, I guess): yacas('Integrate(x)x;') [1] Starting Yacas! Accepting requests from port 9734 YacasServer Could not bind to the socket : Address already in use /usr/local/lib/R/site-library/Ryacas/yacdir/R.ys(1) : File not found CommandLine(1) : Expecting ) closing bracket for sub-expression, but got x instead Any ideas where I may be going wrong? I don't know anything about sockets. I've cross-posted to r-sig-debian. They may be interested. Cheers, Simon. -- Simon Blomberg, B.Sc.(Hons.), Ph.D, M.App.Stat. Centre for Resource and Environmental Studies The Australian National University Canberra ACT 0200 Australia T: +61 2 6125 7800 email: Simon.Blomberg_at_anu.edu.au F: +61 2 6125 0757 CRICOS Provider # 00120C The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. - John Tukey. __ 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.