Re: [R] installation of R on Linux
-Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Friday, January 27, 2006 11:49 PM To: Daniel Nordlund Cc: r-help@stat.math.ethz.ch Subject: Re: [R] installation of R on Linux On Fri, 27 Jan 2006, Daniel Nordlund wrote: R-users, I am new user of Linux (have been using Win XP Pro) and wanted to install R. Since I am just beginning to learn Linux I was wondering, where in the directory structure do users of Linux usually install R? Most of the instructions I have read simply say to untar the tarball where you want to install the program. Any suggestions would be welcome as to an appropriate place. I know I could get an rpm, but wanted to use this as a learning process for a variety of skills. Currently working with SuSE 9.1 There is a definitive set of instructions, in the file INSTALL in the tarball and at https://svn.r-project.org/R/trunk/INSTALL Unpacking and installing are separate operations. There is more information in the R-admin manual (which you already have in a Windows version of R, and is also in the tarball). What most of us do is to untar in any convenient place (I use ~/R), use configure, make, and then use 'make install' to install R. This installs in /usr/local in the conventional subdirectories (and conventionally needs su to access). Having installed, you can wipe out the unpacked version of the tarball. So, in my example cd ~/R tar zxf R-2.2.1.tar.gz cd R-2.2.1 configure make make info pdf su make install install-info install-pdf [leave su shell] cd .. rm -rf R-2.2.1 Rehash and start R. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 Prof. Ripley, Thanks for the example and the pointers to various locations for documentation. As a new user of Linux (with minimal experience in using Unix-like systems), I am somewhat uncomfortable putting programs just anywhere since there seem to be default locations for where many system programs reside. Your concrete example is very helpful. Thanks again, Daniel Nordlund Bothell, WA USA __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] installation of R on Linux
Daniel Nordlund wrote: -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Friday, January 27, 2006 11:49 PM To: Daniel Nordlund Cc: r-help@stat.math.ethz.ch Subject: Re: [R] installation of R on Linux On Fri, 27 Jan 2006, Daniel Nordlund wrote: R-users, I am new user of Linux (have been using Win XP Pro) and wanted to install R. Since I am just beginning to learn Linux I was wondering, where in the directory structure do users of Linux usually install R? Most of the instructions I have read simply say to untar the tarball where you want to install the program. Any suggestions would be welcome as to an appropriate place. I know I could get an rpm, but wanted to use this as a learning process for a variety of skills. Currently working with SuSE 9.1 There is a definitive set of instructions, in the file INSTALL in the tarball and at https://svn.r-project.org/R/trunk/INSTALL Unpacking and installing are separate operations. There is more information in the R-admin manual (which you already have in a Windows version of R, and is also in the tarball). What most of us do is to untar in any convenient place (I use ~/R), use configure, make, and then use 'make install' to install R. This installs in /usr/local in the conventional subdirectories (and conventionally needs su to access). Having installed, you can wipe out the unpacked version of the tarball. So, in my example cd ~/R tar zxf R-2.2.1.tar.gz cd R-2.2.1 configure make make info pdf su make install install-info install-pdf [leave su shell] cd .. rm -rf R-2.2.1 Rehash and start R. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 Prof. Ripley, Thanks for the example and the pointers to various locations for documentation. As a new user of Linux (with minimal experience in using Unix-like systems), I am somewhat uncomfortable putting programs just anywhere since there seem to be default locations for where many system programs reside. Your concrete example is very helpful. Thanks again, Daniel Nordlund Bothell, WA USA One additional point. I have often found it preferable to run configure and make as a regular user and only run 'make install' as root. -- Kevin E. Thorpe Biostatistician/Trialist, Knowledge Translation Program Assistant Professor, Department of Public Health Sciences Faculty of Medicine, University of Toronto email: [EMAIL PROTECTED] Tel: 416.946.8081 Fax: 416.946.3297 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Creating 3D Gaussian Plot
Hello, I requested help a couple of weeks ago creating a dipole field in R but receieved no responses. Eventually I opted to create a 3d sinusoidal plot and concatenate this with its inverse as a means for a next best situation. It seems that this isn't sufficient for my needs and I'm really after creating a continuous 3d gaussian mesh with a positive and negative dipole. Can anyone offer any pointers at all? Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Creating 3D Gaussian Plot
On 1/28/2006 8:55 AM, Laura Quinn wrote: Hello, I requested help a couple of weeks ago creating a dipole field in R but receieved no responses. Eventually I opted to create a 3d sinusoidal plot and concatenate this with its inverse as a means for a next best situation. It seems that this isn't sufficient for my needs and I'm really after creating a continuous 3d gaussian mesh with a positive and negative dipole. The names you're using don't mean anything to me; perhaps there just aren't enough atmospheric scientists on the list and that's why you didn't get any response. If you don't get a response this time, you should describe what you want in basic terms, and/or point to examples of it on the web. Duncan Murdoch Can anyone offer any pointers at all? Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Creating 3D Gaussian Plot
My apologies. With further apologies for the poor graphics, this link demonstrates the sort of 3d mesh which I am hoping to replicate - I would like to be able to replicate a number of these of varying intensity. Demonstrating different levels of potential via the steepness of the slopes. http://maxwell.ucdavis.edu/~electro/potential/images/steep.jpg I then wish to pick a number of grid points at random from the output to perform a further analysis upon. I hope this makes things a little clearer! Again, any help gratefully received, thank you. Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] On Sat, 28 Jan 2006, Duncan Murdoch wrote: On 1/28/2006 8:55 AM, Laura Quinn wrote: Hello, I requested help a couple of weeks ago creating a dipole field in R but receieved no responses. Eventually I opted to create a 3d sinusoidal plot and concatenate this with its inverse as a means for a next best situation. It seems that this isn't sufficient for my needs and I'm really after creating a continuous 3d gaussian mesh with a positive and negative dipole. The names you're using don't mean anything to me; perhaps there just aren't enough atmospheric scientists on the list and that's why you didn't get any response. If you don't get a response this time, you should describe what you want in basic terms, and/or point to examples of it on the web. Duncan Murdoch Can anyone offer any pointers at all? Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] monochrome mosaic plot in vcd package
Michael, How about using grayscale shading and setting the background color (the gaps between the tiles) to middle gray? -- Alan B. Cobo-Lewis, Ph.D. (207) 581-3840 tel Department of Psychology(207) 581-6128 fax University of Maine Orono, ME 04469-5742[EMAIL PROTECTED] http://www.umaine.edu/visualperception r-help@stat.math.ethz.ch on Saturday, January 28, 2006 at 6:00 AM -0500 wrote: Content-Type: message/rfc822 MIME-Version: 1.0 From: Mike Townsley [EMAIL PROTECTED] Precedence: list MIME-Version: 1.0 To: r-help@stat.math.ethz.ch Date: Fri, 27 Jan 2006 11:28:10 + Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=us-ascii; format=flowed Subject: [R] monochrome mosaic plot in vcd package Message: 5 helpeRs, I have a nice looking mosaic plot in an article to be published soon. Sadly, the published version will be in black and white and so ruin the advantage of the default shading scheme of tiles. What would readers suggest as an alternative shading scheme? If I have a black-and-white shading scheme graduated according to suitable cutoffs I won't be able to tell positive from negative residuals. The tile borders can be changed of course, but I'm uncertain that is will be clear enough for a reader. Another option may be to use a fill pattern of sloping lines with different orientations for the sign and density for the magnitude. The problem with this option is I wouldn't know where to start to incorporate into a legend. The shading_binary function is no good as I would like the cells with residuals less than absolute 2 to be different from other cells. How would readers of this list represent a mosaic plot so that it was easily interpretable in monochrome? My data can be used as an example: library(vcd) library(MASS) term.1 - gl(2,1,8, labels = LETTERS[1:2]) term.2 - gl(2,2,8, labels = LETTERS[3:4]) term.3 - gl(2,4,8, labels = LETTERS[5:6]) cell.count - c(72, 19, 5, 8, 117, 115, 81, 85) mosaic(loglm(formula = cell.count ~ term.1 + term.2 + term.3), shade = TRUE, gp = shading_hcl, legend = TRUE, labeling_args = list(rot_labels = rep(0,4)), gp_args = list(lty = 1:2),legend_width = unit(0.2, npc)) Dr Michael Townsley Senior Research Fellow Jill Dando Institute of Crime Science University College London Second Floor, Brook House London, WC1E 7HN Phone: 020 7679 0820 Fax: 020 7679 0828 Email: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Learning - Example programs
I'm working my way up the learning curve for R. A method of learning I find very effective is to work through an existing program. Are there any libraries or archives of R programs on the web ? If not, would this be a good idea for the R website ? I hope this is not a FAQ: I have checked as far as I can. Best Wishes, Martin Holt __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Learning - Example programs
On 28 January 2006 at 15:52, Martin P. Holt wrote: | I'm working my way up the learning curve for R. A method of learning I find | very effective is to work through an existing program. Are there any | libraries or archives of R programs on the web ? If not, would this be a Well, you could try googleing for CRAN and its mirrors; each CRAN archive contains over six hundred contributed packages all of which contain examples for R. Each of which is only one command away from you for use and inspection. And your R installation itself has thousands of functions each with examples. Try help(example) example(example) R comes with six manuals that come with it, and a FAQ document. | good idea for the R website ? | I hope this is not a FAQ: I have checked as far as I can. The FAQ lists several books on R. CRAN and its mirrors host several free books in pdf form. Lastly, some Google scores: 'R example' 140 million hits 'R examples' 78 million hits 'R example code' 63 million hits Hope this helps, Dirk -- Hell, there are no rules here - we're trying to accomplish something. -- Thomas A. Edison __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Learning - Example programs
Typing the function name at the prompt prints that body of the function. By working thrugh the steps in the boot function, helped me both understand the way the bootstrap works and write better R code. Phineas -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Martin P. Holt Sent: Saturday, January 28, 2006 3:53 PM To: r-help Subject: [R] Learning - Example programs I'm working my way up the learning curve for R. A method of learning I find very effective is to work through an existing program. Are there any libraries or archives of R programs on the web ? If not, would this be a good idea for the R website ? I hope this is not a FAQ: I have checked as far as I can. Best Wishes, Martin Holt __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Creating 3D Gaussian Plot
On 1/28/2006 9:52 AM, Laura Quinn wrote: I'm working from a blank canvas! The perspective isn't key - the most important thing is getting the values for the grid mesh points, the method of plotting is less crucial. I was hoping there might be an inbuilt R function which would allow me to create the grid points by specifying amplitude/wavelength parameters but my searches have come up blank thus far. I'd happily knock up a FORTRAN routine to provide me with the coords for the gridpoints, but I can't figure out the underlying equation. Supposing you want the peaks at (1,-1) and (-1,1), a reasonable equation might be fn - function(x, y, scale) dnorm(x,mean=1,sd=scale)*dnorm(y,mean=-1,sd=scale) - dnorm(x,mean=-1,sd=scale)*dnorm(y,mean=1,sd=scale) Then you can plot it on a grid by x - seq(-4,4,len=100) y - seq(-4,4,len=100) z - outer(x,y,fn,scale=0.5) persp(x,y,z,col=green,border=NA,shade=0.75) You can play around with the arguments to persp to change the colours, rotate it, etc. The scale argument controls how pointy the peaks are. You might also want to look at the surface3d function in the rgl package. It does scaling differently, so you'd probably want something like bg3d(white) surface3d(x,y,z*6,col=green) which gives a surface like the one above, but you can rotate it using the mouse. Duncan Murdoch Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] On Sat, 28 Jan 2006, Duncan Murdoch wrote: On 1/28/2006 9:27 AM, Laura Quinn wrote: My apologies. With further apologies for the poor graphics, this link demonstrates the sort of 3d mesh which I am hoping to replicate - I would like to be able to replicate a number of these of varying intensity. Demonstrating different levels of potential via the steepness of the slopes. http://maxwell.ucdavis.edu/~electro/potential/images/steep.jpg I then wish to pick a number of grid points at random from the output to perform a further analysis upon. I hope this makes things a little clearer! Again, any help gratefully received, thank you. That's helpful. You can produce a graph like that using persp(), provided you have already calculated the values at all the points on the grid -- but it sounds as though you haven't got those yet. What sort of input do you have? Duncan Murdoch Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] On Sat, 28 Jan 2006, Duncan Murdoch wrote: On 1/28/2006 8:55 AM, Laura Quinn wrote: Hello, I requested help a couple of weeks ago creating a dipole field in R but receieved no responses. Eventually I opted to create a 3d sinusoidal plot and concatenate this with its inverse as a means for a next best situation. It seems that this isn't sufficient for my needs and I'm really after creating a continuous 3d gaussian mesh with a positive and negative dipole. The names you're using don't mean anything to me; perhaps there just aren't enough atmospheric scientists on the list and that's why you didn't get any response. If you don't get a response this time, you should describe what you want in basic terms, and/or point to examples of it on the web. Duncan Murdoch Can anyone offer any pointers at all? Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Learning - Example programs
In addition to what others have said go the R home page, and under Documentation on the left hand side click on Other and look at that plus from that page click on Contributed Documents which is a link on that page. Also this has lots of code: http://www.ku.edu/~pauljohn/R/Rtips.html On 1/28/06, Martin P. Holt [EMAIL PROTECTED] wrote: I'm working my way up the learning curve for R. A method of learning I find very effective is to work through an existing program. Are there any libraries or archives of R programs on the web ? If not, would this be a good idea for the R website ? I hope this is not a FAQ: I have checked as far as I can. Best Wishes, Martin Holt __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] yet another lmer question
I've been trying to keep track with lmer, and now I have a couple of questions with the latest version of Matrix (0.995-4). I fit 2 very similar models, and the results are severely rounded in one case and rounded not at all in the other. y - 1:10 group - rep (c(1,2), c(5,5)) M1 - lmer (y ~ 1 + (1 | group)) coef(M1) $group (Intercept) 1 3.1 2 7.9 x - rep (c(1,2), c(3,7)) M2 - lmer (y ~ 1 + x + (1 + x | group)) coef(M2) $group (Intercept)x 1 -0.755102 2.755102 20.616483 3.640738 I can't figure out why everything is rounded for the first model but not for the second. Also, mcmcsamp() works for M1 but not for M2: mcmcsamp(M1) (Intercept) log(sigma^2) log(grop.(In)) [1,]9.0990730.5711817 3.246981 attr(,mcpar) [1] 1 1 1 attr(,class) [1] mcmc mcmcsamp(M2) Error: inconsistent degrees of freedom and dimension Error in t(.Call(mer_MCMCsamp, object, saveb, n, trans, PACKAGE = Matrix)) : unable to find the argument 'x' in selecting a method for function 't' -- Andrew Gelman Professor, Department of Statistics Professor, Department of Political Science [EMAIL PROTECTED] www.stat.columbia.edu/~gelman Tues, Wed, Thurs: Social Work Bldg (Amsterdam Ave at 122 St), Room 1016 212-851-2142 Mon, Fri: International Affairs Bldg (Amsterdam Ave at 118 St), Room 711 212-854-7075 Mailing address: 1255 Amsterdam Ave, Room 1016 Columbia University New York, NY 10027-5904 212-851-2142 (fax) 212-851-2164 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] fitting generalized linear models using glmmPQL
I have not seen your particular error message often enough to be confident I know what caused it: Error: NA/NaN/Inf in foreign function call (arg 1) In addition: Warning message: step size truncated due to divergence In this case, the Warning seems more informative to me than the actual Error. The function glmmPQL is an iterative algorithm. The warining says that step size truncated due to divergence. This kind of warning might occur when the iteration found a long, gently sloping plateau and tried to take a giant step to get beyond it. The algorithm decided that the giant step was too large, and so tried to truncate it. Since I don't have your data, I can only guess at what might have caused it. My first guess is that you have the wrong model. Have you considered the following: modelo1a-glmmPQL(DE ~ POB*TEMP*SALINITA, data = datos, random = ~ POB|CLON, family = poisson) Putting nesting with the random effect in the 'fixed' model makes not sense to me and generates an explosion of the number of fixed effect parameters to be estimated. This might cause your problem all by itself. If that doesn't solve the problem, have you tried to get a separate fit for each level of CLON of the same fixed model, something like the following: (CLON.count - table(datos$CLON)) n.CLON - length(CLON.count) glm.fits - vector(n.CLON, mode=list) for(i in 1:n.CLON) glm.fits[[i]] - try(glm(DE ~ POB*TEMP*SALINITA, data = datos[datos$CLON==names(CLON.count[i]))) Under certain circumstances, glmmPQL could still return a good answer even if glm returned an error for every level of CLON in this loop. However, that's far from certain. Also, have you tried changing the two * operators to + in the fixed formula? This reduces the number of parameters to be estimated and might give you sensible results. If you are NOT using the latest version of R with the latest versions of MASS and nlme, please upgrade before submitting another post. And PLEASE do read the posting guide! www.R-project.org/posting-guide.html, especialy the bit about providing a simple, self contained example. I sometimes solve problems like this in the course of trying to prepare a simple example. hope this helps. spencer graves [EMAIL PROTECTED] wrote: Hi, I have tried to run the following (I know it's a huge data set but I tried to perform it with a 1 GB RAM computer): library(foreign) library(MASS) library(nlme) datos-read.spss(file=c:\\Documents and Settings\\Administrador\\Escritorio\\datosfin.sav,to.data.frame=TRUE) str(datos) `data.frame': 1414 obs. of 5 variables: $ POB : Factor w/ 6 levels CHI,HOS,HYR,..: 1 1 1 1 1 1 1 1 1 1 ... $ CLON: num 1 1 1 1 1 1 1 1 2 2 ... $ TEMP: Factor w/ 2 levels 20 C,25 C: 1 1 1 1 2 2 2 2 1 1 ... $ SALINITA: Factor w/ 2 levels 15 g/l,30 g/l: 1 1 2 2 1 1 2 2 1 1 ... $ DE : num 17 0 7 1 15 28 4 14 13 16 ... - attr(*, variable.labels)= Named chr ... ..- attr(*, names)= chr POB CLON TEMP SALINITA ... datos$CLON-as.factor(datos$CLON) modelo1-glmmPQL(DE ~ (POB/CLON)*TEMP*SALINITA, data = datos, random = ~ 1|CLON, family = poisson) And I have obtained the following: Error: NA/NaN/Inf in foreign function call (arg 1) In addition: Warning message: step size truncated due to divergence This is the first time I've observed such a message and I have no idea about what does it mean. Is it possible that the process failed because of the size of the data set (180 levels of the CLON factor)? Or maybe is it a syntax problem? Thank you in advance. Eduardo Moisés García Roger Institut Cavanilles de Biodiversitat i Biologia Evolutiva - ICBIBE. Tel. +34963543664 Fax +34963543670 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Selecting Random Subset From Matrix - retaining indices
Hello, I was wondering whether there is a way to select random samples from a data matrix, retaining the indexing for the rows and columns? I have looked at using the sample() function. Applied directly to my matrix this returns a vector of absolute values but the indices are lost, alternatively I can select a random sample from a length equal to the number of elements in the matrix and then translate each number into an element withing the array but this seems to require a lot of work to ascertain the position and value of each element. Is there a better way of performing this operation? Further to my earlier query I am hoping to pick a random selection of grid points (with (x,y,z) coords) from a 3d map matrix. Thanks in advance. Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] draft of Comment on UCLA tech report
Hi! I suggest that you look in fortune package and you could add some of frotunes to this report. I think thay say a lot. I would just like to add my story. I started stats with SAS and when I heard of R I, being a open source fan, imidiatelly tried it. It was a real pain and I abandoned that idea completely, although I really tried hard. Now I know that my problem was wish to move to R, but not accepting its logic and wish to do that in one day. Then I had to do a simple thing in SAS and I realized that I do not know how to do it in SAS. Just a quick look in R solved my problem and I took about one month of slow study and I am not sorry for that. It really is important to change the approach. Of course there are pros and cons, but I would say that one of the fortunes that involve comparison of various software solutions and money tells it all. -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc at bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- One must learn by doing the thing; for though you think you know it, you have no certainty until you try. Sophocles ~ 450 B.C. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] weighted likelihood for lme
--- Spencer Graves [EMAIL PROTECTED] wrote: Thank you for providing such a marvelous example. I wish I could reward your dilligence with a simple, complete answer. Unfortunately, the best I can offer at the moment is a guess and a reference. First, I believe you are correct in that the weights argument describes the within-group heteroscedasticity structure. To specify between-group heterscadisticity, have you considered the following: foo - Orthodont foo$w - c(rep(1, 5*4), rep(0.5, 22*4)) lme(distance ~ 1, random = ~ w-1|Subject, + method=ML, data = foo) Linear mixed-effects model fit by maximum likelihood Data: foo Log-likelihood: -258.8586 Fixed: distance ~ 1 (Intercept) 23.8834 Random effects: Formula: ~w - 1 | Subject w Residual StdDev: 3.370796 2.233126 Number of Observations: 108 Number of Groups: 27 Nice! I haven't considered this alternative. As you said, it's not a complete answer, but, I say, it's a smart start. Second, have you consulted Pinheiro and Bates (2000) Mixed-Effects Models in S and S-Plus (Springer)? If you have not already, I encourage you to spend some quality time with that book. For me, this book helped transform lme from an inaequately documented and unusable black box into a simple, understandable, elegant tool. I may have recommeded it to more people than any other single work over the past five years. I know the book by Pinheiro and Bates and I do really have to spend some time with it. Thanks very much, Marco hope this helps. spencer graves Marco Geraci wrote: Dear R users, I'm trying to fit a simple random intercept model with a fixed intercept. Suppose I want to assign a weight w_i to the i-th contribute to the log-likelihood, i.e. w_i * logLik_i where logLik_i is the log-likelihood for the i-th subject. I want to maximize the likelihood for N subjects Sum_i {w_i * logLik_i} Here is a simple example to reproduce # require(nlme) foo - Orthodont lme(distance ~ 1, random = ~ 1|Subject, method=ML, data = foo) Linear mixed-effects model fit by maximum likelihood Data: foo Log-likelihood: -257.7456 Fixed: distance ~ 1 (Intercept) 24.02315 Random effects: Formula: ~1 | Subject (Intercept) Residual StdDev:1.888748 2.220312 Number of Observations: 108 Number of Groups: 27 Then I assign arbitrary weights, constant within the group. I want to give weight 1 to the first 5 subjects, and weight 0.5 to the others 22 (4 is the number of repeated measurements for each subject) foo$w - c(rep(1, 5*4), rep(0.5, 22*4)) Maybe I am missing something, but I believe that lme(distance ~ 1, random = ~ 1|Subject, method=ML, data = foo, weight=~w) does not maximize the likelihood Sum_i {w_i * logLik_i}, since 'weight' describes the with-in heteroscedasticity structure. I think I need something like the option 'iweight' (importance weight) for the command 'xtreg' of Stata. Any suggestion for R? Thanks in advance, Marco Geraci sessionInfo() R version 2.2.1, 2005-12-20, i386-pc-mingw32 attached base packages: [1] methods stats graphics grDevices utils [6] datasets base other attached packages: nlme 3.1-66 - What are the most popular cars? Find out at Yahoo! Autos [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] yet another lmer question
Andrew Gelman [EMAIL PROTECTED] writes: I've been trying to keep track with lmer, and now I have a couple of questions with the latest version of Matrix (0.995-4). I fit 2 very similar models, and the results are severely rounded in one case and rounded not at all in the other. y - 1:10 group - rep (c(1,2), c(5,5)) M1 - lmer (y ~ 1 + (1 | group)) coef(M1) $group (Intercept) 1 3.1 2 7.9 x - rep (c(1,2), c(3,7)) M2 - lmer (y ~ 1 + x + (1 + x | group)) coef(M2) $group (Intercept)x 1 -0.755102 2.755102 20.616483 3.640738 I can't figure out why everything is rounded for the first model but not for the second. Also, mcmcsamp() works for M1 but not for M2: Well, dput(coef(M1)[[1]]) structure(list((Intercept) = c(3.106436, 7.893564 )), .Names = (Intercept), row.names = c(1, 2), class = data.frame) c(3.106436, 7.893564) [1] 3.1 7.9 I.e., if you pass fake data, sometimes you get *results* that can be rounded to a few significant digits. R tries to get rid of trailing zeros in its print routines. mcmcsamp(M1) (Intercept) log(sigma^2) log(grop.(In)) [1,]9.0990730.5711817 3.246981 attr(,mcpar) [1] 1 1 1 attr(,class) [1] mcmc mcmcsamp(M2) Error: inconsistent degrees of freedom and dimension Error in t(.Call(mer_MCMCsamp, object, saveb, n, trans, PACKAGE = Matrix)) : unable to find the argument 'x' in selecting a method for function 't' Looks like a buglet, but x [1] 1 1 1 2 2 2 2 2 2 2 group [1] 1 1 1 1 1 2 2 2 2 2 Effects of x can (seemingly?) only be detected within group 1. I.e. the random variation of the effect of x is based on a sample of size 1, so I'm actually more surprised that you get a fit at all... -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] yet another lmer question
D'oh (on the rounding)! But on mcmcsamp(), I'm still confused. I changed the example slightly and got the same problem: y - (1:20)*pi x - (1:20)^2 group - rep (1:2, each=10) M1 - lmer (y ~ 1 + (1 | group)) M2 - lmer (y ~ 1 + x + (1 + x | group)) mcmcsamp (M1, saveb=TRUE) mcmcsamp (M2, saveb=TRUE) Error: inconsistent degrees of freedom and dimension Error in t(.Call(mer_MCMCsamp, object, saveb, n, trans, PACKAGE = Matrix)) : unable to find the argument 'x' in selecting a method for function 't' It really should be able to work (actually, the earlier example should work too), but maybe it gets hung up when there are only two groups. Indeed, when I change 20 and 2 above to 30 and 3, it works fine. So I guess, as a practical matter, this is fine. The domain where lmer() excels is large datasets with many groups; conversely, Bugs works best with small datasets with few groups. However, I do like to use lmer() as a starting point, so I hope that at some point it will fully work in the above example also. Also, since I have you on the line, so to speak, I noticed that coef() gives estimated group-level coefficients, and ranef() gives these coefficients centered at zero: coef(M2) $group (Intercept) x 16.885045 0.2701600 2 23.586015 0.1010110 ranef(M2) An object of class lmer.ranef [[1]] (Intercept) x 1 -8.350485 0.08457451 28.350485 -0.08457451 I was just wondering: is one or the other of these parameterizations preferred by Doug Bates et al.? I wanted to know because we discuss lmer() in our book, and I'd like our examples to remain relevant after the book appears and lmer() continues to be developed. Peter Dalgaard wrote: Andrew Gelman [EMAIL PROTECTED] writes: I've been trying to keep track with lmer, and now I have a couple of questions with the latest version of Matrix (0.995-4). I fit 2 very similar models, and the results are severely rounded in one case and rounded not at all in the other. y - 1:10 group - rep (c(1,2), c(5,5)) M1 - lmer (y ~ 1 + (1 | group)) coef(M1) $group (Intercept) 1 3.1 2 7.9 x - rep (c(1,2), c(3,7)) M2 - lmer (y ~ 1 + x + (1 + x | group)) coef(M2) $group (Intercept)x 1 -0.755102 2.755102 20.616483 3.640738 I can't figure out why everything is rounded for the first model but not for the second. Also, mcmcsamp() works for M1 but not for M2: Well, dput(coef(M1)[[1]]) structure(list((Intercept) = c(3.106436, 7.893564 )), .Names = (Intercept), row.names = c(1, 2), class = data.frame) c(3.106436, 7.893564) [1] 3.1 7.9 I.e., if you pass fake data, sometimes you get *results* that can be rounded to a few significant digits. R tries to get rid of trailing zeros in its print routines. mcmcsamp(M1) (Intercept) log(sigma^2) log(grop.(In)) [1,]9.0990730.5711817 3.246981 attr(,mcpar) [1] 1 1 1 attr(,class) [1] mcmc mcmcsamp(M2) Error: inconsistent degrees of freedom and dimension Error in t(.Call(mer_MCMCsamp, object, saveb, n, trans, PACKAGE = Matrix)) : unable to find the argument 'x' in selecting a method for function 't' Looks like a buglet, but x [1] 1 1 1 2 2 2 2 2 2 2 group [1] 1 1 1 1 1 2 2 2 2 2 Effects of x can (seemingly?) only be detected within group 1. I.e. the random variation of the effect of x is based on a sample of size 1, so I'm actually more surprised that you get a fit at all... -- Andrew Gelman Professor, Department of Statistics Professor, Department of Political Science [EMAIL PROTECTED] www.stat.columbia.edu/~gelman Tues, Wed, Thurs: Social Work Bldg (Amsterdam Ave at 122 St), Room 1016 212-851-2142 Mon, Fri: International Affairs Bldg (Amsterdam Ave at 118 St), Room 711 212-854-7075 Mailing address: 1255 Amsterdam Ave, Room 1016 Columbia University New York, NY 10027-5904 212-851-2142 (fax) 212-851-2164 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Regex question
Dear R useRs, is there any simple, build in function to match specific regular expression in data file and write it to a vector. I have the following text file: *NEW RECORD *ID-001 *AB-text *NEW RECORD *ID-002 *AB-text etc. Now I have to match all ID fields and print them to a vector: 001 002 etc. I know that this is very simple with Perl or R-Perl interface, but if possible, I want to do that 'on the hard way'. Cheers, Andrej __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Creating 3D Gaussian Plot
Getting a picture like this is pretty easy. e.g. x - y - seq(-5, 5, len = 200) X - expand.grid(x = x, y = y) X - transform(X, z = dnorm(x, -2.5)*dnorm(y) - dnorm(x, 2.5)*dnorm(y)) z - matrix(X$z, nrow = 200) persp(x, y, z, col = lightgoldenrod, border = NA, theta = 30, phi = 15, ticktype = detailed, ltheta = -120, shade = 0.25) You can vary things as you wish. I don't follow the remark about picking grid points at random for analysis, though. On simple, entirely deterministic things like this wouldn't you just be analysing the randomness that you inject into it by the choice process, effectively? Bill Venables. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Laura Quinn Sent: Sunday, 29 January 2006 12:28 AM To: Duncan Murdoch Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Creating 3D Gaussian Plot My apologies. With further apologies for the poor graphics, this link demonstrates the sort of 3d mesh which I am hoping to replicate - I would like to be able to replicate a number of these of varying intensity. Demonstrating different levels of potential via the steepness of the slopes. http://maxwell.ucdavis.edu/~electro/potential/images/steep.jpg I then wish to pick a number of grid points at random from the output to perform a further analysis upon. I hope this makes things a little clearer! Again, any help gratefully received, thank you. Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] On Sat, 28 Jan 2006, Duncan Murdoch wrote: On 1/28/2006 8:55 AM, Laura Quinn wrote: Hello, I requested help a couple of weeks ago creating a dipole field in R but receieved no responses. Eventually I opted to create a 3d sinusoidal plot and concatenate this with its inverse as a means for a next best situation. It seems that this isn't sufficient for my needs and I'm really after creating a continuous 3d gaussian mesh with a positive and negative dipole. The names you're using don't mean anything to me; perhaps there just aren't enough atmospheric scientists on the list and that's why you didn't get any response. If you don't get a response this time, you should describe what you want in basic terms, and/or point to examples of it on the web. Duncan Murdoch Can anyone offer any pointers at all? Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Regex question
Is this what you want? result - readLines('/tempxx.txt') result [1] *NEW RECORD *ID-001 *AB-text*NEW RECORD [6] *ID-002 *AB-text result - result[grep('^.ID-', result)] # select only ID lines result [1] *ID-001 *ID-002 sub('^.ID-', '', result) [1] 001 002 On 1/28/06, Andrej Kastrin [EMAIL PROTECTED] wrote: Dear R useRs, is there any simple, build in function to match specific regular expression in data file and write it to a vector. I have the following text file: *NEW RECORD *ID-001 *AB-text *NEW RECORD *ID-002 *AB-text etc. Now I have to match all ID fields and print them to a vector: 001 002 etc. I know that this is very simple with Perl or R-Perl interface, but if possible, I want to do that 'on the hard way'. Cheers, Andrej __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Jim Holtman Cincinnati, OH +1 513 247 0281 What the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Regex question
jim holtman wrote: Is this what you want? result - readLines('/tempxx.txt') result [1] *NEW RECORD *ID-001 *AB-text*NEW RECORD [6] *ID-002 *AB-text result - result[grep('^.ID-', result)] # select only ID lines result [1] *ID-001 *ID-002 sub('^.ID-', '', result) [1] 001 002 On 1/28/06, *Andrej Kastrin* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Dear R useRs, is there any simple, build in function to match specific regular expression in data file and write it to a vector. I have the following text file: *NEW RECORD *ID-001 *AB-text *NEW RECORD *ID-002 *AB-text etc. Now I have to match all ID fields and print them to a vector: 001 002 etc. I know that this is very simple with Perl or R-Perl interface, but if possible, I want to do that 'on the hard way'. Cheers, Andrej __ R-help@stat.math.ethz.ch mailto:R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Jim Holtman Cincinnati, OH +1 513 247 0281 What the problem you are trying to solve? I'm forever indepted to you for this. Cheers, Andrej __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Linearize a Function
1. Have you looked at cumsum? 2. What do you think you are computing when adding 100 to cumsum(log.returns)? To compute cumulative returns in percent from log.returns [or cumusum(log.returns)], compute exp(log.returns) or expm1(log.returns) = (exp(log.returns)-1). Similarly, to compute log.returns from simple.returns, compute log1p(simple.returns) = log(1+simple.returns) [making the obvious conversions between percentages and proportions]. Or am I missing something? hope this helps, spencer graves Gottfried Gruber wrote: hi, i calculate the log-returns in return1 and i want to get the performance for the security. with only one security i have the following code # create matrix to keep performance return100=matrix(rep(100,length(return1)+1)) # matrix for the sum z1=matrix(rep(0,length(return1)+1)) # suming up the returns from current index to start for (i in 1:length(return1)) {z1[i+1]=sum(return1[c(1:i)]) } #adding both matrices return100=return100+z1*100 this works fine for a 1 x n matrix, but if i want the same for a n x m matrix i assume the above code will get time-consuming. is there a trick to linearize the for-loop or any other solution? thanks for any solution effort, tia gg __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] What does this command ~ mean?
Hi all, I am reading books and tutorials about R. I don't understand the following: plot(salary~rank, data=salary) plot(Ozone~date, data=airquality) I don't understand what does ~ here, and how can plot() have a input argument called data... I have looked it up in plot's help but I could not find about argument data. Could you please help me? Thank you! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] What does this command ~ mean?
On 28 January 2006 at 20:12, Michael wrote: | I am reading books and tutorials about R. | | I don't understand the following: | | plot(salary~rank, data=salary) | plot(Ozone~date, data=airquality) | | I don't understand what does ~ here, If all else fails, you could consult the help system via either one of help(~) ?~ and within Emacs/ESS you even get to drop the quotes around ~. In short, ~ stands between the left and right side of a model. So what econometrics books would call Y = X beta + epsilon gets written here as Y ~ X with the coefficient vector beta and errors epsilon being implied. | and how can plot() have a input | argument called data... I have looked it up in plot's help but I could | not find about argument data. The 'R Intro' manual may be of help here. In short plot(Ozone~Day, data=airquality) works because it tells plot that the columns Ozone and Day are part of the data.frame airquality. The shorter plot(Ozone~Day) would fail unless you had attach'ed airquality. Again, the 'R Intro' manual may help. Hth, Dirk -- Hell, there are no rules here - we're trying to accomplish something. -- Thomas A. Edison __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] extracting 'Z' value from a glm result
Hello R users I like to extract z values for x1 and x2. I know how to extract coefficents using model$coef but I don't know how to extract z values for each of independent variable. I looked around using names(model) but I couldn't find how to extract z values. Any help would be appreciated. Thanks TM # summary(model) Call: glm(formula = y ~ x1+ x2, family = binomial) Deviance Residuals: Min 1Q Median 3Q Max -2.1397 -1.2357 0.6875 0.8517 1.5743 Coefficients: Estimate Std. Error z value Pr(|z|) (Intercept) -0.639301.13045 -0.5660.572 x1 0.699560.09459 7.396 1.40e-13 *** x2 1.513891.13212 1.3370.181 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: 1214.9 on 999 degrees of freedom Residual deviance: 1149.8 on 997 degrees of freedom AIC: 1155.8 Number of Fisher Scoring iterations: 4 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html