Re: [R] Pros and Cons of R
R is definitely an excellent environment for data analysis and display. It has quickly become the tool that I use to bind together different models and process the resulting data into reports and graphics. The Sweave package can be especially useful for accomplishing this. R has also been integrated into some GIS environments, the GRASS system is a good example of this. The book Open Source GIS: A GRASS GIS Approach by M.Netler and H. Mitasova. provides an overview of this capability. The following post in the QGIS blog also shows how R can be used to output data as shapefiles which can then be loaded into a GIS application: http://blog.qgis.org/node/112 Monica Pisica wrote: Cons: - R has a very steep learning curve. Based on my my experience conducting data analysis and visualization using Fortran and MATLAB, R was refreshingly easy to learn. The demo() and example() functions provide tremendous insight into the use of different tools in R by executing code and showing the results. I also found it extremely easy to obtain consistent graphical output from R. Producing standardized views of different datasets in MATLAB can be an exercise in frustration compared to what I am able to achieve using R. -- View this message in context: http://www.nabble.com/Pros-and-Cons-of-R-tp17407521p17451695.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] SVD on a matix
the variance is the eigen values of the correlation matrix of yoru matrix X.cor - cor(X) X.e - eigen(X.cor) X.e$values# Eigenvalues of cor(X) = variances you're asking about kayj wrote: Hi All, I performed an svd on a matrix X and saved the first three column of the left singular matrix U. ( I assume that they correspond to the projection of the matrix on the first three eigen vectors that corresponds to the first three largest eigenvalues). I would like to know how much variance is explained by the first eigenvectors? how can I find that. Thanks for your help - Yasir H. Kaheil Catchment Research Facility The University of Western Ontario -- View this message in context: http://www.nabble.com/SVD-on-a-matix-tp17441337p17455129.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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-Excel Macro Problem
hi Nate, could you please email me your excel workbook. thanks y nmarti wrote: I'm trying to write R functions into VBA code. I've done this many other times in other documents and everything has run great. But today I keep recieving an error message Run-time error '1004': Application-defined or object-defined error. Has anyone else encountered this same error message? I do not recieve this error in the document when running regular VBA code. But when I try to run, Call Rinterface.PutDataframe(Data, Range(Sheet1!A1:E2000)) I receive the error. I have the VBA References RExcelVBAlib checked. Any suggestions would be appreiciated, Nate - Yasir H. Kaheil Catchment Research Facility The University of Western Ontario -- View this message in context: http://www.nabble.com/R-Excel-Macro-Problem-tp17450757p17455095.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] IDE
emacs + ess On Fri, May 23, 2008 at 8:54 AM, Alexandra Almeida [EMAIL PROTECTED] wrote: People, I'm a ubunto user and I used to write my scipts in Java Gui for R, but it is a very slow tool to run my scripts... Do you know some efficient IDE for R? Thank!!! Alexandra Almeida -- Alexandra R M de Almeida [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] gray grid on quartz()
On Sun, 25 May 2008, Angel Berihuete Macías wrote: Hello everybody. Recently I update from R6.3 to R7.0 on Mac OS X, and an ugly gray grid appear when I use the function image() or pdf() What I am doing wrong? - there is a list r-sig-mac for MacOS enquiries. - There is no R7.0 nor R6.3. We can guess you meant 2.7.0, but there is no 2.6.3 either. The posting guide specifically asks for accurate version information. - there is no reproducible example here. Now, considering the use of image() on quartz() in R 2.7.0, there is a (equally vague) bug report and thread at https://stat.ethz.ch/pipermail/r-devel/2008-May/049650.html that seems similar to your comments. Simon Urbanek has made some changes to quartz() to alleviate this, so please try a current R-patched build. But this does not apply to pdf(), although the effect is seen in some PDF viewers (and is a bug in those viewers). Thank's for your help, Ángel. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 write a package based on nlme
Dear R Helpers, I try to write a small package that based on nlme however my code does not work. R always appears this message: Error in eval(expr, envir, enclos) : object y not found where y is the response variable. Please help me out! This is my code: require(nlme) AMPmixed-function(y, x, S1=c(asymptotic,logistic), random,data, S2=c(asymptotic,logistic), start) { logist.logist-function(x,alpha,delta,psi.l,tau.l,gamma,h){ delta+(alpha-delta+gamma*(x-(h-1))/exp(x))/(1+exp(-(x-tau.l)/psi.l))} logist.asymp-function(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h){ delta+(alpha-delta)/(1+exp(-(x-tau.l)/psi.l))+(gamma*(x-(h-1))/exp(x))*exp(-exp(1/lpsi.a)*x)} asymp.asymp-function(x,alpha,delta,lpsi.a,gamma,h){ delta+(alpha-delta)*exp(-exp(1/lpsi.a)*x)+(gamma*(x-(h-1))/exp(x))*exp(-exp(1/lpsi.a)*x)} asymp.logist-function(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h){ delta+(alpha-delta)*exp(-exp(1/lpsi.a)*x)+(gamma*(x-(h-1))/exp(x))/(1+exp(-(x-tau.l)/psi.l))} (logistic.logistic-function(y, x, data, start, random){ nlme.out-nlme(y~logist.logist(x,alpha,delta,psi.l,tau.l,gamma,h), data=data, start=start, na.action) list(nlme.out=summary(nlme.out)) }) (logistic.asymptotic-function(y, x, data, start, random){ nlme.out-nlme(y~logist.asymp(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h), data=data, start=start, na.action) list(nlme.out=summary(nlme.out)) }) (asymptotic.logistic-function(y, x, data, start,random){ xy-sortedXyData(x,y,data=data) if(nrow(xy)8){stop(Too few factor levels to fit an asymptotic.logistic)} nlme.out-nlme(y~asymp.logist(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h), data=data, start=start, na.action) list(nlme.out=summary(nlme.out)) }) (asymptotic.asymptotic-function(y, x, data, start, random){ nlme.out-nlme(y~asymp.asymp(x,alpha,delta,lpsi.a,gamma,h), data=data, start=start, fixed=alpha+delta+lpsi.a+gamma+h~1,random=random) list(nlme.out=summary(nlme.out)) }) if(S1==logistic S2==logistic) {(AMPmixed=logistic.logistic(y, x, data, start, random))} else if(S1==logistic S2==asymptotic){(AMPmixed=logistic.asymptotic(y, x, data, start, random))} else if(S1==asymptotic S2==logistic){(AMPmixed=asymptotic.logistic(y, x, data, start, random))} else if(S1==asymptotic S2==asymptotic){(AMPmixed=asymptotic.asymptotic(y, x, data, start, random))} } con rep biomass 10.00 1 1.126 20.32 1 1.096 31.00 1 1.163 43.20 1 0.985 5 10.00 1 0.716 6 32.00 1 0.560 7 100.00 1 0.375 80.00 2 0.833 90.32 2 1.106 10 1.00 2 1.336 11 3.20 2 0.754 12 10.00 2 0.683 13 32.00 2 0.488 14 100.00 2 0.344 iso-read.table(file=E:\\Hormesis\\data\\isobutanol.txt, header=T) aa-groupedData(biomass~con|rep, data=iso) van2-AMPmixed(y=biomass, x=con, S1=asymptotic, S2=asymptotic, data=aa, + start=c(alpha= 0.7954, delta= 0.3231, lpsi.a=-0.2738, gamma= 1.0366, h=0.8429)) Error in eval(expr, envir, enclos) : object y not found Thank you very much~~ Chunhao __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Vector Product question
Hi Ive looked around but I cant figure out how to do this without a for loop. I have a vector of neural net weights from coef.nnet(), which looks like c(3,3,1). I also have a list of weight prefixes, which are c(x,h,y). I would like to obtain a vector that looks like c(x1,x2,x3,h1,h2,h3,y1) - i.e. if we think of the numeric weight vector as a matrix B ([1 2 3],[1 2 3], [1 0 0]), its like a paste() of the element in vector A[i] with each element in the row i: B[i][j]. I can see that Ripley Venables use the following, using seq_len and paste() : wts - object$wts wm - c(b, paste(i, seq_len(object$n[1]), sep=)) if(object$n[2] 0) wm - c(wm, paste(h, seq_len(object$n[2]), sep=)) if(object$n[3] 1) wm - c(wm, paste(o, seq_len(object$n[3]), sep=)) Is it possible to compress this to a one-liner? Cheers Rory __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Configuring emacs/ess on Ubuntu
On Sun, May 25, 2008 at 10:07:52AM -0400, Wade Wall wrote: I don't know if this is the proper place to ask this, but I am trying to configure emacs/ess on Ubuntu 8.04 to run the way described for ESS and Xemacs in Windows (John Fox's guide). I installed ess as directed at http://ess.r-project.org/Manual/ . Under Windows I could use Emacs/ess fine (but I am obviously a novice at emacs), but am having trouble doing so in Ubuntu. At present I have loaded ess, and it opens as a buffer when emacs opens. But I can't open an R session with M-x-R, and can only open R if I have a pre-existing .R file. Also, I would like to have emacs, either by default or with a hot key, open up a file in the upper window and R in the lower. Any hints on how I can do this? If you install ess on Debian/Ubuntu via $ sudo apt-get install ess it should start automatically as an emacs startup file is registered. Dirk -- Three out of two people have difficulties with fractions. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Configuring emacs/ess on Ubuntu
Hi Wade, Wade Wall wrote: Hi all, I don't know if this is the proper place to ask this, but I am trying to configure emacs/ess on Ubuntu 8.04 to run the way described for ESS and I think the easiest way to install emacs/ess on Ubuntu 8.04 is via the repositories. Simply use your favorite package manager (I use synaptic) and choose the ess package. If Emacs hasn't been installed yet, it will do so automatically. I hope this helps, Roland __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Configuring emacs/ess on Ubuntu
$ sudo apt-get install Installs installs ESS version 5.3.0. Is there a repository for more recent version? Thanks. --Dale On Sun, May 25, 2008 at 11:24 AM, Roland Rau [EMAIL PROTECTED] wrote: Hi Wade, Wade Wall wrote: Hi all, I don't know if this is the proper place to ask this, but I am trying to configure emacs/ess on Ubuntu 8.04 to run the way described for ESS and I think the easiest way to install emacs/ess on Ubuntu 8.04 is via the repositories. Simply use your favorite package manager (I use synaptic) and choose the ess package. If Emacs hasn't been installed yet, it will do so automatically. I hope this helps, Roland __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Configuring emacs/ess on Ubuntu
I first installed through the package manager, but was unable to start R without opening a script file. So I installed from the tarball, but am still unable to open R using any commands; ESS loads into a buffer; but I can't use M-x-R to open R. the only way I can open R is to open a script file first. Maybe my question is, how do I create a new script file, type some commands, open R, and run script from the file? Wade [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] marginality principle / selecting the right type of SS for an interaction hypothesis
Dear Bertolt, Since you have specific hypotheses in mind, why not just test them directly as contrasts? That is, test for (1) the difference between men and women in the absence of stereotype threat; (2) the difference between men and women in the presence of stereotype threat; and (3) the difference in these differences (i.e., the interaction). The fact that you expect a positive difference in (1) and (2) doesn't make the test for the gender main effect sensible, because you're averaging simple effects of different magnitude. BTW, although I didn't read it carefully, the your web-page description of a main effect in the presence of an interaction appears to imply that this averages across all individuals, when in fact it averages across the levels of the other factor; the result is different when there are unequal numbers of observations in the cells. As well, you describe the model in your email as an ANCOVA, when in fact it appears to be a two-way ANOVA. I hope this helps, John -- John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bertolt Meyer Sent: May-25-08 10:51 AM To: r-help@r-project.org Subject: [R] marginality principle / selecting the right type of SS for an interaction hypothesis Hello, I have a problem with selecting the right type of sums of squares for an ANCOVA for my specific experimental data and hypotheses. I do have a basic understanding of the differences between Type-I, II, and III SSs, have read about the principle of marginality, and read Venable's Exegeses on Linear Models (http://www.stats.ox.ac.uk/pub/MASS3/Exegeses.pdf). I am pretty new to R and a search of the R-help archive did not answer my question (although I found some good pointers). In brief, leaving my covariates aside, I hypothesize that women (a) generally perform lower then men in a specific task (microworld performance, MWP) and that they (b) perform especially poor if a certain situational condition exists (stereotype threat). N = 160, 80 female 80 male participants, 82 under stereotype threat and 78 not. I realize that it makes no sense to report/interpret a main effect of stereotype threat in the confirmed presence of the interaction effect GENDER:STTHREAT, because a main effect of stereotype threat would actually be caused by the interaction (an error-bar plot illustrating this can be found here if one scrolls a little downwars: http://myowelt.blogspot.com/2008/05/obtaining-same-anova-results-in-r-as- in.html) . I thus tend to use Type-II SSs and calculate my ANOVA with library(car) Anova(lm(MWP ~ GENDER * STTHREAT), type=II) Anova Table (Type II tests) Response: MWP Sum Sq Df F valuePr(F) GENDER 23.939 1 32.3672 6.139e-08 *** STTHREAT 12.684 1 17.1489 5.644e-05 *** GENDER:STTHREAT 4.997 1 6.7557 0.01024 * Residuals 115.380 156 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 However, it would make sense to report the main effect of GENDER in the presence of the interaction and thus violate the marginality principle, because of hypothesis (a) above. Would that mean that Type- III SSs are desirable for the analysis of the main effect of GENDER, and Type-II SSs are desirable for the main effect of STTHREAT and the interaction? Or would it be better to specify a model that only includes the interaction term and the main effect of gender with Type- III SSs? Like this: options(contrasts=c(contr.sum, contr.poly)) fit - aov(MWP ~ GENDER:STTHREAT + GENDER) drop1(fit,~.,test=F) Single term deletions Model: MWP ~ GENDER:STTHREAT + GENDER Df Sum of Sq RSS AIC F value Pr(F) none 115.380 -44.310 GENDER 123.381 138.761 -16.787 31.612 8.475e-08 *** GENDER:STTHREAT 217.680 133.061 -25.499 11.952 1.481e-05 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 If this has been answered before and I was just too blind to find it, I apologize and would appreciate a link to the post. Another question that arises from the use of Type-III SSs: If every factor is corrected for the other factors, the SSs of all factors plus the RSS do not sum up to the total SS of the model. But doesn't that lead to a situation where the standard way of calculating eta-square for a factor by dividing its SS by the total SS cannot be applied? Regards, Bertolt -- Bertolt Meyer Senior Assistant Psychological Institute, University of Zurich Social Psychology Binzmuehlestr. 14, Box 15 CH-8050 Zurich Switzerland [EMAIL PROTECTED] tel: +41446357282 fax: +41446357279 __ R-help@r-project.org mailing list
Re: [R] Configuring emacs/ess on Ubuntu
On Sun, May 25, 2008 at 11:40:07AM -0400, Dale Steele wrote: $ sudo apt-get install Installs installs ESS version 5.3.0. Is there a repository for more recent version? As it happens, yes and no. There is now a small group working on Ess for Debian/Ubuntu, but there is no Ubuntu repository. But as the package is not binary, you can just fetch the most current Debian version (by hand). The package tracking (PTS) page is at http://packages.qa.debian.org/e/ess.html and the pool is at http://ftp.debian.org/debian/pool/main/e/ess/ Just grab the file from there; if you install with my favourite frontend wajig you can just do $ wajig install http://ftp.debian.org/debian/pool/main/e/ess/ess_5.3.8~svn3902-1_all.deb Hth, Dirk Thanks. --Dale On Sun, May 25, 2008 at 11:24 AM, Roland Rau [EMAIL PROTECTED] wrote: Hi Wade, Wade Wall wrote: Hi all, I don't know if this is the proper place to ask this, but I am trying to configure emacs/ess on Ubuntu 8.04 to run the way described for ESS and I think the easiest way to install emacs/ess on Ubuntu 8.04 is via the repositories. Simply use your favorite package manager (I use synaptic) and choose the ess package. If Emacs hasn't been installed yet, it will do so automatically. I hope this helps, Roland __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Three out of two people have difficulties with fractions. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Configuring emacs/ess on Ubuntu
Hi Wade, Wade Wall wrote: I first installed through the package manager, but was unable to start R without opening a script file. So I installed from the tarball, but am still unable to open R using any commands; ESS loads into a buffer; but I can't use M-x-R to open R. the only way I can open R is to open a are you sure R is installed? script file first. Maybe my question is, how do I create a new script file, type some commands, open R, and run script from the file? this is a simple session which should work to create a new script file, typing some commands, opening R and run the whole content from the buffer in R. Please note that there might be a message like Cannot read history file /your/file/path C refers to the CTRL key and M to the Meta key (- ALT) C-x C-f myscript.r rnorm(100) C-x 2 C-x o M-x R C-x o C-c M-b I hope this helps you further, Roland __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] need help for building R in Ubuntu 8.04
Hi everyone I have been trying to build R in ubuntu 8.04 from its source code but am getting the following error. configure: error: --with-x=yes (default) and X11 headers/libs are not available Please help me and consider me a newbie in linux thanks in advance [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] need help for building R in Ubuntu 8.04
Try: ./configure --with-x=no On Sun, May 25, 2008 at 1:20 PM, Roland Rau [EMAIL PROTECTED] wrote: Hi, Nitesh Agrawal wrote: Hi everyone I have been trying to build R in ubuntu 8.04 from its source code but am getting the following error. configure: error: --with-x=yes (default) and X11 headers/libs are not available I am currently sitting in front of a Windows machine but I built R on my laptop at home running Ubuntu 8.04. So hopefully, I don't make a mistake. What I guess you have to do, is to install the xorg-dev package. You could do this by: sudo apt-get install xorg-dev in a terminal window. And then you can start again with ./configure and so on. Does this help? Roland __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] need help for building R in Ubuntu 8.04
On 05/25/08 12:12, Nitesh Agrawal wrote: Hi everyone I have been trying to build R in ubuntu 8.04 from its source code but am getting the following error. configure: error: --with-x=yes (default) and X11 headers/libs are not available Please help me and consider me a newbie in linux Is there a reason why you want to install from source? sudo aptitude install r-base should work, AFAIK, or, if you prefer the GUI, look for R in synaptic. You may have to add an extra repository first; I had to: http://promberger.info/linux/2007/09/04/installing-and-updating-r-with-aptitude/ I'm currently using 7.10 so not 100 percent sure if this works in 8.04. m. -- Marianne Promberger Graduate student in Psychology http://www.psych.upenn.edu/~mpromber __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Need help for nlme
Hi everyone, I try to write a module based on nlme however R always shows me the error message Error in eval(expr, envir, enclos) : object y not found. Does anyone know how to solve this? There is no problem in nls at all. require(nlme) AMPmixed-function(y, x, S1=c(asymptotic,logistic), S2=c(asymptotic,logistic), data, start,random) { logist.logist-function(x,alpha,delta,psi.l,tau.l,gamma,h){ delta+(alpha-delta+gamma*(x-(h-1))/exp(x))/(1+exp(-(x-tau.l)/psi.l))} logist.asymp-function(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h){ delta+(alpha-delta)/(1+exp(-(x-tau.l)/psi.l))+(gamma*(x-(h-1))/exp(x))*exp(-exp(1/lpsi.a)*x)} asymp.asymp-function(x,alpha,delta,lpsi.a,gamma,h){ delta+(alpha-delta)*exp(-exp(1/lpsi.a)*x)+(gamma*(x-(h-1))/exp(x))*exp(-exp(1/lpsi.a)*x)} asymp.logist-function(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h){ delta+(alpha-delta)*exp(-exp(1/lpsi.a)*x)+(gamma*(x-(h-1))/exp(x))/(1+exp(-(x-tau.l)/psi.l))} (logistic.logistic-function(y, x, data, start, random){ nlme.out-nlme(y~logist.logist(x,alpha,delta,psi.l,tau.l,gamma,h), data=data, start=start, fixed=alpha+delta+psi.l+tau.l+gamma+h~1, random=random) list(nlme.out=summary(nlme.out)) }) (logistic.asymptotic-function(y, x, data, start, random){ nlme.out-nlme(y~logist.asymp(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h), data=data, start=start, fixed=alpha+delta+psi.l+tau.l+lpsi.a+gamma+h~1, random=random) list(nlme.out=summary(nlme.out)) }) (asymptotic.logistic-function(y, x, data, start,random){ nlme.out-nlme(y~asymp.logist(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h), data=data, start=start, fixed=alpha+delta+psi.l+tau.l+lpsi.a+gamma+h~1, random=random) list(nlme.out=summary(nlme.out)) }) (asymptotic.asymptotic-function(y, x, data, start, random){ nlme.out-nlme(y~asymp.asymp(x,alpha,delta,lpsi.a,gamma,h), data=data, start=start, fixed=alpha+delta+lpsi.a+gamma+h~1,random=random) list(nlme.out=summary(nlme.out)) }) if(S1==logistic S2==logistic) {(AMPmixed=logistic.logistic(y, x, data, start, random))} else if(S1==logistic S2==asymptotic){(AMPmixed=logistic.asymptotic(y, x, data, start, random))} else if(S1==asymptotic S2==logistic){(AMPmixed=asymptotic.logistic(y, x, data, start, random))} else if(S1==asymptotic S2==asymptotic){(AMPmixed=asymptotic.asymptotic(y, x, data, start, random))} } # con rep biomass 10.00 1 1.126 20.32 1 1.096 31.00 1 1.163 43.20 1 0.985 5 10.00 1 0.716 6 32.00 1 0.560 7 100.00 1 0.375 80.00 2 0.833 90.32 2 1.106 10 1.00 2 1.336 11 3.20 2 0.754 12 10.00 2 0.683 13 32.00 2 0.488 14 100.00 2 0.344 iso-read.table(file=E:\\Hormesis\\data\\isobutanol.txt, header=T) aa-groupedData(biomass~con|rep, data=iso) van2-AMPmixed(y=biomass, x=con, S1=asymptotic, S2=asymptotic, data=aa, random=pdDiag(alpha+delta+lpsi.a+gamma+h~1), start=c(alpha= 0.7954, delta= 0.3231, lpsi.a=-0.2738, gamma= 1.0366, h=0.8429)) van2 Thank you very much in advance. Chunhao __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] naming components of a list
Hi I have a character vector with thousands of names which looks like this: V=c(Fred, Mary, SAM) V [1] Fred Mary SAM class(V) [1] character I would like to change it to a list: L=as.list(V) L [[1]] [1] Fred [[2]] [1] Mary [[3]] [1] SAM but I need to name the components as name1, name2, name3, so it should look like this: $name1 [1] Fred $name2 [1] Mary $name3 [1] SAM Any help will be much appreciated Joseph [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Emacs Bundle...
Atul Kulkarni wrote: Hi List, I remember someone mentioning a R-specific bundle of Emacs. Can you please post link again? Regards, Atul. By the teach a man to fish principle, http://www.r-project.org/search.html search for: emacs ess windows 2nd hit, 4th bullet from the end. -- 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] naming the components of a list
On 26/05/2008, at 7:54 AM, joseph wrote: Hi I have a character vector with thousands of names which looks like this: V=c(Fred, Mary, SAM) V [1] Fred Mary SAM class(V) [1] character I would like to change it to a list: L=as.list(V) L [[1]] [1] Fred [[2]] [1] Mary [[3]] [1] SAM but I need to name the components as name1, name2, name3, so it should look like this: $name1 [1] Fred $name2 [1] Mary $name3 [1] SAM names(L) - paste(name,1:3,sep=) cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Need help for nlme
My advice is to try to simplify this as much as possible. When it is as simple as possible, it will either work or not work. If it works, then you have learned something useful. If it does not work, then send your question again. Right now there is a great deal of detail that may or may not be extraneous. Andrew. On Sun, May 25, 2008 at 01:36:49PM -0500, [EMAIL PROTECTED] wrote: Hi everyone, I try to write a module based on nlme however R always shows me the error message Error in eval(expr, envir, enclos) : object y not found. Does anyone know how to solve this? There is no problem in nls at all. require(nlme) AMPmixed-function(y, x, S1=c(asymptotic,logistic), S2=c(asymptotic,logistic), data, start,random) { logist.logist-function(x,alpha,delta,psi.l,tau.l,gamma,h){ delta+(alpha-delta+gamma*(x-(h-1))/exp(x))/(1+exp(-(x-tau.l)/psi.l))} logist.asymp-function(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h){ delta+(alpha-delta)/(1+exp(-(x-tau.l)/psi.l))+(gamma*(x-(h-1))/exp(x))*exp(-exp(1/lpsi.a)*x)} asymp.asymp-function(x,alpha,delta,lpsi.a,gamma,h){ delta+(alpha-delta)*exp(-exp(1/lpsi.a)*x)+(gamma*(x-(h-1))/exp(x))*exp(-exp(1/lpsi.a)*x)} asymp.logist-function(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h){ delta+(alpha-delta)*exp(-exp(1/lpsi.a)*x)+(gamma*(x-(h-1))/exp(x))/(1+exp(-(x-tau.l)/psi.l))} (logistic.logistic-function(y, x, data, start, random){ nlme.out-nlme(y~logist.logist(x,alpha,delta,psi.l,tau.l,gamma,h), data=data, start=start, fixed=alpha+delta+psi.l+tau.l+gamma+h~1, random=random) list(nlme.out=summary(nlme.out)) }) (logistic.asymptotic-function(y, x, data, start, random){ nlme.out-nlme(y~logist.asymp(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h), data=data, start=start, fixed=alpha+delta+psi.l+tau.l+lpsi.a+gamma+h~1, random=random) list(nlme.out=summary(nlme.out)) }) (asymptotic.logistic-function(y, x, data, start,random){ nlme.out-nlme(y~asymp.logist(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h), data=data, start=start, fixed=alpha+delta+psi.l+tau.l+lpsi.a+gamma+h~1, random=random) list(nlme.out=summary(nlme.out)) }) (asymptotic.asymptotic-function(y, x, data, start, random){ nlme.out-nlme(y~asymp.asymp(x,alpha,delta,lpsi.a,gamma,h), data=data, start=start, fixed=alpha+delta+lpsi.a+gamma+h~1,random=random) list(nlme.out=summary(nlme.out)) }) if(S1==logistic S2==logistic) {(AMPmixed=logistic.logistic(y, x, data, start, random))} else if(S1==logistic S2==asymptotic){(AMPmixed=logistic.asymptotic(y, x, data, start, random))} else if(S1==asymptotic S2==logistic){(AMPmixed=asymptotic.logistic(y, x, data, start, random))} else if(S1==asymptotic S2==asymptotic){(AMPmixed=asymptotic.asymptotic(y, x, data, start, random))} } # con rep biomass 10.00 1 1.126 20.32 1 1.096 31.00 1 1.163 43.20 1 0.985 5 10.00 1 0.716 6 32.00 1 0.560 7 100.00 1 0.375 80.00 2 0.833 90.32 2 1.106 10 1.00 2 1.336 11 3.20 2 0.754 12 10.00 2 0.683 13 32.00 2 0.488 14 100.00 2 0.344 iso-read.table(file=E:\\Hormesis\\data\\isobutanol.txt, header=T) aa-groupedData(biomass~con|rep, data=iso) van2-AMPmixed(y=biomass, x=con, S1=asymptotic, S2=asymptotic, data=aa, random=pdDiag(alpha+delta+lpsi.a+gamma+h~1), start=c(alpha= 0.7954, delta= 0.3231, lpsi.a=-0.2738, gamma= 1.0366, h=0.8429)) van2 Thank you very much in advance. Chunhao __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Andrew Robinson Department of Mathematics and StatisticsTel: +61-3-8344-6410 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 http://www.ms.unimelb.edu.au/~andrewpr http://blogs.mbs.edu/fishing-in-the-bay/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] naming components of a list
try this: names(L) - c(name1,name2,name3) L $name1 [1] Fred $name2 [1] Mary $name3 [1] SAM HTH, Sincerely, Erin On Sun, May 25, 2008 at 2:42 PM, joseph [EMAIL PROTECTED] wrote: Hi I have a character vector with thousands of names which looks like this: V=c(Fred, Mary, SAM) V [1] Fred Mary SAM class(V) [1] character I would like to change it to a list: L=as.list(V) L [[1]] [1] Fred [[2]] [1] Mary [[3]] [1] SAM but I need to name the components as name1, name2, name3, … so it should look like this: $name1 [1] Fred $name2 [1] Mary $name3 [1] SAM Any help will be much appreciated Joseph [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] installing source package RGtk2 on mac os x 10.4.11
Dear All, I'm trying to install the source package RGtk2 (RGtk2_2.12.5-3.tar.gz) on a i-Mac running os x 10.4.11: Nome modello:iMac Identificatore modello: iMac6,1 Nome processore: Intel Core 2 Duo Velocità processore: 2.16 GHz Numero di processori:1 Numero totale di nuclei: 2 L2 Cache (per processore): 4 MB Memoria: 2 GB Velocità bus:667 MHz Versione Boot ROM: IM61.0093.B07 Versione SMC:1.10f3 This is a step needed to use Rattle package, as detailed in: http://datamining.togaware.com/survivor/Installation_Details.html: ...Mac/OSX: download the source package from ggobi,2.12 and run the command line install: Mac/OSX: $ R CMD INSTALL RGtk2_2.8.6.tar.gz (30 minutes) You may not be able to compile RGtk2 via the R GUI on Mac/OSX as the GTK libraries can not be found when gcc is called. Once installed though, R will detect the package--don't try to load it within the GUI as GTK is not a native Mac/OSX application and it will fail. On Mac/OSX be sure to run R from the X11 environment. ... The installation is performed in a Terminal window with the following command: corradogiannasca$ R CMD INSTALL RGtk2_2.12.5-3.tar.gz There is a long listing in output and the installation fails with the following statement: /usr/bin/libtool: internal link edit command failed make: *** [RGtk2.so] Error 1 chmod: /Library/Frameworks/R.framework/Versions/2.7/Resources/library/ RGtk2/libs/i386/*: No such file or directory ERROR: compilation failed for package 'RGtk2' ** Removing '/Library/Frameworks/R.framework/Versions/2.7/Resources/ library/RGtk2' CAN ANYONE HELP IN RESOLVING THIS ERROR? Thank you very much for your support. Corrado Giannasca [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] RSPerl OS X
Hi Duncan, That fix worked I tested it with plot.pl and test2.pl, but I think a similar problem is occurring with RGtk, which I need to install before I can use RGtkviewers which in turn I need before I install IDocs :) I'm hoping the combination of those modules will allow me to produce interactive pages with data processed by Perl and passed to R via RSPerl? $ R CMD INSTALL RGtk_* * Installing to library '/Library/Frameworks/R.framework/Resources/library' * Installing *source* package 'RGtk' ... checking for pkg-config... no checking for gtk-config... no checking for gnome-config... no configure: creating ./config.status config.status: creating src/Makevars config.status: creating cleanup ** libs ** arch - i386 make: --cflags: Command not found gcc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10 .4 -std=gnu99 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/includ e -I/Library/Frameworks/R.framework/Resources/include/i386 -I. -D_R_=1 -DUSE_R=1 -I/Library/Frameworks/R.framework/Resources/include -msse3-fPIC -g -O2 -march=nocona -c GdkManual.c -o GdkManual.o GdkManual.c:1:21: error: gdk/gdk.h: No such file or directory In file included from GdkManual.c:3: gtkUtils.h:6:21: error: gtk/gtk.h: No such file or directory In file included from gtkUtils.h:8, from GdkManual.c:3: RGtk.h:20: error: parse error before 'guint' RGtk.h:20: warning: no semicolon at end of struct or union RGtk.h:21: warning: type defaults to 'int' in declaration of 'R_gtk_CallbackData ' RGtk.h:21: warning: data definition has no type or storage class RGtk.h:23: error: parse error before '*' token RGtk.h:24: error: parse error before '*' token RGtk.h:27: error: parse error before 'type' In file included from GdkManual.c:3: gtkUtils.h:30: warning: parameter names (without types) in function declaration gtkUtils.h:32: error: parse error before 'arg' gtkUtils.h:33: error: parse error before 'GtkArg' gtkUtils.h:35: error: parse error before 'type' GdkManual.c: In function 'S_gdk_window_get_size': GdkManual.c:8: error: 'GdkWindow' undeclared (first use in this function) GdkManual.c:8: error: (Each undeclared identifier is reported only once GdkManual.c:8: error: for each function it appears in.) GdkManual.c:8: error: 'window' undeclared (first use in this function) GdkManual.c:8: error: parse error before ')' token GdkManual.c:12: warning: implicit declaration of function 'gdk_window_get_size' GdkManual.c: In function 'S_getGdkEventButtonX': GdkManual.c:33: error: 'GdkEventButton' undeclared (first use in this function) GdkManual.c:33: error: 'obj' undeclared (first use in this function) GdkManual.c:33: error: parse error before ')' token make: *** [GdkManual.o] Error 1 chmod: /Library/Frameworks/R.framework/Versions/2.6/Resources/library/RGtk/libs/ i386/*: No such file or directory ERROR: compilation failed for package 'RGtk' ** Removing '/Library/Frameworks/R.framework/Versions/2.6/Resources/library/RGtk Cheers David M Duncan Temple Lang wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 That will need the architecture-specific directory, e.g. etc/i386/Makeconf or etc/ppc/Makeconf There is an updated version at ~ http://www.omegahat.org/RSPerl/RSPerl_0.92-2.tar.gz that will hopefully bypass that issue. (It is a rapid fix that may have other issues.) As for finding R.pm, use the appropriate shell script in R-library/RSPerl/scripts/ to set the relevant environment variables to find the Perl code, etc. Thanks for letting me know ~ D. | `/Library/Frameworks/R.framework/Resources/etc/Makeconf'. Stop. | calling make -f Makefile.perl install | make: Makefile.perl: No such file or directory | make: *** No rule to make target `Makefile.perl'. Stop. | chmod: blib/lib/R.pm: No such file or directory | Finished configuration | ** libs | ** arch - i386 | gcc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk | -mmacosx-version-min=10.4 -std=gnu99 -no-cpp-precomp | -I/Library/Frameworks/R.framework/Resources/include | -I/Library/Frameworks/R.framework/Resources/include/i386 -I. -g -pipe | -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing | -I/usr/local/include | -I/System/Library/Perl/5.8.6/darwin-thread-multi-2level/CORE -DPERL_POLLUTE | -D_R_=1 -DUSE_R=1 -DUSE_TOPLEVEL_EXEC=1 -DWITH_R_IN_PERL=1 -msse3 -fPIC | -g -O2 -march=nocona -c Converters.c -o Converters.o | gcc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk | -mmacosx-version-min=10.4 -std=gnu99 -no-cpp-precomp | -I/Library/Frameworks/R.framework/Resources/include | -I/Library/Frameworks/R.framework/Resources/include/i386 -I. -g -pipe | -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing | -I/usr/local/include | -I/System/Library/Perl/5.8.6/darwin-thread-multi-2level/CORE -DPERL_POLLUTE | -D_R_=1 -DUSE_R=1 -DUSE_TOPLEVEL_EXEC=1 -DWITH_R_IN_PERL=1 -msse3 -fPIC | -g -O2 -march=nocona -c ForeignReference.c -o
Re: [R] R-Excel Macro Problem
Yasir, I couldn't find your email address, I'm new to the forum. Here's the code, Sub Run_ModelT() Call Rinterface.StartRServer Call Rinterface.PutDataframe(DataSet, Range(Peram!A1:E2000)) Call Rinterface.RRun(attach(DataSett)) Call Rinterface.RRun(model - lm(Ch_Close_1 ~ Ch_Gold_1)) Call Rinterface.GetArray(coeftest(model), Range(OutPut!D7)) Call Rinterface.GetArray(summary(lm(model))$r.squared, Range(OutPut!G3)) Call Rinterface.GetArray(summary(lm(model))$adj.r.squared, Range(OutPut!G4)) End Sub I'm still looking for the problem. I'm beginning to think it dosen't have anything to do with code. I think there's a problem with the com server or something else. Thanks for the help. Yasir Kaheil wrote: hi Nate, could you please email me your excel workbook. thanks y nmarti wrote: I'm trying to write R functions into VBA code. I've done this many other times in other documents and everything has run great. But today I keep recieving an error message Run-time error '1004': Application-defined or object-defined error. Has anyone else encountered this same error message? I do not recieve this error in the document when running regular VBA code. But when I try to run, Call Rinterface.PutDataframe(Data, Range(Sheet1!A1:E2000)) I receive the error. I have the VBA References RExcelVBAlib checked. Any suggestions would be appreiciated, Nate -- View this message in context: http://www.nabble.com/R-Excel-Macro-Problem-tp17450757p17459745.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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-Excel Macro Problem
glad to hear things worked out. y nmarti wrote: Ok, so I'm embarrassed to admit I made a really dumb mistake. My VBA page was declared as Sheet1 code when it should have been Module1 code. I knew it was something stupid. Sorry for the inconvenience. Yasir Kaheil wrote: hi Nate, could you please email me your excel workbook. thanks y nmarti wrote: I'm trying to write R functions into VBA code. I've done this many other times in other documents and everything has run great. But today I keep recieving an error message Run-time error '1004': Application-defined or object-defined error. Has anyone else encountered this same error message? I do not recieve this error in the document when running regular VBA code. But when I try to run, Call Rinterface.PutDataframe(Data, Range(Sheet1!A1:E2000)) I receive the error. I have the VBA References RExcelVBAlib checked. Any suggestions would be appreiciated, Nate - Yasir H. Kaheil Catchment Research Facility The University of Western Ontario -- View this message in context: http://www.nabble.com/R-Excel-Macro-Problem-tp17450757p17462407.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Solving 100th order equation
On 25/05/2008, at 1:10 PM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Oops! Actually spectacularly bad. I didn't see the positive exponent! Curiously, there appears to be just one bad apple: sort(Mod(p(z))) [1] 1.062855e-10 1.062855e-10 1.328999e-10 1.328999e-10 2.579625e-10 [6] 2.579625e-10 3.834721e-10 3.834721e-10 3.875288e-10 3.875288e-10 [11] 5.287459e-10 5.287459e-10 5.306241e-10 5.306241e-10 6.678424e-10 [16] 6.678424e-10 6.876300e-10 6.876300e-10 8.519089e-10 8.519089e-10 [21] 9.345531e-10 9.345531e-10 9.369015e-10 9.369015e-10 9.789510e-10 [26] 9.789510e-10 1.041601e-09 1.041601e-09 1.046996e-09 1.046996e-09 [31] 1.149073e-09 1.149073e-09 1.209875e-09 1.209875e-09 1.232793e-09 [36] 1.232793e-09 1.244167e-09 1.244167e-09 1.388979e-09 1.388979e-09 [41] 1.556354e-09 1.556354e-09 1.596424e-09 1.596424e-09 1.610661e-09 [46] 1.610661e-09 1.722577e-09 1.722577e-09 1.727842e-09 1.727842e-09 [51] 1.728728e-09 1.728728e-09 1.769644e-09 1.769644e-09 1.863983e-09 [56] 1.863983e-09 1.895296e-09 1.895296e-09 1.907509e-09 1.907509e-09 [61] 1.948662e-09 1.948662e-09 2.027021e-09 2.027021e-09 2.061063e-09 [66] 2.061063e-09 2.116735e-09 2.116735e-09 2.185764e-09 2.185764e-09 [71] 2.209158e-09 2.209158e-09 2.398479e-09 2.398479e-09 2.404217e-09 [76] 2.404217e-09 2.503279e-09 2.503279e-09 2.643436e-09 2.643436e-09 [81] 2.654788e-09 2.654788e-09 2.695735e-09 2.695735e-09 2.921933e-09 [86] 2.921933e-09 2.948185e-09 2.948185e-09 2.953596e-09 2.953596e-09 [91] 3.097433e-09 3.097433e-09 3.420593e-09 3.420593e-09 3.735880e-09 [96] 3.735880e-09 4.190042e-09 4.554964e-09 4.554964e-09 1.548112e+15 snip library(PolynomF) x - polynom() p - x^100 - 2*x^99 + 10*x^50 + 6*x - 4000 z - solve(p) z [1] -1.0741267+0.000i -1.073-0.0680356i -1.073 +0.0680356i -1.0655699-0.1354644i [5] -1.0655699+0.1354644i -1.0568677-0.2030274i -1.0568677 +0.2030274i -1.0400346-0.2687815i ... [93] 1.0595174+0.2439885i 1.0746575-0.1721335i 1.0746575 +0.1721335i 1.0828132-0.1065591i [97] 1.0828132+0.1065591i 1.0879363-0.0330308i 1.0879363 +0.0330308i 2.000+0.000i Now to check how good they are: range(Mod(p(z))) [1] 1.062855e-10 1.548112e+15 It is fascinating to muck about with curve(p,from=a,t=b) for various values of a and b. One eventually discerns that there is a real root just a tad less than 2. Doing uniroot(p,c(1.5,2.5)) gives a root of just *over* 2 with a function value of about 1.9e25. However uniroot(p,c(1.995,2.005)) gives $root [1] 1.93 $f.root [1] -4.570875e+24 $iter [1] 4 $estim.prec [1] 6.103516e-05 What a difference 7.214144e-06 makes! When you're dealing with polynomials of degree 100. Bozhemoi! cheers, Rolf Turner P.S. I suspect that this was a numerical analysis homework question designed to teach a salutary lesson to the nonchalant neophytes. R. T. ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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-Excel Macro Problem
Ok, so I'm embarrassed to admit I made a really dumb mistake. My VBA page was declared as Sheet1 code when it should have been Module1 code. I knew it was something stupid. Sorry for the inconvenience. Yasir Kaheil wrote: hi Nate, could you please email me your excel workbook. thanks y nmarti wrote: I'm trying to write R functions into VBA code. I've done this many other times in other documents and everything has run great. But today I keep recieving an error message Run-time error '1004': Application-defined or object-defined error. Has anyone else encountered this same error message? I do not recieve this error in the document when running regular VBA code. But when I try to run, Call Rinterface.PutDataframe(Data, Range(Sheet1!A1:E2000)) I receive the error. I have the VBA References RExcelVBAlib checked. Any suggestions would be appreiciated, Nate -- View this message in context: http://www.nabble.com/R-Excel-Macro-Problem-tp17450757p17460474.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] nls diagnostics?
Dear Spencer, I just saw your post. If the singular gradient happens during or after iteration one (that is, not at the initial estimates), then calling summary on the nls output would give standard error estimates on the parameters useful for diagnostics. You could also call chol2inv(xx$m$Rmat()) where xx is the object returned by nls to get an estimate of the inverse of the hessian; you could use this estimate to proceed with the diagnostics you were discussing. It would be possible (and in my opinion, desirable) to modify nls to return an object that contains the information above even if the singular gradient is at the intial estimates, but I don't think this can be accomplished without quite a few changes. You could also use nls.lm from the package minpack.lm to get a hessian estimate. By the way, I liked your idea from a while back (https://stat.ethz.ch/pipermail/r-devel/2008-April/048984.html) to do some diagnostics to identify problems with overparameterization automatically. best, Kate On Fri, 23 May 2008, Spencer Graves wrote: Hi, All: What tools exist for diagnosing singular gradient problems with 'nls'? Consider the following toy example: DF1 - data.frame(y=1:9, one=rep(1,9)) nlsToyProblem - nls(y~(a+2*b)*one, DF1, start=list(a=1, b=1), control=nls.control(warnOnly=TRUE)) Error in nlsModel(formula, mf, start, wts) : singular gradient matrix at initial parameter estimates This example is obviously stupid, but other singular gradient problems are not so obvious. If we transfer this problem to 'optim', we can get diagnostics from an eigen analysis of the hessian: dumfun - function(x, y, one){ d - y-(x[1]+2*x[2])*one sum(d^2) } optimToyProblem - optim(c(a=1, b=1), dumfun, hessian=TRUE, y=DF1$y, one=DF1$one) eigen(optimToyProblem$hessian, symmetric=TRUE) $values [1] 9.00e+01 -7.105427e-10 $vectors [,1] [,2] [1,] 0.4472136 -0.8944272 [2,] 0.8944272 0.4472136 The smallest eigenvalue is essentially numerically zero relative to the largest,confirming the 'singular gradient' message. The corresponding eigenvector helps diagnose the problem: Adding (-0.9, 0.45)*z to any solution gives another equally good solution, for any z. I've used this technique to diagnose many subtle convergence problems with 'optim'. Are tools of this nature available for 'nls'? Thanks, Spencer Graves __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] nls diagnostics?
On Sun, May 25, 2008 at 9:32 PM, Katharine Mullen [EMAIL PROTECTED] wrote: Dear Spencer, I just saw your post. If the singular gradient happens during or after iteration one (that is, not at the initial estimates), then calling summary on the nls output would give standard error estimates on the parameters useful for diagnostics. You could also call chol2inv(xx$m$Rmat()) where xx is the object returned by nls to get an estimate of the inverse of the hessian; you could use this estimate to proceed with the diagnostics you were discussing. Try this: library(nls2) DF1 - data.frame(y=1:9, one=rep(1,9)) xx - nls2(y~(a+2*b)*one, DF1, start = c(a=1, b=1), algorithm = brute-force) eigen(chol2inv(xx$m$Rmat())) $values [1] 5.070602e+31 0.00e+00 $vectors [,1] [,2] [1,] -0.8944272 -0.4472136 [2,] 0.4472136 -0.8944272 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Joining Histograms Into a Figure
Hi, I have two histograms created separately using the following code. It creates two separate figures. dat - read.table(file=GDS1096.modelout, head = FALSE ) __BEGIN__ dat - read.table(file=GDS1096.modelout, head = FALSE ) hist(dat$V2, main=AIC Freq, xlab = \# Component, breaks = 36, xlim = c(0,max(dat$V2)), col = dark red, freq = TRUE) hist(dat$V3, main=BIC Freq, xlab = \# Component, breaks = 36, xlim = c(0,max(dat$V2)), col = blue, freq = TRUE) __END__ How can I joint this two histograms into one figure? Regards, Edward __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.