[R] Problem with effects package
sessionInfo() R version 2.15.0 (2012-03-30) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] grid datasets splines utils stats [6] graphics grDevices methods base other attached packages: [1] effects_2.1-0 colorspace_1.1-1 [3] nnet_7.3-1 nlme_3.1-103 [5] lattice_0.20-6 reshape_0.8.4 [7] plyr_1.7.1 catdata_1.0 [9] cacheSweave_0.6-1 stashR_0.3-5 [11] filehash_2.2-1 BiocInstaller_1.4.3 [13] ctv_0.7-4 sos_1.3-1 [15] brew_1.0-6 Hmisc_3.9-3 [17] survival_2.36-12MASS_7.3-17 loaded via a namespace (and not attached): [1] cluster_1.14.2 digest_0.5.2 tools_2.15.0 # copy and paste the following: library( catdata ) data( unemployment ) unempt - unemployment unempt$durbin - unempt$durbin - 1 library( reshape ) unempt - melt( table( unempt ) ) unempw - cast( unempt, age ~ durbin ) names( unempw ) - c( 'age', 'short', 'long' ) modt - glm( durbin ~ age, weights = value, family = binomial, data = unempt ) modw - glm( cbind( short, long ) ~ age, family = binomial, data = unempw ) library( effects ) modt.ef - effect( 'age', modt ) # works! modw.ef - effect( 'age', modw ) # doesn't work! # Error in eval(expr, envir, enclos) : object 'age' not found # end __ Professor Michael Kubovy University of Virginia Department of Psychology for mail add: for FedEx or UPS add: P.O.Box 400400 Gilmer Hall, Room 102 Charlottesville, VA 22904-4400 485 McCormick Road USA Charlottesville, VA 22903 roomphone Office:B011 +1-434-982-4729 Lab:B019+1-434-982-4751 WWW:http://www.people.virginia.edu/~mk9y/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Change in behavior of update.views()?
I haven't seen this cryptic warning before: update.views('Robust') Warning message: In update.views(Robust) : The following packages are not available: covRobust, distr, FRB, MASS, mblm, multinomRob, mvoutlier, quantreg, RandVar, rgam, RobAStBase, robfilter, RobLox, RobRex, robust, RobustAFT, robustbase, ROptEst, ROptRegTS, rrcov, sandwich, wle library(covRobust) It is puzzling because as the second command shows the package covRobust is installed. Here is my sessionInfo() R version 2.14.2 (2012-02-29) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] datasets splines utils stats graphics grDevices methods base other attached packages: [1] covRobust_1.0 ade4_1.4-17 BiocInstaller_1.2.1 ctv_0.7-4 sos_1.3-1 brew_1.0-6 Hmisc_3.9-2 survival_2.36-12 [9] MASS_7.3-17 loaded via a namespace (and not attached): [1] cluster_1.14.2 grid_2.14.2lattice_0.20-0 tools_2.14.2 __ Professor Michael Kubovy University of Virginia Department of Psychology for mail add: for FedEx or UPS add: P.O.Box 400400 Gilmer Hall, Room 102 Charlottesville, VA 22904-4400 485 McCormick Road USA Charlottesville, VA 22903 roomphone Office:B011 +1-434-982-4729 Lab:B019+1-434-982-4751 WWW:http://www.people.virginia.edu/~mk9y/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Packages 'effects' loads 'name' which conflicts with 'lme4' [corrected subject: Package 'effects' loads 'nlme' which conflicts with 'lme4']
Dear John, Thanks for the quick response. It works perfectly. Michael On Mar 7, 2012, at 9:19 PM, John Fox wrote: Dear Michael, effect() works with lmer(). Just load lme4 after the effect package. See the penultimate example in ?effect. I hope this helps, John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Wed, 7 Mar 2012 20:53:20 -0500 Michael Kubovy kub...@virginia.edu wrote: Hi, I would like to use the effect() function (actually a slightly modified version of it) on the output of the lmer() function in the lme4 package. But the effects package requires the nlme pacvkage, which is incompatible with lme4. Workaround? __ Professor Michael Kubovy University of Virginia Department of Psychology for mail add: for FedEx or UPS add: P.O.Box 400400 Gilmer Hall, Room 102 Charlottesville, VA 22904-4400 485 McCormick Road USA Charlottesville, VA 22903 roomphone Office:B011 +1-434-982-4729 Lab:B019+1-434-982-4751 WWW:http://www.people.virginia.edu/~mk9y/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Packages 'effects' loads 'name' which conflicts with 'lme4' [corrected subject: Package 'effects' loads 'nlme' which conflicts with 'lme4']
Hi Spencer, In an Sweave script, which would take me too long to boil down to a reproducible example, lme4 was loaded before effects, and a calculation involving the effect() function failed. This was remedied by following John's advice and loading the two packages in the order he recommended at the beginning of the run. The problem went away. As far as I can tell, no such warning was issued, or at least none was noticed by me, because I'm caching many computations, which may hide warnings. MK On Mar 8, 2012, at 10:29 AM, Spencer Graves wrote: Dear John, et al.: What happens if lme4 is loaded before the effect package? Is this an issue of a user wanting to use two different packages with potentially conflicting names? What are the standard recommendations for handling issues like this? Just to test my comprehension, I assume that the key is that users should routinely watch for warnings of name conflicts and follow the advice of sect. 1.6.1 Specifying imports and exports of Writing R Extensions when that occurs? (This is another reason for writing R packages and using namespaces, so users can record appropriately what they want in situations like this and not have to worry about name conflicts later?) Thanks, Spencer On 3/8/2012 4:19 AM, Michael Kubovy wrote: Dear John, Thanks for the quick response. It works perfectly. Michael On Mar 7, 2012, at 9:19 PM, John Fox wrote: Dear Michael, effect() works with lmer(). Just load lme4 after the effect package. See the penultimate example in ?effect. I hope this helps, John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Wed, 7 Mar 2012 20:53:20 -0500 Michael Kubovykub...@virginia.edu wrote: Hi, I would like to use the effect() function (actually a slightly modified version of it) on the output of the lmer() function in the lme4 package. But the effects package requires the nlme pacvkage, which is incompatible with lme4. Workaround? __ Professor Michael Kubovy University of Virginia Department of Psychology for mail add:for FedEx or UPS add: P.O.Box 400400 Gilmer Hall, Room 102 Charlottesville, VA 22904-4400 485 McCormick Road USA Charlottesville, VA 22903 roomphone Office:B011 +1-434-982-4729 Lab:B019 +1-434-982-4751 WWW:http://www.people.virginia.edu/~mk9y/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com __ Professor Michael Kubovy University of Virginia Department of Psychology for mail add: for FedEx or UPS add: P.O.Box 400400 Gilmer Hall, Room 102 Charlottesville, VA 22904-4400 485 McCormick Road USA Charlottesville, VA 22903 roomphone Office:B011 +1-434-982-4729 Lab:B019+1-434-982-4751 WWW:http://www.people.virginia.edu/~mk9y/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Packages 'effects' loads 'name' which conflicts with 'lme4' [corrected subject: Package 'effects' loads 'nlme' which conflicts with 'lme4']
Dear John, That's most helpful. Thank you. MK On Mar 8, 2012, at 9:03 PM, John Fox wrote: Dear Michael and Spencer, I've modified the development version of the effects package on R-Forge so that the nlme and lme4 packages are listed under Suggests rather than Depends. In this way, neither package is loaded along with effects. Best, John On Thu, 8 Mar 2012 20:45:37 -0500 Michael Kubovy kub...@virginia.edu wrote: Hi Spencer, In an Sweave script, which would take me too long to boil down to a reproducible example, lme4 was loaded before effects, and a calculation involving the effect() function failed. This was remedied by following John's advice and loading the two packages in the order he recommended at the beginning of the run. The problem went away. As far as I can tell, no such warning was issued, or at least none was noticed by me, because I'm caching many computations, which may hide warnings. MK On Mar 8, 2012, at 10:29 AM, Spencer Graves wrote: Dear John, et al.: What happens if lme4 is loaded before the effect package? Is this an issue of a user wanting to use two different packages with potentially conflicting names? What are the standard recommendations for handling issues like this? Just to test my comprehension, I assume that the key is that users should routinely watch for warnings of name conflicts and follow the advice of sect. 1.6.1 Specifying imports and exports of Writing R Extensions when that occurs? (This is another reason for writing R packages and using namespaces, so users can record appropriately what they want in situations like this and not have to worry about name conflicts later?) Thanks, Spencer On 3/8/2012 4:19 AM, Michael Kubovy wrote: Dear John, Thanks for the quick response. It works perfectly. Michael On Mar 7, 2012, at 9:19 PM, John Fox wrote: Dear Michael, effect() works with lmer(). Just load lme4 after the effect package. See the penultimate example in ?effect. I hope this helps, John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Wed, 7 Mar 2012 20:53:20 -0500 Michael Kubovykub...@virginia.edu wrote: Hi, I would like to use the effect() function (actually a slightly modified version of it) on the output of the lmer() function in the lme4 package. But the effects package requires the nlme pacvkage, which is incompatible with lme4. Workaround? Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com __ Professor Michael Kubovy University of Virginia Department of Psychology for mail add: for FedEx or UPS add: P.O.Box 400400 Gilmer Hall, Room 102 Charlottesville, VA 22904-4400 485 McCormick Road USA Charlottesville, VA 22903 roomphone Office:B011 +1-434-982-4729 Lab:B019+1-434-982-4751 WWW:http://www.people.virginia.edu/~mk9y/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Packages 'effects' loads 'name' which conflicts with 'lme4'
Hi, I would like to use the effect() function (actually a slightly modified version of it) on the output of the lmer() function in the lme4 package. But the effects package requires the nlme pacvkage, which is incompatible with lme4. Workaround? __ Professor Michael Kubovy University of Virginia Department of Psychology for mail add: for FedEx or UPS add: P.O.Box 400400 Gilmer Hall, Room 102 Charlottesville, VA 22904-4400 485 McCormick Road USA Charlottesville, VA 22903 roomphone Office:B011 +1-434-982-4729 Lab:B019+1-434-982-4751 WWW:http://www.people.virginia.edu/~mk9y/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Sexpr not getting expanded in Sweave
An Sweave file, 'test.Rnw': \documentclass{article} \title{Sweave minimal} \author{MK} \begin{document} \maketitle We try Sweave: 1= data(airquality) summary(airquality) x - airquality[1, 1] @ I try Sexpr: \Sexpr{x} We plot: \begin{center} 2, fig=TRUE, echo=FALSE = boxplot(Ozone ~ Month, data = airquality) @ \end{center} \end{document} I check the sessionInfo: sessionInfo() R version 2.14.1 (2011-12-22) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] datasets splines utils stats graphics grDevices methods base other attached packages: [1] cacheSweave_0.6 stashR_0.3-4filehash_2.2concord_1.4-9 irr_0.83lpSolve_5.6.6 ca_0.33 rgl_0.92.798 [9] vegan_2.0-2 permute_0.6-3 reshape_0.8.4 plyr_1.7.1 ggplot2_0.9.0 doBy_4.5.2 snow_0.3-8 lme4_0.999375-42 [17] Matrix_1.0-3lattice_0.20-0 multcomp_1.2-10 mvtnorm_0.9-9992R2HTML_2.2 BiocInstaller_1.2.1 ctv_0.7-4 sos_1.3-1 [25] brew_1.0-6 Hmisc_3.9-2 survival_2.36-12MASS_7.3-17 loaded via a namespace (and not attached): [1] car_2.0-12 cluster_1.14.2 colorspace_1.1-1 dichromat_1.2-4 digest_0.5.1 grid_2.14.1memoise_0.1munsell_0.3 nlme_3.1-103 [10] proto_0.3-9.2 RColorBrewer_1.0-5 reshape2_1.2.1 scales_0.1.0 stats4_2.14.1 stringr_0.6tools_2.14.1 and run Sweave: Sweave(file = 'test.Rnw') Writing to file test.tex Processing code chunks with options ... 1 : echo keep.source term verbatim (label = 1) 2 : keep.source term verbatim pdf (label = 2) You can now run (pdf)latex on test.tex It works as it should except for \Sexpr \documentclass{article} \title{Sweave minimmal} \author{MK} \usepackage{Sweave} \begin{document} \maketitle We try Sweave: \begin{Schunk} \begin{Sinput} data(airquality) summary(airquality) \end{Sinput} \begin{Soutput} Ozone Solar.R WindTemp Month Day Min. : 1.0 Min. : 7 Min. : 1.70 Min. :56.0 Min. :5.00 Min. : 1.0 1st Qu.: 18.0 1st Qu.:116 1st Qu.: 7.40 1st Qu.:72.0 1st Qu.:6.00 1st Qu.: 8.0 Median : 31.5 Median :205 Median : 9.70 Median :79.0 Median :7.00 Median :16.0 Mean : 42.1 Mean :186 Mean : 9.96 Mean :77.9 Mean :6.99 Mean :15.8 3rd Qu.: 63.2 3rd Qu.:259 3rd Qu.:11.50 3rd Qu.:85.0 3rd Qu.:8.00 3rd Qu.:23.0 Max. :168.0 Max. :334 Max. :20.70 Max. :97.0 Max. :9.00 Max. :31.0 NA's : 37.0 NA's : 7 \end{Soutput} \begin{Sinput} x - airquality[1, 1] \end{Sinput} \end{Schunk} We try Sexpr: \Sexpr{x} We plot: \begin{center} \includegraphics{test-2} \end{center} \end{document} The beginning of the .log file: This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011) (format=pdflatex 2012.2.4) 23 FEB 2012 18:19 entering extended mode \write18 enabled. %-line parsing enabled. **test.tex (./test.tex LaTeX2e 2011/06/27 Any thought? Please CC me when replying. Michael Kubovy [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem with R 2.13.0 Task Views (on Mac)
Dear R-users, After upgrading to the recent version of R, I'm having a problem updating task views: sessionInfo() R version 2.13.0 (2011-04-13) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] datasets utils stats graphics grDevices methods base other attached packages: [1] ctv_0.7-0 sos_1.3-0 brew_1.0-4 MASS_7.3-12 update.views('Graphics') Error in split.default(X, group) : first argument must be a vector In addition: Warning message: In .get_pkgs_from_ctv_or_repos(views = views, coreOnly = coreOnly, : CRAN task view Graphics not available Thanks, __ Professor Michael Kubovy University of Virginia Department of Psychology for mail add: for FedEx or UPS add: P.O.Box 400400 Gilmer Hall, Room 102 Charlottesville, VA 22904-4400 McCormick Road USA Charlottesville, VA 22903 roomphone Office:B011 +1-434-982-4729 Lab:B019+1-434-982-4751 WWW:http://www.people.virginia.edu/~mk9y/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] odfWeave
Dear -r-helpers, I'm trying to get my students to use odfWeave. Windows users are having trouble. I would appreciate advice. Comment 1: Hello I have spent a while today trying to get odfWeave to be successful I installed the unzip and zip program but it has not changed the error message.I have copied the error message below but I am sure it is the one others have experienced. odfWeave('test.odt','testOut.odt') Copying test.odt Setting wd to C:\Users\Mark\AppData\Local\Temp\RtmpHPp0yb/odfWeave30211245749 Unzipping ODF file using unzip -o test.odt Error in odfWeave(test.odt, testOut.odt) : Error unzipping file In addition: Warning message: In system(zipCmd[2], invisible = TRUE) : unzip not found Please advise on any way to get around this issue. I am running Windows 7. Comment 2: I have been having the same problem as Mark for a few days now. After inputting the odfWeave command, the output looks normal up to this line: Unzipping ODF file using unzip -o test.odt but the next few lines show an error message. It seems to be a problem with the unzipping process, but installing the Zip and Unzip programs do not remedy the problem. I am also running Windows 7. Michael _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400 Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick Road Charlottesville, VA 22903 Office: B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Gray level mosaic plot with shading_Friendly
Dear Achim and Michael, Thank you so much. Indeed, mosaic(Titanic, gp = shading_hcl, gp_args = list(lty = 1:2, c = 0)) does almost what I was looking for, except that for consistency and clarity, I would have expected the negative values on the legend to be be outlined with lty = 2. Michael On Jul 7, 2010, at 2:13 AM, Achim Zeileis wrote: On Tue, 6 Jul 2010, Michael Friendly wrote: Michael Kubovy wrote: Suppose we start with data(Titanic) mosaic(Titanic, shade = TRUE) How do I combine the dashed box contours of shading_Friendly to indicate negative residuals, with three levels of gray: dark for abs(Pearson Resid) 4, lighter for 4 abs(Pearson Resid) 2, and lightest for bs(Pearson Resid) 2 ? Do you mean [1] you want to plot positive residuals in color and negative in gray scale? Or [2] to fold + and - residuals by shading all according to abs(resid), and distinguishing + from - by the dashed box outlines? In fact, I designed this coding scheme so that mosaic plots in color (with my blue - white - red scheme) would approximately do exactly what you might want under [2], when rendered in B/W, since the fully saturated red and blue are close in darkness in B/W. And shading_hcl() has been written to do exactly what you want under [2]. While it is hard to come up with colors of different hues in HSV or HLS space that have the same brightness (aka lightness/luminance) and the same colorfulness (aka chroma), this is easy in HCL. Try mosaic(Titanic, gp=shading_Friendly) save as a jpg/png and try converting to B/W with an image program and see if this is good enough. mosaic(Titanic, shade = TRUE) is the same as mosaic(Titanic, gp = shading_hcl) which you can then modify to have different line types mosaic(Titanic, gp = shading_hcl, gp_args = list(lty = 1:2)) If you print that on a grayscale printer you will see the same plot without any chroma, i.e., mosaic(Titanic, gp = shading_hcl, gp_args = list(lty = 1:2, c = 0)) The shading_hcl() function is introduced in Zeileis et al. (2007, JCGS), see ?shading_hcl, which provides more detailed references to HCL colors etc. Best, Z Alternatively, write your own, shading_Kubovy, modeled on shading_Friendly - function (observed = NULL, residuals = NULL, expected = NULL, df = NULL, h = c(2/3, 0), lty = 1:2, interpolate = c(2, 4), eps = 0.01, line_col = black, ...) { shading_hsv(observed = NULL, residuals = NULL, expected = NULL, df = NULL, h = h, v = 1, lty = lty, interpolate = interpolate, eps = eps, line_col = line_col, p.value = NA, ...) } environment: namespace:vcd attr(,class) [1] grapcon_generator In the defaults, lty=1:2 is what distinguishes + and - for outline line type hope this helps, -Michael __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Gray level mosaic plot with shading_Friendly
Suppose we start with data(Titanic) mosaic(Titanic, shade = TRUE) How do I combine the dashed box contours of shading_Friendly to indicate negative residuals, with three levels of gray: dark for abs(Pearson Resid) 4, lighter for 4 abs(Pearson Resid) 2, and lightest for bs(Pearson Resid) 2 ? Thanks, Michael __ Professor Michael Kubovy University of Virginia Department of Psychology for mail add: for FedEx or UPS add: P.O.Box 400400 Gilmer Hall, Room 102 Charlottesville, VA 22904-4400 McCormick Road USA Charlottesville, VA 22903 roomphone Office:B011 +1-434-982-4729 Lab:B019+1-434-982-4751 WWW:http://www.people.virginia.edu/~mk9y/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] odfWeave produces output file that OO can't open
Dear R-helpers, I'm trying to learn how to use odfSweave. Here is my source file (in /Users/mk/myTeach/2010-1-7720/odfWeave): Analysis of the iris Data Created on \Sexpr{date()} loadLibs, echo = FALSE, results = hide= # I usually load the libraries first so that any output produced by loading the library does not end up in the document library(MASS) library(lattice) library(grid) data(iris) @ This famous (Fisher's or Anderson's) iris data set gives the measurements in centimeters of the variables sepal length and width and petal length and width, respectively, for \Sexpr{dim(iris)[1]/3} flowers from each of \Sexpr{length(levels(iris$Species))} species of iris. The species are \Sexpr{paste(levels(iris$Species), collapse = , )}. Here is a bulleted list of the species: showOutputList, echo = FALSE, results = xml= odfItemize(levels(iris$Species)) @ With R version 2.10.0 (2009-10-26) x86_64-apple-darwin9.8.0 locale: [1] C/C/en_US/C/C/C attached base packages: [1] grid stats graphics grDevices datasets utils methods [8] base other attached packages: [1] MASS_7.3-4 odfWeave_0.7.10 XML_2.6-0 lattice_0.17-26 [5] JGR_1.7-0 iplots_1.1-3JavaGD_0.5-2rJava_0.8-1 loaded via a namespace (and not attached): [1] Matrix_0.999375-32 lme4_0.999375-32 tools_2.10.0 I run: odfWeave('simple1.odt','simpleOut.odt') Copying simple1.odt Setting wd to /var/folders/TG/TG6nWu2pHYCI-BdWWiyMxU+++TI/-Tmp-//RtmplOpSLO/odfWeave13103539684 Unzipping ODF file using unzip -o simple1.odt Removing simple1.odt Creating a Pictures directory Pre-processing the contents Sweaving content.Rnw Writing to file content_1.xml Processing code chunks ... 1 : term hide(label=loadLibs) 2 : term xml(label=showOutputList) 'content_1.xml' has been Sweaved Removing content.xml Post-processing the contents Removing content.Rnw Removing styles.xml Renaming styles_2.xml to styles.xml Removing extra files Packaging file using zip -r simple1.odt . Copying simple1.odt Resetting wd Removing /var/folders/TG/TG6nWu2pHYCI-BdWWiyMxU+++TI/-Tmp-//RtmplOpSLO/odfWeave13103539684 Done Warning message: closing unused connection 3 (content.xml) When I try to open simpleOut.odt I get: Format error discovered in the file in sub-document content.xml at 22,124(row,col). The file content.xml is empty. __ Professor Michael Kubovy University of Virginia Department of Psychology for mail add: P.O.Box 400400 Charlottesville, VA 22904-4400 USA for FedEx or UPS add: Gilmer Hall, Room 102 McCormick Road Charlottesville, VA 22903 USA roomphone 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to tell if its better to standardize your data matrix first when you do principal
On Nov 22, 2009, at 10:22 AM, Uwe Ligges wrote: masterinex wrote: Hi guys , Im trying to do principal component analysis in R . There is 2 ways of doing it , I believe. One is doing principal component analysis right away the other way is standardizing the matrix first using s = scale(m)and then apply principal component analysis. How do I tell what result is better ? What values in particular should i look at . I already managed to find the eigenvalues and eigenvectors , the proportion of variance for each eigenvector using both methods. Generally, it is better to standardize. But in some cases, e.g. for the same units in your variables indicating also the importance, it might make sense not to do so. You should think about the analysis, you cannot know which result is `better' unless you know an interpretation. I noticed that the proportion of the variance for the first pca without standardizing had a larger value . Is there a meaning to it ? Isnt this always the case? At last , if I am supposed to predict a variable ie weight should I drop the variable ie weight from my data matrix when I do principal component analysis ? This sounds a bit like homework. If that is the case, please ask your teacher rather than this list. Anyway, it does not make sense to predict weight using a linear combination (principle component) that contains weight, does it? Uwe Ligges It's likely to have been homework: A quick search on masterinex xevilgang79 reveal which university this undergraduate student is at. It also produces a phone number, which can be used to lookup an address, and a cell phone number. MK __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2::qplot() -- arbitary transformations of coordinate system?
Hi Stephen, Because coord_trans() does all the work of plotting the original values on the tranformed scale. See ?coord_trans. To quote: The difference between transforming the scales and transforming the coordinate system is that scale transformation occurs BEFORE statistics, and coordinate transformation afterwards. # After require(ggplot2) data(diamonds) # Three ways of doing transformating in ggplot: # * by transforming the data qplot(log10(carat), log10(price), data=diamonds) # * by transforming the scales qplot(carat, price, data=diamonds, log=xy) qplot(carat, price, data=diamonds) + scale_x_log10() + scale_y_log10() # * by transforming the coordinate system: qplot(carat, price, data=diamonds) + coord_trans(x = log10, y = log10) Michael On Sep 5, 2009, at 9:01 PM, stephen sefick wrote: why not transform the y-data? On Sat, Sep 5, 2009 at 8:03 PM, Michael Kubovykub...@virginia.edu wrote: Hi, Does anyone know how to do a coord_trans() in which the y-axis is tranformed into (for example) -1000/y? Stephen Sefick _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ggplot2::qplot() -- arbitary transformations of coordinate system?
Hi, Does anyone know how to do a coord_trans() in which the y-axis is tranformed into (for example) -1000/y? Thanks, _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] SMACOF joint configuration plot with bread data?
Dear R-helpers, I have dist class objects for 10 individuals rating the dissimilarities (on a 100-point scale) of the same 10 faces (analogous to the bread data). I would like to get an individual differences scaling jointly for the individual judges and the faces, and plot them on the same axes. This is the example: library(smacof) data(breakfast) res.rect-smacofRect(breakfast, itmax = 1000) plot(res.rect, joint = TRUE, xlim = c(-10, 10)) However, smacofIndDiff() doesn't produce the desired form of output. This is the bread example, which has data in roughly the same form as mine: data(bread) res.uc - smacofIndDiff(bread, itmax = 1000) Thanks, _ 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/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Interaction plots as lines or bars?
Dear r-helpers, An editor has suggested that I use bar plots to capture an interaction of two 2-level factors and an interaction of a 2 by 3 factorial experiment. (It would seem that there's a fear that someone might try to interpolate between, e.g., 'male' and 'female'.) In general it seems to me that an interaction plot with lines is easier to read, and not likely to mislead. Does anyone know if and where this has been discussed? _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Can anyone suggest some r packages for Experimental Designs, specifically for choice and conjoint??? (or is intersted in helping me make 1)
There are quite a few others. See: http://cran.r-project.org/web/views/ExperimentalDesign.html On May 12, 2009, at 7:44 PM, Chris Howden wrote: I've spent the last week or so looking at all the experimental design packages I can find in R. AlgDesign, design.conf and BHH2 being the best one I could find. Unfortunately none of these do a particularly good job for complex designs, in particular for conjoint or discrete choice. (or perhaps they do, and I can't make them work correctly) Specifically, the problem is that none of them optimise the design for main effects or 2-way effects balance. So although the 'd-efficiency' is optimised some 2 way interactions are not present in the design (thereby preventing the interaction from being modelled). And the main effects balance is also quite bad, some levels being seen twice as often as others So I was wondering if anyone out there has any experience in using R for complex design issues, and if so if they could point me in the direction of some good packages? Or maybe help me out with my 'balance' problem? Thanks for your help PS: And if all else fails I'm thinking about trying to extend AlgDesign to incorporate balance as a criteria when searching for designs. So just wondering if there's anyone out there keen to help me (even if its just testing out my beta versions) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Hmisc::latex() help
Dear R-helpers, I have a data frame (info[[j]]) that looks like this: necklace originalPosition same run surprise1 pairsurprise2 triplesurprise3 1110 2 2.709511 11 4.81884167930642110 2.70951129135145 2120 2 2.709511 10 10001 303 NA NANA 00 NA001 NA 404 NA NANA 00 NA100 NA 505 NA NANA 00 NA000 NA 606 NA NANA 00 NA011 NA 707 NA NANA 00 NA000 NA 808 NA NANA 01 NA000 NA I produce a LaTeX table with: j - 1 latex(object = info[[j]], file = paste('info', j, '.tex', sep = ''), rowlabel = NULL, booktabs = TRUE, here = TRUE, caption = paste(df[j, ], collapse = ''), na.blank = TRUE, dcolumn = TRUE, cdec = c(0, 0, 0, 0, 2, 0, 2, 0, 2)) However, na.blank and cdec make no difference, producing: \newcolumntype{.}{D{.}{.}{-1}} \begin{table}[H] \caption{1100\label{info}} \begin{center} \begin{tabular}{lD{.}{.}{-1}D{.}{.}{-1}D{.}{.}{-1}D{.}{.}{-1}D{.}{.} {-1}}\toprule \multicolumn{1}{l}{necklace}\multicolumn{1}{c}{originalPosition} \multicolumn{1}{c}{same}\multicolumn{1}{c}{run}\multicolumn{1}{c} {surprise1}\multicolumn{1}{c}{pair}\multicolumn{1}{c}{surprise2} \multicolumn{1}{c}{triple}\multicolumn{1}{c}{surprise3} \multicolumn{1}{c}{necklace}\tabularnewline \midrule 111~0~22.71114.818841679306421102.70951129135145\tabularnewline 212~0~22.711010001\tabularnewline 30300NA001NA\tabularnewline 40400NA100NA\tabularnewline 50500NA000NA\tabularnewline 60600NA011NA\tabularnewline 70700NA000NA\tabularnewline 80801NA000NA\tabularnewline \bottomrule \end{tabular} \end{center} \end{table} I presume that this is due to the mixed nature of the columns. Suggestions for a fix? (I am also not clear on when R produces NA or NA Thanks, MK _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Find cyclically identical binary sequences
Dear R-helpers, I need to generate all the binary sequences of length n (here n = 8) that start with 1 and have no fewer than two of each digit, and are not cyclic permutations of each other. Here is what I have done: len - 8 df - as.data.frame(numeric(2^(len - 1)) %o% numeric(len)) require(partitions) for (i in 1:2^(len - 1)) df[i, ] - binary(i, dim = len)[[1]] df - df[which(df[, 1] == 1), ] df - df[which(rowSums(df) 1), ] df - df[which(rowSums(df) len - 1), ] The following are cyclic permutations of each other: df[which(rowSums(df) == 3), ][c(2, 15), ] I would like to retain the larger of the two (if considered a binary number). Can someone suggest an algorithm? Thanks, Michael _ 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/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Find cyclically identical binary sequences (corrected)
Dear R-helpers, I need to generate all the binary sequences of length n (here n = 8) that start with 1 and have no fewer than two of each digit, and are not cyclic permutations of each other. Here is what I have done: len - 8 df - as.data.frame(numeric(2^(len - 1)) %o% numeric(len)) require(wle) for (i in 1:2^(len - 1)) df[i, ] - binary(i, dim = len)[[1]] df - df[which(df[, 1] == 1), ] df - df[which(rowSums(df) 1), ] df - df[which(rowSums(df) len - 1), ] The following are cyclic permutations of each other: df[which(rowSums(df) == 3), ][c(2, 15), ] I would like to retain the larger of the two (if considered a binary number). Can someone suggest an algorithm? Thanks, Michael _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sweave and executive summaries
Hi Karen, Once you've run your .Rnw file once, and (say) assigned the output of a lm(y ~ x) to m1, you can add your summary at the beginning of your .Rnw file and output quantities such as the intercept (to be produced later) using $\Sexpr{round(as.numeric(coef(m1)[1]), 3)}$ (it's a good idea to have the $$ because otherwise minus signs will print as hyphens). This is the case that the object m1 will still be available at the beginning of the next run. This is not perfect, b/c if later, during a different R session, you want to run the Rnw file through again, you'll have to remove the \Sexpr{} in your summary until the second run. So you can keep two versions of your Rnw file, a short one for the first run, and a longer one for the second. On Apr 15, 2009, at 1:47 PM, karen_by...@bd.com wrote: I'm learning to use R/Sweave/LaTeK to write my stat reports. Is there a way to have an executive summary in the beginning while still having the analysis code embedded? For example, a study has three independent objectives so I want my report to have three sections. Ideally the code chunk that answers the first objective would be embedded in the first section and so on. However I want a table that summarizes the results from all three objectives at the beginning of the report. Is there a way to generate a summary after the three sections but tell LaTeK to publish it first? Possibly by rearranging the sections/pages? Currently I'm doing all the coding in a big block up front but that waste much of the advantage of weaving to me. HTH, MK _ 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/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem with circular::plot.circular()
require(circular) c - circular(rep(0, 20), zero = pi/2, rotation = 'clock') plot(c, stack = TRUE, shrink = 1.5) Can anyone tell me why the stack is offset from 0? _ 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/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with circular::plot.circular()
Thanks so much. I have another question: why the difference here: require(circular) c1 - circular(pi/2 + .0, zero = pi/2, rotation = 'clock') c2 - circular(pi/2 + .1, zero = pi/2, rotation = 'clock') opar - par(mfrow = c(1, 2)) plot(c1, stack = TRUE, bins = 1, main = expression(pi/2)) plot(c2, stack = TRUE, bins = 1, main = expression(pi/2 + .1)) par(opar) On Mar 29, 2009, at 8:09 AM, Duncan Murdoch wrote: On 29/03/2009 7:39 AM, Michael Kubovy wrote: require(circular) c - circular(rep(0, 20), zero = pi/2, rotation = 'clock') plot(c, stack = TRUE, shrink = 1.5) Can anyone tell me why the stack is offset from 0? It's a histogram, and the bin starts at zero, and runs to pi/10 (I'm guessing, since it appears to choose 20 bins). You can see the binning effect if you set your data to c - circular(runif(20, 0, 2*pi), zero=pi/2, rotation='clock') Set bins to 1 and the offset will be undetectable: plot(c, stack = TRUE, shrink = 1.5, bins=1) Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] newton method
Take a look at the functionsnlm(), optim() in the stats package and maxNR() in the maxLik package. On Mar 22, 2009, at 11:15 PM, Roslina Zakaria wrote: Does R has a topic on newton's method? _ Professor Michael Kubovy University of Virginia Department of Psychology Postal Address: P.O.Box 400400, Charlottesville, VA 22904-4400 Express Parcels Address: Gilmer Hall, Room 102, McCormick Road, Charlottesville, VA 22903 Office:B011;Phone: +1-434-982-4729 Lab:B019; Phone: +1-434-982-4751 WWW:http://www.people.virginia.edu/~mk9y/ Skype name: polyurinsane [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Calling R from Java (trying the R interface to Omegahat and Java)
Dear R-helpers, I run R version 2.8.1 (2008-12-22) on i386-apple-darwin8.11.1 I would like to call R from Java. I downloaded SJava_0.69-0.tar.gz, and then issued the command suggested on http://www.omegahat.org/ RSJava/ : % R INSTALL -c SJava_0.69-0.tar.gz ARGUMENT 'INSTALL' __ignored__ WARNING: unknown option '-c' ARGUMENT 'SJava_0.69-0.tar.gz' __ignored__ I then tried % R CMD INSTALL SJava_0.69-0.tar.gz * Installing to library '/Library/Frameworks/R.framework/Resources/ library' * Installing *source* package 'SJava' ... checking for java... /usr/bin/java Java VM /usr/bin/java checking for javah... no Sorry. We can currently only configure this package for IBM, Blackdown or Sun's Java implementation ERROR: configuration failed for package 'SJava' ** Removing '/Library/Frameworks/R.framework/Resources/library/SJava' Can someone tell me what I'm doing wrong? Since this is a matter of some urgency, I would be grateful if you also cc-ed my email address. _ Professor Michael Kubovy University of Virginia Department of Psychology Postal Address: P.O.Box 400400, Charlottesville, VA 22904-4400 Express Parcels Address: Gilmer Hall, Room 102, McCormick Road, Charlottesville, VA 22903 Office:B011;Phone: +1-434-982-4729 Lab:B019; Phone: +1-434-982-4751 WWW:http://www.people.virginia.edu/~mk9y/ Skype name: polyurinsane [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Calling R from Java (trying the R interface to Omegahat and Java)
Thanks for the tip. I'll start with rJava, and see if that easier approach works. On Mar 20, 2009, at 10:50 PM, Martin Morgan wrote: Michael Kubovy kub...@virginia.edu writes: Dear R-helpers, I run R version 2.8.1 (2008-12-22) on i386-apple-darwin8.11.1 I would like to call R from Java. I downloaded SJava_0.69-0.tar.gz, and then issued the command suggested on http://www.omegahat.org/ RSJava/ : Others will point you to rJava http://www.rforge.net/rJava/ which might well be a good solution for you; if you have reasons for using SJava, then the currently maintained version is at https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/SJava accessible using 'svn' and the instructions at http://wiki.fhcrc.org/bioc/SvnHowTo It has not been tested recently on a mac... % R INSTALL -c SJava_0.69-0.tar.gz This should be R CMD INSTALL --clean SJava_0.69-0.tar.gz ARGUMENT 'INSTALL' __ignored__ WARNING: unknown option '-c' ARGUMENT 'SJava_0.69-0.tar.gz' __ignored__ I then tried % R CMD INSTALL SJava_0.69-0.tar.gz * Installing to library '/Library/Frameworks/R.framework/Resources/ library' * Installing *source* package 'SJava' ... checking for java... /usr/bin/java Java VM /usr/bin/java checking for javah... no you require the JDK (Java Development Kit), not just the JRE (Java Runtime Environment); if you've got the right software installed, you should be able to find the program 'javah' on your system. Hope that helps, Martin Sorry. We can currently only configure this package for IBM, Blackdown or Sun's Java implementation ERROR: configuration failed for package 'SJava' ** Removing '/Library/Frameworks/R.framework/Resources/library/SJava' Can someone tell me what I'm doing wrong? Since this is a matter of some urgency, I would be grateful if you also cc-ed my email address. _ Professor Michael Kubovy University of Virginia Department of Psychology Postal Address: P.O.Box 400400, Charlottesville, VA 22904-4400 Express Parcels Address: Gilmer Hall, Room 102, McCormick Road, Charlottesville, VA 22903 Office:B011;Phone: +1-434-982-4729 Lab:B019; Phone: +1-434-982-4751 WWW:http://www.people.virginia.edu/~mk9y/ Skype name: polyurinsane [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Martin Morgan Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M2 B169 Phone: (206) 667-2793 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Inconsistency in alphabetization of documenation
(1) In CRAN - Contributed Packages ***the order is AaBb*** It has a useful list a of alphabetical links at the top (2) In the package index for R version 2.8.1 (2008-12-22) i386-apple-darwin8.11.1 locale: en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 ***the order is AB ab *** It does not have a list of alphabetical links (3) In the R Package Installer for R version 2.8.1 (2008-12-22) i386-apple-darwin8.11.1 locale: en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 ***the order is case insensitive*** One can restrict the list to a substring of the package name. _ Professor Michael Kubovy University of Virginia Department of Psychology Postal Address: P.O.Box 400400, Charlottesville, VA 22904-4400 Express Parcels Address: Gilmer Hall, Room 102, McCormick Road, Charlottesville, VA 22903 Office:B011;Phone: +1-434-982-4729 Lab:B019; Phone: +1-434-982-4751 WWW:http://www.people.virginia.edu/~mk9y/ Skype name: polyurinsane [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to add direction of time to plot.circular()
Dear r-helpers, I want to show that time is flowing CCW in the following: require(circular) len - 8 labl - as.character(c(0, 1, 1, 1, 0, 0, 1, 0)) r - circular(2*pi* (rep(c(1, 3, 6), each = 200)/len + rnorm(600, 0, 0.025))) r.dens - density(r, bw = 25, adjust = 4, kernel = 'vonmises') plot(r, shrink = 2.5, axes = FALSE, ticks = FALSE, pch = 1, col = 'lightblue', stack = TRUE, bins = 12 * len) axis.circular(at = circular(seq(0, (len - 1) * 2 * pi/len, length.out = len)), label = labl) lines(r.dens, col = 2) I had imagined a directed arc with a smaller radius than the black circle, running from 0 to 315 deg. I also thought that adding a short horizontal line at its beginning might be helpful. I would appreciate advice on how best to do this or anything else that would provide the required information. _ Professor Michael Kubovy University of Virginia Department of Psychology Postal Address: P.O.Box 400400, Charlottesville, VA 22904-4400 Express Parcels Address: Gilmer Hall, Room 102, McCormick Road, Charlottesville, VA 22903 Office:B011;Phone: +1-434-982-4729 Lab:B019; Phone: +1-434-982-4751 WWW:http://www.people.virginia.edu/~mk9y/ Skype name: polyurinsane [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] assuming AR(1) residuals in OLS
?gls On Feb 16, 2009, at 12:28 PM, constantine wrote: In other statistical software, such as Eviews, it is possible to regress a model with the Least Squares method, assuming that the residuals follow an AR(q) process. For example the resulting regression is something like y = 1.2154 + 0.2215 x + 0.251 AR(1) How is it possible to do the same in R? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Extracting coordinates for cluster::clusplot()
Dear Friends, require(cluster) x - rbind(cbind(rnorm(10, 0, 0.5), rnorm(10, 0, 0.5)), cbind(rnorm(15, 5, 0.5), rnorm(15, 5, 0.5))) plot(pp - pam(x, 2), which.plots = 1) How can I extract the coordinates used in the plot? _ Professor Michael Kubovy University of Virginia Department of Psychology Postal Address: P.O.Box 400400, Charlottesville, VA 22904-4400 Express Parcels Address: Gilmer Hall, Room 102, McCormick Road, Charlottesville, VA 22903 Office:B011;Phone: +1-434-982-4729 Lab:B019; Phone: +1-434-982-4751 WWW:http://www.people.virginia.edu/~mk9y/ Skype name: polyurinsane [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem with JGR. Was: Re: Using help()
Dear Friends, Thanks to Rolf Turner, Brian Ripley and Patrick Burns for their answers.They don't quite resolve the problem, which I now realize is due to non-standard behavior of JGR, at least on my machine (I verified that Mac GUI works entirely as expected): My installation Running the JGR GUI: sessionInfo() R version 2.8.1 (2008-12-22) i386-apple-darwin8.11.1 locale: C/C/en_US/C/C/C attached base packages: [1] grid stats graphics grDevices utils datasets methods [8] base other attached packages: [1] JGR_1.6-2 iplots_1.1-2JavaGD_0.5-2rJava_0.6-1 [5] MASS_7.2-45 lattice_0.17-20 loaded via a namespace (and not attached): [1] tools_2.8.1 What happens with ? and ?? ** If I type ?normal I get the long list, not No documentation found. When I type ?plot I get the help page for plot {JM}, and not plot.default {graphics}; when I type ?dnorm I get a rather long list of help pages. If I type ??normal I get ?normal.htm .com.symantec.APSock .com.symantec.aptmp .DM_1039:1232634821l:DlnIrq .DM_11869:1232818209l:m4AGyL .DM_13345:1232655220l:C1js39 .DM_14309:1232822090l:e6wvqw .DM_15688:1232659145l:ffZvPg .DM_16640:1232825979l:n5TrAz .DM_18040:1232662823l:Gb81yX Another JGR problem ** Help pages for newly installed packages are accessible only after JGR is restarted. Thanks, MK On Jan 24, 2009, at 8:54 PM, Rolf Turner wrote: On 25/01/2009, at 2:33 PM, Michael Kubovy wrote: (1) If I type ?normal because I forgot the name dnorm() I get a long list of relevant pages. Getting to right page is laborious. (2) If I remember dnorm() and want to be reminded of the call, I also get a list of pages. If you type ``?normal'' you get a ``No documentation found'' message. If you type ``??normal'' you indeed get a long list of pages, some of which might be relevant. (If you want help on ``dnorm'' then the relevant page is stats::Normal. And then typing ``?Normal'' gets you what you want. Which is somewhat on the obscure side of obvious, IMHO.) If you type ``?dnorm'' then you get exactly what you want immediately. Exactly? Well, there's also info on pnorm, qnorm, and rnorm, but I expect you can live with that. Rolf Turner [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Using help()
Dear R-helpers, I wonder if you can give me advice about the best way to use help(). (1) If I type ?normal because I forgot the name dnorm() I get a long list of relevant pages. Getting to right page is laborious. (2) If I remember dnorm() and want to be reminded of the call, I also get a list of pages. Advice? It seems to me that if the output of help() listed base functions first, it would go a long way toward improving the usefulness of this function. _ Professor Michael Kubovy University of Virginia Department of Psychology Postal Address: P.O.Box 400400, Charlottesville, VA 22904-4400 Express Parcels Address: Gilmer Hall, Room 102, McCormick Road, Charlottesville, VA 22903 Office:B011;Phone: +1-434-982-4729 Lab:B019; Phone: +1-434-982-4751 WWW:http://www.people.virginia.edu/~mk9y/ Skype name: polyurinsane [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with dudi.pca
Dear R-helpers, I have two data frames, op and em4: str(op) 'data.frame': 37 obs. of 5 variables: $ m: num 0.202 0.336 0.122 0.139 0.14 ... $ lln : num 0.798 0.643 0.863 0.835 0.823 ... $ rrn : num 0.789 0.702 0.894 0.895 0.923 ... $ asym2: num 0.177 0.304 0.108 0.187 0.274 ... $ asym3: num 0.0755 0.0975 0.0818 0.0651 0.13 ... str(rownames(op)) chr [1:37] abov-belw ampl-rstr angl-rndd ascn-dscn ... str(em3) 'data.frame': 37 obs. of 9 variables: $ B--: int 4 1 12 14 0 3 2 15 3 5 ... $ P--: int 4 1 2 3 5 15 1 0 3 1 ... $ U--: int 10 16 4 1 13 0 15 3 12 12 ... $ --B: int 5 13 10 15 6 1 5 16 5 8 ... $ --P: int 6 2 5 2 12 16 5 0 13 10 ... $ --U: int 7 3 3 1 0 1 8 2 0 0 ... $ -N-: int 0 2 11 0 17 0 1 0 14 3 ... $ -P-: int 15 0 2 16 0 2 2 16 0 0 ... $ -R-: int 3 16 5 2 1 16 15 2 4 15 ... str(rownames(em3)) chr [1:37] abov-belw ampl-rstr angl-rndd ascn-dscn asym- symm end-bgnn ... Thus the 37 rownames in both are the same. Now I do a pca of op: (op.dudi - dudi.pca(op, scale = F, scan = F)) Duality diagramm class: pca dudi $call: dudi.pca(df = op, scale = F, scannf = F) $nf: 2 axis-components saved $rank: 5 eigen values: 0.09233 0.03109 0.01322 0.002024 0.0001017 vector length modecontent 1 $cw5 numeric column weights 2 $lw37 numeric row weights 3 $eig 5 numeric eigen values data.frame nrow ncol content 1 $tab 37 5modified array 2 $li37 2row coordinates 3 $l137 2row normed scores 4 $co52column coordinates 5 $c152column normed scores other elements: cent norm and of em3 (em3.dudi - dudi.pca(em3, scale = F, scan = F)) Duality diagramm class: pca dudi $call: dudi.pca(df = em3, scale = F, scannf = F) $nf: 2 axis-components saved $rank: 6 eigen values: 105.5 80.73 55.08 24.06 8.83 ... vector length modecontent 1 $cw9 numeric column weights 2 $lw37 numeric row weights 3 $eig 6 numeric eigen values data.frame nrow ncol content 1 $tab 37 9modified array 2 $li37 2row coordinates 3 $l137 2row normed scores 4 $co92column coordinates 5 $c192column normed scores other elements: cent norm I would like to do a coinertia analysis between the two results. coinertia(op.dudi, em3.dudi) Error in paste(COCA, 1:n.axes, sep = ) : element 2 is empty; the part of the args list of ':' being evaluated was: (1, n.axes) coinertia(op.dudi, em3.dudi, n.axes = 2) Error in sqrt(Dp) : Non-numeric argument to mathematical function Can anyone tell me why the coinertia fails, and how to fix it? I would be happy to send the two data files, if you were willing to help. Thanks, MK _ Professor Michael Kubovy University of Virginia Department of Psychology Postal Address: P.O.Box 400400, Charlottesville, VA 22904-4400 Express Parcels Address: Gilmer Hall, Room 102, McCormick Road, Charlottesville, VA 22903 Office:B011;Phone: +1-434-982-4729 Lab:B019; Phone: +1-434-982-4751 WWW:http://www.people.virginia.edu/~mk9y/ Skype name: polyurinsane [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] gamlss.dist
Hi, I'm not sure how use curve(dexGAUS( None of the following four works: rt- rexGAUS(100, mu=300, nu=100, sigma=35) m1-gamlss(rt~1, family=exGAUS) curve(dexGAUS(rt=x, mu=300 ,sigma=35,nu=100), 100, 600, main = The ex- GAUS density mu=300 ,sigma=35,nu=100) curve(dexGAUS(x=rt, mu=300 ,sigma=35,nu=100), 100, 600, main = The ex- GAUS density mu=300 ,sigma=35,nu=100) curve(dexGAUS(y=rt, mu=300 ,sigma=35,nu=100), 100, 600, main = The ex- GAUS density mu=300 ,sigma=35,nu=100) curve(dexGAUS(rt=y, mu=300 ,sigma=35,nu=100), 100, 600, main = The ex- GAUS density mu=300 ,sigma=35,nu=100) But this does: y- rexGAUS(100, mu=300, nu=100, sigma=35) m1-gamlss(y~1, family=exGAUS) curve(dexGAUS(y=x, mu=300 ,sigma=35,nu=100), 100, 600, main = The ex- GAUS density mu=300 ,sigma=35,nu=100) _ 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/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Turn factors to numeric
Dear R-helpers, The FAQ in question says: It may happen that when reading numeric data into R (usually, when reading in a file), they come in as factors. If f is such a factor object, you can use as.numeric(as.character(f)) to get the numbers back. More efficient, but harder to remember, is as.numeric(levels(f))[as.integer(f)] I wonder why the R Core group did not choose to make such a useful operation simpler for the user (i.e., something like a factor2numeric() function that would be a wrapper to the more efficient command). _ 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/ On Oct 9, 2008, at 7:16 AM, Charilaos Skiadas wrote: R-FAQ 7.10: http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-convert-factors-to-numeric_003f On Oct 9, 2008, at 6:59 AM, joseph kambeitz wrote: I am having some problems while trying to fit simple data. I aggregated some data using: data1 - aggregate(data1$T2, list=(SOA=data1$SOA), mean) unfortunatly this coerces my variable SOA into a factor. Therefore when a afterwards try to fit a simple equation to my variable T2 using a formula on SOA i get a error because SOA is a factor and that * is not meaningful for factors... nls(T2 ~ a + b*SOA, start=list(a=1,b=1), data=data1, trace=TRUE) In fact SOA is a numeric variable (in my experiments it is the time that passed!) so i would like to re-coerce it into a numeric variable to do the fit or to find a method to do the fit even though SOA is a factor. Thanks a lot for your help! Best Jokel [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Color of title in legend()
Dear R-helpers, This produces a red title. How do I make it black, without making the labels black? legend(title = 'Channel Integration', 0.7, 0.3, c('loudness','luminance'), col = c('red', 'blue'), text.col = c('red', 'blue'), lty = 1, xjust = 0.5, bty = 'n') _ 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/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Sweave and/or beamer issue
Dear Friends, I not sure whether this is an Sweave or a beamer problem. The Rnw file: \documentclass[compress,smaller]{beamer} %\documentclass{article} %\usepackage{beamerarticle} \usepackage{Sweave} \title{Psychophysics II} \date{September 9, 2008} \begin{document} \frame{ \begin{Schunk} \begin{Sinput} ro - 0.2 c - seq(from = -3, to = 4, by = 0.1) fn - 1 - pnorm(c) fo - 1 - pnorm(c, mean = 1) h - fo + ro - ro * fo f - fn plot(h ~ f, type = l, asp = 1, xlim = c(0.01, 1.01), ylim = c(0.01, 1.01), las = 1, xlab = p(yes | old), + ylab = p(yes | new), main = Dual-process model, p(recollection) = 0.2) \end{Sinput} \end{Schunk} \includegraphics{20080909test-model} } \end{document} The resulting LaTeX ***FAILS: * Runaway argument? ro - 0.2 c - seq(from = -3, to = 4, by = 0.1) fn - 1 - pnorm \ETC. ! Paragraph ended before [EMAIL PROTECTED] was complete. to be read again \par l.27 } ? ** But when the Rnw file starts: ** %\documentclass[compress,smaller]{beamer} \documentclass{article} \usepackage{beamerarticle} ***IT DOES NOT FAIL: * _ 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/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] graphs for pretest data
Dear Juliet, Perhaps start here: require(lattice) mwpp - data.frame(y = c(43,42,26,39,60,60,46,40,41,36,42,54, 58,43,46,56,81,56,70,70,44,52,81,59,69,68), sex = rep(c(rep('men', 14), rep('women', 12))), pp = c(rep(c('pre', 'post'), each = 7), rep(c('pre', 'post'), each = 6)), sub = c(1:7, 1:7, 8:13, 8:13)) xyplot(y ~ pp | sex, groups = sub, type = 'b', mwpp) _ 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/ On Aug 23, 2008, at 12:04 PM, Juliet Hannah wrote: Is there an easy way to make graphs for the following data. I have pretest and posttest scores for men and women. I would like to form a 'titlted segment' plot for the data. That is, make segments joining the scores, with different types of segments for men and women. Example data: menpre - c(43,42,26,39,60,60,46) menpost - c(40,41,36,42,54,58,43) womenpre - c(46,56,81,56,70,70) womenpost - c(44,52,81,59,69,68) Thanks! Juliet [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] an extremely simple question
A cleaner approach than attach()---because you don't need to remember to detach()---is: my.df-data.frame(cbind(x=runif(100), y=rnorm(100))) head(my.df) with(my.df, plot(y~x)) _ 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/ On Jul 22, 2008, at 10:10 PM, milton ruser wrote: Hi Edna, I am not sure the completely right answer, but I suspect that you use data(df) to invoke a data.frame from the sample datasets provided from the packages available on your R system. By other side, if you have a data.frame loaded on your environent, you can use attach do turn the columns available on your environment as objects, like this. my.df-data.frame(cbind(x=runif(100), y=rnorm(100))) head(my.df) plot(y~x) #you get error attach(my.df) plot(y~x) #you get the plot detach(my.df) # remove the x,y objects from your environment plot(y~x) #you get error again. On 7/22/08, Edna Bell [EMAIL PROTECTED] wrote: Hi! What is the difference between using data(somedataset) vs. attach(somedataset), please? thanks, Edna Bell [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Output design question
Dear R-helpers, I was curious why the output of summary (and many other functions in R) does not add a separator between the name of a factor and the label of a level (e.g., in the example below, 'group Trt'). If the user had lower case labels (e.g., 'trt'), the output would be particularly hard to read. 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) summary(lm.D9 - lm(weight ~ group)) gives Call: lm(formula = weight ~ group) Residuals: Min 1Q Median 3Q Max -1.0710 -0.4938 0.0685 0.2462 1.3690 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 5.0320 0.2202 22.850 9.55e-15 *** groupTrt -0.3710 0.3114 -1.1910.249 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.6964 on 18 degrees of freedom Multiple R-squared: 0.07308,Adjusted R-squared: 0.02158 F-statistic: 1.419 on 1 and 18 DF, p-value: 0.249 Why notgroup Trt? _ 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/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] playwith package crashes on Mac
Dear R-helpers, I tried the playwith packages for the first time, and it crashed R: require(playwith) Loading required package: playwith Loading required package: lattice Loading required package: grid Loading required package: gWidgets Loading required package: gWidgetsRGtk2 Loading required package: RGtk2 Loading required package: cairoDevice sessionInfo() R version 2.7.1 (2008-06-23) i386-apple-darwin8.10.1 locale: en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] grid stats graphics grDevices utils datasets methods base other attached packages: [1] playwith_0.9-3 cairoDevice_2.8 gWidgetsRGtk2_0.0-35 RGtk2_2.12.5-3 gWidgets_0.0-28 [6] lattice_0.17-10 loaded via a namespace (and not attached): [1] gridBase_0.4-3 tools_2.7.1 Making links in per-session dir ... done rownames(USArrests) - state.name playwith(plot(Assault ~ UrbanPop, data=USArrests, + xlab=Percent urban population, 1973, + ylab=Assault arrests (per 100,000), 1973)) *** caught bus error *** address 0xa8, cause 'non-existent physical address' Traceback: 1: .Call(L_newpage) 2: grid.newpage() 3: playNewPlot(playState) 4: playwith(plot(Assault ~ UrbanPop, data = USArrests, xlab = Percent urban population, 1973, ylab = Assault arrests (per 100,000), 1973)) Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace Selection: Selection: 3 *** caught segfault *** address 0x611912ca, cause 'memory not mapped' Traceback: 1: .Call(L_newpage) 2: grid.newpage() 3: playNewPlot(playState) 4: playwith(plot(Assault ~ UrbanPop, data = USArrests, xlab = Percent urban population, 1973, ylab = Assault arrests (per 100,000), 1973)) Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace Selection: 2 Mac OS details: System Version: Mac OS X 10.5.4 (9E17) Kernel Version: Darwin 9.4.0 _ 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/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Inconsistent linear model calculations
Hi, To get help with this problem, you will have to create an example that others can duplicate. That is why each message to the list says (at the bottom): PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Before you do any of that, please run some textbook examples using lm(), which will tell you whether lm() is working or not. It is ***extremely*** unlikely that for a function as stable and heavily- used as lm(), the same data and the same command produced different results on different computers, different versions of R, or different OSs. Your list of packages installed is not informative, because these packages are unlikely to affect your running of lm(). To tell the list which version of R you are running please include the output of sessionInfo(). You will find that many people are eager to help beginners, as long as they give enough information about the problem they encountered. _ 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/ On May 15, 2008, at 8:05 AM, e-letter wrote: Readers, Using version 251 I tried the following command: lm(y~a+b,data=datafile) Resulting in, inter alia: ... coefficients (intercept) a 1.2 3.4 Packages installed: snip Why do I get different results when entering the same equation command? The correct answer was obtained using the older version of the software, so I want to replicate using the new version, which is installed onto a new pc that I am using. Any advice. Yours, [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] combining bar and column graphs?
Perhaps ?mosaic or ?mosaicplot _ 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/ On May 11, 2008, at 11:56 AM, Me wrote: Hi, I'm hoping to find out whether R, or an R add-on, can generate a particular type of graph. And, more basically, whether such a type of graph even makes sense. I'm looking for something resembling both a column chart and a bar chart, where the basic visual unit is a solid rectangle of color that can be extended either horizontally, vertically, or both. The data that needs to be graphed consists of the relative contributions of a number (6 or 8) of companies (entities, whatever) to a common fund, over the course of a number of years (say, 1990-2008). I'm picturing years on the X-axis, and dollar amounts on the Y-axis (say, $0-$100,000). From a temporal perspective, every year will have at least one contributor, starting with dollar zero, but some years will have multiple contributors. From a company perspective, some companies will contribute, e.g., dollars $1,001- $5,000 for several years running, visually forming a horizontal block riding on top of whatever happens to be below. So as a simple example, between the years 2000 and 2001, Company A might inhabit a solid block extending from dollar zero to dollar 1000, two years wide. In year 2000, Company B might contribute dollars $1,001-$2,000, while right next door in year 2001, a different Company C might contribute dollars $1,001-$10,000. Is it possible to have this sort of horizontal/vertical chart generated automatically, or is this impossible? Do I need to generate a year-on-year column graph and manually elide the boundaries between companies' contributions in successive years, thus forming the horizontal blocks I have in mind manually? Is there perhaps another software tool that would be good for this? Thanks very much - this is a long question... __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Lattice book
I too have been studying the book and it is indeed outstanding. For my purposes the only topic missing is the straightforward drawing of error bars and bands, for which I've been using Hmisc::xYplot (where error bands seem to be broken for R) or gplots::barplot2. _ 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/ On May 1, 2008, at 7:26 PM, Deepayan Sarkar wrote: On 4/30/08, Charilaos Skiadas [EMAIL PROTECTED] wrote: Actually it's been out for a couple of weeks now at least. Yes, it's been out since March 12, actually. I just finished my first reading of it, and I must say it was spectacular. Congratulations Deepayan, the book gave me exactly the kind of lattice knowledge I needed, and then some. The graphics are really impressive and good illustrations of what lattice can do, and I found the writing very clear, with the complexity increasing at just the right speed. I definitely recommend it to anyone who wants to learn how to use lattice, at any level they desire. Thanks for the great review :-) As Karl mentioned, there is a website with code and figures from the book at http://lmdvr.r-forge.r-project.org/ I also hope to eventually write some short vignettes on topics not covered in the book, and put them up here. Feel free to suggest topics to me. And of course, please report any typos and errors. -Deepayan [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] xYplot error bands not working, was: Re: Lattice book
On R version 2.7.0 (2008-04-22) i386-apple-darwin8.10.1 locale: C/C/en_US/C/C/C attached base packages: [1] splines grid grDevices datasets graphics stats utils methods base other attached packages: [1] Design_2.1-1 survival_2.34-1 Hmisc_3.4-3 languageR_0.92coda_0.13-1 lme4_0.99875-9 [7] Matrix_0.999375-9 zipfR_0.6-0 lattice_0.17-6 MASS_7.2-41 JGR_1.5-18iplots_1.1-2 [13] JavaGD_0.5-1 rJava_0.5-1 loaded via a namespace (and not attached): [1] cluster_1.11.10 tools_2.7.0 From the xYplot() help page (as you can see from the comment, the problem had been noted---although works differently seems to be a euphemism for doesn't work--- reported by me, among others, a while ago): dfr - expand.grid(month=1:12, year=c(1997,1998), reps=1:100) month - dfr$month; year - dfr$year y - abs(month-6.5) + 2*runif(length(month)) + year-1997 s - summarize(y, llist(month,year), smedian.hilow, conf.int=.5) # filled bands: default fill = pastel colors matching solid colors # in superpose.line (this works differently in R) xYplot ( Cbind ( y, Lower, Upper ) ~ month, groups=year, method=filled bands , data=s, type=l) # this produces a bright red band at the top and a black band at the bottom I'll be happy to submit a bug report if this doesn't count and if you tell me how. _ 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/ On May 2, 2008, at 7:50 AM, Frank E Harrell Jr wrote: Michael Kubovy wrote: I too have been studying the book and it is indeed outstanding. For my purposes the only topic missing is the straightforward drawing of error bars and bands, for which I've been using Hmisc::xYplot (where error bands seem to be broken for R) or gplots::barplot2. If these are broken in xYplot we need to have a bug report with a small reproducible example. Frank [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] arcsine transformation
Perhaps you need with(workingdata, asin(BEFORE)) or asin(workingdata$BEFORE) _ 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/ On Apr 30, 2008, at 4:52 PM, Claire Sheller wrote: I have been trying to preform both a bartlett's test and an arcsine transformation on some average percentage data. I've tried inputting it different ways and I keep getting the same error message: head(workingdata) DYAD BEFORE AFTER 1 BG-FL 4.606772 5.787520 2 BG-LL 5.467503 7.847395 3 AD-MV 5.333735 11.107380 4 MM-FL 5.578708 12.063500 5 MM-MV 2.037605 6.415303 6 MM-RM 6.158885 11.911080 bartlett.test(BEFORE ~ AFTER) Error in bartlett.test.default(c(4.606772, 5.467503, 5.333735, 5.578708, : there must be at least 2 observations in each group asin(BEFORE) [1] NaN NaN NaN NaN NaN NaN NaN Warning message: In asin(BEFORE) : NaNs produced I'm at a loss here and I would greatly appreciate any guidance that could be given me. Thank you! -- Claire Sheller Department of Anthropology Tulane University New Orleans, LA 70118 615-210-9129 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] boxplots
?boxplot The boxplot does not show the mean but the median: median(c(0,15,0,60,0,0,0,0,0,60,60,0,60,0,30,0)) b - boxplot(c(0,15,0,60,0,0,0,0,0,60,60,0,60,0,30,0)) b$stats [,1] [1,]0 [2,]0 [3,]0 [4,] 45 [5,] 60 _ 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/ On Apr 29, 2008, at 11:08 PM, Georg Ehret wrote: Dear R user group, I am working with boxplots and cannot solve the following problem: data-c(0,15,0,60,0,0,0,0,0,60,60,0,60,0,30,0) data [1] 0 15 0 60 0 0 0 0 0 60 60 0 60 0 30 0 boxplot(data) The boxplot has the first hinge and the mean-bar both at 0... Why is this the mean is clearly 0! Thanking you and wishing you an excellent day, Georg. *** Georg Ehret Johns Hopkins University Baltimore, US [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Equivalent of intervals() in lmer
Dear Friends, (1) There may be a solution for those (e.g., experimental psychologists) who are *not at all* interested in generalizing the absolute level of the response variable (say, reaction time, rt) to other subjects, but *only* to generalize the effect of the manipulated variables within subjects (because that's what the theory speaks to) to other subjects. First, center the predictor(s) so as to remove any spurious correlation between mean and intercept, and then write the random effect w/o an intercept. Now the model will not address whether rt is different from 0, it will only estimate the slope and whether it's different from 0: require(lme4) require(gmodels) data(sleepstudy) ss - sleepstudy ss$days - with(ss, Days - mean(Days)) (fm1 - lmer(Reaction ~ days + (days|Subject), ss)) (fm3 - lmer(Reaction ~ days + (-1 + days|Subject), ss)) ci(fm1) ci(fm3) # CIs for days are about 14% smaller (2) When the predictor is not continuous, this approach doesn't work. A solution for a designed experiment is to plot CIs for differences, i.e., 5%LSDs (rather than plot the CIs on cell means). Those CIs are smaller and address the question of interest. Here is a one-way ANOVA: recall - c(10, 13, 13, 6, 8, 8, 11, 14, 14, 22, 23, 25, 16, 18, 20, 15, 17, 17, 1, 1, 4, 12, 15, 17, 9, 12, 12, 8, 9, 12) fr - data.frame(rcl = recall, time = factor(rep(c(1, 2, 5), 10)), subj = factor(rep(1:10, each = 3))) (fr.lmer - lmer(rcl ~ time -1 +(1 | subj), fr)) mm - unique(model.matrix(~ time -1, fr)) cm - mm[1, ] - mm[3, ] cm1 - mm[1, ] - mm[2, ] estimable(fr.lmer, cm = cm, conf.into = 0.95) estimable(fr.lmer, cm = cm1, conf.into = 0.95) plot mean \pm 2* 0.366 and call it a 5%LSD (uncorrected for multiple comparisons) In the case of a more-than-one-way ANOVA with interaction (say 2x2), choose which simple effects are of interest, get SEs for those; and then plot the four points with the CIs. These are not quite right for the difference between simple effects, but I don't know what to do about that. _ 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/ On Apr 21, 2008, at 9:05 AM, Dieter Menne wrote: Douglas Bates bates at stat.wisc.edu writes: If you want to examine the three means then you should fit the model as lmer(rcl ~ time - 1 + (1 | subj), fr) True, but for the notorious error bars in plots that reviewers always request the 0.35 is probable more relevant than the 1.87. Which I think is justified in this case, but in most non-orthogonal designs with three or more factors, where we have a mixture of between/withing subject, there is no clear solution. What to do when required to produce error-bars that reasonably mirror p- values? It's easier with British Journals in the medical field that often have statistical professionals as reviewers, but many American Journals with their amateur physician/statisticians (why no t-test on raw data?) drive me nuts. Dieter #- library(lme4) recall - c(10, 13, 13, 6, 8, 8, 11, 14, 14, 22, 23, 25, 16, 18, 20, 15, 17, 17, 1, 1, 4, 12, 15, 17, 9, 12, 12, 8, 9, 12) fr - data.frame(rcl = recall, time = factor(rep(c(1, 2, 5), 10)), subj = factor(rep(1:10, each = 3))) fr.lmer - lmer(rcl ~ time -1 +(1 | subj), fr) summary(fr.lmer) fr.lmer - lmer(rcl ~ time +(1 | subj), fr) summary(fr.lmer) -- Fixed effects: Estimate Std. Error t value time1 11.000 1.879 5.853 time2 13.000 1.879 6.918 time5 14.200 1.879 7.556 Fixed effects: Estimate Std. Error t value (Intercept) 11. 1.8793 5.853 time2 2. 0.3507 5.703 time5 3.2000 0.3507 9.125 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Equivalent of intervals() in lmer
To help Kedar a bit: Here is one way: recall - c(10, 13, 13, 6, 8, 8, 11, 14, 14, 22, 23, 25, 16, 18, 20, 15, 17, 17, 1, 1, 4, 12, 15, 17, 9, 12, 12, 8, 9, 12) fr - data.frame(rcl = recall, time = factor(rep(c(1, 2, 5), 10)), subj = factor(rep(1:10, each = 3))) (fr.lmer - lmer(rcl ~ time + (1 | subj), fr)) require(gmodels) ci(fr.lmer) Now I have a problem to which I would very much appreciate having a solution: The model fr.lmer gives a SE of 1.8793 for the (Intercept) and 0.3507 for the other levels. The reason is that the first took account of the variability of the effect of subjects. Or using simulation: Estimate CI lower CI upper Std. Error p-value (Intercept) 11.107202 6.458765 15.208065 2.1587362 0.004 time22.012064 1.301701 2.795128 0.3743050 0.000 time53.206834 2.502870 3.939791 0.3694384 0.000 Now if I need to draw CI bars around the three means, it seems to me that they should be roughly 11, 13, and 16.2, each \pm 0.75, because I'm trying to estimate the variability of patterns within subjects, and am not interested in the subject to subject variation in the mean for the purposes of prediction. This what the authors in the paper cited below call on p. 402 a narrow [as opposed to a broad] inference space. My question: ***How do I extract the three narrow CIs from the lmer?*** @ARTICLE{BlouinRiopelle2005, author = {Blouin, David C. and Riopelle, Arthur J.}, title = {On confidence intervals for within-subjects designs}, journal = {Psychological Methods}, year = {2005}, volume = {10}, pages = {397--412}, number = {4}, month = dec, abstract = {Confidence intervals (CIs) for means are frequently advocated as alternatives to null hypothesis significance testing (NHST), for which a common theme in the debate is that conclusions from CIs and NHST should be mutually consistent. The authors examined a class of CIs for which the conclusions are said to be inconsistent with NHST in within- subjects designs and a class for which the conclusions are said to be consistent. The difference between them is a difference in models. In particular, the main issue is that the class for which the conclusions are said to be consistent derives from fixed-effects models with subjects fixed, not mixed models with subjects random. Offered is mixed model methodology that has been popularized in the statistical literature and statistical software procedures. Generalizations to different classes of within-subjects designs are explored, and comments on the future direction of the debate on NHST are offered.}, url = {http://search.epnet.com/login.aspx?direct=truedb=pdhan=met104397 } } _ 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/ On Apr 21, 2008, at 2:24 AM, Dieter Menne wrote: kedar nadkarni nadkarnikedar at gmail.com writes: I have been trying to obtain confidence intervals for the fit after having used lmer by using intervals(), but this does not work. intervals() is associated with lme but not with lmer(). What is the equivalent for intervals() in lmer()? ci in Gregory Warnes' package gmodels can do this. However, think twice if you really need lmer. Why not lme? It is well documented and has many features that are currently not in lmer. Dieter [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Equivalent of intervals() in lmer
Thanks Doug, You write: If you want to examine the three means then you should fit the model as lmer(rcl ~ time - 1 + (1 | subj), fr) I do just that (which is what Dieter just sent). But the CIs are much too big compared to the CIs for differences between means (which should be bigger than the CIs on the means themselves). If you write the model as ~ 1 - time, then the CIs are roughly of the same (large) size. But I'm really interested in the CIs on the means that capture the variability *within* subjects. I believe that this is what experimentalists in psychology need (and have been debating for a long time what the correct analysis is that produces these error bars). The theory is not about generalizing to people, but generalizing to responses to different situations within people. The article by Brillouin and Riopelle (2005) is the only one that tries to do this within the framework of LMEMs that I know of, and it's couched in terms of SAS. For the moment I wonder if the solution is not to use CIs based on the two low SEs produced by the ~ 1 - time model, and to treat them as least-significant difference intervals. _ 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/ On Apr 21, 2008, at 7:56 AM, Douglas Bates wrote: On 4/21/08, Michael Kubovy [EMAIL PROTECTED] wrote: To help Kedar a bit: Here is one way: recall - c(10, 13, 13, 6, 8, 8, 11, 14, 14, 22, 23, 25, 16, 18, 20, 15, 17, 17, 1, 1, 4, 12, 15, 17, 9, 12, 12, 8, 9, 12) fr - data.frame(rcl = recall, time = factor(rep(c(1, 2, 5), 10)), subj = factor(rep(1:10, each = 3))) (fr.lmer - lmer(rcl ~ time + (1 | subj), fr)) require(gmodels) ci(fr.lmer) Now I have a problem to which I would very much appreciate having a solution: The model fr.lmer gives a SE of 1.8793 for the (Intercept) and 0.3507 for the other levels. The reason is that the first took account of the variability of the effect of subjects. Or using simulation: Estimate CI lower CI upper Std. Error p-value (Intercept) 11.107202 6.458765 15.208065 2.1587362 0.004 time22.012064 1.301701 2.795128 0.3743050 0.000 time53.206834 2.502870 3.939791 0.3694384 0.000 Now if I need to draw CI bars around the three means, it seems to me that they should be roughly 11, 13, and 16.2, each \pm 0.75, because I'm trying to estimate the variability of patterns within subjects, and am not interested in the subject to subject variation in the mean for the purposes of prediction. If you want to examine the three means then you should fit the model as lmer(rcl ~ time - 1 + (1 | subj), fr) This what the authors in the paper cited below call on p. 402 a narrow [as opposed to a broad] inference space. My question: ***How do I extract the three narrow CIs from the lmer?*** @ARTICLE{BlouinRiopelle2005, author = {Blouin, David C. and Riopelle, Arthur J.}, title = {On confidence intervals for within-subjects designs}, journal = {Psychological Methods}, year = {2005}, volume = {10}, pages = {397--412}, number = {4}, month = dec, abstract = {Confidence intervals (CIs) for means are frequently advocated as alternatives to null hypothesis significance testing (NHST), for which a common theme in the debate is that conclusions from CIs and NHST should be mutually consistent. The authors examined a class of CIs for which the conclusions are said to be inconsistent with NHST in within- subjects designs and a class for which the conclusions are said to be consistent. The difference between them is a difference in models. In particular, the main issue is that the class for which the conclusions are said to be consistent derives from fixed-effects models with subjects fixed, not mixed models with subjects random. Offered is mixed model methodology that has been popularized in the statistical literature and statistical software procedures. Generalizations to different classes of within-subjects designs are explored, and comments on the future direction of the debate on NHST are offered.}, url = {http://search.epnet.com/login.aspx?direct=truedb=pdhan=met104397 } } _ 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
Re: [R] Equivalent of intervals() in lmer
Sorry, I meant to say: For the moment I wonder if the solution is not to use CIs based on the two low SEs produced by the ~ time model, and to treat them as least-significant difference intervals. _ 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/ On Apr 21, 2008, at 9:23 AM, Michael Kubovy wrote: Thanks Doug, You write: If you want to examine the three means then you should fit the model as lmer(rcl ~ time - 1 + (1 | subj), fr) I do just that (which is what Dieter just sent). But the CIs are much too big compared to the CIs for differences between means (which should be bigger than the CIs on the means themselves). If you write the model as ~ 1 - time, then the CIs are roughly of the same (large) size. But I'm really interested in the CIs on the means that capture the variability *within* subjects. I believe that this is what experimentalists in psychology need (and have been debating for a long time what the correct analysis is that produces these error bars). The theory is not about generalizing to people, but generalizing to responses to different situations within people. The article by Brillouin and Riopelle (2005) is the only one that tries to do this within the framework of LMEMs that I know of, and it's couched in terms of SAS. For the moment I wonder if the solution is not to use CIs based on the two low SEs produced by the ~ 1 - time model, and to treat them as least-significant difference intervals. On Apr 21, 2008, at 7:56 AM, Douglas Bates wrote: On 4/21/08, Michael Kubovy [EMAIL PROTECTED] wrote: To help Kedar a bit: Here is one way: recall - c(10, 13, 13, 6, 8, 8, 11, 14, 14, 22, 23, 25, 16, 18, 20, 15, 17, 17, 1, 1, 4, 12, 15, 17, 9, 12, 12, 8, 9, 12) fr - data.frame(rcl = recall, time = factor(rep(c(1, 2, 5), 10)), subj = factor(rep(1:10, each = 3))) (fr.lmer - lmer(rcl ~ time + (1 | subj), fr)) require(gmodels) ci(fr.lmer) Now I have a problem to which I would very much appreciate having a solution: The model fr.lmer gives a SE of 1.8793 for the (Intercept) and 0.3507 for the other levels. The reason is that the first took account of the variability of the effect of subjects. Or using simulation: Estimate CI lower CI upper Std. Error p-value (Intercept) 11.107202 6.458765 15.208065 2.1587362 0.004 time22.012064 1.301701 2.795128 0.3743050 0.000 time53.206834 2.502870 3.939791 0.3694384 0.000 Now if I need to draw CI bars around the three means, it seems to me that they should be roughly 11, 13, and 16.2, each \pm 0.75, because I'm trying to estimate the variability of patterns within subjects, and am not interested in the subject to subject variation in the mean for the purposes of prediction. If you want to examine the three means then you should fit the model as lmer(rcl ~ time - 1 + (1 | subj), fr) This what the authors in the paper cited below call on p. 402 a narrow [as opposed to a broad] inference space. My question: ***How do I extract the three narrow CIs from the lmer?*** @ARTICLE{BlouinRiopelle2005, author = {Blouin, David C. and Riopelle, Arthur J.}, title = {On confidence intervals for within-subjects designs}, journal = {Psychological Methods}, year = {2005}, volume = {10}, pages = {397--412}, number = {4}, month = dec, abstract = {Confidence intervals (CIs) for means are frequently advocated as alternatives to null hypothesis significance testing (NHST), for which a common theme in the debate is that conclusions from CIs and NHST should be mutually consistent. The authors examined a class of CIs for which the conclusions are said to be inconsistent with NHST in within- subjects designs and a class for which the conclusions are said to be consistent. The difference between them is a difference in models. In particular, the main issue is that the class for which the conclusions are said to be consistent derives from fixed-effects models with subjects fixed, not mixed models with subjects random. Offered is mixed model methodology that has been popularized in the statistical literature and statistical software procedures. Generalizations to different classes of within-subjects designs are explored, and comments on the future direction of the debate on NHST are offered.}, url = {http://search.epnet.com/login.aspx?direct=truedb=pdhan=met104397 } } On Apr 21, 2008, at 2:24 AM, Dieter Menne wrote: kedar nadkarni nadkarnikedar at gmail.com writes: I have been trying to obtain
[R] Problem with JGR_1.5-18
R version 2.7.0 Under development (unstable) (2008-03-04 r44677) i386-apple-darwin8.10.1 locale: C attached base packages: [1] grid grDevices datasets graphics stats utils methods base other attached packages: [1] lattice_0.17-6 MASS_7.2-41JGR_1.5-18 iplots_1.1-2 JavaGD_0.5-1 rJava_0.5-1 The following opens a JavaGD window and freezes JGR: super.sym - trellis.par.get(superpose.symbol) (from splom help page). _ 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/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Conditionally swap items in a data frame
df1 - data.frame(a = LETTERS[1:2], b = LETTERS[3:4], c = 1:2) I am looking for an idiom that swaps the elements of df$a and df$b when (e.g.) df$c == 2, resulting in df2 - data.frame(a = LETTERS[c(1, 4)], b = LETTERS[c(3, 2)], c = 1:2) _ 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/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Don't understand error-message (from lattice, I think)
mypal - trellis.par.get('superpose.line')$col[1:2] mycol - mypal[1] trellis.par.set(list(dot.symbol = list(pch = 16, cex = 1.5))) dotplot(1:6 ~ audRating, data = txtA.ci, + scales = list(y = list(at = 1:6, labels = txtA.ci$pitchAud, col = 'black', cex = 1.1)), + ylab = '', aspect = 1.2, xlab = 'rated duration', ylim = c(0.5, 6.5), xlim = c(0, 100), + ) Wed Apr 16 10:36:19 MK-MacPro.local R[12990] Error: The function `CGFontGetGlyphsForUnicodes' is obsolete and will be removed in an upcoming update. Unfortunately, this application, or a library it uses, is using this obsolete function, and is thereby contributing to an overall degradation of system performance. Please use `CGFontGetGlyphsForUnichars' instead. R version 2.7.0 Under development (unstable) (2008-03-04 r44677) i386-apple-darwin8.10.1 locale: en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] grid stats graphics grDevices utils datasets methods base other attached packages: [1] Hmisc_3.4-3 doBy_2.3 coda_0.13-1 gmodels_2.14.1lme4_0.99875-9Matrix_0.999375-9 lattice_0.17-6 loaded via a namespace (and not attached): [1] MASS_7.2-41 car_1.2-7 cluster_1.11.10 gdata_2.4.1 gtools_2.4.0 _ 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/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Equivalent to a BY command in SAS
You might also take a look at the doBy package. On Apr 14, 2008, at 7:30 AM, zerfetzen wrote: Thanks all. I will try to use both tapply and by, and have no idea how I missed the by function. Thanks again. _ 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/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Clash between alr3 and AlgDesign. (Was: Re: Second subsequent calls to function fails. Please help debug.)
Thanks, Duncan, I started a new session under the suspicion that packages were clashing. # # RUN 1 # require(faraway) # Loading required package: faraway data(oatvar) ov.lm - lm(yield ~ variety + block, oatvar) require(alr3) # Loading required package: alr3 out - tukey.nonadd.test(ov.lm) # # RUN 1 OK # RUN 2 # require(HH) #Loading required package: HH #Loading required package: lattice # #Attaching package: 'lattice' # # # The following object(s) are masked from package:faraway : # #melanoma # #Loading required package: grid #Loading required package: multcomp #Loading required package: mvtnorm # #Attaching package: 'HH' # # # The following object(s) are masked from package:alr3 : # #residual.plots # # # The following object(s) are masked from package:faraway : # #vif, #vif.default, #vif.lm # out - tukey.nonadd.test(ov.lm) # # RUN 2 OK # RUN 3 # require(crossdes) #Loading required package: crossdes #Loading required package: AlgDesign #Loading required package: gtools # #Attaching package: 'gtools' # # # The following object(s) are masked from package:faraway : # #logit # #Loading required package: MASS #Loading required package: grDevices out - tukey.nonadd.test(ov.lm) #Error in parse(text = x) : # unexpected symbol in yield ~ variety + block + preds(yield+variety +block+preds.sq)sq # # RUN 3 FAILS # # # CHECKING FOR INTERACTION AMONG PACKAGES # require(MASS) #Loading required package: MASS #Loading required package: grDevices out - tukey.nonadd.test(ov.lm) require(gtools) #Loading required package: gtools # #Attaching package: 'gtools' # # # The following object(s) are masked from package:faraway : # #logit # # out - tukey.nonadd.test(ov.lm) # # alr3 pays well with MASS, grDevices, gtools # require(AlgDesign) #Loading required package: AlgDesign out - tukey.nonadd.test(ov.lm) #Error in parse(text = x) : # unexpected symbol in yield ~ variety + block + preds(yield+variety +block+preds.sq)sq require(crossdes) #Loading required package: crossdes out - tukey.nonadd.test(ov.lm) #Error in parse(text = x) : # unexpected symbol in yield ~ variety + block + preds(yield+variety +block+preds.sq)sq # # BAD INTERACTION BETWEEN alr3 and AlgDesign # What now? _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Clash between alr3 and AlgDesign. (Was: Re: Second subsequent calls to function fails. Please help debug.)
Hi Duncan, Yes, I came to realize that ifelse was not the way to go. Here is how I dealt with it: if(sum('AlgDesign' == (.packages())) 0) detach('package:AlgDesign') It requires me (and my students) to learn only the (.packages()) construct (and avoid knowing anything about search(), match() or pos). As a former student of mine (who has long since gone into business) once said: I avoid learning experiences like the plague. Thanks again, Michael On Mar 30, 2008, at 1:36 PM, Duncan Murdoch wrote: On 30/03/2008 10:06 AM, Michael Kubovy wrote: I've been trying to dynamically detach and attach things in my Sweave, in order to circumvent the problem. Here is my first attempt: pkg - 'package:AlgDesign' p - is.na(match(pkg, search())) ifelse(p == FALSE, detach(pkg), NA) You can't use detach this way. It is fine to say detach(package:AlgDesign) or detach(AlgDesign), but the way detach is written, you're attempting to detach something named pkg. This rewrite of your code is untested, but I think it should work: pkg - 'package:AlgDesign' p - match(pkg, search()) if (!is.na(p)) detach(pos=p) require(alr3) I've also changed your ifelse() to if (), and not just because I don't need an else clause: ifelse() is designed to do computations on vectors, if() is designed for flow control. I think we want flow control here. Duncan Murdoch _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Second subsequent calls to function fails. Please help debug.
Dear R-helpers, I'm running Sweave() on a file. First run: Sweave('20080331.Rnw') Writing to file 20080331.tex Processing code chunks ... 1 : term hide (label=setup) 2 : echo term verbatim (label=oatvar) 3 : echo term verbatim (label=oatvar1) 4 : echo term verbatim (label=oat2wt) 5 : echo term verbatim (label=oat2wt) 6 : echo term verbatim (label=lm) 7 : echo term verbatim (label=diag) 8 : echo term verbatim (label=tukey) 9 : echo term verbatim (label=efficiency) 10 : echo term verbatim (label=wear) 11 : echo term verbatim (label=wearX) 12 : echo term verbatim (label=gyd) Loading required package: crossdes Loading required package: AlgDesign Loading required package: gtools Attaching package: 'gtools' The following object(s) are masked from package:faraway : logit Loading required package: MASS 13 : echo term verbatim (label=2wt) 14 : echo term verbatim (label=ablm) 15 : echo term verbatim (label=abaov) You can now run LaTeX on '20080331.tex' There were 42 warnings (use warnings() to see them) Second run: Sweave('20080331.Rnw') Writing to file 20080331.tex Processing code chunks ... 1 : term hide (label=setup) 2 : echo term verbatim (label=oatvar) 3 : echo term verbatim (label=oatvar1) 4 : echo term verbatim (label=oat2wt) 5 : echo term verbatim (label=oat2wt) 6 : echo term verbatim (label=lm) 7 : echo term verbatim (label=diag) 8 : echo term verbatim (label=tukey) Error: chunk 8 (label=tukey) Error in parse(text = x) : unexpected symbol in yield ~ variety + block + preds(yield+variety +block+preds.sq)sq It failed in: tukey= require(alr3) tukey.nonadd.test(ov.lm) @ At that point I ran debug() on the call: debug(tukey.nonadd.test) tukey.nonadd.test(ov.lm) debugging in: tukey.nonadd.test(ov.lm1) debug: { envir - environment(formula(m)) dd - eval(m$call$data, envir) subs - eval(m$call$subset, envir) wgts - eval(m$call$weights, envir) naa - m$call$na.action dd - data.frame(dd, preds.sq = predict(m, dd)^2) uf - update.formula(formula(m$terms), ~. + preds.sq) environment(uf) - environment(NULL) mup - if (is.null(naa)) lm(uf, data = dd, subset = subs, weights = wgts) else lm(uf, data = dd, subset = subs, weights = wgts, na.action = naa) if (mup$rank m$rank) { ans - summary(mup)$coef[, 3:4] ans - ans[match(preds.sq, rownames(ans)), ] ans[2] - pnorm(-abs(ans[1])) * 2 ans } else c(NA, NA) } Browse[1] debug: envir - environment(formula(m)) Browse[1] debug: dd - eval(m$call$data, envir) Browse[1] debug: subs - eval(m$call$subset, envir) Browse[1] debug: wgts - eval(m$call$weights, envir) Browse[1] debug: naa - m$call$na.action Browse[1] debug: dd - data.frame(dd, preds.sq = predict(m, dd)^2) Browse[1] debug: uf - update.formula(formula(m$terms), ~. + preds.sq) Browse[1] debug: environment(uf) - environment(NULL) Browse[1] debug: mup - if (is.null(naa)) lm(uf, data = dd, subset = subs, weights = wgts) else lm(uf, data = dd, subset = subs, weights = wgts, na.action = naa) Browse[1] Error in parse(text = x) : unexpected symbol in yield ~ variety + preds(yield+variety +preds.sq)sq Advice? _ 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/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Color of CI bars in Hmisc::Dotplot()
Dear R-helpers, (1) I can't figure out how to tell Dotplot that I want the colors of the CI bars to be the same as the colors of the dots. For example: t2a.ci3 - data.frame(est = c(7, 20, 75), lower = c(-9, 0.5, 42), upper = c(22, 39, 109)) mypal - c('skyblue3', 'mistyrose3') condNames - c('noise', 'horn', 'marimba') Dotplot(1:2 ~ Cbind(est, lower, upper), data = t2a.ci3, scales = list(y = list(at = 1:2, labels = condNames)), ylab = '', xlab = 'rated duration', aspect = 0.2, ylim = c(0.5, 2.5), panel = function(x, y){ panel.Dotplot( x, y, col = mypal[c(1, 2)], col.segments = mypal[c(1, 2)]) panel.abline(v = 50, col.line = 'red', lty = 2)} ) My guess was col.segments but that doesn't do the trick. (2) How do I insure that as I change the number of lines and ylim I just change the the height of the y-axis, keep the distance between horizontal lines constant, and do not add white space above and below the figure? This shows how white space changes: Dotplot(1:3 ~ Cbind(est, lower, upper), data = t2a.ci3, scales = list(y = list(at = 1:3, labels = condNames)), ylab = '', xlab = 'rated duration', aspect = 0.3, ylim = c(0.5, 3.5), panel = function(x, y){ panel.Dotplot( x, y, col = mypal[c(1, 2, 1)], col.segments = mypal[c(1, 2, 1)]) panel.abline(v = 50, col.line = 'red', lty = 2)} ) _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to use a reserved word in italics in an expression
Delightfully straightforward! Thanks. On Feb 16, 2008, at 5:15 PM, Duncan Murdoch wrote: On 16/02/2008 4:51 PM, Michael Kubovy wrote: Dear R-helpers, label2 - expression(paste(italic(attraction function:), 'slope')) Error: unexpected 'function' in label2 - expression(paste(italic(attraction function How do I tell R that in this case I don't want 'function' to be treated as a reserved word but as a string in italics? Just put it in quotes. In fact, I think italic(attraction) looks better than italic(attraction), so you may want to do this more generally. For example, plot(1, main=expression(paste(italic(attraction function: ), slope))) Duncan Murdoch _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] re cognizing patterns
Paul, The literature on the topic is extensive. You could start here: @ARTICLE{Burns2004a, author = {Burns, Bruce D.}, title = {Heuristics as beliefs and as behaviors: The adaptiveness of the hot hand}, journal = {Cognitive Psychology}, year = {2004}, volume = {48}, pages = {295--331}, number = {3}, month = may, abstract = {Gigerenzer (2000) and Anderson (1990) analyzed reasoning by asking: what are the reasoner's goals? This emphasizes the adaptiveness of behavior rather than whether a belief is normative. Belief in the hot hand in basketball suggests that players experiencing streaks should be given more shots, but this has been seen as a fallacy due to Gilovich, Vallone, and Tversky (1985) failure to find dependencies between players' shots. Based on their findings, I demonstrate by Markov modeling and simulation that streaks are valid allocation cues for deciding who to give shots to, because this behavior achieves the team goal of scoring more. Empirically I show that this adaptive heuristic is supported by the fallacious belief in dependency, more so as skill level increases. I extend the theoretical analysis to identify general conditions under which following streaks should be beneficial. Overall, this approach illustrates the advantages of analyzing reasoning in terms of adaptiveness.}, keywords = {Decision making, Streaks, Sequential information, Hot hand, Adaptive thinking}, url = {http://www.sciencedirect.com/science/article/B6WCR-4B9K6YH-1/2/f5e0f00147184e3079b48466d43f1cd0 } } and work your way back and forward. On Feb 12, 2008, at 9:59 AM, Paul Artes wrote: DeaRs, i'm looking for some references on a statement as follows: Humans are good at spotting trends and patterns in data, but they are also good at spotting those patterns where none really exist. This is not verbatim but there must be some scholarly work on this. I can't remember where I came across it - perhaps I dreamed it up? Help, anyone? Best wishes Paul _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] grep etc.
Dear R-helpers, How do I transform v - c('insd-otsd', 'sppr-unsp') into c('insd--otsd', 'sppr--unsp') ? _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] \ll and \gg in expression()
How do I enter 'much greater than' and 'much less than' symbols in an expression? _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] \ll and \gg in expression()
On Feb 9, 2008, at 4:41 PM, Prof Brian Ripley wrote: On Sat, 9 Feb 2008, Michael Kubovy wrote: How do I enter 'much greater than' and 'much less than' symbols in an expression? Those are not in the Adobe Symbol encoding used for plotmath. Since you have not told us your platform and locale as requested in the posting guide R version 2.7.0 Under development (unstable) (2008-02-05 r44340) i386-apple-darwin8.10.1 locale: C I don't know if the following is relevant to you. If you have a suitable Unicode font and the means to use it (which most likely means a UTF-8 locale in R 2.7.0) they are the glyphs for \u226a and \u226b (see http://www.alanwood.net/unicode/mathematical_operators.html) . A quick check suggests that not many fonts do. Thanks. The Mac character palette tells me that they correspond to Unicode 226A and B or UTF8 E2 89 AA and AB. My question now is, how do I tell expression() to use the glyphs for these? _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Package simex
On Jan 28, 2008, at 11:30 AM, Liaw, Andy wrote: The original paper is: Cook, J. R. Stefanski L. A. (1994) Simulation--extrapolation estimation in parametric measurement error models. Journal of the American Statistical Association, 89, 1314-1328. From: Michael Kubovy Dear R-helpers, It is not clear to me how you get measurement.error SD when you have a single dataset, and it is not clear to me how sensitive SIMEX is to errors in the estimates of measurement error. Could someone please point me to the relevant literature? Indeed, the article is cited in the package help. Unfortunately it ends with my question: Among the limitations of SIMEX estimation … the two most notable are the requirement that the measurement error variance be known … (p. 1327). The study I'm dealing with does not have a history of similar studies that would allow me to estimate the measurement error variance. _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Package simex
Dear R-helpers, It is not clear to me how you get measurement.error SD when you have a single dataset, and it is not clear to me how sensitive SIMEX is to errors in the estimates of measurement error. Could someone please point me to the relevant literature? _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Read stata file from internet?
Dear R-helpers, I would like to have my students read into R an online Stata dataset: 'http://www.stat.ucla.edu/projects/datasets/risk_project.dta' I was able to read it into R after downloading it and converting it with StatTransfer (http://www.stattransfer.com/). Here is what happens when I use read.dta() as I would use read.table(): require(foreign) risk2 - read.dta('http://www.stat.ucla.edu/projects/datasets/risk_project.dta') Error in read.dta(http://www.stat.ucla.edu/projects/datasets/risk_project.dta ) : unable to open file Then I try: riskTmp - read.table('http://www.stat.ucla.edu/projects/datasets/risk_project.dta') Warning message: In read.table(http://www.stat.ucla.edu/projects/datasets/risk_project.dta ) : incomplete final line found by readTableHeader on 'http://www.stat.ucla.edu/projects/datasets/risk_project.dta' head(riskTmp) V1 1 l\001\001\300 2.%9.0g 3 \342CNTL%8.0g risk2 - read.dta(riskTmp) Error in read.dta(riskTmp) : first argument must be a file name So I tried to save riskTmp as a file, and read it in using read.dta(): save(riskTmp, file = 'risk.dta') risk2 - read.dta('risk.dta') Error in read.dta(risk.dta) : not a Stata version 5-8 .dta file But that presumably garbled the file. (Indeed, StatTransfer told me so.) Would it be appropriate to request this as a feature of foreign::read.dta()? (Thomas Lumley is the author.) _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Change R localization
Dear R-helpers, A student in my Department reports that his R is in Japanese: I lived in Japan and have a US-purchased mac with the Japanese input/ reader enabled, which must be where the Japanese came from. When I uninstalled R and reinstalled it last time (I think I completely uninstalled it, but some folders may have survived?), I installed with the Japanese option turned off. sessionInfo();localeToCharset() R version 2.5.1 (2007-06-27) powerpc-apple-darwin8.9.1 locale: ja_JP.UTF-8/ja_JP.UTF-8/ja_JP.UTF-8/C/ja_JP.UTF-8/ja_JP.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods [7] base other attached packages: lattice faraway reshape car 0.15-11 1.0.2 0.8.0 1.2-7 [1] UTF-8 EUC-JP What should he do to get to locale C? I believe that he isn't subscribed to this list, so please include a cc to him. Thanks, _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Lattice equivalent of par(mfrow = )
Dear R-helpers, On Jan 12, 2008, at 5:17 PM, Deepayan Sarkar wrote: On 1/12/08, Michael Kubovy [EMAIL PROTECTED] wrote: Dear r-helpers, Does anyone have a straightforward example of putting together three unrelated (expect for a common y-axis) xyplot() figures in what would be in base graphics a par(mfrow = c(1, 3)) arrangement? See the examples in ?print.trellis. Thanks. Now how do I insure that the three y-axes are the same scale in the following? states - data.frame(state.x77, state.name = dimnames(state.x77)[[1]], state.region = state.region) plot1 - xyplot(Murder ~ Population, data = states, xlab = grid::textGrob(expression(frac(abs(bold(c)), abs(bold(b, gp=gpar(fontsize=25)), ylab = grid::textGrob(expression(paste(log, frac(italic(p) (italic(c)), italic(p)(italic(b), gp = gpar(fontsize = 25)), ) plot2 - xyplot(Murder ~ Population, data = states, xlab = grid::textGrob(expression(gamma), gp = gpar(fontsize= 25)), ylab = '', ) plot3 - xyplot(Murder ~ Population, data = states, xlab = grid::textGrob(expression(frac(abs( bold(c) ),abs( bold(b) ))), gp = gpar(fontsize = 25)), ylab = '', ) print(plot1, position = c(0.0, 0, 0.33, 1), more = TRUE) print(plot2, position = c(0.33, 0, 0.67, 1), more = TRUE) print(plot3, position = c(0.67, 0, 1, 1)) _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Lattice equivalent of par(mfrow = )
Dear r-helpers, Does anyone have a straightforward example of putting together three unrelated (expect for a common y-axis) xyplot() figures in what would be in base graphics a par(mfrow = c(1, 3)) arrangement? _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Can a dynamic graphic produced by rgl be saved?
Dear r-helpers, Can one save a dynamic graphic produced by rgl, e.g.: open3d(); x - sort(rnorm(1000)); y - rnorm(1000); z - rnorm(1000) + atan2(x,y); plot3d(x, y, z, col=rainbow(1000), size=2) as a dynamic figure that can be embedded in a pdf? _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Random Bernoulli sequences with given point-biserial correlation?
Dear R-listers, Can someone suggest a method for generating a finite Bernoulli sequence that is likely to have a given point-biserial correlation with an existing Bernoulli sequence? _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Using expression in Hmisc Key()
Hi Dieter, I actually solved *my* problem: Key(x = 0.667, y = 0.833, lev = c(expression(italic(b)), expression(italic(c)), expression(italic(d))), other = list(title = expression(italic(v)), cex.title = 1)) I was able to figure this out only by looking at the code for Key(), because I hadn't come across the 'lev' argument in the documentation (in fact Key does not appear in the list of functions of Hmisc; I discovered its usefulness by consulting the examples for xYplot()). I would have expected this argument to be called 'labels' (see help(labels)), (or at least 'levels'): function (x = NULL, y = NULL, lev = c(b, c, d), cex = c(0.7, 0.7, 0.7), col = c(2, 4, 9), font = c(1, 1, 1), pch = c(1, 2, 16), other = NULL) { … } … Note that the NULL setting of the parameter may be useful for programming, but it is not useful to anyone reading the code. How is one to proceed after having read help(NULL)? At the same time, I have no grounds for complaining about the documentation for Key(): Frank Harrell is giving away his work. His examples are extensive, and his functions always work as advertised. Sometimes they also work as not advertised. This is one of the cases where I wish there were a function that exercised all the arguments of a graphics function by visualizing the effect of changing two or three levels of each argument (one by one, of course). This might have the side effect of allowing authors to shorten documentation. I have in mind adding a method to each graphics function, and having the author specify the two or three instructive levels of each argument. See the exhaustive exploration by J.R. Lobry, A.B. Dufour D. Chessel of the graphical parameters accessible by par(), at http://pbil.univ-lyon1.fr/R/fichestd/tdr75.pdf On Dec 6, 2007, at 2:17 AM, Dieter Menne wrote: Michael Kubovy kubovy at virginia.edu writes: Dear r-helpers, How do I tell xYplot() and Key() that I want the labels in italic? Key(x = 0.667, y = 0.833, other = list(title = expression(italic(v)), cex.title = 1, labels = c(expression(italic(b)), expression(italic(c)), expression(italic(d) dev.off() Michael, I have submit a similar case last week to the Bug tracker. Maybe you can raise that enhancement request to defect http://biostat.mc.vanderbilt.edu/trac/Hmisc/ticket/21 Dieter --- The Key function generated by some plot commands should have a ... parameter. Otherwise, the ... in rlegend is useless, and it would be nice to be able to suppress the box, for example. Key = function (x = NULL, y = NULL, lev = c(No Fail, Fail), pch = c(16, 1)) { .. part omitted rlegend(x, y, legend = lev, pch = pch, ...) invisible() } _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Designs with many periods
Dear R-helpers, Jones Kenward (2003)¶ discuss balanced designs with many periods (p). It is my impression the algorithmic design packages (AlgDesign, crossdes, conf.design) in R do not handle cases in which the number of treatments (t) is p. Am I mistaken? To be concrete: I am designing an experiment with t = 12 in a factorial design (3x4) with p = [12,18] (we have our subjects for an hour, which allows us about 18 blocks). We can run in the ballpark of 30 subjects. Pointers welcome. ___ ¶ @BOOK{JonesKenward2003, title = {Design and analysis of cross-over trial}, publisher = {Chapman \ Hall/CRC}, year = {2003}, address = {Boca Raton, FL, USA}, edition = {2nd}, author = {Byron Jones and Michael G. Kenward} } _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ggplot2
Dear r-helpers, I'm using ggplot2::ggplot to plot seven time series on the same graph. c - ggplot(jobm, aes(y = value, x = year, colour = kind)) c + stat_smooth() This gives me a legend with colors that are not very different. Can I label the lines instead? How? _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] mosaic row and column order
Dear R-helpers, I wasn't able to find out how to override the alphabetical ordering of the rows and columns in a vcd::mosaic plot. I would like to have them each ordered by numerical values in a different column of the data frame that contains the contingency data. I would be most grateful for a pointer toward the solution. Thanks, MK _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Selectively swapping labels between factors
Dear R-helpers, I'm trying to selectively swap labels between two factors, depending on an indicator variable i. Can you point me to a solution, and perhaps how I could have found it? labels(fact1) is a character vector of r row numbers levels(fact1) is a character vector of the n r unique levels How do I then get the character vector of length r of the levels of fact1? Once I have that, is there anything else I need to know about swapping labels between factors in a df? _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem with two libraries
Hi, I'm running sessionInfo() R version 2.6.0 (2007-10-03) i386-apple-darwin8.10.1 locale: en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base I have two libraries: (1) /Users/mk/R/i386-apple-darwin8.10.1-library/2.6/ and (2) /Library/Frameworks/R.framework/Versions/2.6/Resources/library/ When I try to load a recently-installed package (plotAndPlayGTK) which got installed in (1) it tries to load RGtk2 which is in (2) and it fails. I would like advice on how to consolidate these two in (2) and make (2) the default library (if that's adivsable) and how to make the upgrade to future versions of R as trouble-free as possible. _ 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.