[R] Problems installing/updating packages in Linux
Hi all, I feel very comfortable with R in Windows, and am trying to switch over to Linux. I have R 2.8.1 on Linux and it works great (so far), except for instalilng/updating packages. For example, using Emacs with ESS as a text editor, I entered: > update.packages() Here are some error messages: /usr/lib/R/bin/INSTALL: 1088: cannot create /usr/share/R/doc/html/search/index.txt: Permission denied The downloaded packages are in /tmp/RtmpV6DGUE/downloaded_packages Updating HTML index of packages in '.Library' Warning messages: 1: In file.create(f.tg) : cannot create file '/usr/share/R/doc/html/packages.html', reason 'Permission denied' 2: In tools:::unix.packages.html(.Library) : cannot create HTML package index > I thought this was a permissions-based issue, so I learned online that to grant permissions to everything in my R directories, to do this in the Linux terminal: chmod -R 777 ./directory And I applied that to several R directories, including /usr/lib/R and a place in /home where I store all my scripts, data sets, etc. I thought that would solve it, but I'm still getting the same permissions-based errors. I could really use some help from someone who knows Linux. Thanks. -- View this message in context: http://www.nabble.com/Problems-installing-updating-packages-in-Linux-tp21884607p21884607.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] Problems installing/updating packages in Linux
Thanks for the replies, they are helping. I downloaded the recommended manual, and I'm sure that will help too. When I installed R, I did not (previously) obtain the R-2.8.1.tar.gz, but tried to follow some instructions I found elsewhere online (which apparently weren't right). I did have the deb source command and when I typed R into the Bash terminal, I had v.2.8.1, but all packages I downloaded went to some folder entitled 2.6.2. Trying to solve things, I was turning on permissions all over the place, and it caused problems. This morning, I have backed up my hard drive, re-formatted my computer again with Linux Ubuntu 8.04 Hardy Heron from scratch, and am trying to follow that R Admin manual. I'm normally good with computers, but am completely new to Linux. The main purpose of this computer is R, so I guess I was hoping to get R set up quickly and correctly, and learn Linux in the background as I go. But it seems very difficult to do this. The first thing I'm stumbling on in the R Admin manual is where am I supposed to unpack R-2.8.1.tar.gz? Somehow, I'll bet this matters. Any step-by-step command help would be greatly appreciated. Thanks. -- View this message in context: http://www.nabble.com/Problems-installing-updating-packages-in-Linux-tp21884607p21891402.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] installing R on Ubuntu
I've read some of R's literature on Linux, including the R Admin manual, and didn't find it very useful, which is probably my own limitation. But I did finally manage to get it working well. I'm posting this to help others. The following worked when installing R 2.8.1 on Ubuntu 8.04 Hardy Heron. Here are truly step-by-step instructions for those who don't know Linux (like me): Installation and Initial Set-Up of R for Ubuntu Linux 1. Open the Bash terminal (Applications > Accessories > Terminal) 2. Type these lines to add the security key to access the latest version of the R Ubuntu package: u...@computer:~$ gpg --keyserver subkeys.pgp.net --recv-key E2A11821 u...@computer:~$ gpg -a --export E2A11821 | sudo apt-key add - 3. Use the Bash terminal to open your sources.list file with gedit (text editor) for editing: u...@computer:~$ sudo gedit /etc/apt/sources.list 4. Add this line to the bottom of the sources.list file: deb http://rh-mirror.linux.iastate.edu/CRAN/bin/linux/ubuntu hardy/ 5. Save the file and go back to the Bash terminal. 6. Type this to update apt-get's database before you install R: u...@computer:~$ sudo apt-get update 7. Install R with this command: u...@computer:~$ sudo apt-get install r-base 8. Go to System > Administration > Synaptic Package Manager, and download the build-essential package. 9. To use R, simply enter R in the Bash terminal. To quit, enter q(). Additional programs will be needed to install other packages or work with other programs: 1. Install compilers for C++ and Fortran u...@computer:~$ sudo apt-get install g++ gfortran 2. Install the developer versions of Blas and Lapack (what are these?) u...@computer:~$ apt-get install libblas-dev liblapack-dev Updating Packages in R 1. Open the Bash terminal and start R with root permissions u...@computer:~$ sudo R 2. Type > update.packages() Installing the R Commander GUI 1. Open the Bash terminal and type: u...@computer:~$ apt-get install r-cran-rcmdr Using the R Commander GUI library(Rcmdr) ...or once the library is open and Commander has been shut down, type: commander() Notes It looks like most of R has been put here: /etc/R (Rprofile.site is here) /usr/lib/R Downloaded Packages seem to go here: /usr/local/lib/R/site-library/ -- View this message in context: http://www.nabble.com/installing-R-on-Ubuntu-tp10025949p21894865.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] installing R on Ubuntu
I've read some of R's literature on Linux, including the R Admin manual, and didn't find it very useful, which is probably my own limitation. But I did finally manage to get it working well. I'm posting this to help others. The following worked when installing R 2.8.1 on Ubuntu 8.04 Hardy Heron. Here are truly step-by-step instructions for those who don't know Linux (like me): Installation and Initial Set-Up of R for Ubuntu Linux 1. Open the Bash terminal (Applications > Accessories > Terminal) 2. Type these lines to add the security key to access the latest version of the R Ubuntu package: u...@computer:~$ gpg --keyserver subkeys.pgp.net --recv-key E2A11821 u...@computer:~$ gpg -a --export E2A11821 | sudo apt-key add - 3. Use the Bash terminal to open your sources.list file with gedit (text editor) for editing: u...@computer:~$ sudo gedit /etc/apt/sources.list 4. Add this line to the bottom of the sources.list file: deb http://rh-mirror.linux.iastate.edu/CRAN/bin/linux/ubuntu hardy/ 5. Save the file and go back to the Bash terminal. 6. Type this to update apt-get's database before you install R: u...@computer:~$ sudo apt-get update 7. Install R with this command: u...@computer:~$ sudo apt-get install r-base 8. Go to System > Administration > Synaptic Package Manager, and download the build-essential package. 9. To use R, simply enter R in the Bash terminal. To quit, enter q(). Additional programs will be needed to install other packages or work with other programs: 1. Install compilers for C++ and Fortran u...@computer:~$ sudo apt-get install g++ gfortran 2. Install the developer versions of Blas and Lapack (what are these?) u...@computer:~$ apt-get install libblas-dev liblapack-dev Updating Packages in R 1. Open the Bash terminal and start R with root permissions u...@computer:~$ sudo R 2. Type > update.packages() Installing the R Commander GUI 1. Open the Bash terminal and type: u...@computer:~$ apt-get install r-cran-rcmdr Using the R Commander GUI library(Rcmdr) ...or once the library is open and Commander has been shut down, type: commander() Notes It looks like most of R has been put here: /etc/R (Rprofile.site is here) /usr/lib/R Downloaded Packages seem to go here: /usr/local/lib/R/site-library/ -- View this message in context: http://www.nabble.com/installing-R-on-Ubuntu-tp10025949p21894862.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] installing R on Ubuntu
I would really like to see a good introduction to Emacs, and will check out that link. I know that Emacs and ESS are supposed to be the best, and are the most customizable. The reason I put the R Commander GUI instead of Emacs/ESS is because in my first attempt to get R on Ubuntu Linux, I did successfully get Emacs/ESS working (sadly, I don't remember how exactly), but found it too frustrating. Again, I'm sure it's the best in the end, but here's what was driving me nuts: Copy/Paste is not Ctrl-c and Ctrl-v...I figured it out, but don't remember what it is. Entering a _ automatically creates a <-, and you must enter __ to get _. There is no "stop" button (hopefully there is one in R Commander, haven't explored yet). It kept trying to establish a working directory, and was inconsistent in when it would accept what directory. I was also looking at the JGS GUI. Online screenshots look incredible, but I didn't go with it because it depends on Java, which is not open-source, and I'm really liking that philosophy, but to each his own. Thanks for the link, I'm anxious to try to figure out Emacs/ESS. I'll go look at it now. Cheers. -- View this message in context: http://www.nabble.com/installing-R-on-Ubuntu-tp10025949p21899227.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] installing R on Ubuntu
Amendment/Question #1: When I update.packages(), it tells me that rgl fails to update because it can't find X11. Again, I'm pretty new to Ubuntu, but it looks like X comes with Ubuntu. I see files under /etc/X11. Does this mean I need to download x11-common (or x11-apps, or x11-utils, or one of the others?) with the Synaptic Package Manager? I hesitate on this because it seems like X11 is not a simple add-on package, but something core to Ubuntu. Any help is appreciated. Thanks. -- View this message in context: http://www.nabble.com/installing-R-on-Ubuntu-tp10025949p21899658.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] Error installing rjags in Ubuntu Linux
Hi, Here is a step-by-step guide to exactly how I've installed R in Ubuntu: http://www.nabble.com/installing-R-on-Ubuntu-td10025949.html#a21894865 Regarding rjags, here is what happened: This webpage (http://yusung.blogspot.com/2009/01/install-jags-and-rjags-in-fedora.html) recommends logging into R as sudo R, and then typing: install.packages("rjags", configure.args="--with-jags-include=/usr/local/include/JAGS --with-jags-lib=/usr/local/lib/JAGS --with-jags-modules=/usr/local/lib/JAGS/modules") ...but I get... Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared library '/usr/local/lib/R/site-library/rjags/libs/rjags.so': ...which is virtually identical to this thread (http://www.nabble.com/unable-to-install-rjags-on-64-bit-Debian-Linux-(etch)-td20404210.html#a20404210) about a 64-bit install. Although my computer has dual AMD64's, I'm sure it's a 32-bit system. I have removed rjags with remove.packages("rjags"). Does anybody know how to install rjags in Ubuntu Linux (I'm specifying it, because I am very new and don't know what I'm doing yet)? Thanks. -- View this message in context: http://www.nabble.com/Error-installing-rjags-in-Ubuntu-Linux-tp21900345p21900345.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] installing R on Ubuntu
Hi Dirk, Sorry, I'm not trying to drag out the installation process here, but just trying to get it to work right in Linux. Dirk Eddelbuettel wrote: > > What is wrong with > > $ sudo apt-get install r-cran-rgl > I tried this suggestion, and here was the terminal output: r-cran-rgl is already the newest version. r-cran-rgl set to manually installed. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. So, just to double-check, I went into R as sudo, entered update.packages(), and got this: rgl : Version 0.76 installed in /usr/lib/R/site-library Version 0.82 available at http://streaming.stat.iastate.edu/CRAN ...and later this... * Installing *source* package 'rgl' ... checking for gcc... gcc -std=gnu99 checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc -std=gnu99 accepts -g... yes checking for gcc -std=gnu99 option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -std=gnu99 -E checking for gcc... (cached) gcc -std=gnu99 checking whether we are using the GNU C compiler... (cached) yes checking whether gcc -std=gnu99 accepts -g... (cached) yes checking for gcc -std=gnu99 option to accept ISO C89... (cached) none needed checking for libpng-config... no checking libpng... checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking png.h usability... no checking png.h presence... no checking for png.h... no checking for png_read_update_info in -lpng... no configure: libpng header and lib found configure: using libpng dynamic linkage checking for X... no configure: error: X11 not found but required, configure aborted. ERROR: configuration failed for package 'rgl' ** Removing '/usr/lib/R/site-library/rgl' ** Restoring previous '/usr/lib/R/site-library/rgl' The downloaded packages are in /tmp/RtmpIW4d37/downloaded_packages Warning message: In install.packages(update[instlib == l, "Package"], l, contriburl = contriburl, : installation of package 'rgl' had non-zero exit status -- View this message in context: http://www.nabble.com/installing-R-on-Ubuntu-tp10025949p21902802.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] installing R on Ubuntu
I'm definitely out of my league here, but I think that if someone only enters that code in an Ubuntu system, then they will have only the latest version of R in Ubuntu, which at this time I think is 2.6.2, instead of 2.8.1, and Ubuntu only "maintains" a handful of packages, instead of 1600+ right now on CRAN. If you want to get the latest R in Ubuntu and download any current package, it seems like you have to follow a method like I've tried to piece together. I hope I'm wrong here. Cheers. Dirk Eddelbuettel wrote: > > On 8 February 2009 at 20:36, Tom Backer Johnsen wrote: > | Dear me. Is the installation of R under Ubuntu really that complex? I > | have a dual boot machine (Linux / Windows, where I use the latter the > | most) and have plans to try R under Linux, but have not done so yet. Is > | it possible to simplify the Linux install procedure to make R more > | accessible to novices? > > Yes. 'sudo apt-get install r-base ess ggobi' and you have working R, ESS > and > Ggobi. Start Emacs, type 'M-x R' and you have an R session inside Emacs. > > Is that really easier to accomplish in Windows? > -- View this message in context: http://www.nabble.com/installing-R-on-Ubuntu-tp10025949p21902883.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] installing R on Ubuntu
Thanks John, I appreciate it. It sounds like Emacs is the way to go for an editor. John Fox-6 wrote: > > Dear Paul, > > I haven't read everything in this thread, but have a couple of comments > relative to using the R Commander: > > ... > > The R Commander isn't meant to be a serious programming editor, but rather > a > basic-statistics GUI. I think that you'll find it disappointing as an > editor. > > ... > > There is no "stop" button in the Rcmdr; having one isn't be a bad idea, > but > I'm not sure how I could implement it in a platform-independent manner (or > even, frankly, in a platform-dependent manner). Perhaps someone has a > suggestion for doing that. > -- View this message in context: http://www.nabble.com/installing-R-on-Ubuntu-tp10025949p21902934.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] installing R on Ubuntu
Hi Dirk, Many thanks for your insight. Dirk Eddelbuettel wrote: > > > Paul, > > Very nice! Comments below. > > On 7 February 2009 at 17:12, Paul Heinrich Dietrich wrote: > | > | I've read some of R's literature on Linux, including the R Admin manual, > and > | didn't find it very useful, which is probably my own limitation. But I > did > | finally manage to get it working well. I'm posting this to help others. > | The following worked when installing R 2.8.1 on Ubuntu 8.04 Hardy Heron. > | Here are truly step-by-step instructions for those who don't know Linux > | (like me): > | > | Installation and Initial Set-Up of R for Ubuntu Linux > | > | 1. Open the Bash terminal (Applications > Accessories > Terminal) > | 2. Type these lines to add the security key to access the latest version > of > | the R Ubuntu package: > | u...@computer:~$ gpg --keyserver subkeys.pgp.net --recv-key E2A11821 > | u...@computer:~$ gpg -a --export E2A11821 | sudo apt-key add - > | 3. Use the Bash terminal to open your sources.list file with gedit (text > | editor) for editing: > | u...@computer:~$ sudo gedit /etc/apt/sources.list > | 4. Add this line to the bottom of the sources.list file: > | deb http://rh-mirror.linux.iastate.edu/CRAN/bin/linux/ubuntu hardy/ > | 5. Save the file and go back to the Bash terminal. > | 6. Type this to update apt-get's database before you install R: > | u...@computer:~$ sudo apt-get update > | 7. Install R with this command: > | u...@computer:~$ sudo apt-get install r-base > | 8. Go to System > Administration > Synaptic Package Manager, and > download > | the build-essential package. > > In 7. you use apt, in 8. you use Synaptic. Why not to both at once: > >$ sudo apt-get install r-base r-base-dev > > as 'r-base-dev' depends on build-essential (and a few other things) and > gets > you all this and more (see below). > > | 9. To use R, simply enter R in the Bash terminal. To quit, enter q(). > | > | > | Additional programs will be needed to install other packages or work > with > | other programs: > | 1. Install compilers for C++ and Fortran > | u...@computer:~$ sudo apt-get install g++ gfortran > | 2. Install the developer versions of Blas and Lapack (what are these?) > | u...@computer:~$ apt-get install libblas-dev liblapack-dev > > The modified step 7 above would have done both for you. > > | Updating Packages in R > | 1. Open the Bash terminal and start R with root permissions > | u...@computer:~$ sudo R > | 2. Type > update.packages() > > Yep. I also like 'sudo apt-get install littler' and I then copy or link > install.r to /usr/local/bin and just use > > $ sudo install.r foo far fie foo > > which would then install the (hyopthetical) packages foo, far, fie and foo > from CRAN. > > | Installing the R Commander GUI > | 1. Open the Bash terminal and type: > |u...@computer:~$ apt-get install r-cran-rcmdr > | > | > | Using the R Commander GUI > | library(Rcmdr) > | ...or once the library is open and Commander has been shut down, type: > | commander() > | > | > | Notes > | It looks like most of R has been put here: > | /etc/R (Rprofile.site is here) > | /usr/lib/R > > Also /usr/share/R for architecture-independent files. > > | Downloaded Packages seem to go here: > | /usr/local/lib/R/site-library/ > > Slightly more complex: > -- 'base R' and recommended packages are in /usr/lib/R/library/ > -- Debian-packaged R packages are in /usr/lib/R/site-library/ > -- packages installed by you / R are in /usr/local/lib/R/site-library/ > > > You did a great job documenting all things. A 'fresh set of eyese' review > helps everybody. I suggest you get in touch with the Debian / Ubuntu > maintainers for CRAN (see the CRAN README in bin/linux/{ubuntu,debian} > about > making this a more visible document. > > Also, for your other emails: 'sudo apt-get install ess' will just get > you > a working ESS. > > Dirk > > | -- > | View this message in context: > http://www.nabble.com/installing-R-on-Ubuntu-tp10025949p21894862.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. > > -- > Three out of two people have difficul
Re: [R] Error installing rjags in Ubuntu Linux
Hi Frank, Thanks for the suggestion. It looks like that is an excellent way to install JAGS. I've also been successful with installing JAGS, but cannot get the rjags package to install, so I can call JAGS from R. Any suggestions there? Thanks. Frank E Harrell Jr wrote: > > See if this helps:http://biostat.mc.vanderbilt.edu/JAGSInstallExample > > Improvements to this approach are welcomed. > Frank > > > Paul Heinrich Dietrich wrote: >> Hi, >> Here is a step-by-step guide to exactly how I've installed R in Ubuntu: >> http://www.nabble.com/installing-R-on-Ubuntu-td10025949.html#a21894865 >> >> Regarding rjags, here is what happened: >> >> This webpage >> (http://yusung.blogspot.com/2009/01/install-jags-and-rjags-in-fedora.html) >> recommends logging into R as sudo R, and then typing: >> >> install.packages("rjags", >> configure.args="--with-jags-include=/usr/local/include/JAGS >> --with-jags-lib=/usr/local/lib/JAGS >> --with-jags-modules=/usr/local/lib/JAGS/modules") >> >> ...but I get... >> >> Error in dyn.load(file, DLLpath = DLLpath, ...) : >> unable to load shared library >> '/usr/local/lib/R/site-library/rjags/libs/rjags.so': >> >> ...which is virtually identical to this thread >> (http://www.nabble.com/unable-to-install-rjags-on-64-bit-Debian-Linux-(etch)-td20404210.html#a20404210) >> about a 64-bit install. Although my computer has dual AMD64's, I'm sure >> it's a 32-bit system. I have removed rjags with >> remove.packages("rjags"). >> Does anybody know how to install rjags in Ubuntu Linux (I'm specifying >> it, >> because I am very new and don't know what I'm doing yet)? Thanks. > > > -- > Frank E Harrell Jr Professor and Chair School of Medicine > Department of Biostatistics Vanderbilt University > > __ > 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. > > -- View this message in context: http://www.nabble.com/Error-installing-rjags-in-Ubuntu-Linux-tp21900345p21903233.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] installing R on Ubuntu
Hi Brian, I'm sure buttons are slow compared to keystrokes, but how do you stop R with a keystroke, similar to the R interface in Windows? Thanks. Sorry about the JGS-JGR goof...just coming across too many new things right now. JGR it is. -- View this message in context: http://www.nabble.com/installing-R-on-Ubuntu-tp10025949p21902978.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] installing R on Ubuntu
Thanks Dirk, it worked like a charm :) Dirk Eddelbuettel wrote: > > > On 8 February 2009 at 12:14, Paul Heinrich Dietrich wrote: > | Hi Dirk, > | Sorry, I'm not trying to drag out the installation process here, but > just > | trying to get it to work right in Linux. > | > | > | Dirk Eddelbuettel wrote: > | > > | > What is wrong with > | > > | > $ sudo apt-get install r-cran-rgl > | > > | > | I tried this suggestion, and here was the terminal output: > | > | r-cran-rgl is already the newest version. > | r-cran-rgl set to manually installed. > | 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. > > Good. You were supposed to stop here :) > > | So, just to double-check, I went into R as sudo, entered > update.packages(), > | and got this: > | > | rgl : > | Version 0.76 installed in /usr/lib/R/site-library > | Version 0.82 available at http://streaming.stat.iastate.edu/CRAN > > You are confusing > > a) having a _pre-compiled binary_ installed (0.76) >===> this implies only libraries for running this > > b) having the ability to _locally compile_ >===> this requires matching header files etc provided by the -dev >packages. > > And a) != b). We provide a) because b) is harder as you discover below. > > Unless you are reasonably experienced with your Linux distro of choice it > is > somewhat difficult to build certain packages, especially when they have > hardware dependencies. > > Which is _precisely_ why we provide the binaries. > > Now, a good compromise is to look at the _source of pre-built package_ as > this contains the Debian/Ubuntu-specific knowledge that the generic source > does not have. In particular: > > Build-Depends: debhelper (>= 5.0.0), r-base-dev (>= 2.8.1), cdbs, > libgl1-mesa-dev | libgl-dev, libglu1-mesa-dev | libglu-dev, libpng12-dev, > libx11-dev, libxt-dev, x11proto-core-dev > > leading to install > > libgl1-mesa-dev or libgl-dev > libglu1-mesa-dev or libglu-dev > libpng12-dev > libx11-dev > libxt-dev > x11proto-core-dev > > after which your local build will probably succeed. > > There is nice way to semi-automate this, and we need to document it > better. It is somewhat more advanced though. > > Hth, Dirk > > | ...and later this... > | > | * Installing *source* package 'rgl' ... > | checking for gcc... gcc -std=gnu99 > | checking for C compiler default output file name... a.out > | checking whether the C compiler works... yes > | checking whether we are cross compiling... no > | checking for suffix of executables... > | checking for suffix of object files... o > | checking whether we are using the GNU C compiler... yes > | checking whether gcc -std=gnu99 accepts -g... yes > | checking for gcc -std=gnu99 option to accept ISO C89... none needed > | checking how to run the C preprocessor... gcc -std=gnu99 -E > | checking for gcc... (cached) gcc -std=gnu99 > | checking whether we are using the GNU C compiler... (cached) yes > | checking whether gcc -std=gnu99 accepts -g... (cached) yes > | checking for gcc -std=gnu99 option to accept ISO C89... (cached) none > needed > | checking for libpng-config... no > | checking libpng... checking for grep that handles long lines and -e... > | /bin/grep > | checking for egrep... /bin/grep -E > | checking for ANSI C header files... yes > | checking for sys/types.h... yes > | checking for sys/stat.h... yes > | checking for stdlib.h... yes > | checking for string.h... yes > | checking for memory.h... yes > | checking for strings.h... yes > | checking for inttypes.h... yes > | checking for stdint.h... yes > | checking for unistd.h... yes > | checking png.h usability... no > | checking png.h presence... no > | checking for png.h... no > | checking for png_read_update_info in -lpng... no > | configure: libpng header and lib found > | configure: using libpng dynamic linkage > | checking for X... no > | configure: error: X11 not found but required, configure aborted. > | ERROR: configuration failed for package 'rgl' > | ** Removing '/usr/lib/R/site-library/rgl' > | ** Restoring previous '/usr/lib/R/site-library/rgl' > | > | The downloaded packages are in > | /tmp/RtmpIW4d37/downloaded_packages > | Warning message: > | In install.packages(update[instlib == l, "Package"], l, contriburl = > | contriburl, : > | installation of package 'rgl' had non-zero exit status > | > | > | > | > | -- > | View this message in context: > http://www
Re: [R] Error installing rjags in Ubuntu Linux
Dirk helped me by pointing out some other downloads I needed in another thread to get updates working with R. After I got that working, in answer to this question, I installed rjags and it worked...next came R2jags, and I ran my first JAGS example with Gelman's school example. Success! Many thanks to all. Frank E Harrell Jr wrote: > > Paul Heinrich Dietrich wrote: >> Hi Frank, >> Thanks for the suggestion. It looks like that is an excellent way to >> install JAGS. I've also been successful with installing JAGS, but cannot >> get the rjags package to install, so I can call JAGS from R. Any >> suggestions there? Thanks. > > After getting jags installed, I did not encounter problems running just > install.packages('rjags'). You might provide some details to the group > and someone may spot the problem. > > Frank > >> >> >> Frank E Harrell Jr wrote: >>> See if this helps:http://biostat.mc.vanderbilt.edu/JAGSInstallExample >>> >>> Improvements to this approach are welcomed. >>> Frank >>> >>> >>> Paul Heinrich Dietrich wrote: >>>> Hi, >>>> Here is a step-by-step guide to exactly how I've installed R in Ubuntu: >>>> http://www.nabble.com/installing-R-on-Ubuntu-td10025949.html#a21894865 >>>> >>>> Regarding rjags, here is what happened: >>>> >>>> This webpage >>>> (http://yusung.blogspot.com/2009/01/install-jags-and-rjags-in-fedora.html) >>>> recommends logging into R as sudo R, and then typing: >>>> >>>> install.packages("rjags", >>>> configure.args="--with-jags-include=/usr/local/include/JAGS >>>> --with-jags-lib=/usr/local/lib/JAGS >>>> --with-jags-modules=/usr/local/lib/JAGS/modules") >>>> >>>> ...but I get... >>>> >>>> Error in dyn.load(file, DLLpath = DLLpath, ...) : >>>> unable to load shared library >>>> '/usr/local/lib/R/site-library/rjags/libs/rjags.so': >>>> >>>> ...which is virtually identical to this thread >>>> (http://www.nabble.com/unable-to-install-rjags-on-64-bit-Debian-Linux-(etch)-td20404210.html#a20404210) >>>> about a 64-bit install. Although my computer has dual AMD64's, I'm >>>> sure >>>> it's a 32-bit system. I have removed rjags with >>>> remove.packages("rjags"). >>>> Does anybody know how to install rjags in Ubuntu Linux (I'm specifying >>>> it, >>>> because I am very new and don't know what I'm doing yet)? Thanks. >>> >>> -- >>> Frank E Harrell Jr Professor and Chair School of Medicine >>> Department of Biostatistics Vanderbilt >>> University >>> >>> __ >>> 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. >>> >>> >> > > > -- > Frank E Harrell Jr Professor and Chair School of Medicine > Department of Biostatistics Vanderbilt University > > __ > 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. > > -- View this message in context: http://www.nabble.com/Error-installing-rjags-in-Ubuntu-Linux-tp21900345p21911131.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] Optimizing Multiple Models...any suggestions?
There are multiple marketing models in place to predict individual-level probabilities of whether or not someone would respond to a solicitation, whether or not they would become a customer, and if they did become a customer, how much money the company is likely to make. Each individual receives a score from each model, and the final goal is to rank all individuals based on a final score. As long as multiple models exist, I'm guessing the method of deriving a final score from multiple model scores is an optimization algorithm. I have no experience with optimization in R, and was wondering if anyone could recommend a package or function, or any other method, for this particular type of problem. Thanks. -- View this message in context: http://www.nabble.com/Optimizing-Multiple-Models...any-suggestions--tp21979556p21979556.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] Optimizing Multiple Models...any suggestions?
Hi Max, Thanks for the suggestion, that's exactly what I was looking for. Thanks again. Paul -- View this message in context: http://www.nabble.com/Optimizing-Multiple-Models...any-suggestions--tp21979556p22006494.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] How to connect R and WinBUGS/OpenBUGS/LinBUGS in Linux in Feb. 2009
Hi all, I've managed to get JAGS working on my Ubuntu Hardy Linux with a 32-bit computer and AMD processors using R 2.8.1. JAGS is great. I've read that JAGS is the fastest, but that hasn't been my experience. At any rate, I have more experience with WinBUGS under Windows and would like a version of that working as well. It seems like I've read a lot on the subject and tried a lot, but haven't managed to get BUGS to work yet. The most success I've had is to install WinBUGS or OpenBUGS using this method: http://www.math.aau.dk/~slb/kurser/bayes-08/install.html What you also need to know is that you need to open Wine and add a drive. Although Z is recommended, I haven't been able to specify it, but have gotten a D drive to work, using: wine D:/opt/OpenBUGS/winbugs.exe Using this method, OpenBUGS opens. Now, to be able to open it with R. I've read all sorts of discussions about BRugs (which is no longer on CRAN, but old versions can still be found), rbugs, and R2WinBUGS (which I'm used to using on Windows with WinBUGS). Some people say R2WinBUGS cannot run OpenBUGS on Linux, some claim they've done it (I think). It seems the same thing with everything else. I've tried making the linbugs and cbugs file recommended elsewhere online. It's all very confusing. Can someone show a method that works currently, along with some sample code? I'm also new to Linux, and confused by path conventions. For example, in rbugs, it shows an example of a path such as "/var/scratch/jyan/wine-20040408/wine", and I don't see how to modify this. I have no /var/scratch to begin with, and think Wine is installed in /home/me/.wine...(I don't have Linux in front of me right now). Please help. Thanks. -- View this message in context: http://www.nabble.com/How-to-connect-R-and-WinBUGS-OpenBUGS-LinBUGS-in-Linux-in-Feb.-2009-tp22058716p22058716.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] How to connect R and WinBUGS/OpenBUGS/LinBUGS in Linux in Feb. 2009
Hi Uwe, Thank you for your guidance. I have installed R2WinBUGS and WinBUGS14 under wine. Using ?bugs for help, it tells me: useWINE: logical; attempt to use the Wine emulator to run 'WinBUGS', defaults to 'FALSE' on Windows, and 'TRUE' otherwise. Not available in S-PLUS. WINE: character, path to 'wine' binary file, it is tried hard (by a guess and the utilities 'which' and 'locate') to get the information automatically if not given. newWINE: Use new versions of Wine that have 'winepath' utility WINEPATH: character, path to 'winepath' binary file, it is tried hard (by a guess and the utilities 'which' and 'locate') to get the information automatically if not given. ..and the following code is a simple Bayesian version of a t-test... Directory Paths MyModelPath <- "/home/me/Compound/R/WinBUGS/" MyBUGSPath <- "/home/me/.wine/drive_c/Program Files/WinBUGS14/" MyModelFile <- paste(MyModelPath, "model.bug", sep="") WINEPATH <- "/usr/bin/wine" Create Data Set # Here is some fake data n_draws <- 50 x <- round(runif(n_draws, 1, 2)) y <- ifelse(x == 1, rnorm(n_draws, 1, 1), rnorm(n_draws, 1.2, 0.8)) MyData <- as.data.frame(cbind(y, x)) y.n <- NROW(MyData$y) x.j <- length(unique(x)) summary(MyData) ## Format Data for WinBUGS ## MyBUGSData <- list(y=MyData$y, x=MyData$x, n=y.n, x.j=x.j) MyBUGSData ## WinBUGS Model File ### library(R2WinBUGS) cat("model { for (i in 1:n) { y[i] ~ dnorm(mu[i], tau) mu[i] <- alpha + beta[x[i]] } ### STZ (Sum-To-Zero) Constraints beta[1] <- -sum(beta[2:x.j]) ### Priors alpha ~ dnorm(0.0, 1.0E-4) for (i in 2:x.j) { beta[i] ~ dnorm(0.0, 1.0E-4) } tau ~ dgamma(0.01, 0.01) precision <- sqrt(1/tau) }", file=MyModelFile) file.show(MyModelFile) # WinBUGS Model # MyModel <- bugs(MyBUGSData, inits=NULL, model.file=MyModelFile, parameters.to.save=c("alpha", "beta", "precision"), n.chains=3, n.iter=2000, n.burnin=1000, n.thin=1, codaPkg=TRUE, bugs.directory = MyBUGSPath, working.directory=MyModelPath, useWINE=TRUE, WINEPATH=WINEPATH, debug=TRUE) The output says: ERROR: cannot open the connection I'm wondering if I've misinterpreted how to set my paths with wine, because I can go to the following path, double-click on WinBUGS14.exe, and open it just fine: /home/me/.wine/drive_c/Program Files/WinBUGS14/ I can also go to Applications > Wine > Browse C:\ Drive and navigate to WinBUGS. Please help if I've done something wrong. Thanks. -- View this message in context: http://www.nabble.com/How-to-connect-R-and-WinBUGS-OpenBUGS-LinBUGS-in-Linux-in-Feb.-2009-tp22058716p22069602.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] How to connect R and WinBUGS/OpenBUGS/LinBUGS in Linux in Feb. 2009
Tobias, this looks great! I'm new to Linux, and I've only installed packages from within R with install.packages(). I'm guessing that I should unzip ROpenBUGS to the following path: /usr/local/lib/R/site-library/ ...just checking because I'm new and don't want to do it wrong. Thanks. PS This really looks great. Any thought to making this a permanently available package on CRAN? Tobias Verbeke-4 wrote: > > Uwe Ligges wrote: > >>> Hi all, >>> I've managed to get JAGS working on my Ubuntu Hardy Linux with a 32-bit >>> computer and AMD processors using R 2.8.1. JAGS is great. I've read >>> that >>> JAGS is the fastest, but that hasn't been my experience. At any rate, I >>> have more experience with WinBUGS under Windows and would like a >>> version of >>> that working as well. >>> >>> It seems like I've read a lot on the subject and tried a lot, but >>> haven't >>> managed to get BUGS to work yet. The most success I've had is to >>> install >>> WinBUGS or OpenBUGS using this method: >>> http://www.math.aau.dk/~slb/kurser/bayes-08/install.html >>> >>> What you also need to know is that you need to open Wine and add a >>> drive. Although Z is recommended, I haven't been able to specify it, >>> but have >>> gotten a D drive to work, using: >>> >>> wine D:/opt/OpenBUGS/winbugs.exe >>> >>> Using this method, OpenBUGS opens. Now, to be able to open it with >>> R. I've >>> read all sorts of discussions about BRugs (which is no longer on CRAN, >>> but >>> old versions can still be found), rbugs, and R2WinBUGS (which I'm used >>> to >>> using on Windows with WinBUGS). Some people say R2WinBUGS cannot run >>> OpenBUGS on Linux, some claim they've done it (I think). It seems the >>> same >>> thing with everything else. I've tried making the linbugs and cbugs >>> file >>> recommended elsewhere online. It's all very confusing. >> >> For short: It is quite unlikely that BRugs / OpenBUGS (which is called >> LinBUGS under Linux) works natively under your Linux (although it might >> work under very specific settings). > > As every now and then I get offline requests from people who stumble on > this thread > > http://finzi.psych.upenn.edu/R/Rhelp08/archive/132855.html > > to give details on how I got OpenBUGS running under GNU/Linux, > I made a stripped-down package that does just that. The approach is > very, very basic and I only tested this on a few machines and > distributions, but if it can be useful to anyone, I temporarily > put it up at > > http://www.openanalytics.be/rOpenBUGS_0.0-1.tar.gz > > Best, > Tobias > > __ > 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. > > -- View this message in context: http://www.nabble.com/How-to-connect-R-and-WinBUGS-OpenBUGS-LinBUGS-in-Linux-in-Feb.-2009-tp22058716p22091812.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] How to connect R and WinBUGS/OpenBUGS/LinBUGS in Linux in Feb. 2009
I went to this webpage (http://ubuntuforums.org/showthread.php?t=624644) and followed the instructions to the letter on getting the latest Wine. I installed WinBUGS again, but this time I cannot open it in Wine. It says Black Box, Trap #101, and some text I can't copy/paste here. Is this the latest Wine that you have, or something different? Thanks. chaogai-2 wrote: > > Hi, > > For me running winbugs through wine just works. Even when I do not specify > any directories. > The example they give in the bugs helpfile was my starting point. > Setup is suse 11.1, latest Wine, R, R2WinBUGS & winbugs. > I assume you first tried without specifying directories? > The directories you use do not work for me, with WINEPATH the culprit. > If you do not have the latest wine I advise to upgrade & not specify > directories. > > Good luck, > Kees > > On Wed, 18 Feb 2009 01:27:18 +0100, Paul Heinrich Dietrich > wrote: > >> >> Hi Uwe, >> Thank you for your guidance. I have installed R2WinBUGS and WinBUGS14 >> under >> wine. Using ?bugs for help, it tells me: >> >> useWINE: logical; attempt to use the Wine emulator to run 'WinBUGS', >> defaults to 'FALSE' on Windows, and 'TRUE' otherwise. Not available in >> S-PLUS. >> >> WINE: character, path to 'wine' binary file, it is tried hard (by a guess >> and the utilities 'which' and 'locate') to get the information >> automatically if not given. >> >> newWINE: Use new versions of Wine that have 'winepath' utility >> >> WINEPATH: character, path to 'winepath' binary file, it is tried hard >> (by a >> guess and the utilities 'which' and 'locate') to get the information >> automatically if not given. >> >> ..and the following code is a simple Bayesian version of a t-test... >> >> Directory Paths >> >> MyModelPath <- "/home/me/Compound/R/WinBUGS/" >> MyBUGSPath <- "/home/me/.wine/drive_c/Program Files/WinBUGS14/" >> MyModelFile <- paste(MyModelPath, "model.bug", sep="") >> WINEPATH <- "/usr/bin/wine" >> >> Create Data Set >> >> # Here is some fake data >> n_draws <- 50 >> x <- round(runif(n_draws, 1, 2)) >> y <- ifelse(x == 1, rnorm(n_draws, 1, 1), rnorm(n_draws, 1.2, 0.8)) >> MyData <- as.data.frame(cbind(y, x)) >> y.n <- NROW(MyData$y) >> x.j <- length(unique(x)) >> summary(MyData) >> >> ## Format Data for WinBUGS >> ## >> MyBUGSData <- list(y=MyData$y, x=MyData$x, n=y.n, x.j=x.j) >> MyBUGSData >> >> ## WinBUGS Model File >> ### >> library(R2WinBUGS) >> cat("model >> { >> for (i in 1:n) >> { >> y[i] ~ dnorm(mu[i], tau) >> mu[i] <- alpha + beta[x[i]] >> } >> ### STZ (Sum-To-Zero) Constraints >> beta[1] <- -sum(beta[2:x.j]) >> ### Priors >> alpha ~ dnorm(0.0, 1.0E-4) >> for (i in 2:x.j) >> { >> beta[i] ~ dnorm(0.0, 1.0E-4) >> } >> tau ~ dgamma(0.01, 0.01) >> precision <- sqrt(1/tau) >> }", >> file=MyModelFile) >> file.show(MyModelFile) >> >> # WinBUGS Model >> # >> MyModel <- bugs(MyBUGSData, inits=NULL, >> model.file=MyModelFile, >> parameters.to.save=c("alpha", "beta", "precision"), >> n.chains=3, n.iter=2000, n.burnin=1000, n.thin=1, codaPkg=TRUE, >> bugs.directory = MyBUGSPath, working.directory=MyModelPath, >> useWINE=TRUE, WINEPATH=WINEPATH, debug=TRUE) >> >> The output says: >> >> ERROR: >> cannot open the connection >> >> I'm wondering if I've misinterpreted how to set my paths with wine, >> because >> I can go to the following path, double-click on WinBUGS14.exe, and open >> it >> just fine: /home/me/.wine/drive_c/Program Files/WinBUGS14/ >> >> I can also go to Applications > Wine > Browse C:\ Drive and navigate to >> WinBUGS. >> >> Please help if I've done something wrong. Thanks. > > > > -- > > __ > 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. > > -- View this message in context: http://www.nabble.com/How-to-connect-R-and-WinBUGS-OpenBUGS-LinBUGS-in-Linux-in-Feb.-2009-tp22058716p22091675.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] How to connect R and WinBUGS/OpenBUGS/LinBUGS in Linux in Feb. 2009
Hi Kees, No harm no foul. I'm glad you posted that anyway, because now anyone who's trying to do the same thing and read this will know to seek your 1.1.9 version and stay away from 1.1.15. Paul chaogai-2 wrote: > > I do not know about the ubuntu instructions, they would not help me on > Suse. The wine version is 1.1.9. > I thought that was the latest,but when I checked latest is 1.1.15, which > does indeed throw the blackbox error. > So, now it does not work for me either > Sorry I gave bad advise > > kees > > On Thu, 19 Feb 2009 01:38:15 +0100, Paul Heinrich Dietrich > wrote: > >> >> I went to this webpage (http://ubuntuforums.org/showthread.php?t=624644) >> and >> followed the instructions to the letter on getting the latest Wine. I >> installed WinBUGS again, but this time I cannot open it in Wine. It says >> Black Box, Trap #101, and some text I can't copy/paste here. Is this the >> latest Wine that you have, or something different? Thanks. >> >> >> chaogai-2 wrote: >>> >>> Hi, >>> >>> For me running winbugs through wine just works. Even when I do not >>> specify >>> any directories. >>> The example they give in the bugs helpfile was my starting point. >>> Setup is suse 11.1, latest Wine, R, R2WinBUGS & winbugs. >>> I assume you first tried without specifying directories? >>> The directories you use do not work for me, with WINEPATH the culprit. >>> If you do not have the latest wine I advise to upgrade & not specify >>> directories. >>> >>> Good luck, >>> Kees >>> >>> On Wed, 18 Feb 2009 01:27:18 +0100, Paul Heinrich Dietrich >>> wrote: >>> >>>> >>>> Hi Uwe, >>>> Thank you for your guidance. I have installed R2WinBUGS and WinBUGS14 >>>> under >>>> wine. Using ?bugs for help, it tells me: >>>> >>>> useWINE: logical; attempt to use the Wine emulator to run 'WinBUGS', >>>> defaults to 'FALSE' on Windows, and 'TRUE' otherwise. Not available in >>>> S-PLUS. >>>> >>>> WINE: character, path to 'wine' binary file, it is tried hard (by a >>>> guess >>>> and the utilities 'which' and 'locate') to get the information >>>> automatically if not given. >>>> >>>> newWINE: Use new versions of Wine that have 'winepath' utility >>>> >>>> WINEPATH: character, path to 'winepath' binary file, it is tried hard >>>> (by a >>>> guess and the utilities 'which' and 'locate') to get the information >>>> automatically if not given. >>>> >>>> ..and the following code is a simple Bayesian version of a t-test... >>>> >>>> Directory Paths >>>> >>>> MyModelPath <- "/home/me/Compound/R/WinBUGS/" >>>> MyBUGSPath <- "/home/me/.wine/drive_c/Program Files/WinBUGS14/" >>>> MyModelFile <- paste(MyModelPath, "model.bug", sep="") >>>> WINEPATH <- "/usr/bin/wine" >>>> >>>> Create Data Set >>>> >>>> # Here is some fake data >>>> n_draws <- 50 >>>> x <- round(runif(n_draws, 1, 2)) >>>> y <- ifelse(x == 1, rnorm(n_draws, 1, 1), rnorm(n_draws, 1.2, 0.8)) >>>> MyData <- as.data.frame(cbind(y, x)) >>>> y.n <- NROW(MyData$y) >>>> x.j <- length(unique(x)) >>>> summary(MyData) >>>> >>>> ## Format Data for WinBUGS >>>> ## >>>> MyBUGSData <- list(y=MyData$y, x=MyData$x, n=y.n, x.j=x.j) >>>> MyBUGSData >>>> >>>> ## WinBUGS Model File >>>> ### >>>> library(R2WinBUGS) >>>> cat("model >>>>{ >>>>for (i in 1:n) >>>>{ >>>>y[i] ~ dnorm(mu[i], tau) >>>>mu[i] <- alpha + beta[x[i]] >>>>} >>>>### STZ (Sum-To-Zero) Constraints >>>>beta[1] <- -sum(beta[2:x.j]) >>>>### Priors >>>>alpha ~ dnorm(0.0, 1.0E-4) >>>>for (i in 2:x.j) >>>>
Re: [R] How to connect R and WinBUGS/OpenBUGS/LinBUGS in Linux in Feb. 2009
I just wanted to post in conclusion to this thread that I have had success running WinBUGS from R via R2WinBUGS, with the help of Gorjanc, Uwe, and Ben by email outside of this thread. I may have had a permissions problem, that was probably corrected by entering this in the terminal: m...@computer:~$ chmod -R u+w /home/me/.wine/drive_c/"Program Files"/WinBUGS14/ >From here, I opened R, entered library(R2WinBUGS), then ?bugs, then copy/pasted the example, and ran it exactly. My mistake that prevented it all from running was that I started R as sudo R, thinking that would give me more permissions, because I thought I was having permissions-oriented problems. But this is wrong. When I started R by merely entering R in the terminal, the example code ran perfectly. Success! Winepaths did not have to be specified because WinBUGS was installed in the usual place (c:/Program Files/WinBUGS14/"). Other people have emailed me, indicating that newer versions of WINE have not worked for them, so I am back with WINE 1.0. I hope this helps others trying to run WinBUGS on Linux. -- View this message in context: http://www.nabble.com/How-to-connect-R-and-WinBUGS-OpenBUGS-LinBUGS-in-Linux-in-Feb.-2009-tp22058716p22136577.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] incomplete data analysis
I like the mi package, or when it's too large I use the Amelia package. evrim akar wrote: > > Dear R users, > > First of all, thank you for your help about goodness of fit tests. > > I have another set of data and i am sure it is incomplete. I searched for > incomplete data analysis with R but I could not find any suggestion, or > method. Lets say (totally hypothetical situation) from a distribution you > can generate a continuous random sample between the numbers 0 and 100. but > I > have data from 20 to 80 and the rest is missing. I suspect this data comes > from the distribution I mentioned. If I use tests like ks.test or > chi-square > to test if the data comes from this distribution it says NO because it > takes > my sample as whole sample. > > If there is any suggestion about the package I have to read, or function I > have to use or I can modify, I would be very glad. > > Thank you in advance. > > PS:I would like to prevent any misunderstanding, I am not asking for a > code. > Maybe, I could not find the right words to search and I would appreciate > any > help (name of the package or search key words or even if it is possible or > not...) > > [[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. > > -- View this message in context: http://www.nabble.com/incomplete-data-analysis-tp22161555p22164827.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] xyplot color question
Hi, I am plotting scatterplots of horsepower by torque, conditional on brand (I'm just making up the variables for this example), and the goal is to see both the scatterplot points as well as the smoothed line. When I do the following code, I get the same color for the points and line, and would like the colors to be different, such as black points and a red smoothed line. How do I do that? I can't find any examples or figure out how to manipulate color. Thanks. xyplot(horsepower ~ torque | brand, MyData, type=c("p","smooth")) -- View this message in context: http://www.nabble.com/xyplot-color-question-tp22288842p22288842.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] Partial Derivatives in logit
Hi, I'm trying to figure out how to have R estimate partial derivatives for logit models. As an example, I'm providing a (fake) scored observation in a MNL with 3 categories of Y and 2 predictors (x01 and x02), and show the right way to calculate it, but am looking for how to use an R function, such as deriv() or anything else. Here is my attempt: ### Variables for an observation x01 <- 0.2 x02 <- 0.1 ### Parameters for an observation b00.1 <- 0.5 b00.2 <- 0.3 b00.3 <- 0 b01.1 <- 0.4 b01.2 <- 0.5 b01.3 <- 0 b02.1 <- 0.3 b02.2 <- -0.1 b02.3 <- 0 ### Predicted Probabilities for an observation phat1 <- 0.6 phat2 <- 0.3 phat3 <- 0.1 ### Correct way to calculate a partial derivative partial.b01.1 <- phat1 * (b01.1 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) partial.b01.2 <- phat2 * (b01.2 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) partial.b01.3 <- phat3 * (b01.3 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) partial.b01.1; partial.b01.2; partial.b01.3 ### Test method...so far, using the deriv() function test <- deriv(phat1 ~ exp(b00.1+b01.1*x01+b02.1*x02) / (exp(b00.1+b01.1*x01+b02.1*x02)+exp(b00.2+b01.2*x01+b02.2*x02)+ exp(b00.3+b01.3*x01+b02.3*x02)), c("x01")) eval(test) Obviously I'm not on the right path. How do I set up something like this? I've read (probably not well enough) the ?deriv() information and found a few threads on here about partial derivatives, but I can't figure it out. Thanks for any suggestions. -- View this message in context: http://www.nabble.com/Partial-Derivatives-in-logit-tp23084203p23084203.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] Function recommendation for this study...
Hi, I'm not used to thinking along these lines, and wanted to ask your advice: Suppose you have a sample of around 100, consisting of patients according to doctors, in which patients and doctors are given a questionnaire with categorical responses. Each patient somehow has roughly 3 doctors, or 3 rows of data. The goal is to assess by category of each question or DV the agreement between the patient and 3 doctors. For example, a question may be asked about how well the treatment is understood by the patient, and the patient answers with their perception, while the 3 doctors each answer with their perception. The person currently working on this has used a Wilcoxon Sign Rank test, and asked what I thought. Personally, I shy away from nonparametrics and prefer parametric Bayesian methods, but of course am up for whatever is most appropriate. I was concerned about using multiple Wilcoxon tests, one for each question, and wondering if there is a parametric method in R for something like this, and a method which is multivariate? Thanks for any suggestions. -- View this message in context: http://www.nabble.com/Function-recommendation-for-this-study...-tp23469646p23469646.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] Partial Derivatives in R
Quick question: Which function do you use to calculate partial derivatives from a model equation? I've looked at deriv(), but think it gives derivatives, not partial derivatives. Of course my equation isn't this simple, but as an example, I'm looking for something that let's you control whether it's a partial or not, such as: somefunction(y~a+bx, with respect to x, partial=TRUE) Is there anything like this in R? -- View this message in context: http://www.nabble.com/Partial-Derivatives-in-R-tp23470413p23470413.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] Partial Derivatives in R
Thank you for suggesting other functions, I will look into them. When I read the deriv() function, it did mention partial, but I (being a newbie) wasn't able to get partials for a simple MNL equation. I'm sure I did something wrong then, but here's what I tried the following and got different answers, concluding prematurely maybe that deriv actually just gives regular derivatives. Thanks for looking: ### Variables for an observation x01 <- rnorm(1,0,1) x02 <- rnorm(1,0,1) ### Parameters for an observation b00.1 <- rnorm(1,0,1) b00.2 <- rnorm(1,0,1) b00.3 <- 0 b01.1 <- rnorm(1,0,1) b01.2 <- rnorm(1,0,1) b01.3 <- 0 b02.1 <- rnorm(1,0,1) b02.2 <- rnorm(1,0,1) b02.3 <- 0 ### Predicted Probabilities for an observation phat1 <- 0.6 phat2 <- 0.3 phat3 <- 0.1 ### Correct way to calculate a partial derivative for MNL partial.b01.1 <- phat1 * (b01.1 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) partial.b01.2 <- phat2 * (b01.2 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) partial.b01.3 <- phat3 * (b01.3 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) partial.b01.1; partial.b01.2; partial.b01.3 partial.b02.1 <- phat1 * (b02.1 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) partial.b02.2 <- phat2 * (b02.2 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) partial.b02.3 <- phat3 * (b02.3 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) partial.b02.1; partial.b02.2; partial.b02.3 ### Derivatives for MNL according to (my interpretation of) the deriv() function dp1.dx <- deriv(phat1 ~ exp(b00.1+b01.1*x01+b02.1*x02) / (exp(b00.1+b01.1*x01+b02.1*x02)+exp(b00.2+b01.2*x01+b02.2*x02)+ exp(b00.3+b01.3*x01+b02.3*x02)), c("x01","x02")) dp2.dx <- deriv(phat2 ~ exp(b00.2+b01.2*x01+b02.2*x02) / (exp(b00.1+b01.1*x01+b02.1*x02)+exp(b00.2+b01.2*x01+b02.2*x02)+ exp(b00.3+b01.3*x01+b02.3*x02)), c("x01","x02")) dp3.dx <- deriv(phat3 ~ exp(b00.3+b01.3*x01+b02.3*x02) / (exp(b00.1+b01.1*x01+b02.1*x02)+exp(b00.2+b01.2*x01+b02.2*x02)+ exp(b00.3+b01.3*x01+b02.3*x02)), c("x01","x02")) attr(eval(dp1.dx), "gradient") attr(eval(dp2.dx), "gradient") attr(eval(dp3.dx), "gradient") -- View this message in context: http://www.nabble.com/Partial-Derivatives-in-R-tp23470413p23475411.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] Function recommendation for this study...
Thank you for the suggestions, I'm sure irr is what I'm looking for. Thanks again. spencerg wrote: > > To look up "observer agreement", you might consider the > "RSiteSearch" package. The "RSiteSearch.function" looks only for > matches in help pages of contributed packages. > > > library(RSiteSearch) > oa <- RSiteSearch.function("observer agreement") > attr(oa, "hits") # 4 functions matching this term > HTML(oa) # to open the results as a table in a web browser. > > > An alternative search term for this is "interrater reliability". > > > ir.r <- RSiteSearch.function("inter-rater reliability") > attr(ir.r, "hits") # 1 > irr <- RSiteSearch.function("interrater reliability") > attr(irr, "hits") # 19 > ir..r <- RSiteSearch.function("inter rater reliability") > attr(ir..r, "hits") # 1 > > > In particular, this identified a package "irr" for interrater > reliability. > > > The development version of the "RSiteSearch" package on R-Forge > includes a "unionRSiteSearch" function that allows one to combine all > these searches. You can get this version using > 'install.packages("RSiteSearch", > repos="http://R-Forge.R-project.org";)'; if this gives you version > 1.0-0, please wait 24 hours and try again, because this version contains > a bug that I just fixed. The new version 1.0-1 should be available in > 24 hours. With it, the following just worked for me: > > > IRR <- unionRSiteSearch(oa, unionRSiteSearch(ir.r, > unionRSiteSearch(irr, ir..r) ) ) > attr(IRR, "hits") > HTML(IRR) > > > Hope this helps. > Spencer Graves > > Murray Cooper wrote: >> Paul, >> >> I suggest looking up "observer agreement". The description of your >> study sounds like a classical >> categorical observer agreement problem. I can't give >> a reference off the top of my head, but if you get >> stuck, e-mail me and I'll try and find a ref to get you started. >> >> Murray M Cooper, Ph.D. >> Richland Statistics >> 9800 N 24th St >> Richland, MI, USA 49083 >> Mail: richs...@earthlink.net >> >> - Original Message - From: "Paul Heinrich Dietrich" >> >> To: >> Sent: Sunday, May 10, 2009 8:25 AM >> Subject: [R] Function recommendation for this study... >> >> >>> >>> Hi, >>> I'm not used to thinking along these lines, and wanted to ask your >>> advice: >>> >>> Suppose you have a sample of around 100, consisting of patients >>> according to >>> doctors, in which patients and doctors are given a questionnaire with >>> categorical responses. Each patient somehow has roughly 3 doctors, or 3 >>> rows of data. The goal is to assess by category of each question or >>> DV the >>> agreement between the patient and 3 doctors. For example, a question >>> may be >>> asked about how well the treatment is understood by the patient, and the >>> patient answers with their perception, while the 3 doctors each >>> answer with >>> their perception. >>> >>> The person currently working on this has used a Wilcoxon Sign Rank >>> test, and >>> asked what I thought. Personally, I shy away from nonparametrics and >>> prefer >>> parametric Bayesian methods, but of course am up for whatever is most >>> appropriate. I was concerned about using multiple Wilcoxon tests, >>> one for >>> each question, and wondering if there is a parametric method in R for >>> something like this, and a method which is multivariate? Thanks for any >>> suggestions. >>> -- >>> View this message in context: >>> http://www.nabble.com/Function-recommendation-for-this-study...-tp23469646p23469646.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. >> > > __ > 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. > > -- View this message in context: http://www.nabble.com/Function-recommendation-for-this-study...-tp23469646p23480875.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] Partial Derivatives in R
Hi Spencer, Thanks for suggesting the genD function. In attempting it, I have rearranged my function from phat1 ~ ... to ... - 1, it apparently doesn't like the first one :) But when I run it, it tells me the partials are all zero. I'm trying out a simple MNL equation before I expand it to what I'm looking for. Here is what I tried (and I get different answers from a textbook solution, deriv(), and genD()): > ### Variables for an observation > x01 <- rnorm(1,0,1) > x02 <- rnorm(1,0,1) > ### Parameters for an observation > b00.1 <- rnorm(1,0,1) > b00.2 <- rnorm(1,0,1) > b00.3 <- 0 > b01.1 <- rnorm(1,0,1) > b01.2 <- rnorm(1,0,1) > b01.3 <- 0 > b02.1 <- rnorm(1,0,1) > b02.2 <- rnorm(1,0,1) > b02.3 <- 0 > ### Predicted Probabilities for an observation > phat1 <- 0.6 > phat2 <- 0.3 > phat3 <- 0.1 > ### Correct way to calculate a partial derivative > partial.b01.1 <- phat1 * (b01.1 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) > partial.b01.2 <- phat2 * (b01.2 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) > partial.b01.3 <- phat3 * (b01.3 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) > partial.b01.1; partial.b01.2; partial.b01.3 [1] 0.04288663 [1] -0.1804876 [1] 0.1376010 > > partial.b02.1 <- phat1 * (b02.1 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) > partial.b02.2 <- phat2 * (b02.2 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) > partial.b02.3 <- phat3 * (b02.3 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) > partial.b02.1; partial.b02.2; partial.b02.3 [1] 0.8633057 [1] 0.3171978 [1] 0.1376010 > ### Derivatives for MNL > dp1.dx <- deriv(phat1 ~ exp(b00.1+b01.1*x01+b02.1*x02) / + (exp(b00.1+b01.1*x01+b02.1*x02)+exp(b00.2+b01.2*x01+b02.2*x02)+ + exp(b00.3+b01.3*x01+b02.3*x02)), c("x01","x02")) > dp2.dx <- deriv(phat2 ~ exp(b00.2+b01.2*x01+b02.2*x02) / + (exp(b00.1+b01.1*x01+b02.1*x02)+exp(b00.2+b01.2*x01+b02.2*x02)+ + exp(b00.3+b01.3*x01+b02.3*x02)), c("x01","x02")) > dp3.dx <- deriv(phat3 ~ exp(b00.3+b01.3*x01+b02.3*x02) / + (exp(b00.1+b01.1*x01+b02.1*x02)+exp(b00.2+b01.2*x01+b02.2*x02)+ + exp(b00.3+b01.3*x01+b02.3*x02)), c("x01","x02")) > attr(eval(dp1.dx), "gradient") x01 x02 [1,] -0.01891354 0.058918 > attr(eval(dp2.dx), "gradient") x01 x02 [1,] -0.1509395 -0.06258685 > attr(eval(dp3.dx), "gradient") x01 x02 [1,] 0.169853 0.003668849 > library(numDeriv) > dp1.dx <- function(x) {exp(b00.1+b01.1*x01+b02.1*x02) / + (exp(b00.1+b01.1*x01+b02.1*x02)+exp(b00.2+b01.2*x01+b02.2*x02)+ + exp(b00.3+b01.3*x01+b02.3*x02)) - phat1} > test <- genD(dp1.dx, c(phat1,b00.1,b01.1,b02.1,x01,x02)); test $D [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [1,]000000000 0 0 0 0 0 [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26] [1,] 0 0 0 0 0 0 0 0 0 0 0 0 [,27] [1,] 0 $p [1] 6 $f0 [1] 0.05185856 $func function(x) {exp(b00.1+b01.1*x01+b02.1*x02) / (exp(b00.1+b01.1*x01+b02.1*x02)+exp(b00.2+b01.2*x01+b02.2*x02)+ exp(b00.3+b01.3*x01+b02.3*x02)) - phat1} $x [1] 0.6 1.401890082 -1.304531849 0.062833294 -0.143141379 [6] -0.005995477 $d [1] 1e-04 $method [1] "Richardson" $method.args $method.args$eps [1] 1e-04 $method.args$d [1] 1e-04 $method.args$zero.tol [1] 1.781029e-05 $method.args$r [1] 4 $method.args$v [1] 2 attr(,"class") [1] "Darray" > spencerg wrote: > > Have you considered genD{numDeriv}? > > If this does not answer your question, I suggest you try the > "RSiteSearch" package. The following will open a list of options in a > web browser, sorted by package most often found with your search term: > > > library(RSiteSearch) > pd <- RSiteSearch.function('partial derivative') > pds <- RSiteSearch.function('partial derivatives') > attr(pd, 'hits') # 58 > attr(pds, 'hits')# 52 > summary(pd) > HTML(pd) > HTML(pds) > > > The development version available via > 'install.packages("RSiteSearch", repos="http://R-Forge.R-project.org";)' > also supports the following: > > > pd. <- unionRSiteSearch(pd, pds) > attr(pd., 'hits')# 94 > HTML(pd.) > > > Hope this helps. > Spencer Graves > > Paul Heinrich Dietrich wrote: >> Quick question: >> >> Which function do you use to calculate partial derivatives from a model >> equation? >> >> I've looked at deriv(), but think it gives derivatives, not partial &
Re: [R] Partial Derivatives in R
Thanks for showing me how to use genD correctly and that it matches deriv here. Like you say, there must be a problem with the manual way of doing it, and I will look at it closely. Thanks again. spencerg wrote: > > Hi, Paul: > > > Your example is so complicated that I don't want to take the time > to check it. You apply "deriv" to an exponential divided by a sum of > exponentials, and I'm not convinced that your manual "Correct way" is > actually correct. It looks like you've followed the examples in the > "deriv" help page, so I would be more inclined to trust that, especially > since it matched the answer I got from genD, as follows. > > > In your "genD" example, x01 and x02 should be x[1] and x[2]: > > p1 <- function(x) {exp(b00.1+b01.1*x[1]+b02.1*x[2]) / > (exp(b00.1+b01.1*x[1]+b02.1*x[2])+ > exp(b00.2+b01.2*x[1]+b02.2*x[2])+ > exp(b00.3+b01.3*x[1]+b02.3*x[2])) - phat1} > test <- genD(p1, c(x01, x02)) > test$D >[,1] [,2][,3] [,4] [,5] > [1,] -0.2012997 0.1296301 -0.03572875 0.07082898 -0.1261376 > > > The first two components of test$D here match your > attr(eval(dp1.dx), "gradient"). The next three are the lower triangular > portion of the matrix of second partials of the function "p1", per the > "genD" documentation. > > > The function numericGradient in the maxLik package could also be > used for this, I believe. However, I won't take the time here to test > that. > > > Hope this helps. > Spencer Graves > > > Paul Heinrich Dietrich wrote: >> Hi Spencer, >> Thanks for suggesting the genD function. In attempting it, I have >> rearranged my function from phat1 ~ ... to ... - 1, it apparently doesn't >> like the first one :) But when I run it, it tells me the partials are >> all >> zero. I'm trying out a simple MNL equation before I expand it to what >> I'm >> looking for. Here is what I tried (and I get different answers from a >> textbook solution, deriv(), and genD()): >> >> >>> ### Variables for an observation >>> x01 <- rnorm(1,0,1) >>> x02 <- rnorm(1,0,1) >>> ### Parameters for an observation >>> b00.1 <- rnorm(1,0,1) >>> b00.2 <- rnorm(1,0,1) >>> b00.3 <- 0 >>> b01.1 <- rnorm(1,0,1) >>> b01.2 <- rnorm(1,0,1) >>> b01.3 <- 0 >>> b02.1 <- rnorm(1,0,1) >>> b02.2 <- rnorm(1,0,1) >>> b02.3 <- 0 >>> ### Predicted Probabilities for an observation >>> phat1 <- 0.6 >>> phat2 <- 0.3 >>> phat3 <- 0.1 >>> ### Correct way to calculate a partial derivative >>> partial.b01.1 <- phat1 * (b01.1 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) >>> partial.b01.2 <- phat2 * (b01.2 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) >>> partial.b01.3 <- phat3 * (b01.3 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) >>> partial.b01.1; partial.b01.2; partial.b01.3 >>> >> [1] 0.04288663 >> [1] -0.1804876 >> [1] 0.1376010 >> >>> partial.b02.1 <- phat1 * (b02.1 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) >>> partial.b02.2 <- phat2 * (b02.2 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) >>> partial.b02.3 <- phat3 * (b02.3 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) >>> partial.b02.1; partial.b02.2; partial.b02.3 >>> >> [1] 0.8633057 >> [1] 0.3171978 >> [1] 0.1376010 >> >>> ### Derivatives for MNL >>> dp1.dx <- deriv(phat1 ~ exp(b00.1+b01.1*x01+b02.1*x02) / >>> >> + (exp(b00.1+b01.1*x01+b02.1*x02)+exp(b00.2+b01.2*x01+b02.2*x02)+ >> + exp(b00.3+b01.3*x01+b02.3*x02)), c("x01","x02")) >> >>> dp2.dx <- deriv(phat2 ~ exp(b00.2+b01.2*x01+b02.2*x02) / >>> >> + (exp(b00.1+b01.1*x01+b02.1*x02)+exp(b00.2+b01.2*x01+b02.2*x02)+ >> + exp(b00.3+b01.3*x01+b02.3*x02)), c("x01","x02")) >> >>> dp3.dx <- deriv(phat3 ~ exp(b00.3+b01.3*x01+b02.3*x02) / >>> >> + (exp(b00.1+b01.1*x01+b02.1*x02)+exp(b00.2+b01.2*x01+b02.2*x02)+ >> + exp(b00.3+b01.3*x01+b02.3*x02)), c("x01","x02")) >> >>> attr(eval(dp1.dx), "gradient") >>> >> x01 x02 >> [1,] -0.01891354 0.058918 >> >>> attr(eval(dp2.dx), "gradient") >>> >>
[R] Cream Text Editor
I'm interested in easing my way into learning VIM by first using the Cream text editor, liking the idea that it will work on both my Linux and Windows computers. I've installed Cream on my Linux machine, but can't figure out how to make Cream talk to R? Does anybody know? I'm using Ubuntu if it makes a difference. Thanks. -- View this message in context: http://www.nabble.com/Cream-Text-Editor-tp23688559p23688559.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] Cream Text Editor
Thank you much for the help, I will work on this over the weekend. Is there a way in Windows to connect R and Cream? Jakson Alves de Aquino wrote: > > > As pointed by JiHO the biggest disadvantage of using the plugin is that > R is running through a pipe and consequently it is less interactive. > Just a note: there is no need of before . Almost all key > bindings work in insert, normal and visual modes. > > The last version of the plugin allows the user to set the terminal > emulator in the vimrc and now all key bindings are customizable. The > details are in the plugin's documentation. > > Please write, to me if you find bugs in the plugin. > > Jakson > > JiHO wrote: >> On 2009-May-23 , at 17:40 , Paul Heinrich Dietrich wrote: >> >>> I'm interested in easing my way into learning VIM by first using the >>> Cream >>> text editor, liking the idea that it will work on both my Linux and >>> Windows >>> computers. I've installed Cream on my Linux machine, but can't figure >>> out >>> how to make Cream talk to R? Does anybody know? I'm using Ubuntu if it >>> makes a difference. Thanks. >> >> You should install the R Vim Plugin and its dependencies: >> http://www.vim.org/scripts/script.php?script_id=2628 >> This creates commands and icons dedicated to the interaction between Vim >> and R. >> >> >> Then switch cream Settings > Preferences > Expert Mode. >> >> This will allow you to work in Cream and have all the simple keyboard >> shortcuts (Control-C, Control-V etc.) but still be able to switch >> between modes as in vim. By default you are in insert mode. You need to >> switch to normal mode (by pressing ESC) to be able to use the commands >> of the R-Vim plugin. >> >> The workflow is therefore: >> - open a R file >> - edit stuff >> - press ESC (to switch to non-edit mode) >> - start R in a terminal (click the icon or press F2) >> - send lines/selection (F9) or document (F5) >> - press ESC (to switch back to insert mode) >> - edit 2 lines >> - ESC >> - F9 >> - F9 >> - ESC >> - edit again >> etc... >> >> The terminal opened this way does not work completely as a regular one >> and there are some caveats when reading help and using general command >> line editing shortcuts (Ctrl-R for backward search for example). I >> haven't found a way around them so I usually open a second terminal to >> read the help in, or set R to display the help as HTML files in a >> browser window. >> >> I must say that those caveats can be quite serious and I often find >> myself just using copy-paste from gedit in a terminal: >> - set your desktop to "focus follow mouse" >> - select text in your editor >> - move the mouse to the terminal >> - click middle mouse button >> - move the mouse back to the editor >> etc... >> More cumbersome but reliable. >> >> Final note: since you are on ubuntu, you may want to change the terminal >> from the default X-term to gnome-terminal. You have to edit the file >> .vim/ftplugin/r.vim. There is a line commented with the gnome-terminal >> command instead of xterm. Uncomment this one and comment the xterm one. >> >> JiHO >> --- >> http://jo.irisson.free.fr/ > > __ > 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. > > -- View this message in context: http://www.nabble.com/Cream-Text-Editor-tp23688559p23692419.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] How to use your own data in gstat and sp?
This seems pretty basic, but I can't get any data to work except for the documented examples. When the goal is to get to SpatialPixels, here is what I see... > x <- runif(10,1,10) > y <- runif(10,1,10) > z <- rnorm(10,0,1) > MyData <- as.data.frame(cbind(x,y,z)) > library(gstat) > coordinates(MyData) <- ~x + y > gridded(MyData) <- TRUE suggested tolerance minimum: 0.893182669294186 Error in points2grid(points, tolerance, round, fuzz.tol) : dimension 1 : coordinate intervals are not constant I've spent way too much time trying to get my data to work. Please help. Thanks. -- View this message in context: http://www.nabble.com/How-to-use-your-own-data-in-gstat-and-sp--tp24994744p24994744.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] How to use your own data in gstat and sp?
Thanks that makes sense. Just a newby to spatial data in R. Thanks. Roger Bivand wrote: > > First re-read the definition of what a SpatialPixels object is - > ?"SpatialPixels-class" - note that it says: "class for defining a pixels, > forming a possibly incomplete rectangular grid of arbitrary dimension". > When you try to coerce a SpatialPointsDataFrame to a > SpatialPixelsDataFrame, it is checked to see that the points form a > "possibly incomplete rectangular grid". Your points are random within a > 1,10 square, so only regularly spaced for a very special setting of the > seed of the RNG, right? Since you are unlikely to hit that very, very rare > seed at random, you are not likely to generate a regular grid in this way. > Did you examine the class(), summary() and str() of the input data in the > examples? > > Hope this helps, > > Roger Bivand > > PS. consider following this up on the R-sig-geo list. > > > Paul Heinrich Dietrich wrote: >> >> This seems pretty basic, but I can't get any data to work except for the >> documented examples. When the goal is to get to SpatialPixels, here is >> what I see... >> >>> x <- runif(10,1,10) >>> y <- runif(10,1,10) >>> z <- rnorm(10,0,1) >>> MyData <- as.data.frame(cbind(x,y,z)) >>> library(gstat) >>> coordinates(MyData) <- ~x + y >>> gridded(MyData) <- TRUE >> suggested tolerance minimum: 0.893182669294186 >> Error in points2grid(points, tolerance, round, fuzz.tol) : >> dimension 1 : coordinate intervals are not constant >> >> I've spent way too much time trying to get my data to work. Please help. >> Thanks. >> > > -- View this message in context: http://www.nabble.com/How-to-use-your-own-data-in-gstat-and-sp--tp24994744p25004653.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] How to Dedup a Spatial Points Data Set
I'm new to spatial analysis and am exploring numerous packages, mostly enjoying sp, gstat, and spBayes. Is there a function that allows the user to dedup a data set with multiple values at the same coordinates and replace those duplicated values with the mean at those coordinates? I've written some cumbersome code that works, but would prefer an efficient R function if it exists. Thanks. -- View this message in context: http://www.nabble.com/How-to-Dedup-a-Spatial-Points-Data-Set-tp25033516p25033516.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] Spatio-Temporal Models in the ramps package
The ramps package looks very appealing. I have run the examples in the package .pdf and gone through the .pdf article at the Journal of Statistical Software, and am very impressed. Is it possible to see a spatio-temporal example in R script as well? Thanks. -- View this message in context: http://www.nabble.com/Spatio-Temporal-Models-in-the-ramps-package-tp25181149p25181149.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.