[R] SVD with positivity constraints
Hello, I have a matrix equation, Ax=b, that I need to solve for x. x should be a vector of positive numbers (between 0 and 1). A is not a square matrix in general. This lead me to using the SVD. However, using the SVD gives me positive and negative numbers, as well. I have some constraints included in the A matrix itself (i.e., that the sum of some xi should be equal to 1) but I do not know how to include the constraint that each xi should be non-negative. Is there in R (or somewhere else) an SVD that includes this kind of constraint? or some other optimizer that can cope with solving non-square matrix equations, including the positivity constraint? I know that this is not really an R question, sorry for that. Jordi Jordi Molins Short Term Products / Treasury Capital Markets Dresdner Kleinwort Wasserstein phone +49 69 713 15329 fax +49 69 713 19804 mobile +49 171 171 64 61 mailto:[EMAIL PROTECTED] The information contained herein is confidential and is inte...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Unable to open html help pages
I recently upgraded R to 1.9.1 for Mac from 1.8.1. I am not able to open the help pages online but get the message If /usr/bin/open is already running, it is *not* restarted, and you must switch to its window. Otherwise, be patient ... However, nothing happens. There are not any other windows open to switch to and I don't know what /usr/bin/open is! I'm using an eMac. I know the 1.9.1 download is only supposed to be for a PowerMac or PowerBook but 1.8.1 seemed to work fine on my eMac (before I downloaded 1.9.1 and deleted it!). Is there anything I can do to open html.help? Dr. Martin G. McCabe Cancer Research UK Clinical Research Training Fellow Cambridge University Department of Pathology Division of Molecular Histopathology Box 231 Level 3, Lab Block Addenbrooke's Hospital Hilld Road Cambridge CB2 2QQ Tel:01223 762084 Fax:01223 586670 email: [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Underline in expression().
Hello All, Is there an analogue to \underbar or the AMS math \underline in graphical math expressions? Thanks, John. -- = Dr. John Janmaat Department of Economics Acadia University Wolfville, Nova Scotia, Canada B4P 2R6 TEL: 902-585-1461 WWW: http://ace.acadiau.ca/~jjanmaat/ EMAIL: [EMAIL PROTECTED] June 10, 2004 to September 7, 2004 Dr. John Janmaat Environmental Econmics and Natural Resources Group Wageningen University. P.O. Box 8130 6700 EW, Wageningen The Netherlands. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] SVD with positivity constraints
If A is not square, which dimension is larger? There will most likely be either no solution or an infinity of solutions. If the latter, I think you are using the Moore-Penrose inverse (depends exactly how you use the SVD), that is the shortest solution, but the SVD will give you the whole space of solutions and you could compute if that intersects the positive orthant. On Tue, 27 Jul 2004, Molins, Jordi wrote: I have a matrix equation, Ax=b, that I need to solve for x. x should be a vector of positive numbers (between 0 and 1). A is not a square matrix in general. This lead me to using the SVD. However, using the SVD gives me positive and negative numbers, as well. I have some constraints included in the A matrix itself (i.e., that the sum of some xi should be equal to 1) but I do not know how to include the constraint that each xi should be non-negative. Is there in R (or somewhere else) an SVD that includes this kind of constraint? or some other optimizer that can cope with solving non-square matrix equations, including the positivity constraint? optim(method=L-BFGS-B) can cope with [0, 1] constraints. -- 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 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] SVD with positivity constraints
Thank you to Prof Brian Ripley and to Ken Knoblauch for your replies. I should explain a little bit more about the problem at hand: in principle, the matrix can have more rows than columns or the other way around. However, I always could include in an artificial way more equations, such that there are more equations than unknowns. So, in practical terms, the first question from Prof Brian Ripley is: more equations than unkowns. I have Additionally, I have seen in several places that is suggested to use La.svd instead of the standard svd. -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: 27 July 2004 10:13 To: Molins, Jordi Cc: '[EMAIL PROTECTED]' Subject: Re: [R] SVD with positivity constraints If A is not square, which dimension is larger? There will most likely be either no solution or an infinity of solutions. If the latter, I think you are using the Moore-Penrose inverse (depends exactly how you use the SVD), that is the shortest solution, but the SVD will give you the whole space of solutions and you could compute if that intersects the positive orthant. On Tue, 27 Jul 2004, Molins, Jordi wrote: I have a matrix equation, Ax=b, that I need to solve for x. x should be a vector of positive numbers (between 0 and 1). A is not a square matrix in general. This lead me to using the SVD. However, using the SVD gives me positive and negative numbers, as well. I have some constraints included in the A matrix itself (i.e., that the sum of some xi should be equal to 1) but I do not know how to include the constraint that each xi should be non-negative. Is there in R (or somewhere else) an SVD that includes this kind of constraint? or some other optimizer that can cope with solving non-square matrix equations, including the positivity constraint? optim(method=L-BFGS-B) can cope with [0, 1] constraints. -- 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 The information contained herein is confidential and is inte...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Recall: [R] SVD with positivity constraints
The sender would like to recall the message, [R] SVD with positivity constraints. The information contained herein is confidential and is inte...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] SVD with positivity constraints
Thank you to Prof Brian Ripley and to Ken Knoblauch for your fast replies. I should explain a little bit more about the problem at hand: in principle, the matrix can have more rows than columns or the other way around. However, I always could include in an artificial way more equations, such that there are more equations than unknowns. So, in practical terms, the answer to the first question from Prof Brian Ripley is: more equations than unkowns. I have checked in the Modern Applied Statistics with S 4th edition, and in page 62 it is shown the use of svd. It is written that svd gives, as result, u, v and d. If there is a space of solutions (as opposed to a unique solution) how is the solution given? how can I retrieve the whole space of solutions? Additionally, I have seen in several places that is suggested to use La.svd instead of the standard svd. Would the La.svd generate also the whole space of solutions? I have looked the documentation (http://cran.r-project.org/doc/packages/RScaLAPACK.pdf) but it is not explicitly written how to retrieve non-unique solutions. An additional question: in the Numerical Recipes for C++ it is written that the small numbers in the diagonal of d should be set manually to 0. Is this done (maybe as an option) in svd or in La.svd? could this resetting have a material effect in the solutions found? thank you J -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: 27 July 2004 10:13 To: Molins, Jordi Cc: '[EMAIL PROTECTED]' Subject: Re: [R] SVD with positivity constraints If A is not square, which dimension is larger? There will most likely be either no solution or an infinity of solutions. If the latter, I think you are using the Moore-Penrose inverse (depends exactly how you use the SVD), that is the shortest solution, but the SVD will give you the whole space of solutions and you could compute if that intersects the positive orthant. On Tue, 27 Jul 2004, Molins, Jordi wrote: I have a matrix equation, Ax=b, that I need to solve for x. x should be a vector of positive numbers (between 0 and 1). A is not a square matrix in general. This lead me to using the SVD. However, using the SVD gives me positive and negative numbers, as well. I have some constraints included in the A matrix itself (i.e., that the sum of some xi should be equal to 1) but I do not know how to include the constraint that each xi should be non-negative. Is there in R (or somewhere else) an SVD that includes this kind of constraint? or some other optimizer that can cope with solving non-square matrix equations, including the positivity constraint? optim(method=L-BFGS-B) can cope with [0, 1] constraints. -- 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 The information contained herein is confidential and is inte...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Display on Windows console from script
Hello, When I launch a script under windows it does not display sequentially my cat calls or maybe the console is not refreshed at every line of my script. For instance with that code cat(\n\n== IMPORT DATA FROM FILE ===\n\n) fileschosen - choose.files(caption=Select gpr files, filters = matrix(c(genepix file,*.gpr), nc=2, byrow=T)) The popup browse window is first displayed and once I've selected my files the cat IMPORT... is displayed. What can I do to make my displays appear at the right time? Thanks a lot. Laetitia Marisa. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Display on Windows console from script
Please consult the rw-FAQ, specifically Q6.3 whose subject looks a perfect fit for your question (and whose answer contains the answer). On Tue, 27 Jul 2004, Laetitia Marisa wrote: When I launch a script under windows it does not display sequentially my cat calls or maybe the console is not refreshed at every line of my script. For instance with that code cat(\n\n== IMPORT DATA FROM FILE ===\n\n) fileschosen - choose.files(caption=Select gpr files, filters = matrix(c(genepix file,*.gpr), nc=2, byrow=T)) The popup browse window is first displayed and once I've selected my files the cat IMPORT... is displayed. What can I do to make my displays appear at the right time? -- 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 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] library manual: documentation of funcs not alphabetically ordered
Hello everybody I'm putting finishing touches to a library, and have noticed that the .dvi file that R CMD check creates does not sort the functions in alphabetical order. I find this odd because I used the tidy routines in section 3.1 of the R-exts manual, which produce R code in which the functions are alphabetically ordered (and I performed R CMD check using the tidied-and-profiled R code). My other library manuals are in alphabetical order. How do I get a dvi manual with functions in alphabetical order? What have I forgotten to do? -- Robin Hankin Uncertainty Analyst Southampton Oceanography Centre SO14 3ZH tel +44(0)23-8059-7743 [EMAIL PROTECTED] (edit in obvious way; spam precaution) __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] SVD with positivity constraints
Hello, what I wrote below is nonsense: if the matrix has more equations than unknowns, it makes no sense considering the general space of solutions. Sorry for that. Another consideration: could somebody give me an opinion about the following procedure? the simplex algorithm maximizes z=a00x0 + a01x1+...+a0(N-1)x(N-1) subject to x0=0, ... x(N-1)=0 and under M=m1+m2+m3 constraints: m1 equations for = inequalities(with x on the left), m2 equations for = inequalities, and m3 equations for equalities (=). Consider a00=a01=...=a0(N-1)=0 (degenerate in some sense), and let me choose also m1=m2=0, and then m3 being the number of equations I have. Using the simplex method for linear programing would give me my solution, or would this method give me a degenerate solution? thank you, and please bear with me my desesperation ;- Jordi -Original Message- From: Molins, Jordi Sent: 27 July 2004 11:33 To: '[EMAIL PROTECTED]' Cc: 'Prof Brian Ripley'; 'Ken Knoblauch' Subject: RE: [R] SVD with positivity constraints Thank you to Prof Brian Ripley and to Ken Knoblauch for your fast replies. I should explain a little bit more about the problem at hand: in principle, the matrix can have more rows than columns or the other way around. However, I always could include in an artificial way more equations, such that there are more equations than unknowns. So, in practical terms, the answer to the first question from Prof Brian Ripley is: more equations than unkowns. I have checked in the Modern Applied Statistics with S 4th edition, and in page 62 it is shown the use of svd. It is written that svd gives, as result, u, v and d. If there is a space of solutions (as opposed to a unique solution) how is the solution given? how can I retrieve the whole space of solutions? Additionally, I have seen in several places that is suggested to use La.svd instead of the standard svd. Would the La.svd generate also the whole space of solutions? I have looked the documentation (http://cran.r-project.org/doc/packages/RScaLAPACK.pdf) but it is not explicitly written how to retrieve non-unique solutions. An additional question: in the Numerical Recipes for C++ it is written that the small numbers in the diagonal of d should be set manually to 0. Is this done (maybe as an option) in svd or in La.svd? could this resetting have a material effect in the solutions found? thank you J -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: 27 July 2004 10:13 To: Molins, Jordi Cc: '[EMAIL PROTECTED]' Subject: Re: [R] SVD with positivity constraints If A is not square, which dimension is larger? There will most likely be either no solution or an infinity of solutions. If the latter, I think you are using the Moore-Penrose inverse (depends exactly how you use the SVD), that is the shortest solution, but the SVD will give you the whole space of solutions and you could compute if that intersects the positive orthant. On Tue, 27 Jul 2004, Molins, Jordi wrote: I have a matrix equation, Ax=b, that I need to solve for x. x should be a vector of positive numbers (between 0 and 1). A is not a square matrix in general. This lead me to using the SVD. However, using the SVD gives me positive and negative numbers, as well. I have some constraints included in the A matrix itself (i.e., that the sum of some xi should be equal to 1) but I do not know how to include the constraint that each xi should be non-negative. Is there in R (or somewhere else) an SVD that includes this kind of constraint? or some other optimizer that can cope with solving non-square matrix equations, including the positivity constraint? optim(method=L-BFGS-B) can cope with [0, 1] constraints. -- 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 The information contained herein is confidential and is inte...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] library manual: documentation of funcs not alphabetically ordered
On Tue, 27 Jul 2004, Robin Hankin wrote: Hello everybody I'm putting finishing touches to a library, package? and have noticed that the .dvi file that R CMD check creates does not sort the functions in alphabetical order. It is not designed to, merely to check that the files can be processed. Use R CMD Rd2dvi to produce a manual: that sorts the man/*.Rd files in the ASCII collate order (which may or may not be the same order as the function names). I find this odd because I used the tidy routines in section 3.1 of the R-exts manual, which produce R code in which the functions are alphabetically ordered (and I performed R CMD check using the tidied-and-profiled R code). My other library manuals are in alphabetical order. The R and man directories are unrelated. How do I get a dvi manual with functions in alphabetical order? What have I forgotten to do? -- 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 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Read SPSS data (*.sav) in R 1.8.0 (ok) and R1.9.1(error)
I have had the same problem (or at least get the same error msg) using the spss.get() function from Hmisc using R1.9.1 to read an SPSS file. I think read.spss() from foreign package still works though. Have not tried spss.get() with any other version of R. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Thomas Lumley Sent: Monday, July 26, 2004 7:29 AM To: Karl Knoblick Cc: [EMAIL PROTECTED] Subject: Re: [R] Read SPSS data (*.sav) in R 1.8.0 (ok) and R1.9.1(error) On Mon, 26 Jul 2004, [iso-8859-1] Karl Knoblick wrote: Hallo! I read SPSS data in the following way: library(Hmisc) library(foreign) dat-spss.get(surv_abb.sav) In R1.9.1 I got the message: Error in all(arg == choices) : Object typeDate not found In R1.8.0 the same script works fine. Does anybody know a possibilty to read a SPSS file under R1.9.1? YOu should just be able to use read.spss in the foreign package. -thomas __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] list problem
Hi all, I have the folowing frame(there are more columns than shown), 1 2 34 5 Year Total TusWhi Norw 1994 1.00 1830 0 355 1995 1.00 0 00 1995 1.00 0 00 1995 1.00 49104280 695 1997 1.00 0 0 110 1997 0.58 0 00 1997 1.00 0 00 1994 1.00 0 00 1997 1.00 0 40 70 1998 1.00 0 0 1252 1999 1.04 0 740 1999 1.00 0 00 1999 1.02 0 00 1999 1.00 0 00 1999 1.00 0 0 171 1999 1.00 1794 0 229 1999 1.00 035250 1997 1.00 13351185 147 1997 1.00 49251057 4801 1997 1.00 06275 1773 I try to get sum(Total) by Year in which Tus0, sum(Total) by Year in which Whi0,,,and so on. I have done something like this; a-as.list(numeric(3)) for (i in 3:5) { a[[i]]-aggregate(frame[,Total],list(Year=frame$Year, Tus=frame$i0),sum) } The result is something like; Year Tus x 1994 FALSE 49.69 1995 FALSE 49.35 1996 FALSE 56.95 1997 FALSE 57.00 1998 FALSE 57.00 1999 FALSE 58.09 2000 FALSE 56.97 2001 FALSE 57.95 2002 FALSE 57.10 2003 FALSE 56.16 2000 TRUE 1.00 2002 TRUE 1.00 2003 TRUE 2.01 But when I try indexing frame[Tus==TRUE,]I just don't get it Thank you Luis Ridao Cruz Fiskirannsóknarstovan Nóatún 1 P.O. Box 3051 FR-110 Tórshavn Faroe Islands Phone: +298 353900 Phone(direct): +298 353912 Mobile: +298 580800 Fax: +298 353901 E-mail: [EMAIL PROTECTED] Web:www.frs.fo __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Luis Ridao Cruz Fiskirannsóknarstovan Nóatún 1 P.O. Box 3051 FR-110 Tórshavn Faroe Islands Phone: +298 353900 Phone(direct): +298 353912 Mobile: +298 580800 Fax: +298 353901 E-mail: [EMAIL PROTECTED] Web:www.frs.fo __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] test for difference between non-independent correlations
Hello, I am wondering whether there is a way to test whether two non-independent correlation coefficients are significantly different, in R? I have an experimentally measure variable Y, and two different variables X1, and X2, which are predictions of Y that were predicted using two different computational models. I would like to see whether the correlation of Y and X1, and Y and X2 is significantly different. Since Y appears in both correlations the correlation coefficients will be non-independent. (so you cannot use a Z test like you would for comparing independent correlation coefficients, I think). I have read that there is a test for comparing non-independent correlation coefficients, by EJ Williams (1959) and Steiger. There is also a test called Hotelling's t test. I'm wondering does anyone know whether I can somehow carry out any of these using an R package, or compare non-independent correlations using R by some other method? I will greatly appreciate any help, thankyou, Avril Coghlan (University College Dublin, Ireland) __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] test for difference between non-independent correlations
On 07/27/04 13:35, Avril Coghlan wrote: Hello, I am wondering whether there is a way to test whether two non-independent correlation coefficients are significantly different, in R? About 20 years ago I asked the same question (without the R), found Steiger's paper (below) and wrote this BASIC program to do it. (If you try to type it in each time you're bound to make a mistake. This has been checked repeatedly.) It is trivial to write this as an R script, of course. I and my colleagues have been using this for about 20 years, and it seems to be OK as judged by comparing it to the jackknife. (Remember, when we did this, the bootstrap was a newfangled idea that we didn't quite trust.) My hunch is that something better has come along, and I'd be interested to see how others respond. Hence I haven't bothered to translate this into R. Or maybe everyone who has this problem just uses the bootstrap now. That is certainly easy enough. (I will eventually add this to our Notes on R for psychology..., since it is a very common problem in psychology research.) 10 print looks for difference between r12 and r13, given r23 12 print (input r121 to quit) 20 input r12 ; r12 22 if r121 then end 30 input r13 ; r13 40 input r23 ; r23 50 input N ; n 52 let rd=1-r12*r12-r13*r13-r23*r23+2*r12*r13*r23 54 let rb=(r12+r13)/2 56 let cube=(1-r23)*(1-r23)*(1-r23) 60 let t2=(r12-r13)*sqrt((n-1)*(1+r23)/(2*rd*(n-1)/(n-3)+rb*rb*cube)) 70 print t (;n-3;) = ;t2 80 print Steiger, J.H. (1980). Tests for comparing elements of a 82 print correlation matrix. Psychological Bulletin, 87, 245-251. 100 goto 12 -- Jonathan Baron, Professor of Psychology, University of Pennsylvania Home page: http://www.sas.upenn.edu/~baron R search page: http://finzi.psych.upenn.edu/ __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] list problem
Hi Luis, maybe there are better ways but you could try something like this, n - length(frame) lapply(split(frame, frame$Year), function(x, n.){ res - numeric(n.-2) for(i in 3:n.) res[i-2] - sum(x$Total[x[,i]0.]) res }, n.=n) I hope this helps. Best, Dimitris Dimitris Rizopoulos Doctoral Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/396887 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm - Original Message - From: Luis Rideau Cruz [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 27, 2004 2:22 PM Subject: [R] list problem Hi all, I have the folowing frame(there are more columns than shown), 1 2 34 5 Year Total TusWhi Norw 1994 1.00 1830 0 355 1995 1.00 0 00 1995 1.00 0 00 1995 1.00 49104280 695 1997 1.00 0 0 110 1997 0.58 0 00 1997 1.00 0 00 1994 1.00 0 00 1997 1.00 0 40 70 1998 1.00 0 0 1252 1999 1.04 0 740 1999 1.00 0 00 1999 1.02 0 00 1999 1.00 0 00 1999 1.00 0 0 171 1999 1.00 1794 0 229 1999 1.00 035250 1997 1.00 13351185 147 1997 1.00 49251057 4801 1997 1.00 06275 1773 I try to get sum(Total) by Year in which Tus0, sum(Total) by Year in which Whi0,,,and so on. I have done something like this; a-as.list(numeric(3)) for (i in 3:5) { a[[i]]-aggregate(frame[,Total],list(Year=frame$Year, Tus=frame$i0),sum) } The result is something like; Year Tus x 1994 FALSE 49.69 1995 FALSE 49.35 1996 FALSE 56.95 1997 FALSE 57.00 1998 FALSE 57.00 1999 FALSE 58.09 2000 FALSE 56.97 2001 FALSE 57.95 2002 FALSE 57.10 2003 FALSE 56.16 2000 TRUE 1.00 2002 TRUE 1.00 2003 TRUE 2.01 But when I try indexing frame[Tus==TRUE,]I just don't get it Thank you Luis Ridao Cruz Fiskirannsóknarstovan Nóatún 1 P.O. Box 3051 FR-110 Tórshavn Faroe Islands Phone: +298 353900 Phone(direct): +298 353912 Mobile: +298 580800 Fax: +298 353901 E-mail: [EMAIL PROTECTED] Web:www.frs.fo __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Luis Ridao Cruz Fiskirannsóknarstovan Nóatún 1 P.O. Box 3051 FR-110 Tórshavn Faroe Islands Phone: +298 353900 Phone(direct): +298 353912 Mobile: +298 580800 Fax: +298 353901 E-mail: [EMAIL PROTECTED] Web:www.frs.fo __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] lattice / pdf bug ?
On Mon, Jul 26, 2004 at 06:50:13PM -0500, Deepayan Sarkar wrote: On Monday 26 July 2004 18:17, Dirk Eddelbuettel wrote: I've been scrathing my head over this one. Suppose I have a data.frame which maps to a 'n x k' lattice, and that one of those cells is empty. An artificial example is generated by Q-data.frame(x1=sample(c(A,B),10,replace=TRUE), x2=c(C, rep(D,9)), y=rnorm(10)) where by having only one obs. for the first level of the second factor x2, we ensure that there won't be full combinations of x1 and x2. The empty cell is not the issue, rather it's the fact that the panel that gets the first observation (x2 = C) has only that one single observation. So for that panel, sd(x, na.rm = TRUE) = NA, hence dnorm(mesh points, mean = whatever, sd = NA) eventually produces a bunch of NA's, which grid.lines tries to draw. grid.lines has known issues with NA's, and I would guess that's what causes the broken pdf. The good news is that there doesn't seem to be any problems in r-devel (possibly because grid handles NA's better now). The natural workaround for your code would be to skip the panel.mathdensity call unless length(x) 1. Confirmed -- that does the trick for 'plain' R 1.9.1 as well. Thanks a lot for this, I had obviously focussed on the wrong aspect (the 'empty' cell rather than the one with just one element). Dirk Deepayan This seems to trip panel.mathdensity(), but only when printing to pdf, and I can't find a way to avoid it. Consider stopifnot(require(lattice)) stopifnot(require(grid)) pdf(testfile.pdf) Q-data.frame(x1=sample(c(A,B),10,replace=TRUE), x2=c(C, rep(D,9)), y=rnorm(10)) print(histogram(~ y | x1+x2, data=Q, panel = function(x, ...) { if (length(x) 0) { panel.histogram(x, ...) panel.mathdensity(dmath = dnorm, col = black, args = list(mean=mean(x, na.rm=TRUE), sd=sd(x, na.rm=TRUE))) } })) dev.off() where the resulting pdf file is broken if and only if the panel.mathdensity call is present. Without it, it works. To the screen, it works with and without -- but copying to pdf again breaks the pdf file if panel.mathdensity is used. It is possible that I am overlooking something simple -- or is it a genuine bug? Platform is win2k, R version is 1.9.1. Thanks for any pointers, Dirk -- Those are my principles, and if you don't like them... well, I have others. -- Groucho Marx __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] X11 device problem on linux: 100% cpu usage
--- Barry Rowlingson [EMAIL PROTECTED] wrote: David Whiting wrote: I'm using R 1.9.1 (patched, 5th July) on linux (Mandrake 9.2) and am having a problem with the X11() device. Trying to plot(1:10) results in my CPU going to 100% I'm not sure where to start with identifying the cause. Can someone suggest some things that I should look at? First off, you can try and figure out if its the client (R) or the server (your X-windows display server). [...] Thanks Barry. I don't have another machine I can play with at the moment, so I dug out an old R-1.8.1 rpm and installed that: same problem. I then tried a different window manager and the problem disappeared. So somehow fluxbox (my usual window manager) sees to be having a proble with R (everything else seems to run okay in fluxbox). For now I'll just use a different window manager until I have time to investigate this further. Thanks again. Dave __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Help R - SNOW package...correct indexation syntax??
Hello! I am trying to apply estimators at various data lengths (data is resident on diferent nodes of a beowulf cluster) in order to save computation time. On one side, suppose that: x - clusterCall(cl,runif,10) (i.e. 100,000 random numbers on each node) then the first say 100 numbers of node say #3 are returned by x.3.100 - x[[3]][1:100] On the other side, if one wanted to compute the average of each series individually, one could use: x.averages - parSapply(cl,x,mean) But what if one wanted to to compute the average of only the first 100 data points resident on each node? What would be the approriate syntax? Is the only (and fastest) solution to write a loop of the type: for (j in numbernodes){x.avearges.100 - mean(x[[j]][1:100]} Or is there a more efficient par_apply method? I've been trying and trying to find a better way unfortunately to no avail. Thanks in advance for your time and help, Renaud Piccinini University of Nebraska-Lincoln Vous manquez despace pour stocker vos mails ? __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] covariate selection in cox model (counting process)
On Tue, 27 Jul 2004, Mayeul KAUFFMANN wrote: Thank you a lot for your time and your answer, Thomas. Like all good answers, it raised new questions for me ;-) In the case of recurrent events coxph() is not using maximum likelihood or even maximum partial likelihood. It is maximising the quantity that (roughly speaking) would be the partial likelihood if the covariates explained all the cluster differences. I could have non repeating events by removing countries once they have experienced a war. But I'm not sure it will change the estimation procedure since this will change the dataset only, not the formula coxph(Surv(start,stop,status)~x1+x2+...+cluster(id),robust=T) I am not sure I understood you well: do you really mean recurrent events alone or any counting process notation (including allowing for recurrent events). No, I mean recurrent events. With counting process notation but no recurrent revents the partial likelihood is still valid, and the approach of treating it as a real likelihood for AIC (and presumably BIC) makes sense. Roughly speaking, you can't tell there is dependence until you see multiple events. I thought the counting process notation did not differ really from the Cox model in R, since Terry M. Therneau (A Package for Survival Analysis in S, April 22, 1996) concludes his mathematical section 3.3 Cox Model by The above notation is derived from the counting process representation [...] It allows very naturally for several extensions to the original Cox model formulation: multiple events per subject, discontinuous intervals of risk [...],left truncation. (I used it to introduce 1. time-dependent covariates, some covariates changing yearly, other irregularly, and 2. left truncation: not all countries existed at the beginning of the study) In the case of recurrent events coxph() is not using maximum likelihood or even maximum partial likelihood. Then, what does fit$loglik give in this case? Still a likelihood or a valid criterion to maximise ? If not, how to get (manually) the criterion that was maximsed? fit$loglik gives the criterion that was maximised. This is the function of the data that *would be* the partial likelihood if there was no within-country dependence. This is a convenient criterion function because it is easy to maximise, and it is known to give valid (and reasonably efficient) estimates for what you might call a proportional rates model in the case of recurrent events. However, it no longer has the same claim to be a real likelihood that the Cox partial likelihood does, because it is not modelling the dependence. That's of interest for me since I created artificial covariates measuring the proximity since some events: exp(-days.since.event/a.chosen.parameter). ...and I used fit$loglik to chose a.chosen.parameter from 8 values, for 3 types of events: That's fine -- within a single model maximising the criterion function is valid. The problem is that you can not assume either that differences between nested models have a chisquared distribution nor that the expected change in loglik is the same as the number of parameters. This means that you don't have any absolute scale for choosing penalties, which is a problem in model selection -- it is hard to balance the increase in fit$loglik with the increase in model complexity. In principle you could use cross-validation to estimate the cost-complexity tradeoff in these models, but this requires the ability to compute the criterion function on a subset not included in the model, which is not entirely straightforward. -thomas Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] computing differences between consecutive vector elements
Dear R-users, I am a newbie to R so please excuse this naive question for which I couldn't seem to find online answers. I have this data frame containing a series of locations through time (x,y,z,t). I would like to compute the difference in x, y and z between t-1 and t. Sounds easy enough, but how on earth does one loop through vector elements and compute this difference? Thanks Thomas *** Le contenu de cet e-mail et de ses pièces jointes est destiné à l'usage exclusif du (des) destinataire(s) expressément désigné(s) comme tel(s). En cas de réception de cet e-mail par erreur, le signaler à son expéditeur et ne pas en divulguer le contenu. L'absence de virus a été vérifié à l'émission du message. Il convient néanmoins de vérifier l'absence de corruption à sa réception. The contents of this email and any attachments are confidential. They are intended for the named recipient(s) only. If you have received this email in error please notify the system manager or the sender immediately and do not disclose the contents to anyone or make copies. eSafe scanned this email for viruses, vandals and malicious content. *** __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] computing differences between consecutive vector elements
Not exactly sure what you want, but seems like you can sort the data frame by `t', then do diff() on the x, y, and z columns. Andy From: Dewez Thomas Dear R-users, I am a newbie to R so please excuse this naive question for which I couldn't seem to find online answers. I have this data frame containing a series of locations through time (x,y,z,t). I would like to compute the difference in x, y and z between t-1 and t. Sounds easy enough, but how on earth does one loop through vector elements and compute this difference? Thanks Thomas *** Le contenu de cet e-mail et de ses pièces jointes est destiné à l'usage exclusif du (des) destinataire(s) expressément désigné(s) comme tel(s). En cas de réception de cet e-mail par erreur, le signaler à son expéditeur et ne pas en divulguer le contenu. L'absence de virus a été vérifié à l'émission du message. Il convient néanmoins de vérifier l'absence de corruption à sa réception. The contents of this email and any attachments are confidential. They are intended for the named recipient(s) only. If you have received this email in error please notify the system manager or the sender immediately and do not disclose the contents to anyone or make copies. eSafe scanned this email for viruses, vandals and malicious content. *** __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] computing differences between consecutive vectorelements
well, sure diff() does it thanks alot Thomas -Message d'origine- De: Liaw, Andy [mailto:[EMAIL PROTECTED] Date: mardi 27 juillet 2004 16:50 À: 'Dewez Thomas'; '[EMAIL PROTECTED]' Objet: RE: [R] computing differences between consecutive vectorelements Not exactly sure what you want, but seems like you can sort the data frame by `t', then do diff() on the x, y, and z columns. Andy From: Dewez Thomas Dear R-users, I am a newbie to R so please excuse this naive question for which I couldn't seem to find online answers. I have this data frame containing a series of locations through time (x,y,z,t). I would like to compute the difference in x, y and z between t-1 and t. Sounds easy enough, but how on earth does one loop through vector elements and compute this difference? Thanks Thomas *** Le contenu de cet e-mail et de ses pièces jointes est destiné à l'usage exclusif du (des) destinataire(s) expressément désigné(s) comme tel(s). En cas de réception de cet e-mail par erreur, le signaler à son expéditeur et ne pas en divulguer le contenu. L'absence de virus a été vérifié à l'émission du message. Il convient néanmoins de vérifier l'absence de corruption à sa réception. The contents of this email and any attachments are confidential. They are intended for the named recipient(s) only. If you have received this email in error please notify the system manager or the sender immediately and do not disclose the contents to anyone or make copies. eSafe scanned this email for viruses, vandals and malicious content. *** __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Notice: This e-mail message, together with any attachments, contains information of Merck Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp Dohme or MSD and in Japan, as Banyu) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system. -- *** Le contenu de cet e-mail et de ses pièces jointes est destiné à l'usage exclusif du (des) destinataire(s) expressément désigné(s) comme tel(s). En cas de réception de cet e-mail par erreur, le signaler à son expéditeur et ne pas en divulguer le contenu. L'absence de virus a été vérifié à l'émission du message. Il convient néanmoins de vérifier l'absence de corruption à sa réception. The contents of this email and any attachments are confidential. They are intended for the named recipient(s) only. If you have received this email in error please notify the system manager or the sender immediately and do not disclose the contents to anyone or make copies. eSafe scanned this email for viruses, vandals and malicious content. *** __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] list problem
This is also the sort of thing tapply() does well: (note that by() and aggregate() are just fancy wrappers for tapply). e.g. tus-tapply(yourframe$Total,list(yourframe$Year,yourframe$Tus0),sum) (One could nest this within an lapply() to loop over the different columns of your frame). Note that the vectors in the list are silently cast to factors for tapply. -- Bert Gunter Non-Clinical Biostatistics Genentech MS: 240B Phone: 650-467-7374 The business of the statistician is to catalyze the scientific learning process. -- George E.P. Box Dimitris Rizopoulos wrote: Hi Luis, maybe there are better ways but you could try something like this, n - length(frame) lapply(split(frame, frame$Year), function(x, n.){ res - numeric(n.-2) for(i in 3:n.) res[i-2] - sum(x$Total[x[,i]0.]) res }, n.=n) I hope this helps. Best, Dimitris Dimitris Rizopoulos Doctoral Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/396887 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm - Original Message - From: Luis Rideau Cruz [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 27, 2004 2:22 PM Subject: [R] list problem Hi all, I have the folowing frame(there are more columns than shown), 1 2 34 5 Year Total TusWhi Norw 1994 1.00 1830 0 355 1995 1.00 0 00 1995 1.00 0 00 1995 1.00 49104280 695 1997 1.00 0 0 110 1997 0.58 0 00 1997 1.00 0 00 1994 1.00 0 00 1997 1.00 0 40 70 1998 1.00 0 0 1252 1999 1.04 0 740 1999 1.00 0 00 1999 1.02 0 00 1999 1.00 0 00 1999 1.00 0 0 171 1999 1.00 1794 0 229 1999 1.00 035250 1997 1.00 13351185 147 1997 1.00 49251057 4801 1997 1.00 06275 1773 I try to get sum(Total) by Year in which Tus0, sum(Total) by Year in which Whi0,,,and so on. I have done something like this; a-as.list(numeric(3)) for (i in 3:5) { a[[i]]-aggregate(frame[,Total],list(Year=frame$Year, Tus=frame$i0),sum) } The result is something like; Year Tus x 1994 FALSE 49.69 1995 FALSE 49.35 1996 FALSE 56.95 1997 FALSE 57.00 1998 FALSE 57.00 1999 FALSE 58.09 2000 FALSE 56.97 2001 FALSE 57.95 2002 FALSE 57.10 2003 FALSE 56.16 2000 TRUE 1.00 2002 TRUE 1.00 2003 TRUE 2.01 But when I try indexing frame[Tus==TRUE,]I just don't get it Thank you Luis Ridao Cruz Fiskirannsóknarstovan Nóatún 1 P.O. Box 3051 FR-110 Tórshavn Faroe Islands Phone: +298 353900 Phone(direct): +298 353912 Mobile: +298 580800 Fax: +298 353901 E-mail: [EMAIL PROTECTED] Web:www.frs.fo __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Luis Ridao Cruz Fiskirannsóknarstovan Nóatún 1 P.O. Box 3051 FR-110 Tórshavn Faroe Islands Phone: +298 353900 Phone(direct): +298 353912 Mobile: +298 580800 Fax: +298 353901 E-mail: [EMAIL PROTECTED] Web:www.frs.fo __ [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Underline in expression().
John Janmaat wrote: Hello All, Is there an analogue to \underbar or the AMS math \underline in graphical math expressions? Thanks, John. Uwe Ligges posted a solution a couple of years ago. I don't know if there is anything built in yet. ?plotmath does not seem to say anything about underlining. http://finzi.psych.upenn.edu/R/Rhelp01/archive/7191.html plot(0:1, 0:1, type=n) underlined(0.5, 0.5, expression(widehat(x %*% y))) --sundar __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] lattice.device in loop
Hi, I am having problems creating a pdf file of a lattice graph. Things work fine for a single image, but I am having trouble using the commands in a loop. To illustrate by example This works with both ps and pdf files. dat = list(x= 1:10, y = 1:10) trellis.device(postscript, file = /d1/pocernic/test.ps) xyplot(y~x, data = dat) dev.off() This does not. It produces a very small, non working output file. for(i in 1:1){ trellis.device(postscript, file = /d1/pocernic/test.ps) xyplot(y~x, data = dat) dev.off() } Really, I would like something like this to produce a large, appended file made from different large datasets. This doesn't work either. trellis.device(postscript, file = /d1/pocernic/test.ps, onefile = TRUE) for(i in 1:5){ xyplot(y~x, data = dat) } dev.off() Any thoughts would be welcomed. Matt Pocernich NCAR - Research Applications Program 303-497-8312 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] lattice.device in loop
Matt Pocernich wrote: Hi, I am having problems creating a pdf file of a lattice graph. Things work fine for a single image, but I am having trouble using the commands in a loop. To illustrate by example This works with both ps and pdf files. dat = list(x= 1:10, y = 1:10) trellis.device(postscript, file = /d1/pocernic/test.ps) xyplot(y~x, data = dat) dev.off() This does not. It produces a very small, non working output file. for(i in 1:1){ trellis.device(postscript, file = /d1/pocernic/test.ps) xyplot(y~x, data = dat) dev.off() } Really, I would like something like this to produce a large, appended file made from different large datasets. This doesn't work either. trellis.device(postscript, file = /d1/pocernic/test.ps, onefile = TRUE) for(i in 1:5){ xyplot(y~x, data = dat) } dev.off() Any thoughts would be welcomed. Matt Pocernich NCAR - Research Applications Program 303-497-8312 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html This is a FAQ 7.24. http://cran.r-project.org/doc/FAQ/R-FAQ.htm --sundar __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] computing differences between consecutive vector elements
Dewez Thomas wrote: Dear R-users, I am a newbie to R so please excuse this naive question for which I couldn't seem to find online answers. I have this data frame containing a series of locations through time (x,y,z,t). I would like to compute the difference in x, y and z between t-1 and t. Sounds easy enough, but how on earth does one loop through vector elements and compute this difference? See ?diff Hence for a data frame X: lapply(X, diff) Uwe Ligges Thanks Thomas *** Le contenu de cet e-mail et de ses pièces jointes est destiné à l'usage exclusif du (des) destinataire(s) expressément désigné(s) comme tel(s). En cas de réception de cet e-mail par erreur, le signaler à son expéditeur et ne pas en divulguer le contenu. L'absence de virus a été vérifié à l'émission du message. Il convient néanmoins de vérifier l'absence de corruption à sa réception. The contents of this email and any attachments are confidential. They are intended for the named recipient(s) only. If you have received this email in error please notify the system manager or the sender immediately and do not disclose the contents to anyone or make copies. eSafe scanned this email for viruses, vandals and malicious content. *** __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Integration with adapt
Hi all, I need to calculate a multidimensional integration on R. I am using the command adapt (from library adapt), although sometimes I get the following error message: Ifail=2, lenwrk was too small. -- fix adapt() ! Check the returned relerr! in: adapt(3, linf, lsup, functn = Integrando1) I guess it happens because the domain of integration is too small, although I tried a change of variables to avoid this problem and it didnt help. The command adapt calls a fortran routine, but I dont know fortran enough to fix the problem. Can someone help me? Thanks a lot Rodrigo Drummond Rodrigo D. Drummond Laboratorio Genoma Funcional Centro de Biologia Molecular e Eng. Genetica Universidade Estadual de Campinas Caixa Postal 6010 13083-875 - Campinas - SP - Brasil Tel: xx-19-3788-1119 Fax: xx-19-3788-1089 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] ghyper package
Hello I am searching ghyper package (generalized hypergeometric distributions). Does anyone can send it to me? Regards from Mexico Lizbeth Román [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] ghyper package
It is in SuppDists. Román Padilla Lizbeth wrote: Hello I am searching ghyper package (generalized hypergeometric distributions). Does anyone can send it to me? Regards from Mexico Lizbeth Román [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Bob Wheeler --- http://www.bobwheeler.com/ ECHIP, Inc. --- Randomness comes in bunches. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] ghyper package
On Tue, 2004-07-27 at 13:54, Romn Padilla Lizbeth wrote: Hello I am searching ghyper package (generalized hypergeometric distributions). Does anyone can send it to me? Regards from Mexico Lizbeth Romn You will find that _function_ in Bob Wheeler's SuppDists package on CRAN: http://cran.us.r-project.org/src/contrib/Descriptions/SuppDists.html So use: install.packages(SuppDists) library(SuppDists) ?ghyper HTH, Marc Schwartz __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] ghyper package
Román Padilla Lizbeth wrote: Hello I am searching ghyper package (generalized hypergeometric distributions). Does anyone can send it to me? Regards from Mexico Lizbeth Román [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Try install.packages(SuppDists). --sundar P.S. You could have discovered this yourself searching CRAN for ghyper, which is what I did. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] BIC vz SBIC vz SIC
2) question: alwasy on BIC, from stepAIC() function help page I found a k=log(n) argument to add. Since that produce an error, is there a way to found the n dinamically? stepAIC(mydata.logistic, trace = F, k=log(nrow(mydata))) -- Daniele Medri (It was 3 weeks ago but I was just myself faced to the same question) Just a little warning, it is not really dynamically done: stepAIC takes the part of mydata that was used to fit mydata.logistic but k=log(nrow(mydata)) will still use the entire set. thus, if there were some missing data in mydata, I suggest you use something like: k=log(sum(complete.cases(mydata))) which will be smaller than k=log(nrow(mydata)). If some data are missing only for a covariate and this one is withdrawn, you will have a warning and it will stop: Error in stepAIC(mydata.logistic (etc.) number of rows in use has changed: remove missing values? Since (I presume) these criteria need to compare two models with identical dataset. In any other case, if you have NAs at the start but the number of NAs does not change in the process, you won't be warned if you use k=log(nrow(mydata)). Mayeul KAUFFMANN Univ. Pierre Mendes France Grenoble - France __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Reading and treating multiple files....
I will get - in a few days- a set of separate files(one for each records~80'000 files pro year) named key.txt in which other info (measurements of pressure and velocity at each second ) is stocked; typically each one of this separate files will hold something between 200 and 1500 recordsI'm supposed to do statistical analysis on this dataset, on the yearly information Well, as you can suspect my problem is thus: - batch processing of these individual files :reading each file (automatically!), I suggest you put all files in a single directory, then you use list.files () or dir() to make a list of this files. myfiles - list.files (c:\\mydir) #on windows Then you do a loop over these files with read.table() You can create a column named file with the name of the file. All of this can be done with: data - NULL;for (i in dir(c:\\temp)) data - rbind(data,cbind(file=i,read.table( paste(c:\\mydir\\,i,sep= Hope that helps Mayeul KAUFFMANN Univ. Pierre Mendes France Grenoble - France __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] interpreting profiling output
On Tue, Jul 27, 2004 at 09:12:56AM +0200, Peter Dalgaard wrote: [What did ess-help have to do with this?? Snipped from CC:] This happens when posting in a hurry using a new mail client. Sorry. See below btw. Kasper Daniel Hansen [EMAIL PROTECTED] writes: Thanks to both of you for considering my question. I still have some problems however. Consider the nnet.default function which uses the .C interface. As typeof(.C) [1] builtin I would guess - from my current understanding - that the time spent in the C functions of nn.default are added to its self.time. Now look at the output prof02.out$by.self[1:10,] self.time self.pct total.time total.pct nnet.default 33.32 11.22186.48 92.1 So nnet.default only used 33.3 on its C calls, but 2186 in total time. From this I would guess that nnet.default - in my case - spends its majority of time setting up the fit and postprocessing it (as this is done by R functions which does not add to its self time). The actual fit (which is done by the C functions) only takes very little time. Looking further down the table I see self.time self.pct total.time total.pct as.integer22.28 7.5 30.92 1.3 as.interger is basically a .Internal call - which ought not to be recorded. But why does it then have such a high self.time? And finally, if a program (such as mine) have a high discrepancy between self.time and sampling.time, does this imply that the far majority of time is spent in .Primitives which are of type special? Hmm... You're using summaryRprof(), obviously. Do the results match up with what you get from R CMD Rprof? Looking at the source for summaryRprof, I see that it uses this construction selft - sapply(ls(envir = self), function(f) get(f, envir = self)) which I suspect does not count function names that start with a dot... It does not. Runnig everything through R CMD Rprof gives a much moe sensible output. I have no further questions. Do I file a bug report on summaryRprof - it is certainly unintentional that it does not compute eg. .C calls when computing the self time? -- Kasper Daniel Hansen, Research Assistant Department of Biostatistics, University of Copenhagen __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] interpreting profiling output
From: Kasper Daniel Hansen On Tue, Jul 27, 2004 at 09:12:56AM +0200, Peter Dalgaard wrote: Hmm... You're using summaryRprof(), obviously. Do the results match up with what you get from R CMD Rprof? Looking at the source for summaryRprof, I see that it uses this construction selft - sapply(ls(envir = self), function(f) get(f, envir = self)) which I suspect does not count function names that start with a dot... It does not. Runnig everything through R CMD Rprof gives a much moe sensible output. I have no further questions. Do I file a bug report on summaryRprof - it is certainly unintentional that it does not compute eg. .C calls when computing the self time? I thought I did see .C in the output of summaryRprof() at one time... Andy -- Kasper Daniel Hansen, Research Assistant Department of Biostatistics, University of Copenhagen __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Re: R-help Digest, Vol 17, Issue 25
hello, I'm trying to use R to take an image matrix and paint it into a tcltk canvas. I'm using R-1.9.0 within ess-5.2.0 on a linux machine running the 2.4.30-31.9smp kernel. I'm using the ActiveTcl8.4.6.1-linux-ix86 tcltk libraries. When I run the following comands, however, I get an R segmentation fault: ~~ library(tcltk) addTclPath(/usr/local/ActiveTcl/lib) tclRequire(Img) Tcl 1.3 tkcmd(image,create,photo,tclVar(),file=/path/to/file.jpg) Process R segmentation fault at Tue Jul 27 18:18:40 2004 ~~ I've run this as root, and I get the same segmentation fault, So I don't think this is a permissions problem. Should I somehow be initializing tclVar()? Can anyone point me to the right way to run this piece of code so that I don't get the segmentation fault? Thanks in advance. --Ross Ross Henderson National Inst. of Mental Health Computer Scientist National Institutes of Health Laboratory of Neuropsychology Bldg. 49, Room 1B-80 Neural Coding and ComputationBethesda, MD USA 20892 tel: 301-496-5625 ext. 251 http://neuron.nimh.nih.gov __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] DESCRIPTION.in
Hello R world! I'm building a bundle of four packages, but I don't always want to build the whole bundle. Usually I just want to tweak one function in one of the packages and rebuild just that package. As such, I have DESCRIPTION and DESCRIPTION.in files sitting in all the package folders. Unfortunately, there's a pesky line in R CMD build that hacks away DESCRIPTION whenever it sees DESCRIPTION.in. This is okay for building the whole bundle, but it makes it a major pain to build any of the packages individually. I am root, so for now I have commented the offending line in /usr/local/lib/R/bin/build. Is this the proper solution or am I overlooking something? Thanks for any help you can provide, Kevin __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Re: R-help Digest, Vol 17, Issue 25
Ross Henderson [EMAIL PROTECTED] writes: hello, I'm trying to use R to take an image matrix and paint it into a tcltk canvas. I'm using R-1.9.0 within ess-5.2.0 on a linux machine running the 2.4.30-31.9smp kernel. I'm using the ActiveTcl8.4.6.1-linux-ix86 tcltk libraries. When I run the following comands, however, I get an R segmentation fault: ~~ library(tcltk) addTclPath(/usr/local/ActiveTcl/lib) tclRequire(Img) Tcl 1.3 tkcmd(image,create,photo,tclVar(),file=/path/to/file.jpg) Process R segmentation fault at Tue Jul 27 18:18:40 2004 ~~ I've run this as root, and I get the same segmentation fault, So I don't think this is a permissions problem. Should I somehow be initializing tclVar()? Can anyone point me to the right way to run this piece of code so that I don't get the segmentation fault? You should assign tclVar() to something, or you will find it difficult to access its value later on. Wouldn't expect that that could provoke a segfault though. Could you get us a traceback from the debugger (gdb)? Also, will similar code run from wish? (need to rule out that it could be a problem entirely within Tcl). -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] interpreting profiling output
On Tue, Jul 27, 2004 at 06:17:10PM -0400, Liaw, Andy wrote: From: Kasper Daniel Hansen On Tue, Jul 27, 2004 at 09:12:56AM +0200, Peter Dalgaard wrote: Hmm... You're using summaryRprof(), obviously. Do the results match up with what you get from R CMD Rprof? Looking at the source for summaryRprof, I see that it uses this construction selft - sapply(ls(envir = self), function(f) get(f, envir = self)) which I suspect does not count function names that start with a dot... It does not. Runnig everything through R CMD Rprof gives a much moe sensible output. I have no further questions. Do I file a bug report on summaryRprof - it is certainly unintentional that it does not compute eg. .C calls when computing the self time? I thought I did see .C in the output of summaryRprof() at one time... Well, I tried Peter's fix and it solves the problem for me. I have filed a bug report including the fix. Thanks for the help everyone. -- Kasper Daniel Hansen, Research Assistant Department of Biostatistics, University of Copenhagen __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Another big data size problem
Hi all, I'm trying to read a 1220 * 2 table in R but I'm having lot of problems. Basically what it happens is that R.bin starts eating all my memory until it gets about 90%. At that point it locks itself in a uninterruptible sleep status (at least that's what top says) where it just sits there barely using the cpu at all but keeping its tons of memory. I've tried with read.table and scan but none of them did the trick. I've also tried some orrible hack like reading one line a time and gradually combining everything in a matrix using rbind... nope! It seems I can read up to 500 lines in a *decent* time but nothing more. The machine is a 3 GHz P4 with HT and 512 MB RAM running R-1.8.1. Will I have to write a little a C program myself to handle this thing or am I missing something? Thanks in advance for your help, fede __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Best way to store negative indexes
Hi, I'm trying to figure out how to properly construct a graph of frequencies of a difference between 2 values, that is | i | - | j |. I'd like to know the best way to store the actual data because of course doing my_vector[i -j] will not work because the index could be negative. I know there's no hash table so what's the best solution, simplicity-wise ? Use a list of pair of values {index, i - j} ? Or can I somehow use negative index, perhaps using 0array ? Any help would be appreciated :) ATM, I use as.character (i-j) to index my data, but I lose all the processing power of R there after. Sorry If it's written somewhere, but I read a lot of docs about it, searched through the ML archives and didn't manage to find an answer. Please also answer me back at my email address as I am not subscribed to the list. Best regards, --Stephane __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Best way to store negative indexes
Do you mean something like abs( my_vector[i] - my_vector[j] ) See if reading help(subset) helps. On Wed, 2004-07-28 at 01:42, StephaneDemurget wrote: Hi, I'm trying to figure out how to properly construct a graph of frequencies of a difference between 2 values, that is | i | - | j |. I'd like to know the best way to store the actual data because of course doing my_vector[i -j] will not work because the index could be negative. I know there's no hash table so what's the best solution, simplicity-wise ? Use a list of pair of values {index, i - j} ? Or can I somehow use negative index, perhaps using 0array ? Any help would be appreciated :) ATM, I use as.character (i-j) to index my data, but I lose all the processing power of R there after. Sorry If it's written somewhere, but I read a lot of docs about it, searched through the ML archives and didn't manage to find an answer. Please also answer me back at my email address as I am not subscribed to the list. Best regards, --Stephane __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] a question about using nlme
Hi, I am using Splus to run a multiphase mixed-effects model. The quations of the models are as below: gf[ij]=b0[i]+b1[i]*age[ij]+b2[i]*max(0,(age[ij]-tau[i]))^2+e[ij] b0[i]=b00+e[i0] b1[i]=b10+e[i1] b2[i]=b20+e[i2] tau[i]=tau+e[i3] i: 1,2,...,100 subjects j: 1,2,...,6 occasions The main scripts of Splus is: simu1-groupedData(gf~age|id) simu.nlme-nlme(gf~(b0 + b1 * age + b2 * max(0,(age-tau))^2),data=simu1,fixed=list(b0~1,b1~1,b2~1,tau~1), + random=list(b0~1,b1~1,b2~1,tau~1),start=c(b0=4,b1=5.32,b2=-5.29,tau=14.8)) But it seems like that there are some errors in it. Error in .C(mixed_EM,: Singularity in backsolve at level 2, block 1 I think maybe there is something wrong in my scripts, could you help me to find it? Thanks a lot Peggy __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Best way to store negative indexes
Can you give a simple example of what you are trying to do? Would the following help? x - sample(10) diffMat - outer(x, x, -) x [1] 1 10 5 8 9 6 3 2 4 7 diffMat [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,]0 -9 -4 -7 -8 -5 -2 -1 -3-6 [2,]905214786 3 [3,]4 -50 -3 -4 -1231-2 [4,]7 -230 -12564 1 [5,]8 -14103675 2 [6,]5 -41 -2 -30342-1 [7,]2 -7 -2 -5 -6 -301 -1-4 [8,]1 -8 -3 -6 -7 -4 -10 -2-5 [9,]3 -6 -1 -4 -5 -2120-3 [10,]6 -32 -1 -21453 0 diffTab - table(diffMat[lower.tri(diffMat, diag=FALSE)]) diffTab -8 -7 -6 -5 -4 -3 -2 -1 1 2 3 4 5 6 7 8 9 1 2 3 3 3 4 5 4 5 3 3 3 2 1 1 1 1 diffTab - table(abs(diffMat[lower.tri(diffMat, diag=FALSE)])) diffTab 1 2 3 4 5 6 7 8 9 9 8 7 6 5 4 3 2 1 Andy From: StephaneDemurget Hi, I'm trying to figure out how to properly construct a graph of frequencies of a difference between 2 values, that is | i | - | j |. I'd like to know the best way to store the actual data because of course doing my_vector[i -j] will not work because the index could be negative. I know there's no hash table so what's the best solution, simplicity-wise ? Use a list of pair of values {index, i - j} ? Or can I somehow use negative index, perhaps using 0array ? Any help would be appreciated :) ATM, I use as.character (i-j) to index my data, but I lose all the processing power of R there after. Sorry If it's written somewhere, but I read a lot of docs about it, searched through the ML archives and didn't manage to find an answer. Please also answer me back at my email address as I am not subscribed to the list. Best regards, --Stephane __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] covariate selection in cox model (counting process)
No, I mean recurrent events. With counting process notation but no recurrent revents the partial likelihood is still valid, and the approach of treating it as a real likelihood for AIC (and presumably BIC) makes sense. Roughly speaking, you can't tell there is dependence until you see multiple events. Thanks a lot, I got it (well, I hope so)! I've read in several places that events in the Andersen-Gill model must be conditionnaly independent, which is sometimes more precisely written as conditionnaly independent given the covariates or even more precisely: the Andersen-Gill (AG) model assumes that each [individual] has a multi-event counting process with independent increments. The observed increments must be conditionally independent given the history of all observable information up to the event times. (http://www.stat.umu.se/egna/danardono/licdd.pdf) Then, there is still another option. In fact, I already modelled explicitely the influence of past events with a proximity of last event covariate, assuming the dependence on the last event decreases at a constant rate (for instance, the proximity covariate varies from 1 to 0.5 in the first 10 years after an event, then from 0.5 to 0.25 in the next ten years, etc). With a well chosen modelisation of the dependence effect, the events become conditionnaly independent, I do not need a +cluster(id) term, and I can use fit$loglik to make a covariate selection based on BIC, right? Thanks a lot again for your time. Mayeul KAUFFMANN Univ. Pierre Mendes France Grenoble - France PS: I wrongly concluded from the R statement (Note: the likelihood ratio and score tests assume independence of observations within a cluster, the Wald and robust score tests do not). that it meant independence between two consecutive observations (without any event). It made sense to me because when only one covariate changes for a given individual, and with a small change, there is a new observation, with a risk very simlar to the risk for the previous observation. But there is still independence with respect to the question of recurrent event. Maybe the warning should be rewritten saying assume *conditionnal* independence of *events* (given the covariates) __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] a question about using nlme
Lijuan Wang [EMAIL PROTECTED] writes: I am using Splus ... So why post to an R list? best, -tony -- Anthony Rossini Research Associate Professor [EMAIL PROTECTED]http://www.analytics.washington.edu/ Biomedical and Health Informatics University of Washington Biostatistics, SCHARP/HVTN Fred Hutchinson Cancer Research Center UW (Tu/Th/F): 206-616-7630 FAX=206-543-3461 | Voicemail is unreliable FHCRC (M/W): 206-667-7025 FAX=206-667-4812 | use Email CONFIDENTIALITY NOTICE: This e-mail message and any attachme...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] automating sequence of multinomial regressions
Disclaimer first: I only heard about R fairly recently, so I apologize if this is either a simple or impossible request, but R looked like it might be a good framework for this sort of thing... Is it possible to write a script to run stepwise multinomial regressions on many *dependent* variables, and then compare results to a validation data set (e.g., Chow test)? Essentially, automate the process of finding best predictive model using a host of dependent and independent variables. I have a fairly short timeframe to work on this, so if someone is willing to help me in the next couple of days, I would be most appreciative. (And there might even be a hefty sum of cash involved!) Thanks, Daniel __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] automating sequence of multinomial regressions
Daniel spamiam at aroint.org writes: Disclaimer first: I only heard about R fairly recently, so I apologize if this is either a simple or impossible request, but R looked like it might be a good framework for this sort of thing... Is it possible to write a script to run stepwise multinomial regressions on many *dependent* variables, and then compare results to a validation data set (e.g., Chow test)? Essentially, automate the process of finding best predictive model using a host of dependent and independent variables. I have a fairly short timeframe to work on this, so if someone is willing to help me in the next couple of days, I would be most appreciative. (And there might even be a hefty sum of cash involved!) Setting aside the basic overfitting problems, the following does a stepwise regression on each of 10 dependent variables using the first 100 rows of birthwt. For the result of each of these 10 it then calculates the number of correct predictions using the remaining rows. require(nnet) require(MASS) # use birthwt data set and generate random matrix whose 10 cols are dep vars data(birthwt) set.seed(1) dep - matrix(sample(2,189*10,rep=T),189)-1 # run one stepwise procedure for each dep variable using rows 1 to 100 # and store result in z so that z[[i]] has output from ith dep variable z - apply(dep[1:100,], 2, function(d) step(multinom(formula = d ~., data = birthwt[1:100,-1]))) # calculate number of correct predictions for each model using rows 101 to 189 sapply(z,function(x) sum(predict(x, birthwt[101:189,-1]) == birthwt [101:189,1])) __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html