[R] Why do I get a linebreak in the legend?
Dear all, W2k, R2.4.0 I want to place a legend in a regression plot, stating the adjusted R-square value. After some struggle with the coding I am nearly there, but only nearly. The best try so far is: legend(topleft, expression(paste(R[adj]^2), = 0.66)) This places the proper information in the legend, but I get a linebreak before the = 0.66 and I want the expression on one single line. All adjustments from this code I have tried so far either produces only half the expression or produces an error message. All the best and sorry for a trivial quastion /CG -- CG Pettersson, MSci, PhD Stud. Swedish University of Agricultural Sciences (SLU) Dep. of Crop Production Ekology. Box 7043. SE-750 07 Uppsala, Sweden [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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Why do I get a linebreak in the legend?
try the following: x - runif(100, -4, 4) y - 1 + 2 * x + rnorm(100, sd = 2) fit - lm(y ~ x) plot(x, y) abline(fit) legend(topleft, expression(paste(R[adj]^2, = 0.66))) ## or plot(x, y) abline(fit) legend(topleft, legend = substitute(R[adj]^2 == x, list(x = summary(fit)$adj.r.squared))) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: CG Pettersson [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Thursday, November 09, 2006 9:10 AM Subject: [R] Why do I get a linebreak in the legend? Dear all, W2k, R2.4.0 I want to place a legend in a regression plot, stating the adjusted R-square value. After some struggle with the coding I am nearly there, but only nearly. The best try so far is: legend(topleft, expression(paste(R[adj]^2), = 0.66)) This places the proper information in the legend, but I get a linebreak before the = 0.66 and I want the expression on one single line. All adjustments from this code I have tried so far either produces only half the expression or produces an error message. All the best and sorry for a trivial quastion /CG -- CG Pettersson, MSci, PhD Stud. Swedish University of Agricultural Sciences (SLU) Dep. of Crop Production Ekology. Box 7043. SE-750 07 Uppsala, Sweden [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 and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Why do I get a linebreak in the legend?
Hi CG, move one of the parens: legend(topleft, expression(paste(R[adj]^2, = 0.66))) Cheers Andrew On Thu, Nov 09, 2006 at 09:10:49AM +0100, CG Pettersson wrote: Dear all, W2k, R2.4.0 I want to place a legend in a regression plot, stating the adjusted R-square value. After some struggle with the coding I am nearly there, but only nearly. The best try so far is: legend(topleft, expression(paste(R[adj]^2), = 0.66)) This places the proper information in the legend, but I get a linebreak before the = 0.66 and I want the expression on one single line. All adjustments from this code I have tried so far either produces only half the expression or produces an error message. All the best and sorry for a trivial quastion /CG -- CG Pettersson, MSci, PhD Stud. Swedish University of Agricultural Sciences (SLU) Dep. of Crop Production Ekology. Box 7043. SE-750 07 Uppsala, Sweden [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 and provide commented, minimal, self-contained, reproducible code. -- Andrew Robinson Department of Mathematics and StatisticsTel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 http://www.ms.unimelb.edu.au/~andrewpr http://blogs.mbs.edu/fishing-in-the-bay/ __ R-help@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 and provide commented, minimal, self-contained, reproducible code.
[R] Plotting symbols with two positions?
Thanks a lot to Demitris for a prompt answer some minutes ago on another tread (see below). To avoid excess mails on the list, I move onto next question: I have another small plotting problem that confuses me. I want to plot results from a field trial series, using the numbers of the trials as symbols in the plot. pch = as.character(trial_no) works fine, but truncates the trial number to the first digit. As I have sixteen trials in the series I get into problems How do I squeeze in two positions as a symbol in a plot? All the best /CG On Thu, November 9, 2006 9:30 am, Dimitris Rizopoulos said: try the following: x - runif(100, -4, 4) y - 1 + 2 * x + rnorm(100, sd = 2) fit - lm(y ~ x) plot(x, y) abline(fit) legend(topleft, expression(paste(R[adj]^2, = 0.66))) ## or plot(x, y) abline(fit) legend(topleft, legend = substitute(R[adj]^2 == x, list(x = summary(fit)$adj.r.squared))) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: CG Pettersson [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Thursday, November 09, 2006 9:10 AM Subject: [R] Why do I get a linebreak in the legend? Dear all, W2k, R2.4.0 I want to place a legend in a regression plot, stating the adjusted R-square value. After some struggle with the coding I am nearly there, but only nearly. The best try so far is: legend(topleft, expression(paste(R[adj]^2), = 0.66)) This places the proper information in the legend, but I get a linebreak before the = 0.66 and I want the expression on one single line. All adjustments from this code I have tried so far either produces only half the expression or produces an error message. All the best and sorry for a trivial quastion /CG -- CG Pettersson, MSci, PhD Stud. Swedish University of Agricultural Sciences (SLU) Dep. of Crop Production Ekology. Box 7043. SE-750 07 Uppsala, Sweden [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 and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm -- CG Pettersson, MSci, PhD Stud. Swedish University of Agricultural Sciences (SLU) Dep. of Crop Production Ekology. Box 7043. SE-750 07 Uppsala, Sweden [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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plotting symbols with two positions?
try this: y - rnorm(16) plot(y, type = n) text(1:16, y, 1:16) Best, Dimitris - Original Message - From: CG Pettersson [EMAIL PROTECTED] To: Dimitris Rizopoulos [EMAIL PROTECTED] Cc: CG Pettersson [EMAIL PROTECTED]; r-help@stat.math.ethz.ch Sent: Thursday, November 09, 2006 10:09 AM Subject: Plotting symbols with two positions? Thanks a lot to Demitris for a prompt answer some minutes ago on another tread (see below). To avoid excess mails on the list, I move onto next question: I have another small plotting problem that confuses me. I want to plot results from a field trial series, using the numbers of the trials as symbols in the plot. pch = as.character(trial_no) works fine, but truncates the trial number to the first digit. As I have sixteen trials in the series I get into problems How do I squeeze in two positions as a symbol in a plot? All the best /CG On Thu, November 9, 2006 9:30 am, Dimitris Rizopoulos said: try the following: x - runif(100, -4, 4) y - 1 + 2 * x + rnorm(100, sd = 2) fit - lm(y ~ x) plot(x, y) abline(fit) legend(topleft, expression(paste(R[adj]^2, = 0.66))) ## or plot(x, y) abline(fit) legend(topleft, legend = substitute(R[adj]^2 == x, list(x = summary(fit)$adj.r.squared))) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: CG Pettersson [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Thursday, November 09, 2006 9:10 AM Subject: [R] Why do I get a linebreak in the legend? Dear all, W2k, R2.4.0 I want to place a legend in a regression plot, stating the adjusted R-square value. After some struggle with the coding I am nearly there, but only nearly. The best try so far is: legend(topleft, expression(paste(R[adj]^2), = 0.66)) This places the proper information in the legend, but I get a linebreak before the = 0.66 and I want the expression on one single line. All adjustments from this code I have tried so far either produces only half the expression or produces an error message. All the best and sorry for a trivial quastion /CG -- CG Pettersson, MSci, PhD Stud. Swedish University of Agricultural Sciences (SLU) Dep. of Crop Production Ekology. Box 7043. SE-750 07 Uppsala, Sweden [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 and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm -- CG Pettersson, MSci, PhD Stud. Swedish University of Agricultural Sciences (SLU) Dep. of Crop Production Ekology. Box 7043. SE-750 07 Uppsala, Sweden [EMAIL PROTECTED] Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plotting symbols with two positions?
On 09-Nov-06 CG Pettersson wrote: Thanks a lot to Demitris for a prompt answer some minutes ago on another tread (see below). To avoid excess mails on the list, I move onto next question: I have another small plotting problem that confuses me. I want to plot results from a field trial series, using the numbers of the trials as symbols in the plot. pch = as.character(trial_no) works fine, but truncates the trial number to the first digit. As I have sixteen trials in the series I get into problems How do I squeeze in two positions as a symbol in a plot? Probably text() will do what you want, though there may be other functions with more resources for such tasks. Best wishes, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 09-Nov-06 Time: 09:36:46 -- XFMail -- __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] axis command and excel time format
You are using two different x's and one has nothing to do with the other. All of your examples are simply internally inconsistent so there is no reason to think they would work. On 11/9/06, Carmen Meier [EMAIL PROTECTED] wrote: Gabor Grothendieck schrieb: Please provide a complete self contained example. I can't follow the partial code below; however, its likely you are plotting one thing and creating axes using another so there is no reason it should come out right. You are right .. seems to be that it was too late at night ... But I tried the right code and sent the wrong one ... the problem is still there library(zoo) library(chron) time - c(2:25:00,2:26:00,2:27:00,2:28:00,2:29:00,2:30:00,2:31:00, 2:32:00,2:33:00,2:34:00,2:35:00,2:36:00,2:37:00,2:38:00, 2:39:00,2:40:00,2:41:00,2:42:00,2:43:00,2:44:00,2:45:00, 2:46:00,2:47:00,2:48:00,2:49:00,2:50:00,2:51:00,2:52:00, 2:53:00,2:54:00,2:55:00,2:56:00,2:57:00,2:58:00,2:59:00, 3:00:00,3:01:00,3:02:00,3:03:00,3:04:00,3:05:00,3:06:00, 3:07:00,3:08:00,3:09:00,3:10:00,3:11:00,3:12:00,3:13:00, 3:14:00) min_time - min(times(time)) max_time - max(times(time)) duration - max_time-min_time h - hours(duration) # not nessesary here m - minutes(duration) par(cex=1.2,lwd=1) range(x - c(0,m)) #50 minutes range(y - c(0,10)) plot(x,y, type=n,adj=0, asp=0, xlab=, ylab=,axes=FALSE,font.axis=2) #axis(1, 0:m,font=2) # works fine but not with times #-- your suggestion mn - times(min_time) mx - times(max_time) n - 12 x - times(seq(mn, mx, length = n)) x - times(unique(sub(..$, 00, x))) axis(1, x, sub(:00$, , x)) # works only with plot data before #-- axis(2, 0:10,font=2) box() Best regards Carmen __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Meta-regression with lmer() ? If so, how ?
Am 9 Nov 2006 um 8:45 hat Emmanuel Charpentier geschrieben: Date sent: Thu, 09 Nov 2006 08:45:36 +0100 From: Emmanuel Charpentier [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] Meta-regression with lmer() ? If so, how ? Dear List, I am (again) looking at meta-regression as a way to refine meta-analytic results. What I want to do is to assess the impact of some fixed factors on the results of a meta-analysis. Some of them may be crossed with the main factor of the meta-analysis (e. g. clinical presentation of a disease, defining subgroups in each of the studies under analysis), some of them may be a grouping factor amond studies (e. g. study design characteristics). Have a look at MiMa at Wolfgang Viechtbauer's page. Is that what you are looking for? http://www.wvbauer.com/downloads.html Bernd __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plotting symbols with two positions?
Aside from the answers to use text you could use letters instead of numbers which would allow you to continue to use a single character and might have advantages in terms of saving space on the chart: pch = letters[trial_no] pch = c(letters, LETTERS)[trial_no] pch = c(1:9, letters, LETTERS)[trial_no] On 11/9/06, CG Pettersson [EMAIL PROTECTED] wrote: Thanks a lot to Demitris for a prompt answer some minutes ago on another tread (see below). To avoid excess mails on the list, I move onto next question: I have another small plotting problem that confuses me. I want to plot results from a field trial series, using the numbers of the trials as symbols in the plot. pch = as.character(trial_no) works fine, but truncates the trial number to the first digit. As I have sixteen trials in the series I get into problems How do I squeeze in two positions as a symbol in a plot? All the best /CG On Thu, November 9, 2006 9:30 am, Dimitris Rizopoulos said: try the following: x - runif(100, -4, 4) y - 1 + 2 * x + rnorm(100, sd = 2) fit - lm(y ~ x) plot(x, y) abline(fit) legend(topleft, expression(paste(R[adj]^2, = 0.66))) ## or plot(x, y) abline(fit) legend(topleft, legend = substitute(R[adj]^2 == x, list(x = summary(fit)$adj.r.squared))) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: CG Pettersson [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Thursday, November 09, 2006 9:10 AM Subject: [R] Why do I get a linebreak in the legend? Dear all, W2k, R2.4.0 I want to place a legend in a regression plot, stating the adjusted R-square value. After some struggle with the coding I am nearly there, but only nearly. The best try so far is: legend(topleft, expression(paste(R[adj]^2), = 0.66)) This places the proper information in the legend, but I get a linebreak before the = 0.66 and I want the expression on one single line. All adjustments from this code I have tried so far either produces only half the expression or produces an error message. All the best and sorry for a trivial quastion /CG -- CG Pettersson, MSci, PhD Stud. Swedish University of Agricultural Sciences (SLU) Dep. of Crop Production Ekology. Box 7043. SE-750 07 Uppsala, Sweden [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 and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm -- CG Pettersson, MSci, PhD Stud. Swedish University of Agricultural Sciences (SLU) Dep. of Crop Production Ekology. Box 7043. SE-750 07 Uppsala, Sweden [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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Why do I get a linebreak in the legend?
Try: legend(topleft, expression(R[adj]^2 == 0.66)) On 11/9/06, CG Pettersson [EMAIL PROTECTED] wrote: Dear all, W2k, R2.4.0 I want to place a legend in a regression plot, stating the adjusted R-square value. After some struggle with the coding I am nearly there, but only nearly. The best try so far is: legend(topleft, expression(paste(R[adj]^2), = 0.66)) This places the proper information in the legend, but I get a linebreak before the = 0.66 and I want the expression on one single line. All adjustments from this code I have tried so far either produces only half the expression or produces an error message. All the best and sorry for a trivial quastion /CG -- CG Pettersson, MSci, PhD Stud. Swedish University of Agricultural Sciences (SLU) Dep. of Crop Production Ekology. Box 7043. SE-750 07 Uppsala, Sweden [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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Repeated Measures MANOVA in R
A. Bolu Ajiboye wrote: Can R do a repeated measures MANOVA and tell what dimensionality the statistical variance occupies? I have been using MATLAB and SPSS to do my statistics. MATLAB can do ANOVAs and MANOVAs. When it performs a MANOVA, it returns a parameter d that estimates the dimensionality in which the means lie. It also returns a vector of p-values, where each p_n tests the null hypothesis that the mean vectors lie in an n-1 dimensional space (0-D space implies same vector, 1-D space implies scaled vectors that point in the same direction, etc...). However, MATLAB does not do repeated measures MANOVA. SPSS can do repeated measures MANOVA but it does not return this dimension output. Hence, I'm trying to find an environment that will allow me to do repeated measures MANOVA and determine the dimensionality of the space, before I spend several weeks trying to learn it. I know the dimensionality parameter is based upon the eigenvalues of the ratio of the different SSCP (sum of squares and cross products) matrices, but a) I'm not sure how to calculate the SSCP matrices for repeated measures MANOVA, and b) once I get these eigenvalues and convert them a Pillai-Bartlett or Wilk's-Lambda value, I don’t know how to convert to an f-statistic. Does anybody know how to do this or has repeated measures MANOVA in R (while returning the dimensionality parameter)? Thanks in advance for your help. I don't know about the dimensionality parameter, but have a look at anova.mlm(). In particular, you might want to run example(anova.mlm) and study the output. Also, you might look at SSD() and summary.manova() in package stats. Bolu -- __ 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 and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plotting symbols with two positions?
Dear Dimitris, Thanks a lot, but I didn't really manage to apply it in my context, I first got an error message and then an ugly plot. I have also got the advice from Gabor Grothendieck to use letters instead of numbers, but I do prefer numbers as this is the normal way of referring to the individual trials. This is what I did, (and failed with): attach(DAT.nr) plot(jd.s,jd.h, type = no) Warning message: plot type 'no' will be truncated to first character in: plot.xy(xy, type, pch, lty, col, bg, cex, lwd, ...) This was not very hopeful, but as an empty frame was produced in the same time, I took a risk with this: text(jd.s, jd.h, pch=as.character(DAT.nr$t_no)) Which, to my surprise, produced a plot. The problem with it was _not_ that the numbers were truncated into the first (as could be expected) but that it seems like the line number, and not the trial number, were used. Not very nice as they number up to 576 and have 36 levels for each trial.. If I instead use the last expression, but as a plot: plot(jd.s, jd.h, pch=as.character(DAT.nr$t_no)) I am back where I begun with the correct numbers, but only the first position of it. What is happening? All the best /CG On Thu, November 9, 2006 10:19 am, Dimitris Rizopoulos said: try this: y - rnorm(16) plot(y, type = n) text(1:16, y, 1:16) Best, Dimitris - Original Message - From: CG Pettersson [EMAIL PROTECTED] To: Dimitris Rizopoulos [EMAIL PROTECTED] Cc: CG Pettersson [EMAIL PROTECTED]; r-help@stat.math.ethz.ch Sent: Thursday, November 09, 2006 10:09 AM Subject: Plotting symbols with two positions? Thanks a lot to Demitris for a prompt answer some minutes ago on another tread (see below). To avoid excess mails on the list, I move onto next question: I have another small plotting problem that confuses me. I want to plot results from a field trial series, using the numbers of the trials as symbols in the plot. pch = as.character(trial_no) works fine, but truncates the trial number to the first digit. As I have sixteen trials in the series I get into problems How do I squeeze in two positions as a symbol in a plot? All the best /CG On Thu, November 9, 2006 9:30 am, Dimitris Rizopoulos said: try the following: x - runif(100, -4, 4) y - 1 + 2 * x + rnorm(100, sd = 2) fit - lm(y ~ x) plot(x, y) abline(fit) legend(topleft, expression(paste(R[adj]^2, = 0.66))) ## or plot(x, y) abline(fit) legend(topleft, legend = substitute(R[adj]^2 == x, list(x = summary(fit)$adj.r.squared))) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: CG Pettersson [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Thursday, November 09, 2006 9:10 AM Subject: [R] Why do I get a linebreak in the legend? Dear all, W2k, R2.4.0 I want to place a legend in a regression plot, stating the adjusted R-square value. After some struggle with the coding I am nearly there, but only nearly. The best try so far is: legend(topleft, expression(paste(R[adj]^2), = 0.66)) This places the proper information in the legend, but I get a linebreak before the = 0.66 and I want the expression on one single line. All adjustments from this code I have tried so far either produces only half the expression or produces an error message. All the best and sorry for a trivial quastion /CG -- CG Pettersson, MSci, PhD Stud. Swedish University of Agricultural Sciences (SLU) Dep. of Crop Production Ekology. Box 7043. SE-750 07 Uppsala, Sweden [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 and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm -- CG Pettersson, MSci, PhD Stud. Swedish University of Agricultural Sciences (SLU) Dep. of Crop Production Ekology. Box 7043. SE-750 07 Uppsala, Sweden [EMAIL PROTECTED] Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm -- CG Pettersson, MSci, PhD Stud. Swedish University of Agricultural Sciences (SLU) Dep. of Crop Production Ekology. Box 7043. SE-750 07 Uppsala, Sweden [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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plotting symbols with two positions?
I think you need the following: attach(DAT.nr) plot(jd.s, jd.h, type = n) text(jd.s, jd.h, t_no) I hope it works. Best, Dimitris - Original Message - From: CG Pettersson [EMAIL PROTECTED] To: Dimitris Rizopoulos [EMAIL PROTECTED] Cc: CG Pettersson [EMAIL PROTECTED]; r-help@stat.math.ethz.ch Sent: Thursday, November 09, 2006 11:37 AM Subject: Re: Plotting symbols with two positions? Dear Dimitris, Thanks a lot, but I didn't really manage to apply it in my context, I first got an error message and then an ugly plot. I have also got the advice from Gabor Grothendieck to use letters instead of numbers, but I do prefer numbers as this is the normal way of referring to the individual trials. This is what I did, (and failed with): attach(DAT.nr) plot(jd.s,jd.h, type = no) Warning message: plot type 'no' will be truncated to first character in: plot.xy(xy, type, pch, lty, col, bg, cex, lwd, ...) This was not very hopeful, but as an empty frame was produced in the same time, I took a risk with this: text(jd.s, jd.h, pch=as.character(DAT.nr$t_no)) Which, to my surprise, produced a plot. The problem with it was _not_ that the numbers were truncated into the first (as could be expected) but that it seems like the line number, and not the trial number, were used. Not very nice as they number up to 576 and have 36 levels for each trial.. If I instead use the last expression, but as a plot: plot(jd.s, jd.h, pch=as.character(DAT.nr$t_no)) I am back where I begun with the correct numbers, but only the first position of it. What is happening? All the best /CG On Thu, November 9, 2006 10:19 am, Dimitris Rizopoulos said: try this: y - rnorm(16) plot(y, type = n) text(1:16, y, 1:16) Best, Dimitris - Original Message - From: CG Pettersson [EMAIL PROTECTED] To: Dimitris Rizopoulos [EMAIL PROTECTED] Cc: CG Pettersson [EMAIL PROTECTED]; r-help@stat.math.ethz.ch Sent: Thursday, November 09, 2006 10:09 AM Subject: Plotting symbols with two positions? Thanks a lot to Demitris for a prompt answer some minutes ago on another tread (see below). To avoid excess mails on the list, I move onto next question: I have another small plotting problem that confuses me. I want to plot results from a field trial series, using the numbers of the trials as symbols in the plot. pch = as.character(trial_no) works fine, but truncates the trial number to the first digit. As I have sixteen trials in the series I get into problems How do I squeeze in two positions as a symbol in a plot? All the best /CG On Thu, November 9, 2006 9:30 am, Dimitris Rizopoulos said: try the following: x - runif(100, -4, 4) y - 1 + 2 * x + rnorm(100, sd = 2) fit - lm(y ~ x) plot(x, y) abline(fit) legend(topleft, expression(paste(R[adj]^2, = 0.66))) ## or plot(x, y) abline(fit) legend(topleft, legend = substitute(R[adj]^2 == x, list(x = summary(fit)$adj.r.squared))) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: CG Pettersson [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Thursday, November 09, 2006 9:10 AM Subject: [R] Why do I get a linebreak in the legend? Dear all, W2k, R2.4.0 I want to place a legend in a regression plot, stating the adjusted R-square value. After some struggle with the coding I am nearly there, but only nearly. The best try so far is: legend(topleft, expression(paste(R[adj]^2), = 0.66)) This places the proper information in the legend, but I get a linebreak before the = 0.66 and I want the expression on one single line. All adjustments from this code I have tried so far either produces only half the expression or produces an error message. All the best and sorry for a trivial quastion /CG -- CG Pettersson, MSci, PhD Stud. Swedish University of Agricultural Sciences (SLU) Dep. of Crop Production Ekology. Box 7043. SE-750 07 Uppsala, Sweden [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 and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm -- CG Pettersson, MSci, PhD Stud. Swedish University of Agricultural Sciences (SLU) Dep. of Crop Production Ekology. Box 7043. SE-750 07 Uppsala, Sweden [EMAIL PROTECTED] Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm -- CG Pettersson, MSci, PhD Stud. Swedish University of Agricultural
[R] problems with loading packages in R 2.4.0
Hi, I have just installed R 2.4.0 and when I try to load fMultivar I get the following error message: Loading required package: methods Error in identical(pkg, [EMAIL PROTECTED]) : formal classes cannot be used without the methods package Error: .onAttach failed in 'attachNamespace' Error: package 'methods' could not be loaded I have already updated all packages using update.packages(checkBuilt = TRUE) the error remains. sessionInfo() R version 2.4.0 (2006-10-03) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets base Regards Jaci -- __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] [Rd] How to link to vignette from .Rd file
Thanks for the tip. Actually I found that I can just write vignette(vignettename) in a demo. I think that's the easiest way to link to a .pdf file. It works only if the .pdf file is built from a Sweave file. I thought that I could just put a .pdf file and an index.html in inst/doc/ but I get no link to the index.html from anywhere. Using a Sweave file seems to be the only solution that works. Prof Brian Ripley wrote: This looks very like the print method for vignettes. This is utils:::print.vignette function (x, ...) { if (length(x$pdf)) { if (.Platform$OS.type == windows) shell.exec(x$pdf) else system(paste(getOption(pdfviewer), x$pdf, )) } else { warning(gettextf(vignette '%s' has no PDF, x$topic), call. = FALSE, domain = NA) } } which is more elegant in several ways than those solutions earlier in this thread (the one below does not even work on Win9x or if CMD.exe is not in the path). Duncan Murdoch wrote: The demo system can be used to compensate for limitations of the help system. You can display PDF files from any package subdirectory using a demo file like this (named demo/ReadPkgDoc.R, and documented in demo/00Index): # ReadPkgDoc.R -- Displays a PDF file as a demo # isWindows - (Sys.info()['sysname'] == 'Windows') file - system.file(doc, PkgManual.pdf, package=PkgName) if(isWindows) { # Windows automatically finds executable based on file type. system(paste(CMD /C , file, \n)) } else { # Change this to use path to Adobe reader if desired. system(paste(xpdf , file, \n)) } To create the PDF file from the Rd file use R CMD Rd2dvi, and dvipdf. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] plot pch
Dear All, I have a data as follows: ID - 1:100 Y - rnorm(100) X - rnorm(100) type - as.factor(rep(1:3,100,time=1)) df - as.data.frame(cbind(ID, Y,X,type)) I want to plot Y versus X by specifying the pch to be as follows: Subjects having type = 1 must be plotted with a character pch = A Subjects having type = 2 must be plotted with a pch = B Subjects having type = 3 must be plotted with a pch = 21 I used the follwomg: df$pch_type = recode(df$type, 1 = 'A'; 2 = 'B'; else = '21' ) plot(df$Y,df$X,pch= df$pch_type) This plots subjects for type 1 and 2 with symbols A and B (this is what expected) however subjects with type = 3 are plotted with a charcater 2 instead of a pch=21. I understand that this is due to the fact that the created vector type_pch cannot be a mixture between characters and numerics ... I tried to use a list for that purpsoe but fail... Any suggestions would be grateful, Many thanks, Bernard - [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Can I set the proxy server and authentification from within R?
Thanks a lot for your help! One more remark if somebody runs into the same problem: The .Renviron file has to be in the correct directory. It can be checked with Sys.getenv('http_proxy') that the settings have been actually read in. The .Renviron file looks like this now: http_proxy=http://proxyname.domain.com:8080/ http_proxy_user=username:password Thanks again, Werner __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Discriminant Analysis- Apparent error rate
R-help, I'm trying to evaluate the misclasification rate of an estimated discrimated function (hyDA) hyDA - with(hyB, lda(Maturity ~ Length + Weight)) , so here is what I do (code from S-plus 6.1 Guide to Statistics Vol. 2 p 101) test - predict(hyDA) tbl - table(hyB$Maturity, test$class) tbl - tbl[-2,-2] tbl1 - cbind(tbl, error = (apply(tbl, 1, sum) - diag(tbl)) / hyDA$counts) sum(hyDA$prior * tbl1[,'error']) The error rates I get is 0.57 which is very large I was wondering if I'm doing something wrong. Thanks in advance. version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 4.0 year 2006 month 10 day03 svn rev39566 language R version.string R version 2.4.0 (2006-10-03) __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] [Rd] How to link to vignette from .Rd file
On 11/9/2006 6:37 AM, Agner Fog wrote: Thanks for the tip. Actually I found that I can just write vignette(vignettename) in a demo. I think that's the easiest way to link to a .pdf file. It works only if the .pdf file is built from a Sweave file. I thought that I could just put a .pdf file and an index.html in inst/doc/ but I get no link to the index.html from anywhere. Using a Sweave file seems to be the only solution that works. Actually how you built the .pdf is irrelevant, but it does look for file with the same name and one of these extensions: Rnw rnw Snw snw Rtex rtex Stex stex So you could just create a zero length file with the same basename and one of those extensions, and it should work. I don't know if this restriction is intentional. Duncan Murdoch Prof Brian Ripley wrote: This looks very like the print method for vignettes. This is utils:::print.vignette function (x, ...) { if (length(x$pdf)) { if (.Platform$OS.type == windows) shell.exec(x$pdf) else system(paste(getOption(pdfviewer), x$pdf, )) } else { warning(gettextf(vignette '%s' has no PDF, x$topic), call. = FALSE, domain = NA) } } which is more elegant in several ways than those solutions earlier in this thread (the one below does not even work on Win9x or if CMD.exe is not in the path). Duncan Murdoch wrote: The demo system can be used to compensate for limitations of the help system. You can display PDF files from any package subdirectory using a demo file like this (named demo/ReadPkgDoc.R, and documented in demo/00Index): # ReadPkgDoc.R -- Displays a PDF file as a demo # isWindows - (Sys.info()['sysname'] == 'Windows') file - system.file(doc, PkgManual.pdf, package=PkgName) if(isWindows) { # Windows automatically finds executable based on file type. system(paste(CMD /C , file, \n)) } else { # Change this to use path to Adobe reader if desired. system(paste(xpdf , file, \n)) } To create the PDF file from the Rd file use R CMD Rd2dvi, and dvipdf. __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot pch
Somebody will come up with a more elagant solution, but a quick fix would be: plot(df$Y[df$pch_type != 21],df$X[df$pch_type != 21], pch=df$pch_type[df$pch_type != 21]) points(df$Y[df$pch_type == 21],df$X[df$pch_type == 21],pch= 21) Marc Bernard wrote: Dear All, I have a data as follows: ID - 1:100 Y - rnorm(100) X - rnorm(100) type - as.factor(rep(1:3,100,time=1)) df - as.data.frame(cbind(ID, Y,X,type)) I want to plot Y versus X by specifying the pch to be as follows: Subjects having type = 1 must be plotted with a character pch = A Subjects having type = 2 must be plotted with a pch = B Subjects having type = 3 must be plotted with a pch = 21 I used the follwomg: df$pch_type = recode(df$type, 1 = 'A'; 2 = 'B'; else = '21' ) plot(df$Y,df$X,pch= df$pch_type) This plots subjects for type 1 and 2 with symbols A and B (this is what expected) however subjects with type = 3 are plotted with a charcater 2 instead of a pch=21. I understand that this is due to the fact that the created vector type_pch cannot be a mixture between characters and numerics ... I tried to use a list for that purpsoe but fail... Any suggestions would be grateful, Many thanks, Bernard - [[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 and provide commented, minimal, self-contained, reproducible code. -- == Joris De Wolf CropDesign N.V. Biometrician Plant Evaluation Technologiepark 3 B-9052 Zwijnaarde Belgium Tel. : +32 9 242 91 55 Fax : +32 9 241 91 73 == confidentiality notice: The information contained in this e-mail is confidential and...{{dropped}} __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Closing R fails
Hello All I cannot close R easily: q() Error in .Last() : could not find function finalizeSession This seems to have started after I used the R.utils package. If I load the R.utils package I can close R successfully. But I do not want to have to do this every time I run R. Is there any way I can switch off /reverse this behaviour? (I have had a look in the archives/documentation but cannot find a solution). Thanks for any help. John Seers R.version$os [1] mingw32 R.version.string [1] R version 2.4.0 Patched (2006-10-29 r39744) [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] query in R
Xiaodong Jin wrote: I just need to query ordinary 3-column excel data e.g. V1 V2 V3 I1 C1 1 I1 C1 1 ... DATA snipped Hi. It is better to keep discussion on list, rather than emailing individuals. You need to read http://cran.r-project.org/doc/manuals/R-data.html#Reading-Excel-spreadsheets RODBC allows you to run arbitrary queries against Excel spreadsheets. I don't use Excel (well, try not to), so I can't vouch for it, but it should work. Best wishes, Mark -- Dr. Mark Wardle Clinical research fellow and Specialist Registrar in Neurology, C2-B2 link, Cardiff University, Heath Park, CARDIFF, CF14 4XN. UK __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Closing R fails
On Thu, 2006-11-09 at 12:18 +, john seers (IFR) wrote: Hello All I cannot close R easily: q() Error in .Last() : could not find function finalizeSession This seems to have started after I used the R.utils package. If I load the R.utils package I can close R successfully. But I do not want to have to do this every time I run R. John, Does R close properly if you invoke R with the --vanilla flag? I forget the best way to do this in Windows, but editing the shortcut is one way. Right click the R shortcut, find the Target, and add --vanilla to the end of it. You might need to enclose the whole path and command in , e.g.: C:\R\R.exe --vanilla. If I've gotten this wrong then I'm sure a Windows user will let us know. Your problem may be related to R loading a previous session that you saved when exiting, where you'd used R.utils, which expects to find R.utils loaded and throws and error when you exit because it isn't. Running R --vanilla will stop R automatically loading the saved R session file .RData. HTH G Is there any way I can switch off /reverse this behaviour? (I have had a look in the archives/documentation but cannot find a solution). Thanks for any help. John Seers -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC ENSIS, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Env: Re: query in R
---BeginMessage--- Hi, Jin, --- Ricardo Rodríguez Your XEN ICT Team Xiaodong Jin[EMAIL PROTECTED] 09/11/06 3:10 I just need to query ordinary 3-column excel data e.g. V1 V2 V3 I1 C1 1 I1 C1 1 I1 C1 1 I need to get select distinct V1, V3, count(distinct V2) as CNT from TABLENAM group by 1,2 order by 1,2 V1 V3 CNT I1 1 2 I1 3 2 I1 9 1 What do I need besides the package RMySQL? Thanks If you need/want to keep your records in Excel files, you don't need RMySQL at all! It is only needed if you are going to store the records in a MySQL relational database management system. From my point of view, this is the best alternative as it will allow you to use the power of the RDBMS to design ad hoc queries and retrieve just what you want out of the whole dataset. Thus, sticking with Excel, there are two options as far as I know: RODBC or the read.xls function included with a number of packages. read.xls temporarely transform your xls files into csv ones. I've never successfully imported data by using this path as I getting a number of errors likely related to my Perl installation (the function uses Perl for the transformation to csv). RODBC is out of the question here as far as we mostly use Mac and Linux boxes. Even though there is ODBC for Mac OS X, we do prefer to avoid it and to natively get the data from MySQL by using RMySQL. As an alternative, you can manually transform the xls files to csv, read it by using read.csv and then using SQL like manipulations on data frames (see this for further reference http://tolstoy.newcastle.edu.au/R/help/06/05/26796.html) It is quite easy to load csv files into a data frame, but as far as I know, you can not use SQL sentences to subset it. Here a rather simple example about loading csv files in a data frame by using the data you have sent to me... jin - read.csv(http://nvx.environmentalchange.net/@rrodriguez/R/jin.csv,sep = ,) print(jin) Once again, I can not post to the list from this location. It will be much better to keep the communication by the list. I am just a R newcomer. There are many people out there mastering R and ready to help! I'll resend this message to the list as soon as I can. HTH, Ricardo ---End Message--- __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Merge: how can I keep discarded values?
Good morning, I am merging two datasets and I would like to save the non-matching rows in a separate file. The problem is how to retrieve the non-matching rows in R. Example: DATASET A code nomi A1 Franco A2 Mario A3 Andrea A4 Sandro A5 Luca DATASET B codebook A1Guerra e Pace A1 Storia di Roma A2 La coscienza di Zeno A4 Ivanhoe A1 I Malavoglia A2 Jude the obscure when merging two rows are unmatched: A3 Andrea A5 Luca And these are exactly the rows I would like to store in a separate file/dataset. I tried with: AM-merge(A,B,all=TRUE) A1-AM[is.na(AM$book),] to keep the rows with a NA value in the book column. The problem is that this works in this particular case, but in real situations I might have other NA values in the book column, not resulting from the merge operation, but that are real missing values: in such cases, with the is.na command I would retrieve also thiese unneeded rows. Can someone suggest a better strategy to tackle this problem? Regards, Filippo Biscarini Wageningen University The Netherlands [[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 and provide commented, minimal, self-contained, reproducible code.
[R] Question about position in row and column
Hi R-users, I have 48 blocks like below 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 in each block there are 18 cloumns and 18 rows which give 18*18*48 observations. The matrix looks like 1 2 3 17 18 1 2 3. ..1 7 18 1 2 3. ..1 7 18 1 2 3 ... 17 18 1 2 Block 1 Block 2 block 3 Block 4 3 . . 17 18 -- 1 2 block 5 block 6 block 7block 8 3 . . 17 18 -- 1 2 3 block 9 block 10 block11 block12 . . 17 18 --- 1 2 3 block 13 block 14block 15 block 16 . . 17 18 . . . til the last row with blocks 45 46 47 48 What i want to do is to add column and row positions to block 2-48 so that the matrix will look like 1 2 317 18 19 20 21...35 36 37 38 39 ...53 54 55 56 ...71 72 1 2 block 1 block 2 block 3block 4 3 . . 17 18 -- 19 20 block 5block 6 block 7 block 8 21 . . 35 36 -- 37 38 39 . . 53 54 --- 55 56 57 . . 71 72 . . . . . --- 198 199 block 45 block 46 block 47 block 48 . . 215 216 How can I do this in R ? I try layout is a matrix contains columns:block, row, column, id name ## Column positions ### blockcol-rep(0,nrow(layout)) if(layout$Block%%4==2) {blockcol=layout$Column+18} if(layout$Block%%4==3){blockcol=layout$Column+36} else {blockcol=layout$Column+54} ## Row positions ### blockrow-rep(0,nrow(layout)) if(layout$Block=4) {blockrow=layout$Row} for (j in 2:12){ if((j-1)*4layout$Block=j*4) {blockrow=layout$Row+(j-1)*18} } but didn't get the desirable result. Thanks for your help, Jenny [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Closing R fails
On 11/9/2006 7:18 AM, john seers (IFR) wrote: Hello All I cannot close R easily: q() Error in .Last() : could not find function finalizeSession This seems to have started after I used the R.utils package. If I load the R.utils package I can close R successfully. But I do not want to have to do this every time I run R. You seem to have a .Last function defined that contains a call to finalizeSession. Remove it and the error should go away: .Last # to print it and see if anything important is there rm(.Last) # to remove it if not Normally you don't need .Last, but you can define it if you want R to do something on shutdown. It looks like R.utils did that for you at some point, and you saved the workspace afterwards. Duncan Murdoch Is there any way I can switch off /reverse this behaviour? (I have had a look in the archives/documentation but cannot find a solution). Thanks for any help. John Seers R.version$os [1] mingw32 R.version.string [1] R version 2.4.0 Patched (2006-10-29 r39744) [[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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Discriminant Analysis- Apparent error rate
The error rates I get is 0.57 which is very large I was wondering if I'm doing something wrong. It is quite possible, if your groups are overlapping or not separated by a linear boundary. Given that you have only two varaibles, have you plotted them? Hadley __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Closing R fails
Hi Gavin Thanks for helping. Does R close properly if you invoke R with the --vanilla flag? It sure does. So, deleting .RData from my workspace seems to fix it more neatly. But, of course, the problem come backs whenever I use R.utils. (Unless I remember not to save my workspace). A good improvement though. Thanks. John --- John Seers Institute of Food Research Norwich Research Park Colney Norwich NR4 7UA tel +44 (0)1603 251497 fax +44 (0)1603 507723 e-mail [EMAIL PROTECTED] e-disclaimer at http://www.ifr.ac.uk/edisclaimer/ Web sites: www.ifr.ac.uk www.foodandhealthnetwork.com -Original Message- From: Gavin Simpson [mailto:[EMAIL PROTECTED] Sent: 09 November 2006 12:46 To: john seers (IFR) Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Closing R fails On Thu, 2006-11-09 at 12:18 +, john seers (IFR) wrote: Hello All I cannot close R easily: q() Error in .Last() : could not find function finalizeSession This seems to have started after I used the R.utils package. If I load the R.utils package I can close R successfully. But I do not want to have to do this every time I run R. John, Does R close properly if you invoke R with the --vanilla flag? I forget the best way to do this in Windows, but editing the shortcut is one way. Right click the R shortcut, find the Target, and add --vanilla to the end of it. You might need to enclose the whole path and command in , e.g.: C:\R\R.exe --vanilla. If I've gotten this wrong then I'm sure a Windows user will let us know. Your problem may be related to R loading a previous session that you saved when exiting, where you'd used R.utils, which expects to find R.utils loaded and throws and error when you exit because it isn't. Running R --vanilla will stop R automatically loading the saved R session file .RData. HTH G Is there any way I can switch off /reverse this behaviour? (I have had a look in the archives/documentation but cannot find a solution). Thanks for any help. John Seers -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC ENSIS, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Env: Re: query in R
2006/11/9, Ricardo Rodríguez [EMAIL PROTECTED]: Thus, sticking with Excel, there are two options as far as I know: RODBC or the read.xls function included with a number of packages. read.xls temporarely transform your xls files into csv ones. I've never successfully imported data by using this path as I getting a number of errors likely related to my Perl installation (the function uses Perl for the transformation to csv). RODBC is out of the question here as far as we mostly use Mac and Linux boxes. Even though there is ODBC for Mac OS X, we do prefer to avoid it and to natively get the data from MySQL by using RMySQL. For Linux/Mac I cannot help*, but on the windows platform I'd like to mention my xlsReadWrite package which is a good thing if you need/want to work with Excelfiles. It contains the two commands: read.xls and write.xls which work with data.frames and/or matrices. The package can be downloaded from cran but there is an update due soon (with explicit support for rownames and datetime handling (as ISO strings)). -- Regards, Hans-Peter *at least right now __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Repeated Measures MANOVA in R
I have an in press paper on HE plots, http://www.math.yorku.ca/SCS/Papers/heplots.pdf that describes methods to visualize the dimensionality of effects in MLMs. The implementation is in SAS, but there's a link to a rudimentary R function in the paper. -Michael A. Bolu Ajiboye wrote: Can R do a repeated measures MANOVA and tell what dimensionality the statistical variance occupies? I have been using MATLAB and SPSS to do my statistics. MATLAB can do ANOVAs and MANOVAs. When it performs a MANOVA, it returns a parameter d that estimates the dimensionality in which the means lie. It also returns a vector of p-values, where each p_n tests the null hypothesis that the mean vectors lie in an n-1 dimensional space (0-D space implies same vector, 1-D space implies scaled vectors that point in the same direction, etc...). However, MATLAB does not do repeated measures MANOVA. SPSS can do repeated measures MANOVA but it does not return this dimension output. Hence, I'm trying to find an environment that will allow me to do repeated measures MANOVA and determine the dimensionality of the space, before I spend several weeks trying to learn it. I know the dimensionality parameter is based upon the eigenvalues of the ratio of the different SSCP (sum of squares and cross products) matrices, but a) I'm not sure how to calculate the SSCP matrices for repeated measures MANOVA, and b) once I get these eigenvalues and convert them a Pillai-Bartlett or Wilk's-Lambda value, I don’t know how to convert to an f-statistic. Does anybody know how to do this or has repeated measures MANOVA in R (while returning the dimensionality parameter)? Thanks in advance for your help. Bolu -- __ 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 and provide commented, minimal, self-contained, reproducible code. -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 CANADA __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Repeated Measures MANOVA in R
Chuck Cleland [EMAIL PROTECTED] writes: A. Bolu Ajiboye wrote: Can R do a repeated measures MANOVA and tell what dimensionality the statistical variance occupies? I have been using MATLAB and SPSS to do my statistics. MATLAB can do ANOVAs and MANOVAs. When it performs a MANOVA, it returns a parameter d that estimates the dimensionality in which the means lie. It also returns a vector of p-values, where each p_n tests the null hypothesis that the mean vectors lie in an n-1 dimensional space (0-D space implies same vector, 1-D space implies scaled vectors that point in the same direction, etc...). However, MATLAB does not do repeated measures MANOVA. SPSS can do repeated measures MANOVA but it does not return this dimension output. Hence, I'm trying to find an environment that will allow me to do repeated measures MANOVA and determine the dimensionality of the space, before I spend several weeks trying to learn it. I know the dimensionality parameter is based upon the eigenvalues of the ratio of the different SSCP (sum of squares and cross products) matrices, but a) I'm not sure how to calculate the SSCP matrices for repeated measures MANOVA, and b) once I get these eigenvalues and convert them a Pillai-Bartlett or Wilk's-Lambda value, I dont know how to convert to an f-statistic. Does anybody know how to do this or has repeated measures MANOVA in R (while returning the dimensionality parameter)? Thanks in advance for your help. I don't know about the dimensionality parameter, but have a look at anova.mlm(). In particular, you might want to run example(anova.mlm) and study the output. Also, you might look at SSD() and summary.manova() in package stats. Yep. You may also want to look at http://www.pubhealth.ku.dk/bs/publikationer/rr-06-11.pdf/ (which is under revision for R News) Re. dimensionality, it is not clear to me what exactly Matlab might be doing and how (and I can't easily find it on the net, or so it seems). -- 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 and provide commented, minimal, self-contained, reproducible code.
[R] Help with plot(augPred()) plot(comparePred()) in nlme
Dear r-helpers, When I issue the commands plot(augPred(mcc.lme, primary = ~ mcc$age, length.out = 2, level = c (0, 1))) or plot(comparePred(mcc1.lis, mcc.lme, primary = ~ mcc$age, length.out = 2), layout = c(4, 3))) no lines are drawn. But fm1 - lme(Orthodont) plot(augPred(fm1, level = 0:1, length.out = 2)) does plot lines. augPred() and comparePredict() seem to be working correctly, as shown below augPred(mcc.lme, primary = ~ mcc$age, length.out = 2, level = c(0, 1)) mcc$age .groups score.type 1 30 1 108 original 2 30 2 103 original 3 30 396 original 4 30 484 original 5 30 5 118 original 6 30 6 110 original ... 91 30 10 101 predict.subject 92 48 10 101 predict.subject 93 30 11 109 predict.subject 94 48 11 109 predict.subject 95 30 12 122 predict.subject 96 48 12 122 predict.subject comparePred(mcc1.lis, mcc.lme, primary = ~ mcc$age, length.out = 2)) mcc$age subject score.type 1 30 1 108 original 2 30 296 original 3 30 3 110 original 4 30 4 122 original 5 30 5 103 original 6 30 6 117 original ... 671 30 10 101 mcc.lme 681 48 10 101 mcc.lme 691 30 11 109 mcc.lme 701 48 11 109 mcc.lme 711 30 12 122 mcc.lme 721 48 12 122 mcc.lme _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Numerical Integration
Here is a simple example using the bkde (binned kernel density estimator) from the KernSmooth package that shows how to use the trapezoidal integration: library(KernSmooth) data(geyser, package=MASS) x - geyser$duration est - bkde(x, grid = 101, bandwidth=0.25) trap.rule(est$x,est$y) [1] 0.61 The answer from the simple trapezoidal rule is pretty good with an error of less than 1.e-04 (number of grid points used is 101, with equal spacing). You could use higher order rules (e.g. Simpson's), but you can get reasonable accuracy with Trapezoidal rule by just increasing the number of grid points. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: Xiaofan Cao [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 08, 2006 4:21 PM To: Ravi Varadhan Cc: 'Doran, Harold'; r-help@stat.math.ethz.ch Subject: RE: [R] Numerical Integration Hi Ravi and Harold, Thanks for the input. I'm using trapezoidal rule and like to know if there's other alternatives. This f(x) is the kernel density estimator and thus we can get an estimate of f(x) at any given x in theory. Thanks again, Martha On Wed, 8 Nov 2006, Ravi Varadhan wrote: Can you get an estimate of f(x) at any given x? If so, the Gaussian quadrature methods will work, but not otherwise since f(x) must be known at all the nodes. A rough approximation to the integral can be obtained using the trapezoidal rule. Here is a simple function to do that: trap.rule - function(x,y) sum(diff(x)*(y[-1]+y[-length(y)]))/2 However, the use of the word knots seems to indicate that some sort of spline is being fit to the data. Martha - can you provide more information about your function f(x)? Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Doran, Harold Sent: Wednesday, November 08, 2006 1:04 PM To: Xiaofan Cao; r-help@stat.math.ethz.ch Subject: Re: [R] Numerical Integration You might try the statmod package which provides nodes and weights for gaussian quadrature. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Xiaofan Cao Sent: Wednesday, November 08, 2006 12:43 PM To: r-help@stat.math.ethz.ch Subject: [R] Numerical Integration Hi everyone, I'm trying to integrate f(x) over x where f(x) does not have a close form but only numerical values at certurn knots of x. Is there a way that I can use any generical R function (such as integrate) or any package to do so? Thanks! I appreciate your time. Best Regards, Martha Cao __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Closing R fails
On Thu, 2006-11-09 at 13:46 +, john seers (IFR) wrote: Hi Gavin Thanks for helping. You're welcome Does R close properly if you invoke R with the --vanilla flag? It sure does. So, deleting .RData from my workspace seems to fix it more neatly. But, of course, the problem come backs whenever I use R.utils. (Unless I remember not to save my workspace). I gave up saving workspaces a while back. I prefer to have everything as a script (or scripts) that I can re-run, describing the analysis from data processing to results. Most of the work I do doesn't involve the huge data sets that some list members work does, so I can usually re-run the scripts from scratch and continue where I left off. If I have complex or tedious data manipulation scripts to process data before analysis, or a computationally complex bit of analysis, I may opt to save the resulting objects using save(), which I then load as required using a load() call within my analysis script, rather than re-run them each time. I've been caught out a few times with things being loaded that I'd forgotten about when I reused a workspace. All the best, G A good improvement though. Thanks. John --- John Seers Institute of Food Research Norwich Research Park Colney Norwich NR4 7UA tel +44 (0)1603 251497 fax +44 (0)1603 507723 e-mail [EMAIL PROTECTED] e-disclaimer at http://www.ifr.ac.uk/edisclaimer/ Web sites: www.ifr.ac.uk www.foodandhealthnetwork.com -Original Message- From: Gavin Simpson [mailto:[EMAIL PROTECTED] Sent: 09 November 2006 12:46 To: john seers (IFR) Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Closing R fails On Thu, 2006-11-09 at 12:18 +, john seers (IFR) wrote: Hello All I cannot close R easily: q() Error in .Last() : could not find function finalizeSession This seems to have started after I used the R.utils package. If I load the R.utils package I can close R successfully. But I do not want to have to do this every time I run R. John, Does R close properly if you invoke R with the --vanilla flag? I forget the best way to do this in Windows, but editing the shortcut is one way. Right click the R shortcut, find the Target, and add --vanilla to the end of it. You might need to enclose the whole path and command in , e.g.: C:\R\R.exe --vanilla. If I've gotten this wrong then I'm sure a Windows user will let us know. Your problem may be related to R loading a previous session that you saved when exiting, where you'd used R.utils, which expects to find R.utils loaded and throws and error when you exit because it isn't. Running R --vanilla will stop R automatically loading the saved R session file .RData. HTH G Is there any way I can switch off /reverse this behaviour? (I have had a look in the archives/documentation but cannot find a solution). Thanks for any help. John Seers -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC ENSIS, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Parameter to show ticks ?
Hi there, is there a parameter in stripchart to control if the ticks (in the axis) are shown or not ? Thanks, Marc. [[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 and provide commented, minimal, self-contained, reproducible code.
[R] summary linear regression
Good morning, I am a PhD student in Barcelona working with R. My question is about the summary of linear regressions. The output of that summary gives some statistical parameters of the regression. One of them is the R-squared. In the help menu i have read that the manner to calculate the R-squared is R^2 = 1 - Sum(R[i]^2) / Sum((y[i]- y*)^2), and when the linear regression is forced to start at the point (0,0) y* is 0. My question is if the R-squared obtained when the linear regression crosses the origin has the same meaning as when it does with an intercept. I'm faced to a theoretical model which brings some values for a variable that compared to the observed ones gives some R*squared of 0.32 when the regression has an intercept and 0.7 when it is forced to cross the origin. To sum up, it may be stated that the theoretical methodolgy followed explains the 70% of of the observed variance? Thank you very much. Gorka Merino. Gorka Merino Institut de Ciències del Mar, CMIMA-CSIC Psg. Marítim de la Barceloneta 37-49 08003-BARCELONA (Spain) Tel.: (34) 932 30 95 48 e-mail: [EMAIL PROTECTED] CMIMA: Tel.: (34) 932 30 95 00 Fax: (34) 932 30 95 55 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] rpart - I'm confused by the loss matrix
Hello, As I couldn't find anywhere in the help to rpart which element in the loss matrix means which loss, I played with this parameter and became a bit confused. What I did was this: I used kyphosis data(classification absent/present, number of 'absent' cases is 64, of 'present' cases 17) and I tried the following lmat=matrix(c(0,17,64,0),ncol=2) lmat [,1] [,2] [1,]0 64 [2,] 170 set.seed(1003) fit1-rpart(Kyphosis~.,data=kyphosis,parms=list(loss=lmat)) set.seed(1003) fit2-rpart(Kyphosis~.,data=kyphosis,parms=list(prior=c(0.5,0.5))) The results I obtained were identical, so I concluded that the losses were [L(true, predicted)]: L(absent,present)=17 L(present,absent)=64. And thus the arrangement of the elements in the loss matrix seemed clear as absent is considered as class 1 and present as class 2 and my problem seemed to be solved. However, I tried also this: residuals(fit1) and became confused. Because for each misclassified 'absent' the residual(which should be loss in this case) was 64, while for a misclassified 'present' it was 17 (in contradiction to the previous.) So am I wrong somewhere? Is the arrangement of elements in the loss matrix such as I deduced it from fitting fit1 and fit2? Thanks for any comments. Barbora __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] solve computationally singular
On Tuesday 07 November 2006 19:46, xchen wrote: Hi uRsers, when inverting a 2 by 2 matrix using solve, I encountered a error message: solve.default(sigma, tol = 1e-07) : system is computationally singular: reciprocal condition number = 1.7671e-017 and then I test the determinant of this matrix: 6.341393e-06. In my program, I have a condition block that whether a matrix is invertible like this: if(det(sigma)1e-7) return NULL; - the determinant isn' t the best way of testing for computational singularity. For example, in the following `a' is computationally singular (it has a condition number of 1e18, but it has a determinant of 1e-6) a- diag(c(1e6,1e-12)) a [,1] [,2] [1,] 1e+06 0e+00 [2,] 0e+00 1e-12 det(a) [1] 1e-06 solve(a) Error in solve.default(a) : system is computationally singular: reciprocal condition number = 1e-18 If you are really only interested in small matrices, then calculation of the condition number as the ratio of largest to smallest singular values is the most reliable thing to do (or you could just trap the `solve' errors). See e.g. Golub and van Loan Matrix Computations for efficient condition number estimators, for larger matrices. Simon but this seems doesnot work to prevent the singularity when inverting a matrix. I am some confused about the relationship between reciprocal condition number and determinant. Can anybody give me some idea how to prevent this situation? Thanks a lot! Xiaohui __ 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 and provide commented, minimal, self-contained, reproducible code. -- Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK +44 1225 386603 www.maths.bath.ac.uk/~sw283 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Making a case for using R in Academia
As a addendum to all this, this is one of the responses I got from one of my colleagues: The problem with R is that our students in many social science fields, are expected to know SPSS when they go to graduate school. Not having a background in SPSS would put these students at a disadvantage. Is this really the case? Does anyone have any such statistics? Charilaos Skiadas Department of Mathematics Hanover College P.O.Box 108 Hanover, IN 47243 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] R Help
Respected Sir I am very new user of R language. Sir i am facing problems in learning R language reading manuals. Sir is there any possibility of learning it by some tutor online? Sir my research work is going to be late because of not having understanding of R. After a long struggle, I am just able to import data. But i am unable to save it as a data file. Sir I request you to please give me some instructions. And how I can make it easier for learning it. I shall be very thank ful to you for your help. Regards -- AMINA SHAHZADI Department of Statistics GC University Lahore, Pakistan. Email: [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Making a case for using R in Academia
I would turn this on its head. The problem with social science grad schools is that students are not expected to know R. In my org doing psychometrics, we won't even consider an applicant if they only know SPSS. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Charilaos Skiadas Sent: Thursday, November 09, 2006 11:18 AM To: r-help@stat.math.ethz.ch Subject: Re: [R] Making a case for using R in Academia As a addendum to all this, this is one of the responses I got from one of my colleagues: The problem with R is that our students in many social science fields, are expected to know SPSS when they go to graduate school. Not having a background in SPSS would put these students at a disadvantage. Is this really the case? Does anyone have any such statistics? Charilaos Skiadas Department of Mathematics Hanover College P.O.Box 108 Hanover, IN 47243 __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] R crashing on linux
Hi everyone, I've had R crashing on rather repeatedly and I'd like to know if there's anything to be done with it. This is with R 2.3.0. That computer does not have R 2.4 installed on it. This is a Linux FC4 on 64bit processor. How to reproduce it: 1- ssh to server with X forwarding. 2- start R in a screen. 3- violently kill ssh on the client machine (in my case this is achieved by the machine crashing and rebooting with no warning) 4- reconnect to server and reattach screen. At this point the following message appears: Error: X11 fatal IO error: please save work and shut down R Complying, I try to quit: q() Save workspace image? [y/n/c]: y *** caught segfault *** address 0x68, cause 'memory not mapped' Possible actions: 1: abort (with core dump) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace Selection: At this point, selecting anything other than 1 will give a repeat of the same message. Interestingly, I do have .RData and .Rhistory with what looks like the proper objects and commands. I admit that this is a rather unusual situation caused by my client machine crashing repeatedly and my trying to work around it. I figure that R still shouldn't crash in this situation. Should I put that as bug report and have anyone else seen this? sessionInfo() Version 2.3.0 (2006-04-24) x86_64-unknown-linux-gnu attached base packages: [1] methods stats graphics grDevices utils datasets [7] base Francois __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] data storage/cubes and pointers in R
Hi all, I am faced with the situation where I want to store/analyze relatively large, organized sets of numerical data, which depend on a number of conditions (biological properties, exposure times, concentrations etc etc). Imagine about a hundred dataframes of a few thousand numerical values, with some annotation in text for some entries. Intuitively, I would like to be able to slice the data in a 'data- cube' kind of way to query, analyze, cluster, fit etc., which resembles the database data-cube way of thinking common in de db world these days. ( http://en.wikipedia.org/wiki/Data_cube ) I have no knowledge of a package that supports such things in an elegant way within R. If this exists, please point me to it. Also considering implementing a similar setup myself, I started wondering about the possibility of use references (or pointers aargh) to dataframes and store them in a list etc. Separate lists can then represent different 'views' on the shared instance dataframes etc. I have no knowledge if that is even possible in R, and if that is even the smart way to do it. If someone could provide some help, that would be great. Other option is of course to link to MySQL and do all data handling in that way. Also considering that. Any thoughts/hints would be appreciated ! thanks, Piet -- Dr. P. van Remortel Intelligent Systems Lab Dept. of Mathematics and Computer Science University of Antwerp Belgium http://www.islab.ua.ac.be +32 3 265 33 57 (secr.) [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] R crashing on linux
Francois Pepin [EMAIL PROTECTED] writes: Hi everyone, I've had R crashing on rather repeatedly and I'd like to know if there's anything to be done with it. This is with R 2.3.0. That computer does not have R 2.4 installed on it. This is a Linux FC4 on 64bit processor. How to reproduce it: 1- ssh to server with X forwarding. 2- start R in a screen. 3- violently kill ssh on the client machine (in my case this is achieved by the machine crashing and rebooting with no warning) 4- reconnect to server and reattach screen. At this point the following message appears: Error: X11 fatal IO error: please save work and shut down R Complying, I try to quit: q() Save workspace image? [y/n/c]: y *** caught segfault *** address 0x68, cause 'memory not mapped' Possible actions: 1: abort (with core dump) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace Selection: At this point, selecting anything other than 1 will give a repeat of the same message. Interestingly, I do have .RData and .Rhistory with what looks like the proper objects and commands. I admit that this is a rather unusual situation caused by my client machine crashing repeatedly and my trying to work around it. I figure that R still shouldn't crash in this situation. Should I put that as bug report and have anyone else seen this? Probably not. What you're seeing is R trying as hard as it can to get out of the mess and failing. The reason for the advice to quit R is exactly that the system is suspected of being in an inconsistent state. This has to do with low level X11 programming; the error comes from the I/O handler and the man page says The XSetIOErrorHandler sets the fatal I/O error handler. Xlib calls the program's supplied error handler if any sort of system call error occurs (for example, the connection to the server was lost). This is assumed to be a fatal condition, and the called routine should not return. If the I/O error handler does return, the client process exits. I.e. I think you're pretty much up the roof without a ladder when this occurs. sessionInfo() Version 2.3.0 (2006-04-24) x86_64-unknown-linux-gnu attached base packages: [1] methods stats graphics grDevices utils datasets [7] base Francois __ 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 and provide commented, minimal, self-contained, reproducible code. -- 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Making a case for using R in Academia
I haven't followed this thread, but I suggest you not judge solely from current and past usage, because I think R's market share is increasing everywhere, and it's increasing the fastest in two groups: (1) People who are price sensitive, e.g., the professors in New Zealand who produced the first prototype of R. (2) People involved in new algorithm development: R is the language of choice for a rapidly growing group of people involved in new algorithm development. If I see software that does something similar to what I want, if it's in R, I can get the source, walk through it line by line to see what it does and quickly modify it to see if my idea seems to work in my application. For commercial software, I've got to start from scratch. This increases the work required to learn and modify something by at least an order of magnitude. Because of this latter point, I now look for an R companion for technical books and articles I read: I will learn more, faster if R code exists than if it doesn't. Bottom line: You need to prepare your students for the future, not the past. Hope this helps. Spencer Graves Doran, Harold wrote: I would turn this on its head. The problem with social science grad schools is that students are not expected to know R. In my org doing psychometrics, we won't even consider an applicant if they only know SPSS. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Charilaos Skiadas Sent: Thursday, November 09, 2006 11:18 AM To: r-help@stat.math.ethz.ch Subject: Re: [R] Making a case for using R in Academia As a addendum to all this, this is one of the responses I got from one of my colleagues: The problem with R is that our students in many social science fields, are expected to know SPSS when they go to graduate school. Not having a background in SPSS would put these students at a disadvantage. Is this really the case? Does anyone have any such statistics? Charilaos Skiadas Department of Mathematics Hanover College P.O.Box 108 Hanover, IN 47243 __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Making a case for using R in Academia
On 11/9/06, Charilaos Skiadas [EMAIL PROTECTED] wrote: As a addendum to all this, this is one of the responses I got from one of my colleagues: The problem with R is that our students in many social science fields, are expected to know SPSS when they go to graduate school. Not having a background in SPSS would put these students at a disadvantage. One measure of the acceptance of R in various disciplines is the number of statistics texts that include R in the title. There was a recent post to this list from a representative of Chapman and Hall describing the texts based on R that they are currently offering. Springer has a special series of books on R and Wiley also offers several. At a recent statistics conference I was struck by the number of books featuring R that were prominently displayed on publishers' tables. If I recall correctly, all the publishers were featuring books based on R. As Spencer Graves mentions in another reply on this thread, interest in R is accelerating in many disciplines. An article in the latest issue of R News describes how R is now the standard software system for analysis of climate prediction data because it allows for reproducible research. Another way of measuring the trend in interest in R is to look at the publication dates of the texts that have R in the title. Most of them are very recent and their numbers are swelling compared to the number of texts that have SPSS in the title. I primarily teach engineering statistics where Minitab was used extensively but I see interest in Minitab waning, even in the engineering. I should mention that as a member of the R Development Core Team I cannot be considered a disinterested observer. P.S. I like Spencer's comment that You should be preparing your students for the future, not the past. That seems fortunes-worthy to me. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Parameter to show ticks ?
On Thu, 2006-11-09 at 07:56 -0800, Marc Feuerstein wrote: Hi there, is there a parameter in stripchart to control if the ticks (in the axis) are shown or not ? The only way I can see to do this easily is to set tcl to 0 in a par call, before you do the plotting: ## from example in ?stripchart opar - par(tcl = 0) with(OrchardSprays, stripchart(decrease ~ treatment, main = stripchart(Orchardsprays), ylab = decrease, vertical = TRUE, log = y)) par(opar) This is because doesn't have a ... argument to pass to other plotting functions like some plot functions have, and it doesn't have an 'axes' argument to suppress axis drawing - probably for good reason. Looking at the internals of stripchart, adding and argument tick = TRUE to stripchart which is used in call to axis() and Axis() in the code might do the trick. Thanks, Marc. HTH G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC ENSIS, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] dissimilarity matrices
Dear All, I have a dissimilarity matrix which I happily convert to a distance object by running: X - as.dist(Y) and I can happily now run either hclust(X) or agnes(X). So that the various bits of output are labelled correctly I would dearly like to be able to give names to the columns and rows of X, as would happen if I ran: mydata-read.table(clipboard,header=T) mydata2-t(mydata) mydists-dist(mydata2) Many thanks for your help. Best wishes, Kris Lockyear. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] data storage/cubes and pointers in R
Intuitively, I would like to be able to slice the data in a 'data- cube' kind of way to query, analyze, cluster, fit etc., which resembles the database data-cube way of thinking common in de db world these days. ( http://en.wikipedia.org/wiki/Data_cube ) I have no knowledge of a package that supports such things in an elegant way within R. If this exists, please point me to it. Have a look at the reshape package (http://had.co.nz/reshape) which supports some of these operations. Hadley __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] function
On 11/9/06, Bill Hunsicker [EMAIL PROTECTED] wrote: I am trying to create a function that i pass a data set to and have the function return some calculations based on data. Allow me to illustrate: myfunc - function(lst,mn,sd){ lst - sort(lst) mn - mean(lst) sd - sqrt(var(lst)) return(lst,mn,sd) } data1 -c (1,2,3,4,5) data2 - c(6,7,8,9,10) myfunc(data1,data1mn,data1sd) myfunc(data2,data2mn,data2sd) This snippet errors that data1mn not find and warns that return is deprecating!!! Can you help me? It is the returning a vector of arguments without wrapping them as a list that is deprecated. You do not need to pass values to be returned as arguments to the function. The simplest way of modifying your function is myfunc - function(dat) { mn - mean(dat) stddev - sd(dat) list(data = dat, mean = mn, sd = stddev) } You could even make it into a one-liner as myfunc - function(dat) list(data = dat, mean = mean(dat), sd = sd(dat)) but it would be better R programming style to do some checking on the argument 'dat' before trying to apply the mean and sd functions to it. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] function
On Thu, 2006-11-09 at 12:58 -0500, Bill Hunsicker wrote: R-help, I am trying to create a function that i pass a data set to and have the function return some calculations based on data. Allow me to illustrate: myfunc - function(lst,mn,sd){ lst - sort(lst) mn - mean(lst) sd - sqrt(var(lst)) return(lst,mn,sd) } data1 -c (1,2,3,4,5) data2 - c(6,7,8,9,10) myfunc(data1,data1mn,data1sd) myfunc(data2,data2mn,data2sd) This snippet errors that data1mn not find and warns that return is deprecating!!! Can you help me? Regards, Bill Bill, using return() in this fashion was deprecated in R version 1.8.0, which was released 3 years ago. From the ONEWS file: o The use of multi-argument return() calls is deprecated: use a (named) list instead. and from ?return: Warning: Prior to R 1.8.0, 'value' could be a series of non-empty expressions separated by commas. In that case the value returned is a list of the evaluated expressions, with names set to the expressions where these are the names of R objects. That is, 'a=foo()' names the list component 'a' and gives it value the result of evaluating 'foo()'. This has been deprecated (and a warning is given), as it was never documented in S, and whether or not the list is named differs by S versions. Thus: myfunc - function(lst,mn,sd){ lst - sort(lst) mn - mean(lst) sd - sqrt(var(lst)) list(lst = lst, mean = mn, sd = sd) } myfunc(data1,data1mn,data1sd) $lst [1] 1 2 3 4 5 $mean [1] 3 $sd [1] 1.581139 HTH, Marc Schwartz __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] function
On Thu, 2006-11-09 at 12:15 -0600, Marc Schwartz wrote: On Thu, 2006-11-09 at 12:58 -0500, Bill Hunsicker wrote: R-help, I am trying to create a function that i pass a data set to and have the function return some calculations based on data. Allow me to illustrate: myfunc - function(lst,mn,sd){ lst - sort(lst) mn - mean(lst) sd - sqrt(var(lst)) return(lst,mn,sd) } data1 -c (1,2,3,4,5) data2 - c(6,7,8,9,10) myfunc(data1,data1mn,data1sd) myfunc(data2,data2mn,data2sd) This snippet errors that data1mn not find and warns that return is deprecating!!! Can you help me? Regards, Bill Thus: myfunc - function(lst,mn,sd){ lst - sort(lst) mn - mean(lst) sd - sqrt(var(lst)) list(lst = lst, mean = mn, sd = sd) } Further tweak, no need to pass the 'mn' and 'sd' argument. Missed that the first time around: myfunc - function(lst){ lst - sort(lst) mn - mean(lst) sd - sqrt(var(lst)) list(lst = lst, mean = mn, sd = sd) } data1 - 5:1 data1 [1] 5 4 3 2 1 myfunc(data1) $lst [1] 1 2 3 4 5 $mean [1] 3 $sd [1] 1.581139 HTH, Marc __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] [Rd] How to link to vignette from .Rd file
Duncan Murdoch wrote: Actually how you built the .pdf is irrelevant, but it does look for file with the same name and one of these extensions: Rnw rnw Snw snw Rtex rtex Stex stex So you could just create a zero length file with the same basename and one of those extensions, and it should work. I don't know if this restriction is intentional. I wouldn't rely on this hack working in future versions. What if it creates an empty pdf file from the zero-length Rnw file or deletes the pdf file for the reason that the Rnw file is invalid. It is better to make the system recognize pdf files than to rely on dirty undocumented hacks, IMHO. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] [Rd] How to link to vignette from .Rd file
On 11/9/2006 1:15 PM, Agner Fog wrote: Duncan Murdoch wrote: Actually how you built the .pdf is irrelevant, but it does look for file with the same name and one of these extensions: Rnw rnw Snw snw Rtex rtex Stex stex So you could just create a zero length file with the same basename and one of those extensions, and it should work. I don't know if this restriction is intentional. I wouldn't rely on this hack working in future versions. What if it creates an empty pdf file from the zero-length Rnw file or deletes the pdf file for the reason that the Rnw file is invalid. It is better to make the system recognize pdf files than to rely on dirty undocumented hacks, IMHO. Actually this is documented to work. R doesn't assume it can build a vignette, so if you supply a .pdf in your source package, it will use that rather than trying to build one. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] random forest importance calculation
Hi all, I am using random forest (regression) and I am having trouble calculating the variable importance for my object (RF). Here is what I tried: RF$importance and importance(RF) The thing is that the reported %incMSE is different between those two. I understand that the function importance() does some re-scaling and averaging of the results, but does that mean that the order of variables with respect to importance changes after that? This is what I got: importance(RFcebus) %IncMSE IncNodePurity vbio128.34672 77950703 vbio429.34845 71261614 vbio12 43.6 126822944 vbio15 34.47683 151702649 vmodis 19.69951 18413449 vfootprint 23.31656 67756166 vgeotopo 30.06409 55710807 vcost_slope 51.85601 210008585 vlight0.0 0 vaccess30 182.90648 136540782 RFcebus$importance %IncMSE IncNodePurity vbio1 13171.572 77950703 vbio4 11617.453 71261614 vbio12 18330.536 126822944 vbio15 16786.781 151702649 vmodis 1736.843 18413449 vfootprint 10619.448 67756166 vgeotopo 8619.964 55710807 vcost_slope 25811.859 210008585 vlight 0.000 0 vaccess30 11037.952 136540782 Any suggestions would be appreciatted. Thanks, Naiara. [[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 and provide commented, minimal, self-contained, reproducible code.
[R] predict.lm variables found question
hello, I'm trying to predict some values based on a linear regression model. I've created the model using one dataframe, and have the prediction values in a second data frame (call it newdata). There are 56 rows in the dataframe used to create the model and 15 in newdata. I ran predict(model1, newdata) and get the warning: 'newdata' had 15 rows but variable(s) found have 56 rows When i checked help(predict.lm) I found this: Variables are first looked for in newdata and then searched for in the usual way (which will include the environment of the formula used in the fit). A warning will be given if the variables found are not of the same length as those in newdata if it was supplied. My questions are - how can I just get predicted values for the 15 rows in the newdata data frame, and if that's not possible, how can I tell which of the 56 predicted values are derived from newdata only, if any. Thanks in advance for your help. Larry __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] predict.lm variables found question
Larry White [EMAIL PROTECTED] writes: hello, I'm trying to predict some values based on a linear regression model. I've created the model using one dataframe, and have the prediction values in a second data frame (call it newdata). There are 56 rows in the dataframe used to create the model and 15 in newdata. I ran predict(model1, newdata) and get the warning: 'newdata' had 15 rows but variable(s) found have 56 rows When i checked help(predict.lm) I found this: Variables are first looked for in newdata and then searched for in the usual way (which will include the environment of the formula used in the fit). A warning will be given if the variables found are not of the same length as those in newdata if it was supplied. My questions are - how can I just get predicted values for the 15 rows in the newdata data frame, and if that's not possible, how can I tell which of the 56 predicted values are derived from newdata only, if any. You need to have all your predictors represented in newdata. You seem to have at least one of them missing (a typo in a variable name could do that). -- 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 and provide commented, minimal, self-contained, reproducible code.
[R] POSIXlt converted to POSIXct in as.data.frame()
In trying to use as.Date(), I've come across the conversion of POSIXlt to POSIXct when a POSIXlt variable is included in a data frame: my_POSIX - strptime(c(11-09-2006, 11-10-2006, 11-11-2006, 11-12-2006, 11-13-2006), %m-%d-%Y) str(my_POSIX) my_Date - as.Date(my_POSIX) str(my_Date) data - format(my_Date) str(data) my_DF - data.frame(my_POSIX) str(my_DF) DF_Date - as.Date(my_DF$my_POSIX) str(DF_Date) DF_Date The consequence (for my LC_TIME and machine time zone) is that when as.Date() is applied to the data frame column, it dispatches on as.Date.POSIXct() not as.Date.POSIXlt(), causing a day shift (actually 60 minutes, but because as.Date.POSIXct() says floor(), it ends up being a whole day). Should data.frame() be changing POSIXlt to POSIXct? As as.data.frame.POSIXlt() is written, it says: as.data.frame.POSIXlt function (x, row.names = NULL, optional = FALSE, ...) { value - as.data.frame.POSIXct(as.POSIXct(x), row.names, optional, ...) if (!optional) names(value) - deparse(substitute(x))[[1]] value } environment: namespace:base which seems a little brutal. Using I() seems to be a work-around: my_DF - data.frame(my_POSIXa=I(my_POSIX)) str(my_DF) class(my_DF$my_POSIXa) DF_Date - as.Date(my_DF$my_POSIXa) str(DF_Date) DF_Date In the original problem (conversion of a list read from PostgreSQL to a data frame with as.data.frame()), having to know that you need to insert I() is perhaps unexpected. Roger -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sweave, R and complex latex projects
All, This is an update to my previous query on dealing with complex (complex in my eyes anyway) LaTeX/Sweave projects. Based on the work of others, please see my current thesis Makefile below. I didn't get Sweave and LaTeX to cope with a master document in one directory, and chapters in subdirectories, so instead I moved all individual chapter .tex and .Rnw files into the same directory. The only reason for having directories in the first place was to group all the charts and tables etc. and Sweave makes that unnecessary anyway. The other issue is that Sweave can interact with typeface settings in a LaTeX document. One may avoid this by using the [noae] option, or just making sure any typeface directives (including \usepackage{times}) come after the \usepackage{Sweave} directive in your master LaTeX document. I hope this is of help to someone else... No guarantees as I am not a Makefile expert! # # Makefile # # # Global project Makefile # # # This makefile was based on # http://209.85.135.104/search?q=cache:-fU4UEn36AgJ:kriemhild.uft.uni-bremen.de/viewcvs/Makefile.rnoweb+makefile+sweave+latexhl=enct=clnkcd=10client=safari # (The original file found on Google is no longer available and I couldn't track a new version) # This is credited to Johannes Ranke, based on work by Nicholas Lewin-Koh and Rouben Rostmaian, and also from Deepayan Sarkar's email on the R-help mailing list. # # The master document (document preamble, \include's the other files) is thesis.tex MASTER = thesis.pdf # the master document depends on all of the tex files RNWFILES = $(wildcard *.Rnw) TEXFILES = $(wildcard *.tex) DEPENDS = $(patsubst %.Rnw,%.tex,$(RNWFILES)) $(TEXFILES) RERUN = (There were undefined references|Rerun to get (citations|cross-references|the bars) (correct|right)|Table widths have changed. Rerun LaTeX.|Linenumber reference failed) RERUNBIB = No file.*\.bbl|Citation.*undefined all: $(MASTER) $(MASTER): $(DEPENDS) %.tex: %.Rnw R CMD SWEAVE '$' %.pdf: %.tex @pdflatex $ @egrep -c $(RERUNBIB) $*.log (bibtex $*;pdflatex $); true @egrep $(RERUN) $*.log (pdflatex $) ; true @egrep $(RERUN) $*.log (pdflatex $) ; true clean: @rm -f *.aux *.log *.bbl *.blg *.brf *.cb *.ind *.idx *.ilg \ *.inx *.ps *.dvi *.toc *.out *.lot *~ *.lof *.ttt *.fff \ *.eps *.pdf @rm -f $(patsubst %.Rnw,%.tex,$(RNWFILES)) -- Dr. Mark Wardle Clinical research fellow and Specialist Registrar in Neurology, C2-B2 link, Cardiff University, Heath Park, CARDIFF, CF14 4XN. UK __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Variance Functions in lme
Using the weight argument with a variance function in lme (nlme), you can allow for heteroscedasticity of the within-group error. Is there a way to do this for the other variance components? For example, suppose you had subjects, days nested within subjects, and visits nested within days within subjects (a fully nested two-way design) and you had, say men and women subjects. Could you allow for differences in the variance components for men and women? Rick B. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Variance Functions in lme
Rick, most likely, either by using the varIdent class, or conditioning the varPower class on sex. See p. 177, and 208-225 of Pinheiro and Bates. As usual, it's best to frame your question so that the list can send you some relevant code. If you'd like a more focused answer, I suggest that you write some code that generates a sample dataset such as you describe below. Andrew On Thu, Nov 09, 2006 at 02:43:54PM -0500, Rick Bilonick wrote: Using the weight argument with a variance function in lme (nlme), you can allow for heteroscedasticity of the within-group error. Is there a way to do this for the other variance components? For example, suppose you had subjects, days nested within subjects, and visits nested within days within subjects (a fully nested two-way design) and you had, say men and women subjects. Could you allow for differences in the variance components for men and women? Rick B. __ 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 and provide commented, minimal, self-contained, reproducible code. -- Andrew Robinson Department of Mathematics and StatisticsTel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 http://www.ms.unimelb.edu.au/~andrewpr http://blogs.mbs.edu/fishing-in-the-bay/ __ R-help@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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] data storage/cubes and pointers in R
What kind of operations do you need to be able to do? I frequently use 3 and higher dimensional arrays for storing data, and then I use indexing operations to extract slices of data, or sometimes apply() and friends to process the data. The abind() function (in the 'abind' package) will bind together vectors and arrays into higher dimensional arrays -- it might come in handy for you. -- Tony Plate Piet van Remortel wrote: Hi all, I am faced with the situation where I want to store/analyze relatively large, organized sets of numerical data, which depend on a number of conditions (biological properties, exposure times, concentrations etc etc). Imagine about a hundred dataframes of a few thousand numerical values, with some annotation in text for some entries. Intuitively, I would like to be able to slice the data in a 'data- cube' kind of way to query, analyze, cluster, fit etc., which resembles the database data-cube way of thinking common in de db world these days. ( http://en.wikipedia.org/wiki/Data_cube ) I have no knowledge of a package that supports such things in an elegant way within R. If this exists, please point me to it. Also considering implementing a similar setup myself, I started wondering about the possibility of use references (or pointers aargh) to dataframes and store them in a list etc. Separate lists can then represent different 'views' on the shared instance dataframes etc. I have no knowledge if that is even possible in R, and if that is even the smart way to do it. If someone could provide some help, that would be great. Other option is of course to link to MySQL and do all data handling in that way. Also considering that. Any thoughts/hints would be appreciated ! thanks, Piet -- Dr. P. van Remortel Intelligent Systems Lab Dept. of Mathematics and Computer Science University of Antwerp Belgium http://www.islab.ua.ac.be +32 3 265 33 57 (secr.) [[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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Algorithm needed
I have a matrix of size n and I want to create a new one in which the columns are sums of the original matrix, with some order in the sums. For example, if matrix A has 4 columns, then the new matrix should have 6 columns with the following info from the columns of A: 1+2, 1+3, 1+4, 2+3, 2+4, 3+4. If matrix A has 5 columns, then the new matrix has 10 columns: 1+2, 1+3, 1+4, 1+5, 2+3, 2+4, 2+5, 3+4, 3+5, 4+5 I thought of using a for loop: for (i in 1:n-1) { for (j in (i+1):n) { A[,i] + A[,j] } } but I don't know how to store the results so the new matrix has all the columns. I know the number of columns in the new matrix is given by n(n-1)/2. Any ideas? Thanks. Hiram __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Single precision data behaviour with readBin()
Hi all, I am running R version 2.4.0 (2006-10-03) on an i686 pc with Mandrake 10.2 Linux. I was given a binary data file containing single precision numbers that I would like to read into R. In a previous posting, someone suggested reading in such data as double(), which is what I've tried: zz - file(file, rb) h1 - readBin(con = zz, what = double(), n = 1, size = 4) h1 [1] 0.050007451 Except that I know that the first value should be exactly 0.05. To get rid of the unwanted (or really unknown) values, I try using signif(), which gives me: h1 - signif(h1, digits = 8) h1 [1] 0.05001 I suppose I could use: h1 - signif(h1, digits = 7) h1 [1] 0.05 But this does not seem ideal to me. Apparently I don't understand machine precision very well, because I don't understand where the extra values are coming from. So I also don't know if this use of signif() will be reliable for all possible values. What about a value of 1.2e-8? Will this be read in as: signif(1.2034e-8, digits = 7) [1] 1.2e-08 or could this occur?: signif(1.234e-8, digits = 7) [1] 1.23e-08 Thanks for any advice. Eric Thompson Graduate Student Tufts University Civil Environmental Engineering Medford, MA 02144 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] 2007 John M. Chambers Statistical Software Award
(sorry for cross-posting) John M. Chambers Statistical Software Award Statistical Computing Section American Statistical Association The Statistical Computing Section of the American Statistical Association announces the competition for the John M. Chambers Statistical Software Award. In 1998 the Association for Computing Machinery presented its Software System Award to John Chambers for the design and development of S. Dr. Chambers generously donated his award to the Statistical Computing Section to endow an annual prize for statistical software written by an undergraduate or graduate student. The prize carries with it a cash award of $1000, plus a substantial allowance for travel to the annual Joint Statistical Meetings where the award will be presented. Teams of up to 3 people can participate in the competition, with the cash award being split among team members. The travel allowance will be given to just one individual in the team, who will be presented the award at JSM. To be eligible, the team must have designed and implemented a piece of statistical software. The individual within the team indicated to receive the travel allowance must have begun the development while a student, and must either currently be a student, or have completed all requirements for her/his last degree after January 1, 2004. To apply for the award, teams must provide the following materials: Current CV's of all team members. A letter from a faculty mentor at the academic institution of the individual indicated to receive the travel award. The letter should confirm that the individual had substantial participation in the development of the software, certify her/his student status when the software began to be developed (and either the current student status or the date of degree completion), and briefly discuss the importance of the software to statistical practice. A brief, one to two page description of the software, summarizing what it does, how it does it, and why it is an important contribution. If the team member competing for the travel allowance has continued developing the software after finishing her/his studies, the description should indicate what was developed when the individual was a student and what has been added since. Access to the software by the award committee for their use on inputs of their choosing. Access to the software can consist of an executable file, Web-based access, macro code, or other appropriate form. Access should be accompanied by enough information to allow the judges to effectively use and evaluate the software (including its design considerations.) This information can be provided in a variety of ways, including but not limited to a user manual (paper or electronic), a paper, a URL, online help to the system, and source code. In particular, the entrant must be prepared to provide complete source code for inspection by the committee if requested. All materials must be in English. We prefer that electronic text be submitted in Postscript or PDF. The entries will be judged on a variety of dimensions, including the importance and relevance for statistical practice of the tasks performed by the software, ease of use, clarity of description, elegance and availability for use by the statistical community. Preference will be given to those entries that are grounded in software design rather than calculation. The decision of the award committee is final. All application materials must be received by 5:00pm EST, Monday, February 26, 2007 at the address below. The winner will be announced in May and the award will be given at the 2007 Joint Statistical Meetings. Information on the competition can also be accessed on the website of the Statistical Computing Section (www.statcomputing.org or see the ASA website, www.amstat.org for a pointer), including the names and contributions of previous winners. Inquiries and application materials should be emailed or mailed to: Chambers Software Award c/o J.R. Lockwood The RAND Corporation 4570 Fifth Avenue, Suite 600 Pittsburgh, PA 15213 [EMAIL PROTECTED] This email message is for the sole use of the intended recip...{{dropped}} __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Making a case for using R in Academia
Dear Charilaos, It's very difficult to give definitive answers to the questions that you pose because we don't have any good data (at least as far as I know) about how widely R is used. I recall a claim, I think on the r-help list, that R is now second to SAS in use world-wide, but I'm not sure how one would establish that. I do, however, have anecdotal evidence about R use that may be of some help, and perhaps others can contribute their impressions, especially if they differ from mine. I think that it's fair to say that the S language is more or less the standard among statisticians, and that R has now far surpassed S-PLUS in use. For rough evidence one could look, for example, to the relative levels of activity on the r-help and s-news email lists. Among social scientists the picture is not as clear. My impression is that SPSS is used very widely for low-levels methods courses taught to undergraduates, and not very extensively in the best social-science graduate programmes. I would expect that, at present, Stata use in social-science graduate programmes exceeds R, and that SAS and R would also be used fairly widely. In my opinion, these are the only reasonable choices -- I don't think that SPSS is sufficiently capable to compete with R, Stata, or SAS. There are, for example, several different packages used at the ICPSR Summer Program in Quantitative Methods for Social Research, but several relatively advanced courses now use R. Likewise, the Oxford Spring School, hosted by the Department of Politics and International Relations at Oxford, has mostly employed R and Stata. Of course, my own preference is for R. Regards, John John Fox Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Charilaos Skiadas Sent: Thursday, November 09, 2006 11:18 AM To: r-help@stat.math.ethz.ch Subject: Re: [R] Making a case for using R in Academia As a addendum to all this, this is one of the responses I got from one of my colleagues: The problem with R is that our students in many social science fields, are expected to know SPSS when they go to graduate school. Not having a background in SPSS would put these students at a disadvantage. Is this really the case? Does anyone have any such statistics? Charilaos Skiadas Department of Mathematics Hanover College P.O.Box 108 Hanover, IN 47243 __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] command for stopping and then hit return and continue (fwd)
-- Forwarded message -- Date: Thu, 9 Nov 2006 16:38:46 -0500 From: Leeds, Mark (IED) [EMAIL PROTECTED] To: Leeds, Mark (IED) [EMAIL PROTECTED] Subject: command for stopping and then hit return and continue when i do sequential plotting, i use the park(ask=TRUE) command so that when a plot is plotted, i have to hit the return key before it goes to the next one. is it possible to implement the same sort of thing when you aren't plotting. in other words, i am in a loop and each time through the loop i want to print a set of values, have it stop, then only have it continue when i hit return ? thanks. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] data storage/cubes and pointers in R
Look at using netcdf files (http://www.unidata.ucar.edu/software/netcdf/), and one of several R packages for manipulating netcdf files, such as ncdf. -Roy At 2:12 PM -0700 11/9/06, Tony Plate wrote: What kind of operations do you need to be able to do? I frequently use 3 and higher dimensional arrays for storing data, and then I use indexing operations to extract slices of data, or sometimes apply() and friends to process the data. The abind() function (in the 'abind' package) will bind together vectors and arrays into higher dimensional arrays -- it might come in handy for you. -- Tony Plate Piet van Remortel wrote: Hi all, I am faced with the situation where I want to store/analyze relatively large, organized sets of numerical data, which depend on a number of conditions (biological properties, exposure times, concentrations etc etc). Imagine about a hundred dataframes of a few thousand numerical values, with some annotation in text for some entries. Intuitively, I would like to be able to slice the data in a 'data- cube' kind of way to query, analyze, cluster, fit etc., which resembles the database data-cube way of thinking common in de db world these days. ( http://en.wikipedia.org/wiki/Data_cube ) I have no knowledge of a package that supports such things in an elegant way within R. If this exists, please point me to it. Also considering implementing a similar setup myself, I started wondering about the possibility of use references (or pointers aargh) to dataframes and store them in a list etc. Separate lists can then represent different 'views' on the shared instance dataframes etc. I have no knowledge if that is even possible in R, and if that is even the smart way to do it. If someone could provide some help, that would be great. Other option is of course to link to MySQL and do all data handling in that way. Also considering that. Any thoughts/hints would be appreciated ! thanks, Piet -- Dr. P. van Remortel Intelligent Systems Lab Dept. of Mathematics and Computer Science University of Antwerp Belgium http://www.islab.ua.ac.be +32 3 265 33 57 (secr.) [[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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code. -- ** The contents of this message do not reflect any position of the U.S. Government or NOAA. ** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center 1352 Lighthouse Avenue Pacific Grove, CA 93950-2097 e-mail: [EMAIL PROTECTED] (Note new e-mail address) voice: (831)-648-9029 fax: (831)-648-8440 www: http://www.pfeg.noaa.gov/ Old age and treachery will overcome youth and skill. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Single precision data behaviour with readBin()
Hi, what you are observing is the fact that there is always a limit in the precision a floating-point values can be stored. The value you are trying to read is stored in 4 bytes (floats). For higher precision, the value could be stored in 8 bytes (doubles). BTW, R works with 8 byte floating-toint values. Example illustrating this (R --vanilla): # Write data x - 0.05 writeBin(x, con=float.bin, size=4) writeBin(x, con=double.bin, size=8) # Read data yF - readBin(float.bin, what=double, size=4) yD - readBin(double.bin, what=double, size=8) # Display data with different precisions options(digits=7) # Default in R (unless you change it) getOption(digits) [1] 7 yF [1] 0.05 yD [1] 0.05 options(digits=8) yF [1] 0.05001 yD [1] 0.05 options(digits=12) yF [1] 0.050007451 yD [1] 0.05 # Difference between 0.5 stored as double and float log10(abs(yD-yF)) [1] -9.12780988455 # Eventually you will see the same for doubles too: options(digits=22) 1e-24 [1] 9.99924e-25 Hope this helps! Henrik On 11/10/06, Eric Thompson [EMAIL PROTECTED] wrote: Hi all, I am running R version 2.4.0 (2006-10-03) on an i686 pc with Mandrake 10.2 Linux. I was given a binary data file containing single precision numbers that I would like to read into R. In a previous posting, someone suggested reading in such data as double(), which is what I've tried: zz - file(file, rb) h1 - readBin(con = zz, what = double(), n = 1, size = 4) h1 [1] 0.050007451 Except that I know that the first value should be exactly 0.05. To get rid of the unwanted (or really unknown) values, I try using signif(), which gives me: h1 - signif(h1, digits = 8) h1 [1] 0.05001 I suppose I could use: h1 - signif(h1, digits = 7) h1 [1] 0.05 But this does not seem ideal to me. Apparently I don't understand machine precision very well, because I don't understand where the extra values are coming from. So I also don't know if this use of signif() will be reliable for all possible values. What about a value of 1.2e-8? Will this be read in as: signif(1.2034e-8, digits = 7) [1] 1.2e-08 or could this occur?: signif(1.234e-8, digits = 7) [1] 1.23e-08 Thanks for any advice. Eric Thompson Graduate Student Tufts University Civil Environmental Engineering Medford, MA 02144 __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Single precision data behaviour with readBin()
On 11/9/2006 4:20 PM, Eric Thompson wrote: Hi all, I am running R version 2.4.0 (2006-10-03) on an i686 pc with Mandrake 10.2 Linux. I was given a binary data file containing single precision numbers that I would like to read into R. In a previous posting, someone suggested reading in such data as double(), which is what I've tried: zz - file(file, rb) h1 - readBin(con = zz, what = double(), n = 1, size = 4) h1 [1] 0.050007451 Except that I know that the first value should be exactly 0.05. That's impossible. You can't represent 0.05 in either single or double precision floats. What you're seeing is the error in the single precision version of its representation. Duncan Murdoch To get rid of the unwanted (or really unknown) values, I try using signif(), which gives me: h1 - signif(h1, digits = 8) h1 [1] 0.05001 I suppose I could use: h1 - signif(h1, digits = 7) h1 [1] 0.05 But this does not seem ideal to me. Apparently I don't understand machine precision very well, because I don't understand where the extra values are coming from. So I also don't know if this use of signif() will be reliable for all possible values. What about a value of 1.2e-8? Will this be read in as: signif(1.2034e-8, digits = 7) [1] 1.2e-08 or could this occur?: signif(1.234e-8, digits = 7) [1] 1.23e-08 Thanks for any advice. Eric Thompson Graduate Student Tufts University Civil Environmental Engineering Medford, MA 02144 __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] optimize function with integral form ?
Hi all, Does anybody have the experience of using optim to estimate variables with integral forms? here the code: trun.mean- function(x) # t is the threshold { mu=x[1]; sigma=x[2]; t=x[3]; f - function(x) (1/(sigma*sqrt(2*pi)))*exp(-(x-mu)^2/(2*sigma^2)); pdf.fun - function(x) x*f(x); integrate(f,thre,upper=Inf)$value/integrate(pdf.fun,thre,upper=Inf)$value ; } when I run : optim(c(200,100,113),trun.mean) Error in optim(c(2, 3, 3), trun.mean) : function cannot be evaluated at initial parameters I need your help, thanks! Jen. [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Algorithm needed
[EMAIL PROTECTED] writes: I have a matrix of size n and I want to create a new one in which the columns are sums of the original matrix, with some order in the sums. For example, if matrix A has 4 columns, then the new matrix should have 6 columns with the following info from the columns of A: 1+2, 1+3, 1+4, 2+3, 2+4, 3+4. If matrix A has 5 columns, then the new matrix has 10 columns: 1+2, 1+3, 1+4, 1+5, 2+3, 2+4, 2+5, 3+4, 3+5, 4+5 I thought of using a for loop: for (i in 1:n-1) { for (j in (i+1):n) { A[,i] + A[,j] } } but I don't know how to store the results so the new matrix has all the columns. I know the number of columns in the new matrix is given by n(n-1)/2. Any ideas? Thanks. This should work in 2.4.0 n - ncol(A) cmb - combn(n,2) res - A[,cmb[1,]] + A[,cmb[2,]] -- 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Making a case for using R in Academia
John (and everyone else), On Nov 9, 2006, at 4:20 PM, John Fox wrote: Dear Charilaos, It's very difficult to give definitive answers to the questions that you pose because we don't have any good data (at least as far as I know) about how widely R is used. Yes it certainly isn't an easy question to answer, and I don't necessarily need complete data. The situation as presented to me by my colleagues in the Social Sciences is really that SPSS is the standard, so I am basically hoping for evidence to just shake this view (unless it is true, but I have to say I doubt it). I am more hoping for particular examples of cases in the Social Sciences, where SPSS is far from the standard, and the programs and schools you mention below are exactly the sort of thing I was looking for! For now unfortunately we will be sticking with SPSS, despite the considerable cost (which was mainly our problem at the moment, so SAS is not even being considered for that reason), but I am hoping to slowly build enough evidence of the extensive use of R for when all this comes up again. Even just a list of the universities and departments that use it would be very helpful, so any of you who would like to send such information about your departments or other departments you might know about, off the list, it would be extremely helpful to me. Perhaps it would be useful for such a list to exist somewhere online? (I guess you could say google, but I find it hard to use google to look up such information on R, for the obvious reason of the shortness of the name. [snip] Among social scientists the picture is not as clear. My impression is that SPSS is used very widely for low-levels methods courses taught to undergraduates, and not very extensively in the best social-science graduate programmes. I would expect that, at present, Stata use in social- science graduate programmes exceeds R, and that SAS and R would also be used fairly widely. In my opinion, these are the only reasonable choices -- I don't think that SPSS is sufficiently capable to compete with R, Stata, or SAS. There are, for example, several different packages used at the ICPSR Summer Program in Quantitative Methods for Social Research, but several relatively advanced courses now use R. Likewise, the Oxford Spring School, hosted by the Department of Politics and International Relations at Oxford, has mostly employed R and Stata. Thanks, I will be looking into those. I basically just need to look at various universities and their social sciences departments, and see what they use there. As other suggested, I will be looking into the number of books and papers in R and how it is increasing every year. Once again thank you all for your comments, this has been a very helpful discussion for me, and it's a great pleasure to find such a helpful and friendly mailing list. Of course, my own preference is for R. Regards, John Haris __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Algorithm needed
On Thu, 2006-11-09 at 22:32 +0100, Peter Dalgaard wrote: [EMAIL PROTECTED] writes: I have a matrix of size n and I want to create a new one in which the columns are sums of the original matrix, with some order in the sums. For example, if matrix A has 4 columns, then the new matrix should have 6 columns with the following info from the columns of A: 1+2, 1+3, 1+4, 2+3, 2+4, 3+4. If matrix A has 5 columns, then the new matrix has 10 columns: 1+2, 1+3, 1+4, 1+5, 2+3, 2+4, 2+5, 3+4, 3+5, 4+5 I thought of using a for loop: for (i in 1:n-1) { for (j in (i+1):n) { A[,i] + A[,j] } } but I don't know how to store the results so the new matrix has all the columns. I know the number of columns in the new matrix is given by n(n-1)/2. Any ideas? Thanks. This should work in 2.4.0 n - ncol(A) cmb - combn(n,2) res - A[,cmb[1,]] + A[,cmb[2,]] Peter, May I suggest that there be reciprocal See Alsos added to ?expand.grid and ?combn. I had forgotten that this was added to 2.4.0, initially looked at the former to begin a solution and then finally decided to propose: do.call(cbind, sapply(2:ncol(A), function(x) A[, x - 1] + A[, x:ncol(mat)])) which is certainly more cumbersome, albeit a single line of code. I then noted your reply, which of course sparked my aging neurons... Thanks for the consideration. Regards, Marc __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] optimize function with integral form ?
Hi Jenny, whenever a function that calls a function complains about the function it is calling, it helps to try to run that function yourself. So, I declared your function trun.mean as below and tried to call it: trun.mean(c(200,100,113)) Error in integrate(f, thre, upper = Inf) : object thre not found This might help you identify the current, and possibly future, errors. Cheers Andrew On Thu, Nov 09, 2006 at 02:32:18PM -0700, Jenny Stadt wrote: Hi all, Does anybody have the experience of using optim to estimate variables with integral forms? here the code: trun.mean- function(x) # t is the threshold { mu=x[1]; sigma=x[2]; t=x[3]; f - function(x) (1/(sigma*sqrt(2*pi)))*exp(-(x-mu)^2/(2*sigma^2)); pdf.fun - function(x) x*f(x); integrate(f,thre,upper=Inf)$value/integrate(pdf.fun,thre,upper=Inf)$value ; } when I run : optim(c(200,100,113),trun.mean) Error in optim(c(2, 3, 3), trun.mean) : function cannot be evaluated at initial parameters I need your help, thanks! Jen. [[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 and provide commented, minimal, self-contained, reproducible code. -- Andrew Robinson Department of Mathematics and StatisticsTel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 http://www.ms.unimelb.edu.au/~andrewpr http://blogs.mbs.edu/fishing-in-the-bay/ __ R-help@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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] data storage/cubes and pointers in R
In case the other replies aren't to your liking, and you want to write something yourself... Piet van Remortel [EMAIL PROTECTED] writes: [snip] Also considering implementing a similar setup myself, I started wondering about the possibility of use references (or pointers aargh) to dataframes and store them in a list etc. Separate lists My own experimentation with this is to create an S4 'View' class that indexes / subsets / accesses small parts of the 'big' data, with the actual data treated essentially as 'read-only' or otherwise abstracted out of memory. Something along the lines of setClass(ViewSet, representation=representation( data=environment, # environments are reference-like idx=list # 1 element per dimension, or something more clever )) setMethod(initialize, signature(.Object=ViewSet), function(.Object, ...) { env - new.env() ## get the big data: arguments to new / SQL query / ??? ## assign big data to env (e.g., see below) then [EMAIL PROTECTED] - env ## set up idx ## ... .Object }) setMethod([, signature(x=ViewSet), function (x, i, j, ..., drop = TRUE) { ## adjust [EMAIL PROTECTED], maybe querying [EMAIL PROTECTED] for help }) setReplaceMethod([, signature(x=ViewSet), function (x, i, j, ..., value) ## adjust [EMAIL PROTECTED], j, ... ## return x, i.e., a ViewSet -- bigData not changed / copied }) can then represent different 'views' on the shared instance dataframes etc. I have no knowledge if that is even possible in R, and if that is even the smart way to do it. If someone could provide some help, that would be great. Other option is of course to link to MySQL and do all data handling in that way. Also considering that. or do both, i.e., write ViewSqlSet to 'contain' ViewSet, etc. Any thoughts/hints would be appreciated ! Probably you could implement the same ideas in the less intimidating S3 way, using e.g., a list with makeView - function(data) { ## e.g., 'data' a named list of commonly-sized elements, in or out ## of memory -- details depend on needs env - new.env() for (elt in names(data)) env[[elt]] - data[[elt]] ## initialize index idx - list(rows=1:nrow(data[[1]]), cols=1:ncol(data[[1]])) lst - list(env=env, idx=idx) class(lst) - View lst } [.View - function (x, i, j, ..., drop = TRUE) { ## x will be like lst from above, use i, j, etc to subset ## adjust and then return idx, e.g.,... x$idx$rows - x$idx$rows[i] x } getData - function(x, ...) UseMethod(getData) getData.View - function(x, ...) { ## return list of subsetted elements res - with(x, lapply(ls(env), function(elt) env[[elt]][idx$rows, idx$cols])) names(res) - ls(x$env) res } and then... bigView - makeView(list(df=data.frame(x=1:100, y=100:1), + m=matrix(1:200, ncol=2))) smallView - bigView[1:5,] getData(smallView) ## copies, but only the 'small' data $df x y 5 5 96 4 4 97 3 3 98 2 2 99 1 1 100 $m [,1] [,2] [1,]5 105 [2,]4 104 [3,]3 103 [4,]2 102 [5,]1 101 Obviously a hack, but perhaps it gets you going... thanks, Piet -- Dr. P. van Remortel Intelligent Systems Lab Dept. of Mathematics and Computer Science University of Antwerp Belgium http://www.islab.ua.ac.be +32 3 265 33 57 (secr.) [[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 and provide commented, minimal, self-contained, reproducible code. -- Martin T. Morgan Bioconductor / Computational Biology http://bioconductor.org __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Algorithm needed
On 09-Nov-06 [EMAIL PROTECTED] wrote: I have a matrix of size n and I want to create a new one in which the columns are sums of the original matrix, with some order in the sums. For example, if matrix A has 4 columns, then the new matrix should have 6 columns with the following info from the columns of A: 1+2, 1+3, 1+4, 2+3, 2+4, 3+4. If matrix A has 5 columns, then the new matrix has 10 columns: 1+2, 1+3, 1+4, 1+5, 2+3, 2+4, 2+5, 3+4, 3+5, 4+5 I thought of using a for loop: for (i in 1:n-1) { for (j in (i+1):n) { A[,i] + A[,j] } } but I don't know how to store the results so the new matrix has all the columns. I know the number of columns in the new matrix is given by n(n-1)/2. Any ideas? Thanks. Hiram What an intriguing little question! The natural place to look for all the combinations of 2 out of n (in the order you require) is the function combn() in the package combinat. Then I noticed the argument fun in ?combn, which led to the following (using a simple example): library(combinat) A-cbind(c(1,2,3,4),c(1,3,5,7),c(1,4,7,10),c(1,5,9,13)) A # [,1] [,2] [,3] [,4] # [1,]1111 # [2,]2345 # [3,]3579 # [4,]47 10 13 summit-function(y)(rowSums(A[,y])) S-combn((1:4),2,fun=summit) S # [,1] [,2] [,3] [,4] [,5] [,6] # [1,]222222 # [2,]567789 # [3,]8 10 12 12 14 16 # [4,] 11 14 17 17 20 23 so it looks as though this will do exactly what you want! Thanks for asking the question: I hadn't spotted this very useful feature of combn() before. Best wishes, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 09-Nov-06 Time: 22:36:38 -- XFMail -- __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Making a case for using R in Academia
I would just like to add a comment to this thread that a good reason to use R is that it's so ***EASY*** to use! You can get R to do what ***you*** want. E.g. I want to set my students an exercise in which they simulate a data set from a certain distribution (using the inverse probability transform), plot a histogram of the resulting data on a density scale, and then superimpose a graph of the probability density function. The class I am teaching uses Minitab (which is a pretty good package, but ). The last item --- superimpose a graph --- CANNOT be done in Minitab. Fitted densities from a list specified by Minitab can be superimposed, but not a density that you have specified which is off that list. It's incredibly frustrating. In R, of course, it's so easy that falling off a log is difficult by comparison. cheers, Rolf Turner [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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Algorithm needed
On Thu, 2006-11-09 at 16:24 -0600, Marc Schwartz wrote: On Thu, 2006-11-09 at 22:32 +0100, Peter Dalgaard wrote: [EMAIL PROTECTED] writes: I have a matrix of size n and I want to create a new one in which the columns are sums of the original matrix, with some order in the sums. For example, if matrix A has 4 columns, then the new matrix should have 6 columns with the following info from the columns of A: 1+2, 1+3, 1+4, 2+3, 2+4, 3+4. If matrix A has 5 columns, then the new matrix has 10 columns: 1+2, 1+3, 1+4, 1+5, 2+3, 2+4, 2+5, 3+4, 3+5, 4+5 I thought of using a for loop: for (i in 1:n-1) { for (j in (i+1):n) { A[,i] + A[,j] } } but I don't know how to store the results so the new matrix has all the columns. I know the number of columns in the new matrix is given by n(n-1)/2. Any ideas? Thanks. This should work in 2.4.0 n - ncol(A) cmb - combn(n,2) res - A[,cmb[1,]] + A[,cmb[2,]] Peter, May I suggest that there be reciprocal See Alsos added to ?expand.grid and ?combn. I had forgotten that this was added to 2.4.0, initially looked at the former to begin a solution and then finally decided to propose: do.call(cbind, sapply(2:ncol(A), function(x) A[, x - 1] + A[, x:ncol(mat)])) Speaking of aging neurons, that should be: do.call(cbind, sapply(2:ncol(A), function(x) A[, x - 1] + A[, x:ncol(A)])) I accidentally left that last 'mat' in there from testing... Marc __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] optimize function with integral form ?
Thank you Andrew for the nice suggestion. I found out the mistake I made in the code. Here is the complete function with the problem of optimization. trun.mean- function(x) { mu=x[1]; sigma=x[2]; thre=x[3]; f - function(x) (1/(sigma*sqrt(2*pi)))*exp(-(x-mu)^2/(2*sigma^2)); pdf.fun - function(x) x*f(x); sd.fun - function(x) x^2*f(x); a=integrate(pdf.fun,thre,upper=Inf)$value; a1=integrate(f,thre,upper=Inf)$value; st=integrate(sd.fun,thre,upper=Inf)$value; mut - a/a1; sdt - sqrt(st/a1-(a/a1)^2) (mut-mu)^2+(sdt-sd)^2 } I need to minimize trun.mean ( ), so I tried trun.mean(c(100,20,13)) [1] 399200454 optim(c(200,100,112),trun.mean); Error in integrate(f, thre, upper = Inf) : roundoff error is detected in the extrapolation table Thanks! Jenny -Original Message- From:Andrew Robinson , [EMAIL PROTECTED] Sent: 2006-11-09, 15:14:58 To: Jenny Stadt CC:r-help@stat.math.ethz.ch Subject: Re: [R] optimize function with integral form ? Hi Jenny, whenever a function that calls a function complains about the function it is calling, it helps to try to run that function yourself. So, I declared your function trun.mean as below and tried to call it: trun.mean(c(200,100,113)) Error in integrate(f, thre, upper = Inf) : object thre not found This might help you identify the current, and possibly future, errors. Cheers Andrew On Thu, Nov 09, 2006 at 02:32:18PM -0700, Jenny Stadt wrote: Hi all, Does anybody have the experience of using optim to estimate variables with integral forms? here the code: trun.mean - function(x) # t is the threshold { mu=x[1]; sigma=x[2]; t=x[3]; f - function(x) (1/(sigma*sqrt(2*pi)))*exp(-(x-mu)^2/(2*sigma^2)); pdf.fun - function(x) x*f(x); integrate(f,thre,upper=Inf)$value/integrate(pdf.fun,thre,upper=Inf)$value ; } when I run : optim(c(200,100,113),trun.mean) Error in optim(c(2, 3, 3), trun.mean) : function cannot be evaluated at initial parameters I need your help, thanks! Jen. [[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 and provide commented, minimal, self-contained, reproducible code. -- Andrew Robinson Department of Mathematics and StatisticsTel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 http://www.ms.unimelb.edu.au/~andrewpr http://blogs.mbs.edu/fishing-in-the-bay/ [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Making a case for using R in Academia
On 09-Nov-06 Charilaos Skiadas wrote: John (and everyone else), On Nov 9, 2006, at 4:20 PM, John Fox wrote: Dear Charilaos, It's very difficult to give definitive answers to the questions that you pose because we don't have any good data (at least as far as I know) about how widely R is used. Yes it certainly isn't an easy question to answer, and I don't necessarily need complete data. The situation as presented to me by my colleagues in the Social Sciences is really that SPSS is the standard, My own experience (such as it is) suggested to me that you were likely to meet this argument. Certainly, the more mature members of the Social Sciences community were brought up on SPSS, and may be reluctant to bid goodbye to an old friend. so I am basically hoping for evidence to just shake this view (unless it is true, but I have to say I doubt it). I am more hoping for particular examples of cases in the Social Sciences, where SPSS is far from the standard, and the programs and schools you mention below are exactly the sort of thing I was looking for! While it may have some force to be able to indicate how many departments are using SPSS, SAS, STATA and R, showing that R is not a negligible minority, the very presence (and it will not be negligible) of SPSS could reassure your colleagues that their attitude is not unreasonable. It could add considerable force to your advocacy to be able to demonstrate the use of R in some realistic Social Science applications, to show that it has the cabailities -- and reasonable ease of use and learnability -- to be considered a feasible alternative. At which point the cost argument might be decisive. I'm sure many of us would be willing to demonstrate what can be done, using R, with the kind of analysis you put up to us as typical of the work you and your colleagues would want to do. Some of us may even be able to perform comparative demonstrations! Hoping that this too is of some help, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 09-Nov-06 Time: 23:01:24 -- XFMail -- __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Extracting the full coefficient matrix from a gls summary?
Hi, I am trying to extract the coefficients matrix from a gls summary. Contrary to the lm function, the command fit$coefficients returns only the estimates of the model, not the whole matrix including the std errors, the t and the p values. example: ctl - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group - gl(2,10,20, labels=c(Ctl,Trt)) weight - c(ctl, trt) fitlm-lm(weight~group) summary(fitlm)$coefficients ### returns estimates, std errors, t values and Pr(|t|) fitgls-gls(weight~group) summary(fitgls)$coefficients ### returns only the estimates. I would like to be able to extract the whole coefficient matrix form the gls. Any ideas how I could do that ? Thanks for the help, Tifennhttp://www.marinemammal.org/MMRU/tiphaine.html [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] interaction term between two categorical variables in ARIMA
hello, I am using arima to evaluate a time series regression model. I am using categorical variables such as day of week(Su-Sa), month(Jan-Dec), and holiday status (1/0) as my independent variables. There is evidence of multiplicative interaction between holiday status and weekday and I would like to add an interaction term to my arima model, but I am not sure about best way to go about doing it. example code: arr - rpois(98,70) WKDY - rep(c(s,m,t,w,th,f,sa),14) HD - c(rep(0,30),1,rep(0,25),1,rep(0,43)) arima(x= arr,order=c(1,0,0), xreg=cbind(WKDY,HD, HD*WKDY)) error message: Error in HD * WKDY : non-numeric argument to binary operator any help would be appreciated, I am sory if ithis is a bone-headed question. thanks, spencer [[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 and provide commented, minimal, self-contained, reproducible code.
[R] advanced plotting
!urgent! Hi all. I am facing a problem plotting a indicatormatrix to visualize the pattern. Matrix consist from 1 and 0. for example x - matrix(c(0,0,1,0, 1,1,1,1, 0,0,0,1, 1,0,1,1), nrow = 4, ncol=4) an i want to have a plot like | . | . . . . | . | . . . |___ I thinking of somethink like a for loop, which creates a data point whenever a data point in x[i,j]=1. Anybody can give me a hint or has an idea how to do this thanks in advance for every help. Lars -- View this message in context: http://www.nabble.com/-R--advanced-plotting-tf2605043.html#a7269085 Sent from the R help mailing list archive at Nabble.com. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] advanced plotting
downunder wrote: !urgent! Hi all. I am facing a problem plotting a indicatormatrix to visualize the pattern. Matrix consist from 1's and 0's. for example x - matrix(c(0,0,1,0, 1,1,1,1, 0,0,0,1, 1,0,1,1), nrow = 4, ncol=4) an i want to have a plot like | . | . . . . | . | . . . |___ I thinking of somethink like a for loop, which creates a data point whenever a data point in x[i,j]=1. Anybody can give me a hint or has an idea how to do this thanks in advance for every help. Lars ?image -- *mangosolutions* /data analysis that delivers/ Tel +44 1249 467 467 Fax +44 1249 467 468 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] R and Fortran 9x -- advice
Hi, I found some bottlenecks in my R code with Rprof. First I wanted to rewrite them in C, but a colleague keeps suggesting that I learn Fortran, so maybe this is the time to do it... I like to learn new languages and do it fairly quickly. I would appreciate the advice of others about these questions: 1) I hear bad things about Fortran. Sure, F77 looks archaic, but F90/95 seems nicer. Is it worth learning, especially when I plan to use it mainly from R? Dusting off my C knowledge would take a bit of time too, and I never liked C that much. 2) Does it interface well with R? Is F90/95 supported, or only F77? Thanks, Tamas __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] summary linear regression
Gorka See the message from Brian Ripley, which is the first item from RSiteSearch('R-squared') Peter Alspach -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gorka Merino Sent: Friday, 10 November 2006 4:54 a.m. To: r-help@stat.math.ethz.ch Subject: [R] summary linear regression Good morning, I am a PhD student in Barcelona working with R. My question is about the summary of linear regressions. The output of that summary gives some statistical parameters of the regression. One of them is the R-squared. In the help menu i have read that the manner to calculate the R-squared is R^2 = 1 - Sum(R[i]^2) / Sum((y[i]- y*)^2), and when the linear regression is forced to start at the point (0,0) y* is 0. My question is if the R-squared obtained when the linear regression crosses the origin has the same meaning as when it does with an intercept. I'm faced to a theoretical model which brings some values for a variable that compared to the observed ones gives some R*squared of 0.32 when the regression has an intercept and 0.7 when it is forced to cross the origin. To sum up, it may be stated that the theoretical methodolgy followed explains the 70% of of the observed variance? Thank you very much. Gorka Merino. Gorka Merino Institut de Ciències del Mar, CMIMA-CSIC Psg. Marítim de la Barceloneta 37-49 08003-BARCELONA (Spain) Tel.: (34) 932 30 95 48 e-mail: [EMAIL PROTECTED] CMIMA: Tel.: (34) 932 30 95 00 Fax: (34) 932 30 95 55 __ 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 and provide commented, minimal, self-contained, reproducible code. __ The contents of this e-mail are privileged and/or confidenti...{{dropped}} __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] advanced plotting
Hi Romain, this looks already very nice. thanks for your help. lars Romain Francois wrote: downunder wrote: !urgent! Hi all. I am facing a problem plotting a indicatormatrix to visualize the pattern. Matrix consist from 1's and 0's. for example x - matrix(c(0,0,1,0, 1,1,1,1, 0,0,0,1, 1,0,1,1), nrow = 4, ncol=4) an i want to have a plot like | . | . . . . | . | . . . |___ I thinking of somethink like a for loop, which creates a data point whenever a data point in x[i,j]=1. Anybody can give me a hint or has an idea how to do this thanks in advance for every help. Lars ?image -- *mangosolutions* /data analysis that delivers/ Tel +44 1249 467 467 Fax +44 1249 467 468 __ 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 and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/-R--advanced-plotting-tf2605043.html#a7269500 Sent from the R help mailing list archive at Nabble.com. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] command for stopping and then hit return and continue (fwd)
[EMAIL PROTECTED] writes: -- Forwarded message -- is it possible to implement the same sort of thing when you aren't plotting. in other words, i am in a loop and each time through the loop i want to print a set of values, have it stop, then only have it continue when i hit return ? thanks. readline(Hit Return ) -- Jeff __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Problem with as.data.frame when an extra attribute is present
I have a problem when one of the vectors in a list needs to be replicated to have the appropriate length, and an attribute is present. w - list(a=1, b=2:3) as.data.frame(w) a b 1 1 2 2 1 3 attr(w$a,'label') - 'foo' as.data.frame(w) Error in data.frame(a = 1, b = c(2, 3), check.names = TRUE) : arguments imply differing number of rows: 1, 2 I usually use the Hmisc label function to make a variable of class 'labelled' and define as.data.frame.labelled as as.data.frame.vector, but that also fails here. Any help appreciated. -Frank sessionInfo() R version 2.2.1, 2005-12-20, i486-pc-linux-gnu [also fails in 2.4.0] attached base packages: [1] methods stats graphics grDevices utils datasets [7] base -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Extracting the full coefficient matrix from a gls summary?
library(nlme) ctl - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group - gl(2,10,20, labels = c(Ctl, Trt)) weight - c(ctl, trt) fitgls - gls(weight ~ group) summary(fitgls)$tTable Value Std.Error t-value p-value (Intercept) 5.032 0.2202177 22.850117 9.547128e-15 groupTrt-0.371 0.3114349 -1.191260 2.490232e-01 Best, Renaud 2006/11/10, Tiphaine Jeanniard Du Dot [EMAIL PROTECTED]: Hi, I am trying to extract the coefficients matrix from a gls summary. Contrary to the lm function, the command fit$coefficients returns only the estimates of the model, not the whole matrix including the std errors, the t and the p values. example: ctl - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group - gl(2,10,20, labels=c(Ctl,Trt)) weight - c(ctl, trt) fitlm-lm(weight~group) summary(fitlm)$coefficients ### returns estimates, std errors, t values and Pr(|t|) fitgls-gls(weight~group) summary(fitgls)$coefficients ### returns only the estimates. I would like to be able to extract the whole coefficient matrix form the gls. Any ideas how I could do that ? Thanks for the help, Tifennhttp://www.marinemammal.org/MMRU/tiphaine.html [[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 and provide commented, minimal, self-contained, reproducible code. -- Renaud LANCELOT Département Elevage et Médecine Vétérinaire (EMVT) du CIRAD Directeur adjoint chargé des affaires scientifiques CIRAD, Animal Production and Veterinary Medicine Department Deputy director for scientific affairs Campus international de Baillarguet TA 30 / B (Bât. B, Bur. 214) 34398 Montpellier Cedex 5 - France Tél +33 (0)4 67 59 37 17 Secr. +33 (0)4 67 59 39 04 Fax +33 (0)4 67 59 37 95 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] PCA reconstruction funtion
See ?rconst in package ade4. You will need to fit the PCA with dudi.pca (same package). Best, Renaud 2006/11/9, Poizot Emmanuel [EMAIL PROTECTED]: Dear all, I did performed a PCA analysis (using prcomp function) on a data matrix. Then I would like to reconstruction part of the original data set using only specifics and choosen eigenvectors. I would like to know if there is a function under R witch can perform this reconstruction. Regards -- Emmanuel Poizot Cnam/Intechmer B.P. 324 50103 Cherbourg Cedex Phone (Direct) : (00 33)(0)233887342 Fax : (00 33)(0)233887339 __ 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 and provide commented, minimal, self-contained, reproducible code. -- Renaud LANCELOT Département Elevage et Médecine Vétérinaire (EMVT) du CIRAD Directeur adjoint chargé des affaires scientifiques CIRAD, Animal Production and Veterinary Medicine Department Deputy director for scientific affairs Campus international de Baillarguet TA 30 / B (Bât. B, Bur. 214) 34398 Montpellier Cedex 5 - France Tél +33 (0)4 67 59 37 17 Secr. +33 (0)4 67 59 39 04 Fax +33 (0)4 67 59 37 95 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Making a case for using R in Academia
Charles, As a psychologist in one of departments that you are trying to send your Hanover undergrads to for grad school let me say that 1) my various colleagues use SPSS, JMP, SAS and R. 2) I teach R as a supplement to my section of the undergraduate research methods course and in the advanced undergraduate course in personality research. For both of these I have prepared short tutorials that get them up and running very rapidly. 3) At the graduate level, in my psychometrics course, all my examples are done in R, but most of the students do the work in SPSS or JMP. (Although today, a 2nd year clinical student gave a wonderful talk about her data which she had analyzed in R, having just started using it last week.) 4) In terms of using R in psychological research, a recent paper of mine in Motivation and Emotion used John Fox's wonderful sem package and we also included an appendix with the R code for the simulations that we had run. Why did I want to buy LISREL when I had sem? (We do have a site license for LISREL just in case I wanted to use it.) 5) As further evidence that editors in the social sciences accept analyses done in R, I have a chapter in press in a handbook in personality research that includes an appendix in R on how to do simulated experiments and then how to analyze the data. So, you can tell your colleagues that at least some social science departments think highly of undergrads who know R. In answer to your does anyone have any statistics on the use of R in the social sciences? I don't know. Would not knowing SPSS put students at a disadvantage? No. I agree with Harold Doran that just knowing SPSS would put them at a disadvantage. Bill As a addendum to all this, this is one of the responses I got from one of my colleagues: The problem with R is that our students in many social science fields, are expected to know SPSS when they go to graduate school. Not having a background in SPSS would put these students at a disadvantage. Is this really the case? Does anyone have any such statistics? Charilaos Skiadas Department of Mathematics Hanover College P.O.Box 108 Hanover, IN 47243 __ 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 and provide commented, minimal, self-contained, reproducible code. -- William Revelle http://pmc.psych.northwestern.edu/revelle.html Professor http://personality-project.org/personality.html Department of Psychology http://www.wcas.northwestern.edu/psych/ Northwestern University http://www.northwestern.edu/ __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Command Line Prompt Symbol
Hi I run R in Windows. Is there a simple way of changing the prompt symbol to, say, R ? (Not just for a temporary session, but every time R command window is opened.) The documentation of doing this is rather sparse. Much appreciated for your assistance. Jacob Jacob L van Wyk Department of Statistics University of Johannesburg, APK P O Box 524 Auckland Park 2006 South Africa Tel: +27 11 489 3080 Fax: +27 11 489 2832 [[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 and provide commented, minimal, self-contained, reproducible code.
[R] Re : Command Line Prompt Symbol
?prompt Justin BEM Elève Ingénieur Statisticien Economiste BP 294 Yaoundé. Tél (00237)9597295. - Message d'origine De : Jacob van Wyk [EMAIL PROTECTED] À : r-help@stat.math.ethz.ch Envoyé le : Vendredi, 10 Novembre 2006, 6h32mn 57s Objet : [R] Command Line Prompt Symbol Hi I run R in Windows. Is there a simple way of changing the prompt symbol to, say, R ? (Not just for a temporary session, but every time R command window is opened.) The documentation of doing this is rather sparse. Much appreciated for your assistance. Jacob Jacob L van Wyk Department of Statistics University of Johannesburg, APK P O Box 524 Auckland Park 2006 South Africa Tel: +27 11 489 3080 Fax: +27 11 489 2832 [[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 and provide commented, minimal, self-contained, reproducible code. ___ Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internaut [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Command Line Prompt Symbol
The simplest way to do this is to put options(prompt = R ) in your .Rprofile file. If you don't have an .Rprifile file, then persuading Windows to let you call a file by that name can be frustrating. I suggest you delegate the job to R itself and use something like this --- wd - getwd() setwd(Sys.getenv(R_USER)) ## change working directories cat('\noptions(prompt = R )\n', file = .Rprofile, append = TRUE) setwd(wd) --- Putting the .Rprofile in the R_USER directory ensures that it will be used prior to all invocations of R you make. Bill Venables, CMIS, CSIRO Laboratories, PO Box 120, Cleveland, Qld. 4163 AUSTRALIA Office Phone (email preferred): +61 7 3826 7251 Fax (if absolutely necessary):+61 7 3826 7304 Mobile (rarely used):+61 4 1963 4642 Home Phone: +61 7 3286 7700 mailto:[EMAIL PROTECTED] http://www.cmis.csiro.au/bill.venables/ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jacob van Wyk Sent: Friday, 10 November 2006 3:33 PM To: r-help@stat.math.ethz.ch Subject: [R] Command Line Prompt Symbol Hi I run R in Windows. Is there a simple way of changing the prompt symbol to, say, R ? (Not just for a temporary session, but every time R command window is opened.) The documentation of doing this is rather sparse. Much appreciated for your assistance. Jacob Jacob L van Wyk Department of Statistics University of Johannesburg, APK P O Box 524 Auckland Park 2006 South Africa Tel: +27 11 489 3080 Fax: +27 11 489 2832 [[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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Comparison between GARCH and ARMA
Hi i was just going by this thread, i thought of igniting my mind and got something wierd so i thought of making it wired. i think whether you take ARMA or GARCH. In computer science these are feedback systems or put it simply new values are function of past values. In ARMA case it is the return series and the error series. In case of GARCH it is the errors and stdev or returns and shock with propotionality of coeficient. In any case we are trying to find the returns only. What if i put stdev in ARMA and returns in GARCH ? I want to ask what it would end up showing me. For me both are having similar structure having two parts : 1. regression depending on past values 2. trying to reduce errors by averaging them i hope i am correct. please correct me where i am wrong. thanks and regards Email(Office) :- [EMAIL PROTECTED] , Email(Personal) :- [EMAIL PROTECTED] Wensui Liu [EMAIL PROTECTED] Sent by: [EMAIL PROTECTED] 08-11-06 12:24 AM To Leeds, Mark (IED) [EMAIL PROTECTED] cc r-help@stat.math.ethz.ch, Megh Dal [EMAIL PROTECTED] Subject Re: [R] Comparison between GARCH and ARMA Mark, I totally agree that it doesn't make sense to compare arma with garch. but to some extent, garch can be considered arma for conditional variance. similarly, arch can be considered ma for conditional variance. the above is just my understanding, which might not be correct. thanks. On 11/7/06, Leeds, Mark (IED) [EMAIL PROTECTED] wrote: Hi : I'm a R novice but I consider myself reasonably versed in time series related material and I have never heard of an equivalence between Garch(1,1) for volatility and an ARMA(1,1) in the squared returns and I'm almost sure there isn't. There are various problems with what you wrote. 1) r(t) = h(t)*z(t) not h(i) but that's not a big deal. 2) you can't write the equation in terms of r(t) because r(t) = h(t)*z(t) and h(t) is UPDATED FIRST And then the relation r(t) = h(t)*z(t) is true ( in the sense of the model ). So, r(t) is a function of z(t) , a random variable, so trying to use r(t) on the left hand side of the volatility equation doesn't make sense at all. 3) even if your equation was valid, what you wrote is not an ARMA(1,1). The AR term is there but the MA term ( the beta term ) Has an r_t-1 terms in it when r_t-1 is on the left side. An MA term in an ARMA framework multiples lagged noise terms not the lag of what's on the left side. That's what the AR term does. 4) even if your equation was correct in terms of it being a true ARMA(1,1) , you Have common coefficients on The AR term and MA term ( beta ) so you would need contraints to tell the Model that this was the same term in both places. 5) basically, you can't do what you Are trying to do so you shouldn't expect to any consistency in estimates Of the intercept for the reasons stated above. why are you trying to transform in such a way anyway ? Now back to your original garch(1,1) model 6) a garch(1,1) has a stationarity condition that alpha + beta is less than 1 So this has to be satisfied when you estimate a garch(1,1). It looks like this condition is satisfied so you should be okay there. 7) also, if you are really assuming/believe that the returns have mean zero to begin with, without subtraction, Then you shouldn't be subtracting the mean before you estimate Because eseentially you will be subtracting noise and throwing out useful Information that could used in estimating the garch(1,1) parameters. Maybe you aren't assuming that the mean is zero and you are making the mean zero which is fine. I hope this helps you. I don't mean to be rude but I am just trying to get across that what you Are doing is not valid. If you saw the equivalence somewhere in the literature, Let me know because I would be interested in looking at it. mark -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Megh Dal Sent: Tuesday, November 07, 2006 2:24 AM To: r-help@stat.math.ethz.ch Subject: [R] Comparison between GARCH and ARMA Dear all R user, Please forgive me if my problem is too simple. Actually my problem is basically Statistical rather directly R related. Suppose I have return series ret with mean zero. And I want to fit a Garch(1,1) on this. my is r[t] = h[i]*z[t] h[t] = w + alpha*r[t-1]^2 + beta*h[t-1] I want to estimate the three parameters here; the R syntax is as follows: # download data: data(EuStockMarkets) r - diff(log(EuStockMarkets))[,DAX] r = r - mean(r) # fit a garch(1,1) on this: library(tseries) garch(r) The estimated parameters are given below: * ESTIMATION WITH ANALYTICAL GRADIENT * Call: garch(x = r) Coefficient(s): a0 a1 b1 4.746e-06 6.837e-02 8.877e-01 Now it is straightforward to transform Garch(1,1) to a ARMA like this: r[t]^2 = w + (alpha+beta)*r[t-1]^2 + beta*(h[t-1] - r[t-1]^2) -
[R] Problems with metaMDS from vegan
Hello all, I recently used the Vegan library quite extensively (in the context of text similarity assessment) on an Ubuntu 6.06 LTS system with R version 2.2.1 (2005-12-20 r36812). The Vegan lib is version 1.6-10. I hit on a problem yesterday, though, when trying to install R and Vegan on two further computers - one Windows XP and one further Ubuntu 6.06 machine, taking either R version 2.4.0 on XP or 2.2.1 (as above) on Ubuntu, and the newer Vegan version 1.8-3 on both machines. On the new Ubuntu machine I even tried to regress to the Vegan 1.6-10, but to no avail, as the error remains the same: As soon as a I try to process an R matrix (see below) to obtain the MDS I am confronted with: meta - metaMDS(distab.dist, distance=bray, k, trymax=50) Fehler in rowSums(x, na.rm = TRUE) : 'x' muss ein Array mit mindestens zwei Dimensionen sein Ausführung angehalten ( translated: error in rowSums(x, a.rm = TRUE) : 'x' must be an array of at least two dimensions. Execution stopped ) This error is not appearing on identical data when using my older installation. The only relevant googled mentioning of that error points to a surplus (0,0) entry in the matrix to be processed, but this is definitely not the case here. I crosschecked with *identical* data sets on the mentioned systems. Following are my (rather small) processing program and a (small cut of a) matrix that produces the error, but runs smoothly on the older version mentioned: R batch script: library(vegan) simitab - read.table(r.csv, header = TRUE, row.names = 1, sep = ;) olimit - max(simitab) distab - simitab / olimit distab.dist - vegdist(distab) k - 2 meta - metaMDS(distab.dist, distance=bray, k, trymax=50) postscript(metaMDS-CASE-DIMENd.ps, horizontal=TRUE) plot(meta$points, col=blue, xlab=Dim 1, ylab=Dim 2, main=sprintf(metaMDS für Variante = \CASE\, dim = %d, Stress = %.2f %%, k, meta$stress)) text(meta$points+xinch(0.09), labels=names(distab), cex=0.8) ### Cut of data set: ### US-1020525;US-1027783;US-1032733 US-1020525;1.;0.00903941;0.93719674 US-1027783;0.00903941;1.;0.01013081 US-1032733;0.93719674;0.01013081;1. ### (Remark: I did *not* test exactly the given small data set cut but took the larger original one, being a 100*100 matrix + headers that I'd rather not post in here.) I'd appreciate any help in making the script functional again on our newer installations! Regards, Peter __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Meta-regression with lmer() ? If so, how ?
Dear Bernd, dear list, Bernd Weiss a écrit : [ ... ] Have a look at MiMa at Wolfgang Viechtbauer's page. Is that what you are looking for? http://www.wvbauer.com/downloads.html As far as I can tell, mima does what I mean to do, but there are some limits : - mima works on effects, and therefore has an unusual form in R models - as far as I can tell, mima allows to asses the effect of variables *nesting* studies, but not of variables *crossed* in each study ; therefore, ypou cannot directly test the effect of such variables ; - as far as I can tell, the variables of interest (moderators, in mima parlance) can be either two-level factors, booleans or numeric variables, i. e variables having a single regression coeffiient : mima builds an estimator for the regression coefficient of each variable and its variance, and tests by a Z-test. This is not applicable to n-valued factors (n2) or ordered factors, which could be tested by {variance|deviance} analysis. Of those limitations, the least important is the first. The second may be worked around (at least for cases I have in mind writing this), but the last one is quite serious. A cursory look at mima code lets me think that it may be used to implement a form of deviance analysis ; in this case, the recoding of n-valued factors is something standard in R, that can be easily retrofitted. In short : mima will be quite helpful, but is not really what I had in mind. to be more precise, what I want to do is : mod1-foo(Outcome~Treatment*(Presentation+Design), random=(1|Study %in% Design), sd=Sds, data=RawData, ...) Testing for an interaction of Treatment and Presentation (i. e. Is the efficacy of the treatment the same for all possible clinical presentations ?) would be done with mod2- update(mod1,.~.-Treatment:Presentation) # build a restricted #model, nested in the first anova(mod1,mod2) # test it with some form of deviance analysis Similarly, testing for possible bias of design would be done with mod3- update(mod1,.~.-Treatment:Design) anova(mod1,mod3) Currently, mima seems to allow for this latter comparison (by building and testing a regression coefficient for Design), but not the former. Sincerely, Emmanuel Charpentier __ 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 and provide commented, minimal, self-contained, reproducible code.