[R] Plots from categorial data
Hello everybody, Since my first message was caught by the spam filter, I just try to do it again: I want to use R to generate plots from categorial data. The data contains results from OCR scans over images with are preprocessed by different image filtering techniques. A small sample data set looks as following: data - read.csv(d:/tmp_da/sql_data/filter_d_tool.csv, header=T) data ocrtool filter_setting avg.hit. 1 FineReader2x10.383 2 FineReader2x20.488 3 FineReader3x20.268 4 FineReader3x30.198 5 FineReader4x30.081 6 FineReader4x40.056 7gocr2x10.153 8gocr2x20.102 9gocr3x20.047 10 gocr3x30.052 11 gocr4x30.014 12 gocr4x40.002 13 ocrad2x10.085 14 ocrad2x20.094 15 ocrad3x20.045 16 ocrad3x30.050 17 ocrad4x30.025 18 ocrad4x40.009 I now want to draw a plot with the categories (filter_setting) as X axis, and the avg_hit as Y axis. There should be lines for each ocrtool. But when I draw a plot, the resulting plot always contains bars, even if I specify type=n. plot(data$filter_setting, data$avg.hit., type=n) When I only plot the categories, without data, there appear strange grey (but empty) boxes. plot(data$filter_setting, type=n) Who do I get a clean white box to draw the different lines in? Thanks and regards, Christoph --- Christoph Krammer Student University of Mannheim Laboratory for Dependable Distributed Systems A5, 6 68131 Mannheim Germany __ 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] How to save results from chisq.test or mantelhaen.test to file
[EMAIL PROTECTED] wrote: Hi, I am new to these functions. I'm wondering if there is anyway to save the entire results (all attributes of the result object) from the chisq.test or mantelhaen.test functions? For example, from chisq.test function, you will have statistic, parameter, p.value, expected, etc. in the result list. How can I save all of them in one shot to, says, a text file or csv file? Thank you. - adschai You could unlist() the result, coerce it to a data frame, then use write.table(). For example, something like this: write.table(as.data.frame(t(unlist(chisq.test(InsectSprays$count 7, InsectSprays$spray, quote=FALSE) or write.table(as.data.frame(unlist(chisq.test(InsectSprays$count 7, InsectSprays$spray))), quote=FALSE) __ 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.
[R] How to start a R script from a dos command?
Hi everybody, I want to start a R programm from a dos command. Are there any possibilities that I can start e.g. the file Test.R from dos? Maybe something like: R.exe -Test.R ? Thank you very much! Regards, Maja -- __ 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] Plots from categorial data
Perhaps this will do what you want: library(ggplot2) qplot(filter_setting, avg.hit, data=data, colour=ocrtool, geom=line) find out more about ggplot2 at http://had.co.nz/ggplot2 Hadley On 7/1/07, Christoph Krammer [EMAIL PROTECTED] wrote: Hello everybody, Since my first message was caught by the spam filter, I just try to do it again: I want to use R to generate plots from categorial data. The data contains results from OCR scans over images with are preprocessed by different image filtering techniques. A small sample data set looks as following: data - read.csv(d:/tmp_da/sql_data/filter_d_tool.csv, header=T) data ocrtool filter_setting avg.hit. 1 FineReader2x10.383 2 FineReader2x20.488 3 FineReader3x20.268 4 FineReader3x30.198 5 FineReader4x30.081 6 FineReader4x40.056 7gocr2x10.153 8gocr2x20.102 9gocr3x20.047 10 gocr3x30.052 11 gocr4x30.014 12 gocr4x40.002 13 ocrad2x10.085 14 ocrad2x20.094 15 ocrad3x20.045 16 ocrad3x30.050 17 ocrad4x30.025 18 ocrad4x40.009 I now want to draw a plot with the categories (filter_setting) as X axis, and the avg_hit as Y axis. There should be lines for each ocrtool. But when I draw a plot, the resulting plot always contains bars, even if I specify type=n. plot(data$filter_setting, data$avg.hit., type=n) When I only plot the categories, without data, there appear strange grey (but empty) boxes. plot(data$filter_setting, type=n) Who do I get a clean white box to draw the different lines in? Thanks and regards, Christoph --- Christoph Krammer Student University of Mannheim Laboratory for Dependable Distributed Systems A5, 6 68131 Mannheim Germany __ 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] How to start a R script from a dos command?
R CMD BATCH blah.r R.exe --help would have been helpful for you here :) Jared On 7/1/07, Maja Schröter [EMAIL PROTECTED] wrote: Hi everybody, I want to start a R programm from a dos command. Are there any possibilities that I can start e.g. the file Test.R from dos? Maybe something like: R.exe -Test.R ? Thank you very much! Regards, Maja -- __ 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. [[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] moving-window (neighborhood) analysis
Hi Milton thanks for your help I want to compute a lot of things.. :) for instance, I want to look at the large scale (regional, non-local) behavior of slope and aspect, but since aspect is a circular variable, I can't just go around with mean/median/etc, which are the tools I have on GIS, so I was hoping I could find some way to define the moving-window and the apply some function (from a package or user-defined) to the values within the window (like circular statistics). best regards Carlos (Brazil / UK) On 7/1/07, Milton Cezar Ribeiro [EMAIL PROTECTED] wrote: Hi Carlos, What are really you looking for? What you want to compute for the central pixel? I use FRAGSTATS to compute some landscape metrics using moving windows. There you can define circular and rectangular shaped search windows, sized as you want. Kind regards, Miltinho Brazil - Mensagem original De: Carlos Guâno Grohmann [EMAIL PROTECTED] Para: r-help@stat.math.ethz.ch Enviadas: Quarta-feira, 27 de Junho de 2007 12:27:28 Assunto: [R] moving-window (neighborhood) analysis Hello all I was wondering what would be the best way to do a moving-window analysis of a matrix? By moving-window I mean that kind of analysis common in GIS, where each pixel (matrix element) of the resulting map is a function of it neighbors, and the neighborhood is a square matrix. I was hoping there was some function in R that could do that, where I could define the size of the neighborhood, and then apply some function to the values, some function I don't have in GIS packages (like circular statistics). thanks all. Carlos -- +---+ Carlos Henrique Grohmann - Guano Visiting Researcher at Kingston University London - UK Geologist M.Sc - Doctorate Student at IGc-USP - Brazil Linux User #89721 - carlos dot grohmann at gmail dot com +---+ _ Good morning, doctors. I have taken the liberty of removing Windows 95 from my hard drive. --The winning entry in a What were HAL's first words contest judged by 2001: A SPACE ODYSSEY creator Arthur C. Clarke __ 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. Novo Yahoo! Cadê? - Experimente uma nova busca. -- +---+ Carlos Henrique Grohmann - Guano Visiting Researcher at Kingston University London - UK Geologist M.Sc - Doctorate Student at IGc-USP - Brazil Linux User #89721 - carlos dot grohmann at gmail dot com +---+ _ Good morning, doctors. I have taken the liberty of removing Windows 95 from my hard drive. --The winning entry in a What were HAL's first words contest judged by 2001: A SPACE ODYSSEY creator Arthur C. Clarke __ 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] Plots from categorial data
Christoph Krammer wrote: Hello everybody, Since my first message was caught by the spam filter, I just try to do it again: I want to use R to generate plots from categorial data. The data contains results from OCR scans over images with are preprocessed by different image filtering techniques. A small sample data set looks as following: data - read.csv(d:/tmp_da/sql_data/filter_d_tool.csv, header=T) data ocrtool filter_setting avg.hit. 1 FineReader2x10.383 2 FineReader2x20.488 3 FineReader3x20.268 4 FineReader3x30.198 5 FineReader4x30.081 6 FineReader4x40.056 7gocr2x10.153 8gocr2x20.102 9gocr3x20.047 10 gocr3x30.052 11 gocr4x30.014 12 gocr4x40.002 13 ocrad2x10.085 14 ocrad2x20.094 15 ocrad3x20.045 16 ocrad3x30.050 17 ocrad4x30.025 18 ocrad4x40.009 I now want to draw a plot with the categories (filter_setting) as X axis, and the avg_hit as Y axis. There should be lines for each ocrtool. But when I draw a plot, the resulting plot always contains bars, even if I specify type=n. plot(data$filter_setting, data$avg.hit., type=n) When I only plot the categories, without data, there appear strange grey (but empty) boxes. plot(data$filter_setting, type=n) Who do I get a clean white box to draw the different lines in? Hi Christoph, How about this? plot(as.numeric(krammer$filter_setting[1:6]),krammer$avg_hit[1:6], type=b,col=2,ylim=c(0,0.5),main=OCR performance, xlab=Filter setting,ylab=Average hits,axes=FALSE) points(as.numeric(krammer$filter_setting[7:12]),krammer$avg_hit[7:12], type=b,col=3) points(as.numeric(krammer$filter_setting[13:18]),krammer$avg_hit[13:18], type=b,col=4) box() axis(1,at=1:6,labels=c(2x1,2x2,3x2,3x3,4x3,4x4)) axis(2) Jim __ 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] Plots from categorial data
Hello Hadley, Thanks a lot for your help. I got the plot I want out of this module with a slightly more complicated command. But now, I have an additional problem: In the given case, the filtersetting column contains letters, so R takes the values as categories. But I have other filters, which only have numeric categories like 0.125, 0.25, 1, and so on. But there is no real distance between these values, so the data is still categorial. But if I draw a plot from this data, the result is a plot with axis labels like 0.2, 0.4, 0.6, ... How do I tell R to treat the numbers in the filtersetting column as categories? Thanks and regards, Christoph -Ursprüngliche Nachricht- Von: hadley wickham [mailto:[EMAIL PROTECTED] Gesendet: Sonntag, 1. Juli 2007 12:21 An: Christoph Krammer Cc: r-help@stat.math.ethz.ch Betreff: Re: [R] Plots from categorial data Perhaps this will do what you want: library(ggplot2) qplot(filter_setting, avg.hit, data=data, colour=ocrtool, geom=line) find out more about ggplot2 at http://had.co.nz/ggplot2 Hadley On 7/1/07, Christoph Krammer [EMAIL PROTECTED] wrote: Hello everybody, Since my first message was caught by the spam filter, I just try to do it again: I want to use R to generate plots from categorial data. The data contains results from OCR scans over images with are preprocessed by different image filtering techniques. A small sample data set looks as following: data - read.csv(d:/tmp_da/sql_data/filter_d_tool.csv, header=T) data ocrtool filter_setting avg.hit. 1 FineReader2x10.383 2 FineReader2x20.488 3 FineReader3x20.268 4 FineReader3x30.198 5 FineReader4x30.081 6 FineReader4x40.056 7gocr2x10.153 8gocr2x20.102 9gocr3x20.047 10 gocr3x30.052 11 gocr4x30.014 12 gocr4x40.002 13 ocrad2x10.085 14 ocrad2x20.094 15 ocrad3x20.045 16 ocrad3x30.050 17 ocrad4x30.025 18 ocrad4x40.009 I now want to draw a plot with the categories (filter_setting) as X axis, and the avg_hit as Y axis. There should be lines for each ocrtool. But when I draw a plot, the resulting plot always contains bars, even if I specify type=n. plot(data$filter_setting, data$avg.hit., type=n) When I only plot the categories, without data, there appear strange grey (but empty) boxes. plot(data$filter_setting, type=n) Who do I get a clean white box to draw the different lines in? Thanks and regards, Christoph --- Christoph Krammer Student University of Mannheim Laboratory for Dependable Distributed Systems A5, 6 68131 Mannheim Germany __ 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] Standard Probability Distributions.
David Barron mothsailor at googlemail.com writes: Try RSiteSearch to look for specific distributions. also try http://wiki.r-project.org/rwiki/doku.php?id=tips:stats-distri:0verviews=binomial __ 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] SEM model fit
Dear Frank, My apologies for the slow response: I'm away from home and checking r-help infrequently. To find the confidence interval for the RMSEA it's necessary to compute two chisquare noncentrality parameters. summary.sem() does this by one-dimensional optimizations. If the upper bound of the CI is very large or the lower bound very close to 0, it might not be possible to find the values with sufficient precision, and NA is printed. Looking at the code for summary.sem(), however, I see that the optimizations could fail spuriously if the sample size is large; moreover, under these circumstances, both the upper and lower bounds will be NA, even if the lower bound could have been determined. I've therefore modified summary.sem() so that it should work more reliably, and have attached a file with the modified function to this email. Let me know if it provides more satisfactory results. (Because you didn't give the input correlation matrix, I can't check myself.) I'll eventually incorporate the new function is an updated version of the package. BTW, I doubt that the RMSEA confidence interval is correct for polychoric correlations. Regards, John original message -- I wonder if someone could explain why, when I perform confirmatory factor-analysis model using polychoric correlations why I do not get an estimated confidence interval for the RMSEA. My experience with these type models is that I would obtain a confidence interval estimate. I did not get any warning messages with the output. RESULTS: Model Chisquare = 1374 Df = 185 Pr(Chisq) = 0 Chisquare (null model) = 12284 Df = 210 Goodness-of-fit index = 0.903 Adjusted goodness-of-fit index = 0.88 RMSEA index = 0.0711 90% CI: (NA, NA) Bentler-Bonnett NFI = 0.888 Tucker-Lewis NNFI = 0.888 Bentler CFI = 0.902 SRMR = 0.0682 BIC = 51.4 SYNTAX rm(sem.enf.rq) mdl.rq - specify.model() enf - law2, NA, 1 enf - law3, lam2, 1 enf - law4, lam3, 1 enf - enf, psi1, 0.6 law2 - law2, theta1, 0.3 law3 - law3, theta2, 0.3 law4 - law4, theta3, 0.5 gender- enf, a1, 0.2 incomex - enf, a2, 0.2 oftdrnkr - enf, a3, 0.2 attn - nvatt, NA, 1 attn - crimatt, lam4, 1.3 attn - asltatt, lam5, 1.2 attn - attn, psi2, 0.5 nvatt - nvatt,theta4, 0.5 crimatt - crimatt, theta5, 0.1 asltatt - asltatt, theta6, 0.2 gender- attn, a4, 0.2 acon - acon1,NA, 1 acon - acon2,lam4, 1.5 acon - acon,psi2, 0.1 mcon - mvcon1, NA, 1 mcon - mvcon2, lam5, 1 mcon - mcon,psi3, 0.3 ocon - oicon1, NA, 1 ocon - oicon2, lam6, 1 ocon - ocon,psi4, 0.2 con- acon, NA, 1 con- mcon, lam7, 0.8 con- ocon, lam8, 0.9 con - con, psi5, 0.3 acon1 - acon1, theta7, 0.4 acon2 - acon2, theta8, 0.2 mvcon1- mvcon1, theta9, 0.2 mvcon2- mvcon2, theta10, 0.3 oicon1- oicon1, theta11, 0.2 oicon2- oicon2, theta12, 0.3 gender- con, a5, 0.1 incomex - con, a6, -0.1 oftdrnkr - con, a7, -0.2 attn - con, gam1, 0.2 sev - aophys, NA,1 sev - mvphys, NA,1 sev - oiphys, NA,1 sev - sev, psi6, 0.5 aophys- aophys, theta13,0.5 mvphys- mvphys, theta14,0.5 oiphys- oiphys, theta14,0.5 con - sev, gam3, 0.8 prev - mvpct,NA,1 prev - oipct,NA,1 prev - alcpct, NA,1 prev - prev,psi8, 0.4 mvpct - mvpct, theta15,0.5 oipct - oipct, theta15,0.5 alcpct- alcpct, theta15,0.5 con - prev, gam5, 0.8 prev - enf, gam6, 0.4 sem.enf.rq - sem(ram = mdl.rq, S = hcor(dx), N = nrow(dx), obs.v = names(dx), raw = F, fixed = names(dx)[4:6], par.size = 's', maxiter = 1e3, analytic = F, gradtol = 1e-10) ##set raw to False summary(obj = sem.enf.rq, dig = 3, conf = 0.9) Respectfully, Frank Lawrence
Re: [R] Plots from categorial data
On 7/1/07, Christoph Krammer [EMAIL PROTECTED] wrote: Hello Hadley, Thanks a lot for your help. I got the plot I want out of this module with a slightly more complicated command. But now, I have an additional problem: In the given case, the filtersetting column contains letters, so R takes the values as categories. But I have other filters, which only have numeric categories like 0.125, 0.25, 1, and so on. But there is no real distance between these values, so the data is still categorial. But if I draw a plot from this data, the result is a plot with axis labels like 0.2, 0.4, 0.6, ... How do I tell R to treat the numbers in the filtersetting column as categories? Just make it a factor: qplot(factor(filter_setting), avg.hit, data=data, colour=ocrtool, geom=line) 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.
[R] [R-pkgs] Clusterfly
clusterfly http://had.co.nz/clusterfly/ Typically, there is somewhat of a divide between statistics and visualisation software. Statistics software, particularly R, provides implementation of cutting edge research methods, but limited graphics. Visualisation software will provide sophisticated visual interfaces, but few statistical algorithms. The clusterfly package presents some early experimentation aimed at overcoming this deficiency by linking R and GGobi. Cluster analysis was chosen as it is an exploratory method that needs sophisticated visualisation and statistical algorithms. Clusterfly provides some tools that work with all clustering algorithms, and some that are tailored for particular ones. Generic tools allow you to animate between clusterings (see ?cfly_animate) and produce common static graphics (?cfly_dist, ?cfly_pcp). Specific algorithms are available for: * Self organising maps (aka Kohonen neural networks), ?ggobi.som. Displays the self organising map/net in the original space of the data. * Hierarchical clustering, ?hierfly. Connects data points with lines like a dendrogram, but in the high-dimensional space of the original data * Model based clustering, ?mefly. Adds ellipsoids from the multivariate normal distributions the clusters are based on You will need GGobi (http://www.ggobi.org) and rggobi (http://www.ggobi.org/rggobi) installed to be able to use clusterfly. Regards, Hadley ___ R-packages mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-packages __ 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] Plots from categorial data
On 7/1/07, Jim Lemon [EMAIL PROTECTED] wrote: Christoph Krammer wrote: Hello everybody, Since my first message was caught by the spam filter, I just try to do it again: I want to use R to generate plots from categorial data. The data contains results from OCR scans over images with are preprocessed by different image filtering techniques. A small sample data set looks as following: data - read.csv(d:/tmp_da/sql_data/filter_d_tool.csv, header=T) data ocrtool filter_setting avg.hit. 1 FineReader2x10.383 2 FineReader2x20.488 3 FineReader3x20.268 4 FineReader3x30.198 5 FineReader4x30.081 6 FineReader4x40.056 7gocr2x10.153 8gocr2x20.102 9gocr3x20.047 10 gocr3x30.052 11 gocr4x30.014 12 gocr4x40.002 13 ocrad2x10.085 14 ocrad2x20.094 15 ocrad3x20.045 16 ocrad3x30.050 17 ocrad4x30.025 18 ocrad4x40.009 I now want to draw a plot with the categories (filter_setting) as X axis, and the avg_hit as Y axis. There should be lines for each ocrtool. But when I draw a plot, the resulting plot always contains bars, even if I specify type=n. plot(data$filter_setting, data$avg.hit., type=n) When I only plot the categories, without data, there appear strange grey (but empty) boxes. plot(data$filter_setting, type=n) Who do I get a clean white box to draw the different lines in? Hi Christoph, How about this? plot(as.numeric(krammer$filter_setting[1:6]),krammer$avg_hit[1:6], type=b,col=2,ylim=c(0,0.5),main=OCR performance, xlab=Filter setting,ylab=Average hits,axes=FALSE) points(as.numeric(krammer$filter_setting[7:12]),krammer$avg_hit[7:12], type=b,col=3) points(as.numeric(krammer$filter_setting[13:18]),krammer$avg_hit[13:18], type=b,col=4) box() axis(1,at=1:6,labels=c(2x1,2x2,3x2,3x3,4x3,4x4)) axis(2) And this is mostly equivalent to with(krammer, interaction.plot(filter_setting, ocrtool, avg_hit)) or (with the original names) with(data, interaction.plot(filter_setting, ocrtool, avg.hit.)) -Deepayan __ 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] How to save results from chisq.test or mantelhaen.test to file
Thank you Chuck. This is really neat! I just learned that we can unlist thing. - adschai- Original Message -From: Chuck Cleland Date: Sunday, July 1, 2007 4:53 amSubject: Re: [R] How to save results from chisq.test or mantelhaen.test to fileTo: [EMAIL PROTECTED]: r-help@stat.math.ethz.ch [EMAIL PROTECTED] wrote: Hi,I am new to these functions. I'm wondering if there is anyway to save the entire results (all attributes of the result object) from the chisq.test or mantelhaen.test functions? For example, from chisq.test function, you will have statistic, parameter, p.value, expected, etc. in the result list. How can I save all of them in one shot to, says, a text file or csv file? Thank you.- adschai You could unlist() the result, coerce it to a data frame, then use write.table(). For example, something like this: write.table(as.data.frame(t(unlist(chisq.test(InsectSprays$count 7, InsectSprays$spray, quote=FALSE)! or write.table(as.data.frame(unlist(chisq.test(InsectSprays$count 7, InsectSprays$spray))), quote=FALSE) __ 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 [[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] unequal variance assumption for lme (mixed effect model)
Thanks for Spencer and Simon's help. I've got very interesting results based on your suggestions. One more question, how to handle unequal variance problme in lm()? Isn't the weights option also, which means weighted least squares, right? Can you give me an example of setting this parameter in lm() to account for different variance assumption in each group? Thanks again, Shirley On 6/29/07, Spencer Graves [EMAIL PROTECTED] wrote: comments in line shirley zhang wrote: Hi Simon, Thanks for your reply. Your reply reminds me that book. I've read it long time ago, but haven't try the weights option in my projects yet:) Is the heteroscedastic test always less powerful because we have to estimate the within group variance from the given data? SG: In general, I suspect we generally lose power when we estimate more parameters. SG: You can check this using the 'simulate.lme' function, whose use is illustrated in the seminal work reported in sect. 2.4 of Pinheiro and Bates (2000) Mixed-Effects Models in S and S-Plus (Springer). Should we check whether each group has equal variance before using weights=varIdent()? If we should, what is the function for linear mixed model? SG: The general advice I've seen is to avoid excessive overparameterization of heterscedasticity and correlations. However, parsimonious correlation had heterscedasticity models would likely be wise. Years ago, George Box expressed concern about people worrying too much about outliers, which are often fairly obvious and relatively easy to detect, while they worried too little, he thought, about dependence, especially serial dependence, which is generally more difficult to detect and creates bigger problems in inference than outliers. He wrote, Why worry about mice when there are tigers about? SG: Issues of this type can be fairly easily evaluated using 'simulate.lme'. Hope this helps. Spencer Graves Thanks, Shirley On 6/27/07, Simon Blomberg [EMAIL PROTECTED] wrote: The default settings for lme do assume equal variances within groups. You can change that by using the various varClasses. see ?varClasses. A simple example would be to allow unequal variances across groups. So if your call to lme was: lme(...,random=~1|group,...) then to allow each group to have its own variance, use: lme(...,random=~1|group, weights=varIdent(form=~1|group),...) You really really should read Pinheiro Bates (2000). It's all there. HTH, Simon. , On Wed, 2007-06-27 at 21:55 -0400, shirley zhang wrote: Dear Douglas and R-help, Does lme assume normal distribution AND equal variance among groups like anova() does? If it does, is there any method like unequal variance T-test (Welch T) in lme when each group has unequal variance in my data? Thanks, Shirley __ 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 Blomberg, BSc (Hons), PhD, MAppStat. Lecturer and Consultant Statistician Faculty of Biological and Chemical Sciences The University of Queensland St. Lucia Queensland 4072 Australia Room 320, Goddard Building (8) T: +61 7 3365 2506 email: S.Blomberg1_at_uq.edu.au The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. - John Tukey. __ 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] How to save results from chisq.test or mantelhaen.test to file
Maybe _dput_ is another way, and you can use _dget _ to get it back. 2007/7/1, Chuck Cleland [EMAIL PROTECTED]: [EMAIL PROTECTED] wrote: Hi, I am new to these functions. I'm wondering if there is anyway to save the entire results (all attributes of the result object) from the chisq.test or mantelhaen.test functions? For example, from chisq.test function, you will have statistic, parameter, p.value, expected, etc. in the result list. How can I save all of them in one shot to, says, a text file or csv file? Thank you. - adschai You could unlist() the result, coerce it to a data frame, then use write.table(). For example, something like this: write.table(as.data.frame(t(unlist(chisq.test(InsectSprays$count 7, InsectSprays$spray, quote=FALSE) or write.table(as.data.frame(unlist(chisq.test(InsectSprays$count 7, InsectSprays$spray))), quote=FALSE) __ 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. -- Ronggui Huang Department of Sociology Fudan University, Shanghai, China __ 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] package with roc, sensitivity, specificity, kappa etc
Dear Guru's, Is there a package (R of course) with programs for diagnostics - roc, sens , spec, kappa etc? Best wishes Fredrik L __ 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] package with roc, sensitivity, specificity, kappa etc
Fredrik Lundgren wrote: Dear Guru's, Is there a package (R of course) with programs for diagnostics - roc, sens , spec, kappa etc? Your question is not very specific, but you might have a look at the ROCR package for visualizing classifier performance. http://cran.r-project.org/src/contrib/Descriptions/ROCR.html HTH, Tobias -- Tobias Verbeke - Consultant Business Decision Benelux Rue de la révolution 8 1000 Brussels - BELGIUM +32 499 36 33 15 [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] package with roc, sensitivity, specificity, kappa etc
for ROC and AUC calculation, you might try verification package. On 7/1/07, Fredrik Lundgren [EMAIL PROTECTED] wrote: Dear Guru's, Is there a package (R of course) with programs for diagnostics - roc, sens , spec, kappa etc? Best wishes Fredrik L __ 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. -- WenSui Liu A lousy statistician who happens to know a little programming (http://spaces.msn.com/statcompute/blog) __ 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] unequal variance assumption for lme (mixed effect model)
The 'weights' argument on 'lm' is assumed to identify a vector of the same length as the response, giving numbers that are inversely proportional to the variance for each observation. However, 'lm' provides no capability to estimate weights. If you want to do that, the varFunc capabilities in the 'nlme' package is the best tool I know for that purpose. If someone thinks there are better tools available for estimating heterscedasticity, I hope s/he will enlighten us both. Hope this helps. Spencer Graves shirley zhang wrote: Thanks for Spencer and Simon's help. I've got very interesting results based on your suggestions. One more question, how to handle unequal variance problme in lm()? Isn't the weights option also, which means weighted least squares, right? Can you give me an example of setting this parameter in lm() to account for different variance assumption in each group? Thanks again, Shirley On 6/29/07, Spencer Graves [EMAIL PROTECTED] wrote: comments in line shirley zhang wrote: Hi Simon, Thanks for your reply. Your reply reminds me that book. I've read it long time ago, but haven't try the weights option in my projects yet:) Is the heteroscedastic test always less powerful because we have to estimate the within group variance from the given data? SG: In general, I suspect we generally lose power when we estimate more parameters. SG: You can check this using the 'simulate.lme' function, whose use is illustrated in the seminal work reported in sect. 2.4 of Pinheiro and Bates (2000) Mixed-Effects Models in S and S-Plus (Springer). Should we check whether each group has equal variance before using weights=varIdent()? If we should, what is the function for linear mixed model? SG: The general advice I've seen is to avoid excessive overparameterization of heterscedasticity and correlations. However, parsimonious correlation had heterscedasticity models would likely be wise. Years ago, George Box expressed concern about people worrying too much about outliers, which are often fairly obvious and relatively easy to detect, while they worried too little, he thought, about dependence, especially serial dependence, which is generally more difficult to detect and creates bigger problems in inference than outliers. He wrote, Why worry about mice when there are tigers about? SG: Issues of this type can be fairly easily evaluated using 'simulate.lme'. Hope this helps. Spencer Graves Thanks, Shirley On 6/27/07, Simon Blomberg [EMAIL PROTECTED] wrote: The default settings for lme do assume equal variances within groups. You can change that by using the various varClasses. see ?varClasses. A simple example would be to allow unequal variances across groups. So if your call to lme was: lme(...,random=~1|group,...) then to allow each group to have its own variance, use: lme(...,random=~1|group, weights=varIdent(form=~1|group),...) You really really should read Pinheiro Bates (2000). It's all there. HTH, Simon. , On Wed, 2007-06-27 at 21:55 -0400, shirley zhang wrote: Dear Douglas and R-help, Does lme assume normal distribution AND equal variance among groups like anova() does? If it does, is there any method like unequal variance T-test (Welch T) in lme when each group has unequal variance in my data? Thanks, Shirley __ 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 Blomberg, BSc (Hons), PhD, MAppStat. Lecturer and Consultant Statistician Faculty of Biological and Chemical Sciences The University of Queensland St. Lucia Queensland 4072 Australia Room 320, Goddard Building (8) T: +61 7 3365 2506 email: S.Blomberg1_at_uq.edu.au The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. - John Tukey. __ 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] working with R graphics remotely
Hi netters, Now I'm connecting from my local windows machine to a remote linux machine and launch R out there using SSH. When I tried to create grahics, like using plot or heatmap, I cannot see the output. Maybe a new R window displaying the graphics has popped out in the remote machine? Or I need to change some settings for the graphics to display? I don't know. I googled it and tried dev.copy but it didn't work. Can anyone help me here? I need to be able to see the output graphics and save it to a file (like jpeg) Thanks a lot! _ 享用世界上最大的电子邮件系统― MSN Hotmail。 http://www.hotmail.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.
[R] Extracting sums for individual factors in data frames
I have a data frame with two columns, one of which is a factor (Species) and the other is numeric (BA, which stands for basal area). Here's a sample: Species BA ACSA55.7632696 FRAM122.9933524 ACSA67.54424205 ACSA89.22123136 ACSA82.46680716 ACSA22.46238747 ACSA19.94911335 ACSA20.42035225 ACSA19.00663555 ACSA21.67698931 ACSA57.80530483 ACSA30.31636911 Dead43.98229715 Dead40.21238597 Dead16.49336143 Dead40.21238597 Dead16.49336143 ACSA78.53981634 VIPR3.926990817 AEGL11.78097245 AEGL0 AEGL0 ACSA0 ACSA0 ACSA0 VIPR0 I would like to calculate relative basal area for each species in this plot. For that, I need to divide the total basal area per species by the total basal area in the plot. Getting the total basal area in the plot is easy. However, I'm mystified on how to get the total basal area per species. Is there a way to extract and/or sum the total basal area per species? Thank you in advance. Jim Milks Graduate Student Environmental Sciences Ph.D. Program Wright State University 3640 Colonel Glenn Hwy Dayton, OH 45435 [[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] Extracting sums for individual factors in data frames
?tapply ## Attention:\ This e-mail message is privileged and 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] Extracting sums for individual factors in data frames
Does this do what you want? x - Species BA + ACSA55.7632696 + FRAM122.9933524 + ACSA67.54424205 + ACSA89.22123136 + ACSA82.46680716 + ACSA22.46238747 + ACSA19.94911335 + ACSA20.42035225 + ACSA19.00663555 + ACSA21.67698931 + ACSA57.80530483 + ACSA30.31636911 + Dead43.98229715 + Dead40.21238597 + Dead16.49336143 + Dead40.21238597 + Dead16.49336143 + ACSA78.53981634 + VIPR3.926990817 + AEGL11.78097245 + AEGL0 + AEGL0 + ACSA0 + ACSA0 + ACSA0 + VIPR0 x - read.table(textConnection(x), header=TRUE) # compute area for each species y - tapply(x$BA, x$Species, sum) # get ratio y/sum(x$BA) ACSAAEGLDeadFRAMVIPR 0.656210104 0.013678643 0.182746672 0.142805034 0.004559548 On 7/1/07, James R. Milks [EMAIL PROTECTED] wrote: I have a data frame with two columns, one of which is a factor (Species) and the other is numeric (BA, which stands for basal area). Here's a sample: Species BA ACSA55.7632696 FRAM122.9933524 ACSA67.54424205 ACSA89.22123136 ACSA82.46680716 ACSA22.46238747 ACSA19.94911335 ACSA20.42035225 ACSA19.00663555 ACSA21.67698931 ACSA57.80530483 ACSA30.31636911 Dead43.98229715 Dead40.21238597 Dead16.49336143 Dead40.21238597 Dead16.49336143 ACSA78.53981634 VIPR3.926990817 AEGL11.78097245 AEGL0 AEGL0 ACSA0 ACSA0 ACSA0 VIPR0 I would like to calculate relative basal area for each species in this plot. For that, I need to divide the total basal area per species by the total basal area in the plot. Getting the total basal area in the plot is easy. However, I'm mystified on how to get the total basal area per species. Is there a way to extract and/or sum the total basal area per species? Thank you in advance. Jim Milks Graduate Student Environmental Sciences Ph.D. Program Wright State University 3640 Colonel Glenn Hwy Dayton, OH 45435 [[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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] align() function missing in R ?
On 6/29/07, Markus Loecher [EMAIL PROTECTED] wrote: Thank you for your responses, I should have given an example of the functionality I am looking for, here are three typical scenarios that I deal with a lot in my work: - a regular timeseries with lots of missing values that I want to convert to the corresponding regular time series with mssing values replaced by NAs, e.g.: x = timeSeries(c(0.5,0.2,0.3,0.4,0.3,0.2,0.3), pos = c(1,2,5,8,9,12,14)); x.align = align(x, pos = 1:14, method = NA); - a regular timeseries at a coarse scale which I want to linearly interpolate to a finer time scale: x = ts(1:10, frequency = 4); x.align = align(x, frequency = 8, method = interp) - an irregular timeseries which I want to linearly interpolate to a regular time grid: x = timeSeries(c(0.5,0.2,0.3,0.4,0.3,0.2,0.3), pos = c(1,2.5,3.2,4.1,5.7,6.5,7.3)); x.align = align(x, pos = 1:7, method = interp); I am wondering how to easily code such a function using only window, ts.union and ts.intersect. Here it is using zoo series: library(zoo) x - c(0.5, 0.2, 0.3, 0.4, 0.3, 0.2, 0.3) x1 - zoo(x, c(1, 2, 5, 8, 9, 12, 14)) as.zoo(as.ts(x1)) x2 - zooreg(1:10, frequency = 4) frequency(x2) - 8 x2 x3 - zoo(x, c(1, 2.5, 3.2, 4.1, 5.7, 6.5, 7.3)) tt - 1:7 zoo(approx(time(x3), x3, tt)$y, tt) # or tt - as.numeric(1:7) # can omit if warning in next line ok window(na.approx(cbind(x3, zoo(, tt))), tt) For more on zoo: library(zoo) vignette(zoo) __ 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 sums for individual factors in data frames
Does this do what you want? with(dat, tapply(BA, Species, sum)) ACSA AEGL Dead FRAM VIPR 565.172518 11.780972 157.393792 122.993352 3.926991 Cheers, Simon. On Sun, 2007-07-01 at 23:15 -0400, James R. Milks wrote: I have a data frame with two columns, one of which is a factor (Species) and the other is numeric (BA, which stands for basal area). Here's a sample: Species BA ACSA 55.7632696 FRAM 122.9933524 ACSA 67.54424205 ACSA 89.22123136 ACSA 82.46680716 ACSA 22.46238747 ACSA 19.94911335 ACSA 20.42035225 ACSA 19.00663555 ACSA 21.67698931 ACSA 57.80530483 ACSA 30.31636911 Dead 43.98229715 Dead 40.21238597 Dead 16.49336143 Dead 40.21238597 Dead 16.49336143 ACSA 78.53981634 VIPR 3.926990817 AEGL 11.78097245 AEGL 0 AEGL 0 ACSA 0 ACSA 0 ACSA 0 VIPR 0 I would like to calculate relative basal area for each species in this plot. For that, I need to divide the total basal area per species by the total basal area in the plot. Getting the total basal area in the plot is easy. However, I'm mystified on how to get the total basal area per species. Is there a way to extract and/or sum the total basal area per species? Thank you in advance. Jim Milks Graduate Student Environmental Sciences Ph.D. Program Wright State University 3640 Colonel Glenn Hwy Dayton, OH 45435 [[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. -- Simon Blomberg, BSc (Hons), PhD, MAppStat. Lecturer and Consultant Statistician Faculty of Biological and Chemical Sciences The University of Queensland St. Lucia Queensland 4072 Australia Room 320, Goddard Building (8) T: +61 7 3365 2506 email: S.Blomberg1_at_uq.edu.au The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. - John Tukey. __ 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] How to set constraints on output layer of Neural Networks
Hi, Please bear with me as I never use NN in R before. I have a network whose my output has, says K node. I would like to put a set of constraints on this layer. Indeed, I have two type of constraints. The first type is that their outputs should sum up to one. The second type is monotonic increasing from the first output node to the K-th node. How can I achieve this? Thank you so much in advance. - adschai __ 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] working with R graphics remotely
You need to forward the X11 window to your local machine, which would need to be running an X server. We do this using Exceed and PUTTY settings, but your sysadmins will be able to help you: it is not a question about R per se. On Mon, 2 Jul 2007, zhihua li wrote: Hi netters, Now I'm connecting from my local windows machine to a remote linux machine and launch R out there using SSH. When I tried to create grahics, like using plot or heatmap, I cannot see the output. Maybe a new R window displaying the graphics has popped out in the remote machine? Or I need to change some settings for the graphics to display? I don't know. I googled it and tried dev.copy but it didn't work. Can anyone help me here? I need to be able to see the output graphics and save it to a file (like jpeg) Thanks a lot! -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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.