Re: [R] CGIwithR installation failure
On 08/06/2013 23:27, rex wrote: Hello, CGIwithR apparently is not available on CRAN for R 2.15.x, so I It is not hosted on CRAN. You should ask its maintainer (and package installation problems most often belong on the R-devel list). See what the posting guide says about that and about upgrading your R before posting. downloaded the source (0.73) and tried: ~/Downloads$ R CMD INSTALL CGIwithR * installing to library ‘/home/rex/R/x86_64-pc-linux-gnu-library/2.15’ * installing *source* package ‘CGIwithR’ ... configure: creating ./config.status config.status: creating R/CGIwithR.R * After the installation of this R package is complete copy the files R.cgi and .Rprofile in /home/rex/R/x86_64-pc-linux-gnu-library/2.15/CGIwithR/cgi-bin/ to the cgi-bin area of your Web server. If necessary, modify the settings in the first part of R.cgi to suit your local configuration. * ** R Error in parse(outFile) : embedded nul in string: '\0' ERROR: unable to collate and parse R files for package ‘CGIwithR’ Any suggestions, including using a different package, appreciated. Background: I want to solve the classic diet linear programming problem. The CGI code needs to parse a POST, access a MySQL DB, solve the problem (probably using the linprog package), and present the solution to the vistor. I've done CGI programming in Python, but not in R and don't know if CGIwithR is a good choice. It hasn't been updated since 2005, so a more current package may be a better choice. OTOH, my needs are (currently) simple so CGIwithR may be an OK choice. I've a Python version that does the above, except for finding the lowest cost diet that meets constraints. The Python input form will be used in the R version (no point in reinventing the wheel). http://www.nosyntax.net/birdnutrit/ Thanks for any help. -rex -- Brian D. Ripley, rip...@stats.ox.ac.uk 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.
Re: [R] CGIwithR installation failure [SOLVED]
rex r...@nosyntax.net [2013-06-08 18:05]: CGIwithR apparently is not available on CRAN for R 2.15.x, so I downloaded the source (0.73) and tried: ~/Downloads$ R CMD INSTALL CGIwithR Typo. Actually, I downloaded 0.72. Later, I found 0.73 here: http://cran.r-project.org/src/contrib/Archive/CGIwithR/ D/L 0.73 tar -xzvf CGIwithR_0.73-0.tar.gz R CMD INSTALL CGIwithR * installing to library ‘/home/rex/R/x86_64-pc-linux-gnu-library/2.15’ * installing *source* package ‘CGIwithR’ ... ** package ‘CGIwithR’ successfully unpacked and MD5 sums checked configure: creating ./config.status config.status: creating R/CGIwithR.R * After the installation of this R package is complete copy the files R.cgi and .Rprofile in /home/rex/R/x86_64-pc-linux-gnu-library/2.15/CGIwithR/cgi-bin/ to the cgi-bin area of your Web server. If necessary, modify the settings in the first part of R.cgi to suit your local configuration. * ** R ** inst ** preparing package for lazy loading ** help *** installing help indices ** building package indices ** installing vignettes ** testing if installed package can be loaded * DONE (CGIwithR) My slightly modified R.cgi, trivial.html trivial.R are below for reference (I'm running Debian Testing R 2.15.3). R.cgi #! /bin/sh ### A shell script to make CGI scripting possible in R. Part of the ### CGIwithR package for R. ### ### Author: David Firth, University of Warwick ### (d.fi...@warwick.ac.uk) ### ### Terms of use: GPL version 2 or later. See COPYING in the ### R distribution. ### ### NO WARRANTY GIVEN, AND NO LIABILITY ACCEPTED FOR LOSS CAUSED BY ### USE OF THIS PROGRAM ### ### ### INSTALLING IT: ### ### This file, and the one-line .Rprofile file included with the ### package, must be placed together in a cgi-bin directory. Both ### files should be readable (and this file executable) by the web ### server. ### ### ### CONFIGURING IT: ### ### First locate R on the local system (typically the answer ### to which R). This is the command to run R. ### Individual R CGI scripts may request execution by a ### different, elsewhere-installed version of R; the R specified ### here is the default. R_DEFAULT=/usr/bin/R #R_DEFAULT=/usr/local/bin/R ### Graphs can be included in the output using either the ### GDD package (available from cran.r-project.org) ### or via ghostscript. ### GDD is the default. If it is not installed, the webPNG() ### function will attempt to use ghostscript. You can specify ### where the executable is located on your system via the R_GSCMD ### environment variable. If using GDD, you can ignore this. R_GSCMD=/usr/bin/gs #R_GSCMD=/usr/local/bin/gs export R_GSCMD ### The next two lines may optionally be edited to limit access ### to local resources. ### ### This line allows specification of the priority ### given to the R process. A nice of 0 is the normal ### priority, while e.g. +10 causes R to be run as a ### low-priority process. The value NONE should be given if ### nice is not implemented locally. R_NICE=NONE ### This line allows the imposition of a length limit on the data ### entered on an HTML form for processing by an R script. ### Setting MAX_DATA_LENGTH=1000, for example, aborts ### execution if the data length exceeds 1000 characters. Or ### use MAX_DATA_LENGTH=NONE to impose no limit here. MAX_DATA_LENGTH=1000 ### ### To make use of packages not installed in the default library for R ### i.e. `R RHOME`/library/, set the environment R_LIBS to identify ### one or more library directories containing the packages (separated by :). ### This is only necessary if the CGIwithR package itself is not located ### in the default library, e.g. if one is using a different version. R_LIBS=/home/rex/R/x86_64-pc-linux-gnu-library/2.15/ export R_LIBS ### No further configuration is needed. No changes made in R.cgi below here. trivial.html !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd; html head titleAn example form for CGIwithR/title meta name=generator content=BBEdit 6.1.2 /head FORM action=http://www.nosyntax.net/cgi-bin/R.cgi/trivial.R; method=POST body Enter some words: INPUT type=text name=words value= size=20 BRBR Now some numbers (separated by any kind of white space):BR textarea name=numbers rows=6 cols=20/textarea PINPUT type=submit size=3 /body /html trivial.R #! /usr/bin/R tag(HTML) tag(HEAD) tag(TITLE) cat(An example R.cgi output page) untag(TITLE) untag(HEAD) comments(Some comments to be ignored by the web browser) lf(2) tag(BODY, bgcolor = lightyellow) lf(2) tag(h3) cat(A large heading) untag(h3) lf(2) tag(p) cat(Your words in italics:)
Re: [R] CGIwithR installation failure [SOLVED]
On 09/06/2013 08:05, rex wrote: rex r...@nosyntax.net [2013-06-08 18:05]: CGIwithR apparently is not available on CRAN for R 2.15.x, so I downloaded the source (0.73) and tried: ~/Downloads$ R CMD INSTALL CGIwithR Typo. Actually, I downloaded 0.72. Later, I found 0.73 here: http://cran.r-project.org/src/contrib/Archive/CGIwithR/ But see http://cran.r-project.org/package=CGIwithR for the current host. -- Brian D. Ripley, rip...@stats.ox.ac.uk 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.
Re: [R] CGIwithR installation failure
Prof Brian Ripley rip...@stats.ox.ac.uk [2013-06-08 23:23]: On 08/06/2013 23:27, rex wrote: CGIwithR apparently is not available on CRAN for R 2.15.x, so I It is not hosted on CRAN. You should ask its maintainer (and package installation problems most often belong on the R-devel list). Actually it is, but not in the usual place. See what the posting guide says about that and about upgrading your R before posting. I did read the posting guide before posting, and I'm in no hurry to upgrade R, thank you. As you can see from my [Solved] post, the problem was with 0.72, and 0.73 works with R 2.15.3. Background: I want to solve the classic diet linear programming problem. The CGI code needs to parse a POST, access a MySQL DB, solve the problem (probably using the linprog package), and present the solution to the vistor. I've done CGI programming in Python, but not in R and don't know if CGIwithR is a good choice. It hasn't been updated since 2005 [0.73 was updated in 2010], so a more current package may be a better choice. OTOH, my needs are (currently) simple so CGIwithR may be an OK choice. It would have been nice to get some feedback on the suitability of CGIwithR compared to other CGI alternatives. -rex -- Life would be easier if I had the source 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] CGIwithR installation failure [SOLVED]
Prof Brian Ripley rip...@stats.ox.ac.uk [2013-06-09 00:22]: On 09/06/2013 08:05, rex wrote: Typo. Actually, I downloaded 0.72. Later, I found 0.73 here: http://cran.r-project.org/src/contrib/Archive/CGIwithR/ But see http://cran.r-project.org/package=CGIwithR for the current host. I did; that's where I found the link to the CRAN archive that has 0.73. The http://www.omegahat.org/CGIwithR/ link is to 0.72. IOW, the CRAN archive is more up-to-date than the current host. -rex -- Nostalgia ain't what it used to be. __ 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 on window() function of the 'zoo' package
Hello, Actually, Dat_zoo is not a matrix, it is an object of classes zooreg and zoo, with a dim attribute: class(Dat_zoo) dim(Dat_zoo) And the output of window() is of the same classes but without a dim attribute: wnd - window(Dat_zoo, start = as.Date(2001-01-02)) class(wnd) dim(wnd) # NULL You can set the dim attribute manually like this: dim(wnd) - c(length(wnd), 1) Hope this helps, Rui Barradas Em 08-06-2013 22:02, Ron Michael escreveu: Hi, I observed that if I use window() function available with the 'zoo' package to extract a portion of my times series and if that time series data is stored in some 'zoo' object with only 1 column, then the resulting zoo object is becoming vector. Here is my observation: library(zoo) Dat - matrix(1:3, nc = 1) Dat [,1] [1,]1 [2,]2 [3,]3 Dat_zoo - zooreg(Dat, start = as.Date(2001-01-01), frequency = 1) Dat_zoo 2001-01-01 1 2001-01-02 2 2001-01-03 3 window(Dat_zoo, start = as.Date(2001-01-02)) ### why it is becoming vector? I want to retain it as matrix only 2001-01-02 2001-01-03 2 3 Here you can see that, originally my 'Dat_zoo ' object was basically a matrix. However once I use window() function, it became vector. Is there any possibility to retain the shape of the original object, particularly if that object is matrix with 1 column? Thank you very much for your help. [[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. __ 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] Dyn.load of sharing object with GSL library
Dear R-list, I want to use shared library of gsl in R(2.15.1) on unix .I have a makefile such as CC = gcc CFLAGS = -fPIC -O2 PKG_LIBS -lgsl -lgslcblas -lm -lpthread OBJS_SPB = calc_spb.o k.o dk.o ddk.o calc_spb.so : $(OBJS_SPB) $(CC) -shared -o calc_spb.so $(LIBS) $(OBJS_SPB) clean : rm -f ../*.o *.o clean.so: rm -f *.so I use R CMD SHLIB calc_spb.c in terminal window of unix and in my directory was built calc_spb.o and calc_spb.so. And I use dyn.load in R the error is Dyn.load(“calc_spb.so”) Error in dyn.load(“calc_spb.so”): Unable to load shared object ‘/home/mir/cal/calc_spb.so’: /home/mir/cal/calc_spb.so: undefined symbol :gsl_finite Thanks to all who tried to help me in solving my problem. A problem.pdf Description: Adobe PDF document __ 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] agnes() in package cluster on R 2.14.1 and R 3.0.1
Dear R users, I discovered something strange using the function agnes() of the cluster package on R 3.0.1 and on R 2.14.1. Indeed, the clusterings obtained are different whereas I ran exactly the same code. I quickly looked at the source code of the function and I discovered that there was an important change: agnes() in R 2.14.1 used a FORTRAN code whereas agnes() in R 3.0.1 uses a C code. Here is one of the contingency table between R 2.14.1 and R 3.0.1: classe.agnTani.2.14.1 classe.agnTani.3.0.1 12 3 174 0229 2 02350 3 120 0 15 So, I was wondering if it was normal that the C and FORTRAN codes give different results? Best regards, Hugo Varet [[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] Dyn.load of sharing object with GSL library
On 09/06/2013 08:27, moghadameh mirzai wrote: Dear R-list, I want to use shared library of gsl in R(2.15.1) on unix .I have a makefile such as Well, don't try to use a Makefile as you do not know what you are doing. Use Makevars instead. CC = gcc CFLAGS = -fPIC -O2 PKG_LIBS -lgsl -lgslcblas -lm -lpthread That is missing a = OBJS_SPB = calc_spb.o k.o dk.o ddk.o calc_spb.so : $(OBJS_SPB) $(CC) -shared -o calc_spb.so $(LIBS) $(OBJS_SPB) You 'defined' PKG_LIBS not LIBS and your terms are in the wrong order. Whether the latter matters depends on which 'unix' this is. On most 'unix' systems a Makevars with PKG_LIBS = -lgsl -lgslcblas -lm would suffice. Or even PKG_LIBS = `gsl-config --libs` clean : rm -f ../*.o *.o clean.so: rm -f *.so I use R CMD SHLIB calc_spb.c in terminal window of unix and in my directory was built calc_spb.o and calc_spb.so. And I use dyn.load in R the error is Dyn.load(“calc_spb.so”) Error in dyn.load(“calc_spb.so”): Unable to load shared object ‘/home/mir/cal/calc_spb.so’: /home/mir/cal/calc_spb.so: undefined symbol :gsl_finite Thanks to all who tried to help me in solving my problem. __ 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, rip...@stats.ox.ac.uk 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] Fortunes nomination (was: colour coded dotchart)
On reading the help pages, On 13-06-08 9:32 PM, Rolf Turner wrote: ... You need to get the hang of reading the online help. The information required is actually there in ?dotchart --- it's just tersely and obscurely expressed. A certain degree of optimism is required. You need to ***believe*** that the information is there; then ask yourself What could they possibly mean by what they have written that would tell me what I need to know?. Duncan Murdoch __ 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] Fortunes nomination (was: colour coded dotchart)
On Sun, 9 Jun 2013, Duncan Murdoch wrote: On reading the help pages, Thanks, online on R-Forge now :-) Best, Z On 13-06-08 9:32 PM, Rolf Turner wrote: ... You need to get the hang of reading the online help. The information required is actually there in ?dotchart --- it's just tersely and obscurely expressed. A certain degree of optimism is required. You need to ***believe*** that the information is there; then ask yourself What could they possibly mean by what they have written that would tell me what I need to know?. Duncan Murdoch __ 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] generate simple function with pre-defined constants
Dear Bill, On Thu, Jun 6, 2013 at 5:36 PM, William Dunlap wdun...@tibco.com wrote: Try the following: generateABFunction - function(a, b) { force(a) force(b) function(x) a*x + b } f12 - generateABFunction(1, 2) f53 - generateABFunction(5,6) f12(10:12) # get 12, 13, 14 f53(10:12) # get 56, 61, 66 See, e.g., yesterday's discussion under the subject Trying to build up functions with its names by means of lapply on why the force() calls are required. Read up on R's environments to see why f12 and f53 look the same but act differently (hint: look at ls.str(environment(f12))). This is exactly what I was trying to do. Thank you for the explanations, Liviu Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Liviu Andronic Sent: Thursday, June 06, 2013 8:00 AM To: r-help@r-project.org Help Subject: Re: [R] generate simple function with pre-defined constants On Thu, Jun 6, 2013 at 4:48 PM, Liviu Andronic landronim...@gmail.com wrote: Dear all, Given: a - 2 b - 3 I'd like to obtain the following function: f - function(x) 2 + 3*x but when I do this: f - function(x) a + b*x ##f ##function(x) a + b*x the 'a' and 'b' objects do not get evaluated to their constants. How could I do that? I found one solution: a - 2 b - 3 f - eval(parse(text=paste(function(z), a, + z * , b))) f ##function(z) 2 + z * 3 but I still have nightmares from: fortune(parse) If the answer is parse() you should usually rethink the question. -- Thomas Lumley R-help (February 2005) Is there a nicer way to approach this? Thanks, Liviu Thanks, Liviu -- Do you know how to read? http://www.alienetworks.com/srtest.cfm http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader Do you know how to write? http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail -- Do you know how to read? http://www.alienetworks.com/srtest.cfm http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader Do you know how to write? http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail __ 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. -- Do you know how to read? http://www.alienetworks.com/srtest.cfm http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader Do you know how to write? http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail __ 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] Not sure this is something R could do but it feels like it should be.
Calum Hi Calum, I can only answer from the perspective of someone who calculated doses of alcohol for experimental subjects many years ago. It was not possible to apply a linear function across the range due to a number of factors. One is that BAC, which was the target value, is dependent upon the proportion of the weight that represents the water compartment of the body. This varies with both weight (heavier people typically have a higher proportion of fat) and sex (women also tend to have slightly more fat). The real monkey wrench in the works was absorption rate, which often made nonsense of my calculations. This may not be as important in therapeutic drugs, for we were aiming at a specified BAC at a certain time after dosing rather than an average level. All those things affect therapeutic dosing. I may have oversimplified what we are trying to achieve to avoid getting bogged down in the detail of what we are trying to achieve and provide something people might be able to relate to. However, we can assume that they are already sorted out, so we know the theoretically know what the 'correct' dose is for a patient. The hard bit is unless you want to give everyone liquid so you can measure any dose possible you have to have a dose that is a multiple of something (Amoxicillin doses in adults are multiples of 250 because thats the size of the capsule). What we are trying to do is determine the most appropriate number to make the capsules. (Our dosing is more complex but lets stick to something simple. I can safely assure you that vritually no-one actually needs 250 or 500mg as a dose of amoxicillin... ...thats just a dose to get them into a therapeutic window, and I'm 99% certain 250 and 500 are used coz they are round numbers. if 337.5 more reliably got everyone in the window without kicking anyone out the window that'd be a better dose to use! So... what I'm looking to do is model the 'theoretical dose required' (which we know) and the dose delivered using several starting points to get the 'best fit'. We know they need to be within 7% of each other, but if one starting point can get 85% of doses within 5% we think that might be better than one that only gets 50% within 5%. However, I suspect that many therapeutic drugs have a different dose by weight for children (we weren't dosing children) and choosing a starting point at the bottom of the range would almost certainly introduce a systematic error. My intuition would be to anchor the dosage rate in the middle of the scale and then extrapolate in both directions (adults only, of course). We are actually using a starting point that may be middle and going up and down if need be. I think what we may want to do is run a loop through each weight (in 1kg increments) and calculate their theoretical dose, and the dose for each possible starting point (there are certain contraints on that already so there may only be 20 possible start points), then we calculate the % variance for each dose to theoretical dose and calculate the Area Under Above (some will be negative) the curve and the one that has the lowest AUC is then the one that most precisely will dose the patient...? __ 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 read a .rar file in R
Hi, Thanks in advance. May I request you to assist me for the following please. I am using R-3.0.1 on Windows. Is there any R package or R function to read a .rar file (file with an extension rar)? Once again, thank you very much for the time you have given. Regards, Deb [[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] How to read a .rar file in R
On 09/06/2013 11:58, Deb Midya wrote: Hi, Thanks in advance. May I request you to assist me for the following please. I am using R-3.0.1 on Windows. Is there any R package or R function to read a .rar file (file with an extension rar)? Use system() with however you unpack rar files on your OS. .rar files are archives, not files you could usefully read into R (just like tar and zip archives). At least, the commonest such files are, and those are already pretty uncommon. There are several ways to unpack on Windows, at least 7-zip, WinZip, UnRAR (2x), WinRAR. Once again, thank you very much for the time you have given. Regards, Deb [[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. -- Brian D. Ripley, rip...@stats.ox.ac.uk 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.
Re: [R] multilevel binary and ordered regression models
Rune, Thanks a lot for pointing me to your ordinal package. It is wonderful, and I tried a random intercept model and it worked well except that probably there is something wrong with my data (size is big), I got some warning messages indicating that In sqrt(diag(vc)[1:npar]) : NaNs produced. Therefore, some of the coefficients do not have standard errors. I also have a follow-up question: if I want to estimate a slope as outcome model, how am I supposed to specify the model. I tried following the few tutorials you posted on CRAN, but was not able to figure it out: Here is my model: level 1: y*_ij = beta_0j + beta_1j*x1_ij + beta_2j*x2_ij + beta_3j*x3_ij + epsilon_ij where y* is a latent continuous variable and y is an observed binary dependent variable. y is an observed ordinal variable, say ranging from 1-4, and has been coded as a factor variable. x's are predictors at level 1 beta's are regression coefficients at level 1 epsilon's are error terms in level 1 equations level 2 Eq1: beta_0j = gamma_00 + gamma_01*w1_j + gamma_02*w2_j + mu_0j Level 2 Eq2: beta_1j = gamma_10 + gamma_11*w1_j + gamma_02*w2_j + mu_1j My guess would be: # try 1 clmm(y~ x1 + x2 + x3 + w1 + w2 + w1:x1 + w2:x2 + (1 + x1 | group), # like the syntax in lmer or glmer data=alllev, link=logit, na.action=na.omit, Hess=T) # or try 2 clmm(y~ x1 + x2 + x3 + w1 + w2 + w1:x1 + w2:x2 + (1 | group) + (1 | group:x1), data=alllev, link=logit, na.action=na.omit, Hess=T) but none worked. After I issued the first try, I got the following message: Error: Matrices must have same number of columns in rbind2(..1, r) In addition: Warning messages: 1: In cntnew:male : numerical expression has 10 elements: only the first used and after the second try, simply it says that I got to following the (1|factor) format. I would appreciate that if you could point me to the right direction. Also, I know I am dealing with a relatively large data set, but is there any way to speed up the estimation a bit. Thanks a lot! Jun On Fri, Jun 7, 2013 at 1:04 AM, Rune Haubo rune.ha...@gmail.com wrote: On 6 June 2013 00:13, Xu Jun junx...@gmail.com wrote: Dear r-helpers, I have two questions on multilevel binary and ordered regression models, respectively: 1. Is there any r function (like lmer or glmer) to run multilevel ordered regression models? Yes, package ordinal will fit such models. Cheers, Rune __ 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] Error Object Not Found
On 08.06.2013 21:35, Court wrote: Hello, I am having difficulty with a command. An error message pops up saying: Error: object 'RWGJ.wload' not found. I have installed the packages needed to run the analysis, and have saved them to my working directory. And have you actually loaded them? Uwe Ligges -- View this message in context: http://r.789695.n4.nabble.com/Error-Object-Not-Found-tp4669041.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. __ 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] Package 'ChoiceModelR' - Xbetas.csv? Rbetas.csv? betadraws?
On 07.06.2013 21:25, Dimitri Liakhovitski wrote: Hope to get some clarity from the creators of a (wonderful) package ChoiceModelR. I am using the main function 'choicemodelr'. Since we do not know if these creators are reading the list, why not ask them directly? Best, Uwe Ligges Everything works. ?choicemodelr says average of MCMC draws of unit-level model coefficients are written to Xbetas.csv Question 1: Is this a typo? The real file created in the working directory seems to be Rbetas.csv Questions 2: Are these the averages of the 'use' draws (specified in my choicemodelr statement)? Question 3: If I had constraints, I assume these averages will be taking into account constraints, right? ?choicemodelr also says that choicemodelr produces an object that contains, among other things, two elemens: betadraw An ni by natt by floor(use/keep) array of MCMC random draws of unit-level multinomial logit model parameter estimates. betadraw.c An ni by natt by floor(use/keep) array of constrained MCMC random draws of unit-level multinomial logit model parameter estimates. If I do: apply(out$betadraw.c,c(1,2),mean) then what is the difference between the result and the file written to Disk? One difference I noticed: apply(out$betadraw.c, c(1,2),mean) contains as many columns as parameters, not as many columns as the number of levels. What else? Thank you very much! __ 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] Identifying breakpoints/inflection points?
Please quote the question you are answering and also send the answer to the original poster, not only to this *mailing list* the original poster may not be reading himself. Best, Uwe Ligges On 07.06.2013 09:08, dchristop wrote: You can try this: library(inflection) #you have to instsall package inflection first a-findiplist(cbind(year),cbind(piproute),1) a The answer: [,1] [,2] [,3] [1,]5 35 1986.0 [2,]5 30 1983.5 shows that the total inflection point is between 1983 and 1986, if we treat data as first concave and then convex, as it can be found from a simple graph. -- View this message in context: http://r.789695.n4.nabble.com/Identifying-breakpoints-inflection-points-tp2065886p4668889.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. __ 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] It seams that fast99 function (sensitivity package) does not work out for norm distribution.
On 08.06.2013 00:54, Marino David wrote: Dear all mailing listers, Does Anyone have the same problem as mine when using the fast99 (extended-FAST method) to perform SA of model with norm distribution inputs? Why not ask the authors of the function? Best, Uwe Ligges See the simple example given following. Any suggestion will be greatly appreciated. Thank you! Marino # Simple example # 1. uniform version (It works well) library(sensitivity) Myfun-function(x){return(rowSums(x))} SA1 - fast99(model = Myfun, factors = 3, n = 1000, q = qunif, q.arg = list(min = 0, max = 1)) SA1 Call: fast99(model = Myfun, factors = 3, n = 1000, q = qunif, q.arg = list(min = 0, max = 1)) Model runs: 3000 Estimations of the indices: first order total order X1 0.3335243 0.3350584 X2 0.3335243 0.3350584 X3 0.3335243 0.3350584 # 2. norm version (it does not work) SA2 - fast99(model = Myfun, factors = 3, n = 1000, q = qnorm, q.arg = list(mean = 0, sd = 1)) SA2 Call: fast99(model = Myfun, factors = 3, n = 1000, q = qnorm, q.arg = list(mean = 0, sd = 1)) Model runs: 3000 Estimations of the indices: first order total order X1 NA NA X2 NA NA X3 NA NA [[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. __ 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] segfault -- address 0x29, cause 'memory not mapped'
On 08.06.2013 15:38, mathias kuhnt wrote: Dear List, after a night of calculating, R says goodbye with a segmentation fault. *** caught segfault *** address 0x29, cause 'memory not mapped' In my functions I subsequently read in network files of about 20KB using the IGraph package. Admittedly, I read in about 1 million files, in total 20GB. Still, the function saves the data to the same object and memory of the prior file should be freed. The crash occurs after some hours but not at the same time, last time after having read in 99% of the files. It probably depends on what I did before I started the function. Can anybody tell me if these are limitations of the program and I have to live with it or am I doing something wrong? Is it a general R problem or rather one of the IGraph package? I guess igraph, butz cannot be sure without a reproducible example. Perhaps the best idea is to find an example that generates the problem rather quickly and send it to the igraph maintainer. Best, Uwe Ligges Thanks in advance, Mathias here the code: # library(igraph) modnumber-1200 its-1000 seriespath-/daten/netgen_series/series_m1q2/ mylim-200 max-100 startval-1 sampledegcorr - function (model, its, max) # I suppose it does not matter what I do here but as you see I read in 1000 network files and analyze them { dc-rep(NA,max) for (i in 0:(its-1)) { net-read.graph(paste(seriespath,model,/,i,.net, sep = ),format=pajek) net-simplify(net) ndeg - sapply(V(net),function(x) mean(degree(net,neighbors(net,x))-1)) bo-stats.bin(degree(net),ndeg,breaks=seq(-0.5,max ,1)) dc-cbind(dc,bo$stats[2,]) } dck-as.vector(apply(dc,1,mean, na.rm=T)) return(cbind(seq(0,max-1,1),dck)) } dc-seq(0,max-1,1) for (i in startval:(modnumber)) # here i start the function above with 1200 different networks { print(paste(calculating model , i, sep=)) dc-cbind(dc,sampledegcorr(paste(m, i, sep=),its,mylim)[,2]) save(dc,file=series_m1q2_dc_results.RData) } ## here my specs: R 3.0.1-3precise R crashed with SIGSEGV in Rf_StringTrue() Ubuntu 12.04.1 4 GB RAM __ 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] Regression Tolerance Intervals - Dr. Young's Code
On 08.06.2013 05:17, Muhuri, Pradip (SAMHSA/CBHSQ) wrote: Hello, Below is a reproducible example to generate the output by using Dr. Young's R code on the above subject . As commented below, the issue is that part of the code (regtol.int and plottol) does not seem to work. I would appreciate receiving your advice toward resolving the issue. Thanks and regards, Pradip Muhuri setwd (E:/) require (tolerance) d1- xlndur ylnant 8.910797 0.33901690 9.001415 0.36464311 8.983936 0.53976194 8.948035 0.33901690 9.056784 0.39266961 9.018593 0.18617770 9.001415 0.53976194 8.983936 -0.11005034 8.966147 0.53102826 8.948035 0.59885086 6.90 NA xd1 - read.table(textConnection(d1), header=TRUE, as.is=TRUE) print (xd1); str (xd1) #This code works xout1 - regtol.int (reg=lm (formula=ylnant ~ xlndur, data=xd1), alpha=.05, P=0.99, side=2) print (xout1) #This code does not work xout2 - regtol.int (reg=lm (formula=ylnant ~ xlndur, data=xd1), new.xlndur = NULL, alpha=.05, P=0.99, side=2) Come on, start using your brain and replace new.xlndur by new.x? print (xout2) #This code does not work plottol(xout1, x=cbind(1,x), y=y, side=two, x.lab=X, y.lab=Y ) So replace x and y appropriately? Best, Uwe Ligges #This code does not work plottol(xout2, x=cbind(1,x), y=y, side=two, x.lab=X, y.lab=Y ) [[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. __ 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] import from Stata, get NA
Dear all, I have troubles figuring out how to convert missing values from Stata (treated as -1 and -2) into NAs in R. To read in the dta file I use: data - read.dta(data.dta) Is there an option to tell R to convert the -1 and -2 into NAs ? Your help is appreciated. Thanks a lot in advance. Rike [[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] import from Stata, get NA
On Jun 9, 2013, at 7:41 AM, Ulrike Pasda wrote: Dear all, I have troubles figuring out how to convert missing values from Stata (treated as -1 and -2) into NAs in R. To read in the dta file I use: data - read.dta(data.dta) Is there an option to tell R to convert the -1 and -2 into NAs ? The documentation for read.dta in the foreign package suggests that true Stata missingness is handled. (I also did not see an 'na.strings=' argument as exists in read.table.) So perhaps you are not using Stata missing indicators and have a private convention for missing. If that is the case then: is.na(data$colA) - data$colA %in% c(-1, -2) All this assumes many things which I cannot verify (whether that column is numeric class for one). You should in further questions to Rhelp offer dput(head(dorm)) where the `data` is is the name of the dataframe. Since `data` is an R function (as is df) I would suggest that you use 'dfr'm for data.frames. (That is not the cause of any problems but will be confusing to readers of your code.) -- David Winsemius Alameda, CA, USA __ 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] Fortunes nomination (was: colour coded dotchart)
Oh, Lord, give me strength, for I am about to read an R Help file! Give me insight, for I must parse the words of statisticians forced by R CMD check to follow the way of the Literate Programmer! And please, Oh Lord, give me the wisdom to recall these tribulations when I set foot upon that road, that I may mark the path I blaze clearly for the novitiate to follow yet my words not become as obscure as those I read! Commentary: There is both truth and fiction in Rolf's advice, and for the truth I applaud the nomination, but for the fiction I fear the picture it paints in the unsuspecting mind. On the one hand, it seems odd to ask that the R user believe that meaning is there because this is software, not the Bible. On the other hand, some people seem to think they should not have to study to use this tool properly, so perhaps some faith will help them dig a little harder. Writing documentation is hard, and R CMD check at least makes package developers write SOMETHING down. That doesn't mean that it verifies that it is complete or clearly written. You can drag the horse to water but you cannot make them drink. Fortunately, the author of the code often does write just what you need to use it... even if it is a bit terse. There is also a bit of transformation that happens as one learns how R code works, that makes the obscure documentation more intuitive. What the beginner does not seem to realize is that documentation that they would think is perfect would likely have to be customized to fit their specific set of educational holes, but would bore others who knew all that stuff. The solution is for certain conventions and shorthand to be used, and to let the user search as deep as they need to get their answer. Also, it is common for teenagers to say they will never be like their parents, yet later find themselves doing just that. It is worth reminding new users that the maintainer() function is the key to helping improve R documentation, since what beginners think of as R is not a monolithic product but rather is the product of many individuals. Having the package maintainer be the gateway for such changes is a bit random, since different maintainers have different time and skills for the job, but communicating with the right person (rather than expecting them to read every message on R- help) is in general the best practice for fixing problems in packages. (Faulty documentation is indeed a problem, but a constructive suggestion for fixing it is far more likely to bring about change than either throwing of stones or abasing oneself before the guru.) --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Achim Zeileis achim.zeil...@uibk.ac.at wrote: On Sun, 9 Jun 2013, Duncan Murdoch wrote: On reading the help pages, Thanks, online on R-Forge now :-) Best, Z On 13-06-08 9:32 PM, Rolf Turner wrote: ... You need to get the hang of reading the online help. The information required is actually there in ?dotchart --- it's just tersely and obscurely expressed. A certain degree of optimism is required. You need to ***believe*** that the information is there; then ask yourself What could they possibly mean by what they have written that would tell me what I need to know?. Duncan Murdoch __ 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. __ 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] Not sure this is something R could do but it feels like it should be.
On Jun 9, 2013, at 6:14 AM, Calum Polwart wrote: Calum Hi Calum, I can only answer from the perspective of someone who calculated doses of alcohol for experimental subjects many years ago. It was not possible to apply a linear function across the range due to a number of factors. One is that BAC, which was the target value, is dependent upon the proportion of the weight that represents the water compartment of the body. This varies with both weight (heavier people typically have a higher proportion of fat) and sex (women also tend to have slightly more fat). The real monkey wrench in the works was absorption rate, which often made nonsense of my calculations. This may not be as important in therapeutic drugs, for we were aiming at a specified BAC at a certain time after dosing rather than an average level. All those things affect therapeutic dosing. I may have oversimplified what we are trying to achieve to avoid getting bogged down in the detail of what we are trying to achieve and provide something people might be able to relate to. However, we can assume that they are already sorted out, so we know the theoretically know what the 'correct' dose is for a patient. The hard bit is unless you want to give everyone liquid so you can measure any dose possible you have to have a dose that is a multiple of something (Amoxicillin doses in adults are multiples of 250 because thats the size of the capsule). I think you may have under-simplified rather than over-simplified. There is no such thing as getting bogged down in detail. We need all the relevant details. I suspect that you have in mind a situation where you have multiple drugs and multiple forms in which they can be administered and are hoping for a processing method that rounds to the nearest tespoonful or tablet size given some set of patient specific factors such as age sex height or weight. If my guess is correct then you need to offer a sample set of data of at least theree types for A) drugs and phamacokinetic parameters, B) dosage forms, C) patient features. You also need to supply rules for rounding to he nearest nice unit of administration. What we are trying to do is determine the most appropriate number to make the capsules. (Our dosing is more complex but lets stick to something simple. I can safely assure you that vritually no-one actually needs 250 or 500mg as a dose of amoxicillin... ...thats just a dose to get them into a therapeutic window, and I'm 99% certain 250 and 500 are used coz they are round numbers. if 337.5 more reliably got everyone in the window without kicking anyone out the window that'd be a better dose to use! So... what I'm looking to do is model the 'theoretical dose required' (which we know) and the dose delivered using several starting points to get the 'best fit'. We know they need to be within 7% of each other, but if one starting point can get 85% of doses within 5% we think that might be better than one that only gets 50% within 5%. However, I suspect that many therapeutic drugs have a different dose by weight for children (we weren't dosing children) and choosing a starting point at the bottom of the range would almost certainly introduce a systematic error. My intuition would be to anchor the dosage rate in the middle of the scale and then extrapolate in both directions (adults only, of course). We are actually using a starting point that may be middle and going up and down if need be. You need to describe explicitly how that determination is made. I think what we may want to do is run a loop through each weight (in 1kg increments) and calculate their theoretical dose, and the dose for each possible starting point (there are certain contraints on that already so there may only be 20 possible start points), then we calculate the % variance for each dose to theoretical dose and calculate the Area Under Above (some will be negative) the curve and the one that has the lowest AUC is then the one that most precisely will dose the patient…? I think you need to classify what pharmacokinetics apply to a particular drug (zeroth, or first order kinetics, volume of distribution affected by whatever) and choose from a limited number of heuristics for drugs rahter than solving each case from first principles. -- David Winsemius Alameda, CA, USA __ 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] Regression Tolerance Intervals - Dr. Young's Code
Uwe and Dennis - Thank you so much for your comments, tips and advice. The following reproducible code has worked and given me the desired results. Pradip ### Revised Code # setwd (C:/RAPP) require (tolerance) set.seed (100);x - runif (200,0,10); y - 20+5*x + rnorm (100,0,20); data.frame (cbind (x,y)) out - regtol.int (reg=lm(y~x), new.x=cbind (c(3,6,12)), side=2, alpha=.05, P=.90); plottol(out, x=cbind(1,x), y=y, side=two, x.lab=X, y.lab=Y ) From: Uwe Ligges [lig...@statistik.tu-dortmund.de] Sent: Sunday, June 09, 2013 11:54 AM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: R help [r-help@r-project.org]; mridulb...@aol.com Subject: Re: [R] Regression Tolerance Intervals - Dr. Young's Code On 08.06.2013 05:17, Muhuri, Pradip (SAMHSA/CBHSQ) wrote: Hello, Below is a reproducible example to generate the output by using Dr. Young's R code on the above subject . As commented below, the issue is that part of the code (regtol.int and plottol) does not seem to work. I would appreciate receiving your advice toward resolving the issue. Thanks and regards, Pradip Muhuri setwd (E:/) require (tolerance) d1- xlndur ylnant 8.910797 0.33901690 9.001415 0.36464311 8.983936 0.53976194 8.948035 0.33901690 9.056784 0.39266961 9.018593 0.18617770 9.001415 0.53976194 8.983936 -0.11005034 8.966147 0.53102826 8.948035 0.59885086 6.90 NA xd1 - read.table(textConnection(d1), header=TRUE, as.is=TRUE) print (xd1); str (xd1) #This code works xout1 - regtol.int (reg=lm (formula=ylnant ~ xlndur, data=xd1), alpha=.05, P=0.99, side=2) print (xout1) #This code does not work xout2 - regtol.int (reg=lm (formula=ylnant ~ xlndur, data=xd1), new.xlndur = NULL, alpha=.05, P=0.99, side=2) Come on, start using your brain and replace new.xlndur by new.x? print (xout2) #This code does not work plottol(xout1, x=cbind(1,x), y=y, side=two, x.lab=X, y.lab=Y ) So replace x and y appropriately? Best, Uwe Ligges #This code does not work plottol(xout2, x=cbind(1,x), y=y, side=two, x.lab=X, y.lab=Y ) [[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. __ 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] Coefficients paths - comparison of ridge, lasso and elastic net regression
Hi, beginner Do you have reproducible data? I think your question is more related to statistical learning theory than R. You may want to watch Prof.Hastie's webinar. http://www.stanford.edu/~hastie/lectures.htm On Wed, Jun 5, 2013 at 10:22 AM, beginner pa...@nottingham.ac.uk wrote: I would like to compare models selected with ridge, lasso and elastic net. Fig. below shows coefficients paths using all 3 methods: ridge (Fig A, alpha=0), lasso (Fig B; alpha=1) and elastic net (Fig C; alpha=0.5). The optimal solution depends on the selected value of lambda, which is chosen based on cross validation. http://r.789695.n4.nabble.com/file/n4668722/regularization.jpg When looking at these plots, I would expect the elastic net (Fig C) to exhibit a grouping effect. However it is not clear in the presented case. The coefficients path for lasso and elastic net are very similar. What could be the reason for this ? Is it just a coding mistake ? I used the following code in R: library(glmnet) X- as.matrix(mydata[,2:22]) Y- mydata[,23] par(mfrow=c(1,3)) ans1-cv.glmnet(X, Y, alpha=0) # ridge plot(ans1$glmnet.fit, lambda, label=FALSE) text (6, 0.4, A, cex=1.8, font=1) ans2-cv.glmnet(X, Y, alpha=1) # lasso plot(ans2$glmnet.fit, lambda, label=FALSE) text (-0.8, 0.48, B, cex=1.8, font=1) ans3-cv.glmnet(X, Y, alpha=0.5) # elastic net plot(ans3$glmnet.fit, lambda, label=FALSE) text (0, 0.62, C, cex=1.8, font=1) The code used to plot elastic net coefficients paths is exactly the same as for ridge and lasso. The only difference is in the value of alpha. Alpha parameter for elastic net regression was selected based on the lowest MSE (mean squared error) for corresponding lambda values. Thank you for your help ! -- View this message in context: http://r.789695.n4.nabble.com/Coefficients-paths-comparison-of-ridge-lasso-and-elastic-net-regression-tp4668722.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. [[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] It seams that fast99 function (sensitivity package) does not work out for norm distribution.
The author has already gave the illustration and solution as well. Thanks. 2013/6/9 Uwe Ligges lig...@statistik.tu-dortmund.de On 08.06.2013 00:54, Marino David wrote: Dear all mailing listers, Does Anyone have the same problem as mine when using the fast99 (extended-FAST method) to perform SA of model with norm distribution inputs? Why not ask the authors of the function? Best, Uwe Ligges See the simple example given following. Any suggestion will be greatly appreciated. Thank you! Marino # Simple example # 1. uniform version (It works well) library(sensitivity) Myfun-function(x){return(**rowSums(x))} SA1 - fast99(model = Myfun, factors = 3, n = 1000, q = qunif, q.arg = list(min = 0, max = 1)) SA1 Call: fast99(model = Myfun, factors = 3, n = 1000, q = qunif, q.arg = list(min = 0, max = 1)) Model runs: 3000 Estimations of the indices: first order total order X1 0.3335243 0.3350584 X2 0.3335243 0.3350584 X3 0.3335243 0.3350584 # 2. norm version (it does not work) SA2 - fast99(model = Myfun, factors = 3, n = 1000, q = qnorm, q.arg = list(mean = 0, sd = 1)) SA2 Call: fast99(model = Myfun, factors = 3, n = 1000, q = qnorm, q.arg = list(mean = 0, sd = 1)) Model runs: 3000 Estimations of the indices: first order total order X1 NA NA X2 NA NA X3 NA NA [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html 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] It seams that fast99 function (sensitivity package) does not work out for norm distribution.
On Jun 9, 2013, at 4:08 PM, Marino David wrote: The author has already gave the illustration and solution as well. Is that supposed to mean that you emailed the author and got a private response? Thanks. 2013/6/9 Uwe Ligges lig...@statistik.tu-dortmund.de On 08.06.2013 00:54, Marino David wrote: Dear all mailing listers, Does Anyone have the same problem as mine when using the fast99 (extended-FAST method) to perform SA of model with norm distribution inputs? Why not ask the authors of the function? Best, Uwe Ligges See the simple example given following. Any suggestion will be greatly appreciated. Thank you! Marino # Simple example # 1. uniform version (It works well) library(sensitivity) Myfun-function(x){return(**rowSums(x))} SA1 - fast99(model = Myfun, factors = 3, n = 1000, q = qunif, q.arg = list(min = 0, max = 1)) SA1 Call: fast99(model = Myfun, factors = 3, n = 1000, q = qunif, q.arg = list(min = 0, max = 1)) Model runs: 3000 Estimations of the indices: first order total order X1 0.3335243 0.3350584 X2 0.3335243 0.3350584 X3 0.3335243 0.3350584 # 2. norm version (it does not work) SA2 - fast99(model = Myfun, factors = 3, n = 1000, q = qnorm, q.arg = list(mean = 0, sd = 1)) SA2 Call: fast99(model = Myfun, factors = 3, n = 1000, q = qnorm, q.arg = list(mean = 0, sd = 1)) Model runs: 3000 Estimations of the indices: first order total order X1 NA NA X2 NA NA X3 NA NA [[alternative HTML version deleted]] -- David Winsemius Alameda, CA, USA __ 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] Using Lattice, LatticeExtra - Hide right and top axes in multipanel plots
Dear Rxperts, How do I hide the top and right axes in multiple panel plots? A couple of examples are provided below.. Would highly appreciate appreciate your assistance.. #Example 1 library(latticeExtra) xyplot((1:200)/20 ~ (1:200)/20, type = c(p, g), scales = list(x = list(log = 2,alternating=0), y = list(log = 10,alternating=0)), xscale.components = xscale.components.log10ticks, yscale.components = yscale.components.log10ticks,top=F,right=F) #Example 2 q - data.frame(G=rep(paste(G,1:3,sep=),each=50),D=rep(paste(D,1:5,sep=),each=30),a=rep(1:15,each=10),t=rep(seq(10),15),b=round(runif(150,10,20))) q$grp - paste(q$D,q$a,sep=:) q$grp - ordered(q$grp, levels=unique(q$grp)) q$dcol - unlist(sapply(q$D,function(x) switch(x,D1=orange,D2=blue,D3=red, D4=seagreen, D5=black))) q2 - q[order(q$G,q$D,q$a,q$t),] xyplot(b~t|G,data=q2,groups=grp,type=l,as.table=T, layout=c(3,1), par.strip.text = list(lines = 2), scales=list(x=list(rela='free',alternating=0),y=list(rela='free',alternating=0),col=1,tck=c(1,0)), panel=panel.superpose, panel.groups=function(x=x,y=y,subscripts=subscripts,groups=groups,...,group.number) { require(grid) panel.axis(side=top,labels = F,draw.labels = F,ticks = F,line.col=NA, line.lty=NA, line.lwd=0, line.alpha=0) panel.xyplot(x=x,y=y,subscripts=subscripts,pch=NA,lwd=1,type=l, col=q2$dcol[subscripts],lty=1,cex=0.7) }, strip=F, # strip=strip.custom(strip.names=T,strip.levels=T,par.strip.text=list(cex=1.7,font=2),bg=0, var.name=School), xlab=t, ylab=b, main=Overlay of Profiles by Schools and Classes, ) Thanks so much, Santosh [[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] Using Lattice, LatticeExtra - Hide right and top axes in multipanel plots
I updated the code for the second example.. This time.. all the axes disappeared!! xyplot(b~t|G,data=q2,groups=grp,type=l,as.table=T, layout=c(3,1), par.settings=list(axis.line=list(col=0)), scales=list(x=list(rela='free',alternating=0),y=list(rela='free',alternating=0),col=1,tck=c(1,0)), panel=panel.superpose, panel.groups=function(x=x,y=y,subscripts=subscripts,groups=groups,...,group.number) { require(grid) panel.axis(side=top,labels = F,draw.labels = F,ticks = F,line.col=NA, line.lty=NA, line.lwd=0, line.alpha=0) panel.xyplot(x=x,y=y,subscripts=subscripts,pch=NA,lwd=1,type=l, col=q2$dcol[subscripts],lty=1,cex=0.7) }, strip=F, # strip=strip.custom(strip.names=T,strip.levels=T,par.strip.text=list(cex=1.7,font=2),bg=0, var.name=School), xlab=t, ylab=b, main=Overlay of Profiles by Schools and Classes, ) On Sun, Jun 9, 2013 at 5:52 PM, Santosh santosh2...@gmail.com wrote: Dear Rxperts, How do I hide the top and right axes in multiple panel plots? A couple of examples are provided below.. Would highly appreciate appreciate your assistance.. #Example 1 library(latticeExtra) xyplot((1:200)/20 ~ (1:200)/20, type = c(p, g), scales = list(x = list(log = 2,alternating=0), y = list(log = 10,alternating=0)), xscale.components = xscale.components.log10ticks, yscale.components = yscale.components.log10ticks,top=F,right=F) #Example 2 q - data.frame(G=rep(paste(G,1:3,sep=),each=50),D=rep(paste(D,1:5,sep=),each=30),a=rep(1:15,each=10),t=rep(seq(10),15),b=round(runif(150,10,20))) q$grp - paste(q$D,q$a,sep=:) q$grp - ordered(q$grp, levels=unique(q$grp)) q$dcol - unlist(sapply(q$D,function(x) switch(x,D1=orange,D2=blue,D3=red, D4=seagreen, D5=black))) q2 - q[order(q$G,q$D,q$a,q$t),] xyplot(b~t|G,data=q2,groups=grp,type=l,as.table=T, layout=c(3,1), par.strip.text = list(lines = 2), scales=list(x=list(rela='free',alternating=0),y=list(rela='free',alternating=0),col=1,tck=c(1,0)), panel=panel.superpose, panel.groups=function(x=x,y=y,subscripts=subscripts,groups=groups,...,group.number) { require(grid) panel.axis(side=top,labels = F,draw.labels = F,ticks = F,line.col=NA, line.lty=NA, line.lwd=0, line.alpha=0) panel.xyplot(x=x,y=y,subscripts=subscripts,pch=NA,lwd=1,type=l, col=q2$dcol[subscripts],lty=1,cex=0.7) }, strip=F, # strip=strip.custom(strip.names=T,strip.levels=T,par.strip.text=list(cex=1.7,font=2),bg=0, var.name=School), xlab=t, ylab=b, main=Overlay of Profiles by Schools and Classes, ) Thanks so much, Santosh [[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] Using Lattice, LatticeExtra - Hide right and top axes in multipanel plots
Hi You had to references to strip The axis.line in the par settings removes the axis line Have made some slight changes to your code which may be of interest I keep the panel arguments last and so avoid duplication require(grid) xyplot(b~t|G,data=q2,groups=grp, type=l, aspect = 1, as.table=T, layout=c(3,1), xlab=t, ylab=b, main=Overlay of Profiles by Schools and Classes, par.settings=list(layout.heights = list(strip =2), axis.line=list(col=0)), strip=strip.custom(strip.names=T,strip.levels=T,par.strip.text=list(cex=1.7,font=2),bg=0,var.name=School), scales=list(x=list(rela='free',alternating=0), y=list(rela='free',alternating=0), col=1, tck=c(1,0)), panel=panel.superpose, panel.groups=function(x=x,y=y,subscripts=subscripts,groups=groups,...,group.number){ panel.axis(side=top,labels = F,draw.labels = F,ticks = F, line.lwd=0, line.alpha=0) panel.xyplot(x=x,y=y,subscripts=subscripts, lwd=1,type=l, col=q2$dcol[subscripts], lty=1, cex=0.7) } ) Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 Email: home: mac...@northnet.com.au At 11:04 10/06/2013, you wrote: I updated the code for the second example.. This time.. all the axes disappeared!! xyplot(b~t|G,data=q2,groups=grp,type=l,as.table=T, layout=c(3,1), par.settings=list(axis.line=list(col=0)), scales=list(x=list(rela='free',alternating=0),y=list(rela='free',alternating=0),col=1,tck=c(1,0)), panel=panel.superpose, panel.groups=function(x=x,y=y,subscripts=subscripts,groups=groups,...,group.number) { require(grid) panel.axis(side=top,labels = F,draw.labels = F,ticks = F,line.col=NA, line.lty=NA, line.lwd=0, line.alpha=0) panel.xyplot(x=x,y=y,subscripts=subscripts,pch=NA,lwd=1,type=l, col=q2$dcol[subscripts],lty=1,cex=0.7) }, strip=F, # strip=strip.custom(strip.names=T,strip.levels=T,par.strip.text=list(cex=1.7,font=2),bg=0, var.name=School), xlab=t, ylab=b, main=Overlay of Profiles by Schools and Classes, ) On Sun, Jun 9, 2013 at 5:52 PM, Santosh santosh2...@gmail.com wrote: Dear Rxperts, How do I hide the top and right axes in multiple panel plots? A couple of examples are provided below.. Would highly appreciate appreciate your assistance.. #Example 1 library(latticeExtra) xyplot((1:200)/20 ~ (1:200)/20, type = c(p, g), scales = list(x = list(log = 2,alternating=0), y = list(log = 10,alternating=0)), xscale.components = xscale.components.log10ticks, yscale.components = yscale.components.log10ticks,top=F,right=F) #Example 2 q - data.frame(G=rep(paste(G,1:3,sep=),each=50),D=rep(paste(D,1:5,sep=),each=30),a=rep(1:15,each=10),t=rep(seq(10),15),b=round(runif(150,10,20))) q$grp - paste(q$D,q$a,sep=:) q$grp - ordered(q$grp, levels=unique(q$grp)) q$dcol - unlist(sapply(q$D,function(x) switch(x,D1=orange,D2=blue,D3=red, D4=seagreen, D5=black))) q2 - q[order(q$G,q$D,q$a,q$t),] xyplot(b~t|G,data=q2,groups=grp,type=l,as.table=T, layout=c(3,1), par.strip.text = list(lines = 2), scales=list(x=list(rela='free',alternating=0),y=list(rela='free',alternating=0),col=1,tck=c(1,0)), panel=panel.superpose, panel.groups=function(x=x,y=y,subscripts=subscripts,groups=groups,...,group.number) { require(grid) panel.axis(side=top,labels = F,draw.labels = F,ticks = F,line.col=NA, line.lty=NA, line.lwd=0, line.alpha=0) panel.xyplot(x=x,y=y,subscripts=subscripts,pch=NA,lwd=1,type=l, col=q2$dcol[subscripts],lty=1,cex=0.7) }, strip=F, # strip=strip.custom(strip.names=T,strip.levels=T,par.strip.text=list(cex=1.7,font=2),bg=0, var.name=School), xlab=t, ylab=b, main=Overlay of Profiles by Schools and Classes, ) Thanks so much, Santosh [[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. __ 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] cannot load pbdMPI package after compilation
Hello, I am not sure whether it helps you, but I was able to install it. OpenSUSE 12.3 R version 3.0.1 Patched (2013-06-09 r62918) pbdMPI version 0.1-6 gcc version 4.7.2 OpenMPI version 1.6.3 I didn't try with the most recent version of ompi (1.6.4). Regards, Pascal On 07/06/13 21:42, Antoine Migeon wrote: Hello, I try to install pbdMPI. Compilation successful, but load fails with segfault. Is anyone can help me? R version 3.0.0 pbdMPI version 0.1-6 Intel compiler version 13.1.1 OpenMPI version 1.6.4-1 CPU Intel x86_64 # R CMD INSTALL pbdMPI_0.1-6.tar.gz .. checking for gcc... icc -std=gnu99 checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether icc -std=gnu99 accepts -g... yes checking for icc -std=gnu99 option to accept ISO C89... none needed checking for mpirun... mpirun checking for mpiexec... mpiexec checking for orterun... orterun checking for sed... /bin/sed checking for mpicc... mpicc checking for ompi_info... ompi_info checking for mpich2version... F found sed, mpicc, and ompi_info ... TMP_INC_DIRS = /opt/openmpi/1.6.4-1/intel-13.1.1/include checking /opt/openmpi/1.6.4-1/intel-13.1.1/include ... found /opt/openmpi/1.6.4-1/intel-13.1.1/include/mpi.h ... TMP_LIB_DIRS = /opt/openmpi/1.6.4-1/intel-13.1.1/lib64 checking /opt/openmpi/1.6.4-1/intel-13.1.1/lib64 ... found /opt/openmpi/1.6.4-1/intel-13.1.1/lib64/libmpi.so ... found mpi.h and libmpi.so ... TMP_INC = /opt/openmpi/1.6.4-1/intel-13.1.1/include TMP_LIB = /opt/openmpi/1.6.4-1/intel-13.1.1/lib64 checking for openpty in -lutil... yes checking for main in -lpthread... yes *** Results of pbdMPI package configure * TMP_INC = /opt/openmpi/1.6.4-1/intel-13.1.1/include TMP_LIB = /opt/openmpi/1.6.4-1/intel-13.1.1/lib64 MPI_ROOT = MPITYPE = OPENMPI MPI_INCLUDE_PATH = /opt/openmpi/1.6.4-1/intel-13.1.1/include MPI_LIBPATH = /opt/openmpi/1.6.4-1/intel-13.1.1/lib64 MPI_LIBS = -lutil -lpthread MPI_DEFS = -DMPI2 MPI_INCL2 = PKG_CPPFLAGS = -I/opt/openmpi/1.6.4-1/intel-13.1.1/include -DMPI2 -DOPENMPI PKG_LIBS = -L/opt/openmpi/1.6.4-1/intel-13.1.1/lib64 -lmpi -lutil -lpthread * .. icc -std=gnu99 -I/usr/local/R/3.0.0/intel13/lib64/R/include -DNDEBUG -I/opt/openmpi/1.6.4-1/intel-13.1.1/include -DMPI2 -DOPENMPI -O3 -fp-model precise -pc 64 -axAVX-fpic -O3 -fp-model precise -pc 64 -axAVX -c comm_errors.c -o comm_errors.o icc -std=gnu99 -I/usr/local/R/3.0.0/intel13/lib64/R/include -DNDEBUG -I/opt/openmpi/1.6.4-1/intel-13.1.1/include -DMPI2 -DOPENMPI -O3 -fp-model precise -pc 64 -axAVX-fpic -O3 -fp-model precise -pc 64 -axAVX -c comm_sort_double.c -o comm_sort_double.o . .. ** testing if installed package can be loaded sh: line 1: 2905 Segmentation fault '/usr/local/R/3.0.0/intel13/lib64/R/bin/R' --no-save --slave 21 /tmp/RtmpGkncGK/file1e541c57190 ERROR: loading failed *** caught segfault *** address (nil), cause 'unknown' Traceback: 1: .Call(spmd_initialize, PACKAGE = pbdMPI) 2: fun(libname, pkgname) 3: doTryCatch(return(expr), name, parentenv, handler) 4: tryCatchOne(expr, names, parentenv, handlers[[1L]]) 5: tryCatchList(expr, classes, parentenv, handlers) 6: tryCatch(fun(libname, pkgname), error = identity) 7: runHook(.onLoad, env, package.lib, package) 8: loadNamespace(package, c(which.lib.loc, lib.loc)) 9: doTryCatch(return(expr), name, parentenv, handler) 10: tryCatchOne(expr, names, parentenv, handlers[[1L]]) 11: tryCatchList(expr, classes, parentenv, handlers) 12: tryCatch(expr, error = function(e) {call - conditionCall(e) if (!is.null(call)) {if (identical(call[[1L]], quote(doTryCatch))) call - sys.call(-4L)dcall - deparse(call)[1L]prefix - paste(Error in, dcall, : ) LONG - 75Lmsg - conditionMessage(e)sm - strsplit(msg, \n)[[1L]]w - 14L + nchar(dcall, type = w) + nchar(sm[1L], type = w)if (is.na(w)) w - 14L + nchar(dcall, type = b) + nchar(sm[1L], type = b)if (w LONG) prefix - paste0(prefix, \n )}else prefix - Error : msg - paste0(prefix, conditionMessage(e), \n) .Internal(seterrmessage(msg[1L]))if (!silent identical(getOption(show.error.messages), TRUE)) { cat(msg, file = stderr()).Internal(printDeferredWarnings()) }invisible(structure(msg, class = try-error, condition = e))}) 13: try({ns - loadNamespace(package, c(which.lib.loc, lib.loc)) env - attachNamespace(ns, pos = pos, deps)}) 14: library(pkg_name, lib.loc = lib, character.only = TRUE, logical.return = TRUE) 15: withCallingHandlers(expr, packageStartupMessage = function(c) invokeRestart(muffleMessage)) 16:
[R] Sending Email with Attachment
Hi, I am trying to send an email through gmail or outlook from my Windows PC and finding trouble to send the email. The code which I am using is given below: Code : library(sendmailR) from - a...@outlook.com to - mailto:e...@gmail.com e...@gmail.com subject - Run at mailControl = list(smtpServer=blu-m.hotmail.com) attachment - type_1.pdf attachmentName - target_score.pdf attachmentObject - mime_part(x= attachment,name= attachmentName) body - Email Body bodywithAttachement - list(body, attachmentObject) sendmail(from=from,to=to,subject=subject,msg= bodywithAttachement,control=mailControl) However it gives me following Error: Error: Error in socketConnection(host = server, port = port, blocking = TRUE) : cannot open the connection In addition: Warning message: In socketConnection(host = server, port = port, blocking = TRUE) : blu-m.hotmail.com:25 cannot be opened I have also tried the other library i.e. mail but it does not support attaching the object. And also tried it with following command which was also unfruitful with password given. Code : sendmail(from= e...@gmail.com mailto:e...@gmail.com , to= e...@gmail.com mailto:e...@gmail.com%22,%20text=%22Send , text=Send Email, subject=MAil, smtp=smtp.gmail.com, user= e...@gmail.com, pw=pwd) Error: Error in socketConnection(host = server, port = port, blocking = TRUE) : cannot open the connection In addition: Warning message: In socketConnection(host = server, port = port, blocking = TRUE) : localhost:25 cannot be opened Please let me know if we have some solution for this. Best Regards, Bhupendrasinh Thakre [[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] Sending Email with Attachment
Bhupendrasinh Thakre vickytha...@gmail.com [2013-06-09 20:03]: library(sendmailR) from - a...@outlook.com to - mailto:e...@gmail.com e...@gmail.com subject - Run at mailControl = list(smtpServer=blu-m.hotmail.com) attachment - type_1.pdf attachmentName - target_score.pdf attachmentObject - mime_part(x= attachment,name= attachmentName) body - Email Body bodywithAttachement - list(body, attachmentObject) sendmail(from=from,to=to,subject=subject,msg= bodywithAttachement,control=mailControl) However it gives me following Error: Error: Error in socketConnection(host = server, port = port, blocking = TRUE) : cannot open the connection In addition: Warning message: In socketConnection(host = server, port = port, blocking = TRUE) : blu-m.hotmail.com:25 cannot be opened It's an unsurprising result since telnet doesn't connect either: telnet blu-m.hotmail.com 25 Trying 65.55.121.94... telnet: Unable to connect to remote host: Connection timed out Try port 443: telnet blu-m.hotmail.com 443 Trying 65.55.121.94... Connected to eas-blu.hot.glbdns.microsoft.com. Escape character is '^]'. But it's probably expecting TLS, and sendmailR doesn't support it. Please let me know if we have some solution for this. If you want to use sendmailR, you need to find a mail server that does not require TLS. This may mean running your own mail server. Or, you can call an external program that handles a TLS connection. -rex -- Proofread carefully to see if you any words out. __ 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] Sending Email with Attachment
Thanks Rex for the help. So it seems that I might have to use Python or Perl to perform the action. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of rex Sent: Sunday, June 09, 2013 10:27 PM To: r-help@r-project.org Subject: Re: [R] Sending Email with Attachment Bhupendrasinh Thakre vickytha...@gmail.com [2013-06-09 20:03]: library(sendmailR) from - a...@outlook.com to - mailto:e...@gmail.com e...@gmail.com subject - Run at mailControl = list(smtpServer=blu-m.hotmail.com) attachment - type_1.pdf attachmentName - target_score.pdf attachmentObject - mime_part(x= attachment,name= attachmentName) body - Email Body bodywithAttachement - list(body, attachmentObject) sendmail(from=from,to=to,subject=subject,msg= bodywithAttachement,control=mailControl) However it gives me following Error: Error: Error in socketConnection(host = server, port = port, blocking = TRUE) : cannot open the connection In addition: Warning message: In socketConnection(host = server, port = port, blocking = TRUE) : blu-m.hotmail.com:25 cannot be opened It's an unsurprising result since telnet doesn't connect either: telnet blu-m.hotmail.com 25 Trying 65.55.121.94... telnet: Unable to connect to remote host: Connection timed out Try port 443: telnet blu-m.hotmail.com 443 Trying 65.55.121.94... Connected to eas-blu.hot.glbdns.microsoft.com. Escape character is '^]'. But it's probably expecting TLS, and sendmailR doesn't support it. Please let me know if we have some solution for this. If you want to use sendmailR, you need to find a mail server that does not require TLS. This may mean running your own mail server. Or, you can call an external program that handles a TLS connection. -rex -- Proofread carefully to see if you any words out. __ 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] arima time series in R
I am just performing arima time series analysis here.. and package used is forecast. I am just not able what is ar1,ma1 and ma2. -Original Message- From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] Sent: Friday, June 07, 2013 5:29 PM To: Aakanksha Dahiya01 Cc: r-help@r-project.org Subject: Re: [R] arima time series in R On 07/06/2013 12:21, Aakanksha Dahiya01 wrote: Hi Could just anyone explain me the coefficients in the output of arima model The person who wrote the help page already did, but that is hardly 'just anyone'. timeseriesarima - arima(series, order=c(1,1,2)) timeseriesarima Series: series ARIMA(1,1,2) Coefficients: ar1 ma1 ma2 0.9744 -1.7695 0.7873 s.e. 0.0310 0.0481 0.0426 sigma^2 estimated as 337.4: log likelihood=-1096.03 AIC=2200.07 AICc=2200.23 BIC=2214.2 That is not from arima in package stats, so you need to follow the posting guide to tell us whose wrapper it is and hence which help page to read. (Possibly package TSA.) [[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. That does mean you. -- Brian D. Ripley, rip...@stats.ox.ac.uk 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 CAUTION - Disclaimer * This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system. ***INFOSYS End of Disclaimer INFOSYS*** __ 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] Loop through variables and estimate effects on several outcomes
Hi, I assume this is what you wanted: #Your code library(gamair) data(chicago) library(mgcv) library(splines) chicago1- chicago chicago1$date- seq(from=as.Date(1987-01-01),to=as.Date(2000-12-31),length=5114) chicago1$trend-seq(dim(chicago1)[1]) names(chicago1) [2] -pm10 names(chicago1) [3] -pm25 names(chicago1) [4] -ozone names(chicago1) [5] -so2 names(chicago1) [7] -temp chicago1$cv-rpois(5114, lambda = 35) chicago1$resp-rpois(5114, lambda = 13) chicago1$trend-seq(dim(chicago1)[1]) chicago1$year-as.numeric(format(chicago1$date,%Y)) m1-glm(death ~ pm10 + pm25+ ns(trend,35) + ns(temp, 6), poisson , na.action = na.omit , data =chicago1) m4-gam(death ~ pm10 + pm25+ s(trend,k=35) + s(temp, k=6), quasipoisson , na.action = na.omit , data =chicago1) Extracting estimates coef(summary(m1))[-1,1][!grepl(ns,names(coef(summary(m1))[-1,1]))] # pm10 pm25 # 0.001772681 -0.001481798 summary(m4)$p.coeff[-1] # pm10 pm25 #0.001346275 -0.001182925 varlist-names(chicago1)[c(1,10:11)] varlist #[1] death cv resp glm fun2glm- function(varName){ res- sapply(varName,function(x){ model1- glm(get(x)~ pm10 + pm25+ ns(trend,35) + ns(temp, 6) , poisson , na.action = na.omit , data =chicago1) sM- coef(summary(model1))[-1,1] indx- grepl(ns,names(sM)) sM1- sM[!indx] }) res } fun2glm(varlist) # death cv resp #pm10 0.001772681 0.0003505286 -0.0006736290 #pm25 -0.001481798 -0.0004193602 0.0005567137 gam fun2gam- function(varName){ res- sapply(varName,function(x){ model1- gam(get(x)~pm10+pm25+s(trend,k=35)+s(temp,k=6),quasipoisson,na.action=na.omit,data=chicago1) sM- summary(model1)$p.coeff[-1] }) res } fun2gam(varlist) # death cv resp #pm10 0.001346275 0.0003902584 -0.0008447569 #pm25 -0.001182925 -0.0007072599 0.0002807046 A.K. From: Gustav Sigtuna gsigt...@gmail.com To: arun smartpink...@yahoo.com Sent: Friday, June 7, 2013 5:56 PM Subject: Re: Loop through variables and estimate effects on several outcomes Hi Arun, Thanks for your response. I use GLM and GAM for Poisson distributed data. I have attached a sample code and data. In the summary I am interested to extract the linear estimates and not the spline terms. Thanks for your help G On Fri, Jun 7, 2013 at 12:01 AM, smartpink...@yahoo.com wrote: quote author='decoder' HI, No problem. Are you using the same dataset or different? If you are using poisson or other distribution, the summary output table may be a bit different. If you can show the codes and an example dataset (if different), I can take a look. Thanks A.K. The code works for lm and thanks for that. I have some outcomes which are counts and wanted to run GLM with the same code and got the error message below. fun2(varlist) Error in glm.fit(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, : (subscript) logical subscript too long Can you explain what went wrong with the GLM code and how to rectify it? Thanks /quote Quoted from: http://r.789695.n4.nabble.com/Loop-through-variables-and-estimate-effects-on-several-outcomes-tp4668814p4668875.html _ Sent from http://r.789695.n4.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] Error Object Not Found
Hi, I think that they are loaded. Here is the response that I get: package ‘foreign’ successfully unpacked and MD5 sums checked -- View this message in context: http://r.789695.n4.nabble.com/Error-Object-Not-Found-tp4669041p4669100.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.
[R] All against all correlation matrix with GGPLOT Facet
I have the following data: v - rnorm(13) w - rnorm(13) x - rnorm(13) y - rnorm(13) z - rnorm(13) Using GGPLOT facet, what I want to do is to create a 5*5 matrix, where each cells plot the correlation between each pair of the above data. E.g. v-v,v-w; v-x,...,z-z What's the way to do it? Attached is the image. GV. __ 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] arima time series in R
It would be great help if someone just tell me what does ar1,ma1 and ma2 signify here.. how do I further predict from these coefficients.. -Original Message- From: Aakanksha Dahiya01 Sent: Monday, June 10, 2013 9:54 AM To: 'Prof Brian Ripley' Cc: r-help@r-project.org Subject: RE: [R] arima time series in R I am just performing arima time series analysis here.. and package used is forecast. I am just not able what is ar1,ma1 and ma2. -Original Message- From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] Sent: Friday, June 07, 2013 5:29 PM To: Aakanksha Dahiya01 Cc: r-help@r-project.org Subject: Re: [R] arima time series in R On 07/06/2013 12:21, Aakanksha Dahiya01 wrote: Hi Could just anyone explain me the coefficients in the output of arima model The person who wrote the help page already did, but that is hardly 'just anyone'. timeseriesarima - arima(series, order=c(1,1,2)) timeseriesarima Series: series ARIMA(1,1,2) Coefficients: ar1 ma1 ma2 0.9744 -1.7695 0.7873 s.e. 0.0310 0.0481 0.0426 sigma^2 estimated as 337.4: log likelihood=-1096.03 AIC=2200.07 AICc=2200.23 BIC=2214.2 That is not from arima in package stats, so you need to follow the posting guide to tell us whose wrapper it is and hence which help page to read. (Possibly package TSA.) [[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. That does mean you. -- Brian D. Ripley, rip...@stats.ox.ac.uk 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 CAUTION - Disclaimer * This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system. ***INFOSYS End of Disclaimer INFOSYS*** __ 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 expand.grid with string elements (the half!)
I have the following result of expand grid: d - expand.grid(c(x,y,z),c(x,y,z)) What I want is to create a combination of strings but only the half of the all combinations: Var1 Var2 1xx 2yx 3 yy 4 zy 5 xz 6zz What's the way to do it? G.V. [[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] arima time series in R
Hi, library(forecast) ?Arima And if you don't know what ar and ma are, you probably should read some book before to go further. Regards, Pascal On 10/06/13 14:03, Aakanksha Dahiya01 wrote: It would be great help if someone just tell me what does ar1,ma1 and ma2 signify here.. how do I further predict from these coefficients.. -Original Message- From: Aakanksha Dahiya01 Sent: Monday, June 10, 2013 9:54 AM To: 'Prof Brian Ripley' Cc: r-help@r-project.org Subject: RE: [R] arima time series in R I am just performing arima time series analysis here.. and package used is forecast. I am just not able what is ar1,ma1 and ma2. -Original Message- From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] Sent: Friday, June 07, 2013 5:29 PM To: Aakanksha Dahiya01 Cc: r-help@r-project.org Subject: Re: [R] arima time series in R On 07/06/2013 12:21, Aakanksha Dahiya01 wrote: Hi Could just anyone explain me the coefficients in the output of arima model The person who wrote the help page already did, but that is hardly 'just anyone'. timeseriesarima - arima(series, order=c(1,1,2)) timeseriesarima Series: series ARIMA(1,1,2) Coefficients: ar1 ma1 ma2 0.9744 -1.7695 0.7873 s.e. 0.0310 0.0481 0.0426 sigma^2 estimated as 337.4: log likelihood=-1096.03 AIC=2200.07 AICc=2200.23 BIC=2214.2 That is not from arima in package stats, so you need to follow the posting guide to tell us whose wrapper it is and hence which help page to read. (Possibly package TSA.) [[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. That does mean you. __ 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.