[R] Two lines, two scales, one graph
First of all, thanks to everyone who answers these questions - it's most helpful. I'm new to R and despite searching have not found an example of what I want to do (there are some good beginner's guides and a lot of complex plots, but I haven't found this). I would like to plot two variables against the same abscissa values. They have different scales. I've found how to make a second axis on the right for labeling, but not how to plot two lines at different scales. Thanks, - Rick r...@ece.pdx.edu __ 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] Is there t.test with null hypothesis?
You need to include the argument "mu=1" (without parentheses). For example: > t.test(group1,group2, mu=1) for a two-sample independent groups t-test. If you type: > ?t.test you can see the help information for the t.test function. RIck On 09/08/2016 08:06 AM, Matti Viljamaa wrote: I’m trying to do a t-test, where the null hypothesis for the two data sets has to be: “the means are the same”/“difference in means is equal to one” Using the t.test function in R I’m able to see that it uses the following “alternative hypothesis”: alternative hypothesis: true difference in means is not equal to 0 but does not seem to specify null hypothesis. I believe alternative and null hypotheses are different, although I don’t exactly know how. So what should I use for my t-test? Or is t.test ok? __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fstat.ethz.ch%2fmailman%2flistinfo%2fr-help&data=01%7c01%7crab45%40pitt.edu%7c99a5b7c1533548c5ead708d3d7e0bb76%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=Pf9Tku8lIeH9quNmY2dEmR4HNSLgShRP7p7Hx9HUCMY%3d PLEASE do read the posting guide https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fwww.R-project.org%2fposting-guide.html&data=01%7c01%7crab45%40pitt.edu%7c99a5b7c1533548c5ead708d3d7e0bb76%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=eGCmYy70ceyiJ%2bpgDXA8SaHHma%2f4DbxhIbSARUDYwxg%3d and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Lavaan
Have you considered using the semPlot package? It works nicely with lavaan models (among other sem packages). There is also the DiagrammeR package. Rick On 06/23/2015 10:48 AM, DzR wrote: Dear Senior users of R/R Studio, I am very new to this environment hence am unable to plot the SEM models including use of graphic package ggplot. Request for some help in getting the plots please. Thanks, - Deva __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Richard A. Bilonick, PhD Assistant Professor Dept. of Ophthalmology, School of Medicine Dept. of Biostatistics, Graduate School of Public Health Dept. of Orthodontics, School of Dental Medicine University of Pittsburgh Principal Investigator for the Pittsburgh Aerosol Research and Inhalation Epidemiology Study (PARIES) 412 647 5756 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R vs. RStudio?
I have four years in the R trenches, and code in R on the Ubuntu command line and the Windows R GUI. Here is an RStudio comparative overview: In the absence of Rstudio, to construct and debug a script I need: 1) A programmer's editor (such as VIM (bad) or Bluefish (better)), in which I enter the script 2) The R GUI / command/console window to run the script To test / debug the script: use the source() function to load and execute. To pause the script: insert browser(); statements at desired stopping points (thus adding needles complexity to the code) To view variable contents: use the message() and sprintf() functions to print text Viewing R help files using the ?() command opens another popup window or windows with the help files. These must be manually closed when not needed. When using RStudio, I need: *Only* the RStudio app running - its GUI includes: - A very good color-coded programmer's editor, - The R console, and (when activated), an excellent debug information window., - The Debug information window, which displays execution information (e.g., variable values), once the debugger is activated (see below) - The R documentation window, to display help files. To step through / debug the R script: Use RStudio's integrated debugger, which takes approximately 5 minutes to learn. for more info: https://support.rstudio.com/hc/en-us/articles/200713843-Debugging-with-RStudio?version=0.98.1091&mode=desktop OR within RStudio, select Debug/Debugging Help The quality and usability of RStudio has markedly improved since the early versions: Most beginner-level R programmers can become comfortable using RStudio in 45 minutes. They will recoup their time investment within the first three hours of R development. Hope this helps, Rick Reeves Foxgrove Solutions, Ltd On 1/10/2015 6:47 PM, John Sorkin wrote: I urge you to try it. John John David Sorkin M.D., Ph.D. Professor of Medicine Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Bert Gunter 1/10/2015 9:46 PM >>> That is what websites are for. Go to rstudio.com and make your own judgment . I have found that they provide much useful functionality above and beyond R's bare bones GUI. Bert On Saturday, January 10, 2015, Boris Steipe wrote: Could someone kindly enlighten me whether there are currently advantages to use R Studio vs. the normal R GUI? On the Mac I can't seem to find anything compelling, on Windows (which I don't use myself) I noticed last year that there seems to be no syntax highlighting available for the R GUI but R Studio had it. Surely there must be some value proposition in that project, what am I missing? Thanks, Boris __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] HISTOGRAM
First, a histogram would not be appropriate (your data appear to be categorical - a histogram is for continuous numeric vales) - you would need a bar plot. You should make two vectors (one for the category names and the other for the frequencies) and use the barplot function. On Fri, Nov 9, 2018 at 1:46 PM Medic wrote: > What would be the correct code (simplest version) (without gplot()) > for histogram (with 7 bars), which would include 7 names of bars under > the X-axis. The data are: > > name number > ds6277 > lk 24375 > ax46049 > dd70656 > az216544 > df 220620 > gh641827 > > (I'm attaching mydata.r, making with dput.) > > My attempt is: > > options(scipen=999) > with (mydata, hist(number)) > > P.S. I can't understand how the column "name" to include in a code > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help&data=02%7C01%7Crab45%40pitt.edu%7C55f2571738b246f9dc1e08d646739b27%7C9ef9f489e0a04eeb87cc3a526112fd0d%7C1%7C0%7C636773859721875419&sdata=haHuxll2%2FO0Dci0fSpd0evjfi0MTmLi0JoghvHxlz3o%3D&reserved=0 > PLEASE do read the posting guide > https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.R-project.org%2Fposting-guide.html&data=02%7C01%7Crab45%40pitt.edu%7C55f2571738b246f9dc1e08d646739b27%7C9ef9f489e0a04eeb87cc3a526112fd0d%7C1%7C0%7C636773859721875419&sdata=aL6arSyKx4m9LBdOMhdhSpsdJmGCHubfdI%2Fns4Rgytw%3D&reserved=0 > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] chi-square test
ll (near zero, less than 1) hence the warning message. More importantly, does this application of the Chi-squared test make sense? What am I missing? Rick -- Richard A. Bilonick, PhD Assistant Professor Dept. of Ophthalmology, School of Medicine Dept. of Biostatistics, Graduate School of Public Health Dept. of Orthodontics, School of Dental Medicine University of Pittsburgh Principal Investigator for the Pittsburgh Aerosol Research and Inhalation Epidemiology Study (PARIES) 412 647 5756 __ 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] Logical operator in R
On 01/22/2016 10:46 AM, li li wrote: Hi all, I encountered the following strange phenomenon. For some reason, the obs_p[1] and res1$st_p[89] have the same value but when I run "==", it returns FALSE. Can anyone help give some explanation on this? Thanks very much! Hanna obs_p[1] [1] 0.002201438 res1$st_p[89] [1] 0.002201438 res1$st_p[89]==obs_p[1] [1] FALSE res1$st_p[89] [1] FALSE res1$st_p[89]>obs_p[1] [1] TRUE [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. I believe the decimal representation is only approximate. The real internal values in binary are different. If you want to have comparisons like this result in being considered equal, I think there is a way to use a fuzzy comparison but I don't remember the details. Rick -- Richard A. Bilonick, PhD Assistant Professor Dept. of Ophthalmology, School of Medicine Dept. of Biostatistics, Graduate School of Public Health Dept. of Orthodontics, School of Dental Medicine University of Pittsburgh Principal Investigator for the Pittsburgh Aerosol Research and Inhalation Epidemiology Study (PARIES) 412 647 5756 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] New Package: lrequire v0.1.3 - use modules to encapsulate and cache your R scripts
Dear R Users, I am happy to announce the initial release (v0.1.3) of lrequire<https://cran.r-project.org/web/packages/lrequire/>, now available on CRAN. https://cran.r-project.org/web/packages/lrequire/ lrequire supports modularization of R Scripts, enabling encapsulation of information and caching of scripts. This is very similar to the require()<https://nodejs.org/api/modules.html> support in node.js<https://nodejs.org/>. Use of lrequire encourages separation of responsibility and using modules to encapsulate specific functionality. This leads to more easily-maintained scripts and encourages reuse. lrequire also cache loaded modules (scripts) such that the next load (source) of the script does not execute its contents, unless specified. For example, if a module is built around sourcing a slowly-changing dataset that is time-consuming to retrieve, frequent reloads of the module will only return the cached copy of the data, saving the time expense. I found this very useful for developing dashboard components – lrequire permitted me the freedom to keep tweaking the UI without having to wait for the live reload of the data. How It Works Goal: build a reusable module to welcome an individual. Any environment artifacts necessary to build that module are encapsulated in the lrequire() call and only the functionality is returned. For example: File: welcome.R data.that.will.not.be.exposed <- 'some work' hello <- function(person.name) { return (paste0('Hello, ', person.name, '!')) } module.exports = hello ____ File: main.R hello <- lrequire(welcome) hello('Rick') Note that the variable declared in welcome.R will not be visible in main.R only the hello() function. Multiple pieces of information can be exposed by returning a list() object in module.exports. Refer to the documentation for details. All the best, Rick Wargo https://linkedin.com/in/rickwargo/ https://www.rickwargo.com/ @rickwargo [[alternative HTML version deleted]] ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] nlsList {nlme} - control arguments problem
Hi All. I'd like to send some control arguments to the nls function when performing a nlsList analysis. I'm fitting a power model to some grouped data and would like to impose lower bounds on the estimates using the "port" algorithm. Obtaining the lower bound constraint works fine with a direct call to nls for a single level of the grouping variable. However, the bounds aren't imposed when performing the nlsList analysis across the levels of the grouping variable. Any idea why this isn't working? # Generate example data ## trial <- 1:100 result <- list() for (i in 1:3) { min <- rnorm(max(trial),250,5) dif <- rnorm(max(trial),500,5) p <- rnorm(max(trial),-.5,.1) e <- rnorm(max(trial),mean=0,sd=5) y <- min + dif*(trial)^p + e result[[i]] <- data.frame(y,trial,id=i) } newdf <-do.call('rbind',result) df.gr <- groupedData( y ~ trial | id, data=newdf) ### Single unit analysis ### The boundary condition on the dplt parameter is enforced! .. df.one <- subset(df.gr,id==1) nls(y~SSpowrDplt(trial,min,dplt,dif,p),data=df.one,algorithm="port",lower=c(0.0,0.0,0.0,-10)) .. example output... >Nonlinear regression model > model: y ~ SSpowrDplt(trial, min, dplt, dif, p) > data: df.one > min dplt dif p >247.052 0.000 491.965 -0.462 > residual sum-of-squares: 234322 > Algorithm "port", convergence message: relative convergence (4) ## ### nlsList analysis ### Boundary condition on dplt is not enforced . Lfit.nls <- nlsList(y~SSpowrDplt(trial,min,dplt,dif,p),data=df.gr,control=list(algorithm='port',lower=c(0.0,0.0,0.0,-10),maxiter=100)) .. example output... >Call: > Model: y ~ SSpowrDplt(trial, min, dplt, dif, p) | id > Data: df.gr >Coefficients: > min > Estimate Std. Error t value Pr(>|t|) >1 276.2354 16.16609 17.087337 1.086442e-44 >2 257.0127 20.43564 12.576694 3.390686e-30 >3 206.4017 29.01315 7.114075 7.354863e-12 > dplt > Estimate Std. Error t value Pr(>|t|) >1 -0.06579982 0.03848086 -1.7099365 0.0951222 >2 -0.01694362 0.04161933 -0.4071093 0.6786473 >3 0.08981518 0.04636532 1.9371199 0.0528957 > dif > Estimate Std. Error t value Pr(>|t|) >1 477.5049 21.89002 21.81382 6.679439e-62 >2 488.7171 22.11908 22.09482 4.466288e-66 >3 552.7105 25.04206 22.07129 9.215344e-65 > p > Estimate Std. Error t value Pr(>|t|) >1 -0.5455936 0.06262040 -8.712713 7.615265e-16 >2 -0.4839114 0.06074282 -7.966560 1.307734e-14 >3 -0.4059903 0.05455864 -7.441355 9.297527e-13 >Residual standard error: 27.43384 on 888 degrees of freedom # If you look at the structure of Lfit.nls, it looks like the control arguments are passed correctly. str(Lfit.nls) List of 3 $ 1:List of 6 ..$ control :List of 7 .. ..$ maxiter : num 100 .. ..$ tol : num 1e-05 .. ..$ minFactor: num 0.000977 .. ..$ printEval: logi FALSE .. ..$ warnOnly : logi FALSE .. ..$ algorithm: chr "port" .. ..$ lower : num [1:4] 0 0 0 -10 If it helps, here's the selfStart function that I'm using powrDpltInit <- function(mCall, LHS, data) { xy <- sortedXyData(mCall[["x"]],LHS,data) min.s <- min(y) dif.s <- max(y)-min(y) dplt.s <- 0.5 p.s <- -.20 value <- c(min.s, dplt.s, dif.s, p.s) names(value) <- mCall[c("min","dplt","dif","p")] value } SSpowrDplt<-selfStart(~min + dplt*x + dif*x^p,initial=powrDpltInit, parameters=c("min","dplt","dif","p")) Thanks for your help! Rick DeShon __ 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] Tck/tk help
I am trying to create a simple window that displays a dataframe. I was able to put together a function from a couple of examples on the web. For the most part my function works. The only problem is with resizing the window. I found a post where someone suggested using with(env,tkpack("configure",etc. ) but using tkpack messes around with the layout obtained from tkgrid(). Any tips would be appreciated. toTclArray<-function(dsn,dig=2) { # Converts Data Frame/Matrix to a Tcl Array for Use in Displaying Tables # dsn is the data set name # dig is the number of digits to round to require(tcltk) tclarray1<-tclArray() for (i in 0:(dim(dsn)[1])) { for (j in 0:(dim(dsn)[2]-1)) { # First Row is Set to Column Names to be Used as Labels if (i==0) { tclarray1[[i,j]]<-colnames(dsn)[j+1] } else { tem<-dsn[i,j+1] tclarray1[[i,j]]<-ifelse(is.na(tem),".", ifelse(is.numeric(tem),round(tem,digits=dig), as.character(tem))) } } } return (tclarray1) } displayInTable<-function(dsn,title="",height=-1,width=-1,dig=2,colwd=14) { tclarray<-toTclArray(dsn,dig=dig) require(tcltk) tt<-tktoplevel() tclRequire("Tktable") tkwm.title(tt,title) table1<-tkwidget(tt,"table",rows=(dim(dsn)[1]+1),cols=dim(dsn)[2], titlerows=1,titlecols=0,colwidth=colwd, height=height+1,width=width+1, xscrollcommand=function(...) tkset(xscr,...), yscrollcommand=function(...) tkset(yscr,...) ) xscr<-tkscrollbar(tt,orient="horizontal",command=function(...) tkxview(table1,...) ) yscr<-tkscrollbar(tt,command=function(...) tkxview(table1,...) ) tkgrid(table1,yscr) tkgrid.configure(yscr,sticky="nsw") tkgrid(xscr,sticky="new") tkconfigure(table1,variable=tclarray,background="white", selectmode="extended",state="disabled") with(tt,{tkpack("configure",table1,expand=TRUE,fill="both") tkpack("configure",yscr,expand=TRUE,fill="y") tkpack("configure",xscr,expand=TRUE,fill="x") }) return(table1) } # Example try<-data.frame(matrix(1:100,5,20,byrow=TRUE)) colnames(try)<-1:20 displayInTable(try,title="1 to 100") -- View this message in context: http://n4.nabble.com/Tck-tk-help-tp1837711p1837711.html Sent from the R help mailing list archive at Nabble.com. __ 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] -network- package in R: removing nodes
Dear all, If you have experience with the -network- package, can you show me how to remove nodes based on their degrees? For instance, removing all nodes with an out-degree or in-degree of 1? Thank you very much for your help! Rick __ 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] -network- package in R: removing nodes
Dear all, If you have experience with the -network- package, can you show me how to remove nodes based on their degrees? For instance, removing all nodes with an out-degree or in-degree of 1? Thank you very much for your help! Rick __ 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] Installing Rmpi on Centos 5.2
I am trying to install the R package "Rmpi" which needs libmpi. I've installed openmpi and lam in Centos 5.2: [r...@rab45-1 /]# rpm -qv openmpi openmpi-1.2.5-5.el5 openmpi-1.2.5-5.el5 [r...@rab45-1 /]# rpm -qv lam lam-7.1.2-14.el5 lam-7.1.2-14.el5 I'm using this to install Rmpi: R CMD INSTALL /home/rick/Rmpi_0.5-7.tar.gz --with-mpi=/usr/lib64/lam/include But I get the following error message: /usr/bin/ld: skipping incompatible /usr/lib/lam/lib/libmpi.so when searching for -lmpi I'm not sure what else to install/uninstall to fix this. Rick B. __ 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] CFA with lavaan or with SEM
Not sure if you are aware of the OpenMx SEM package (http://openmx.psyc.virginia.edu/). It's a very full-featured structural equation modeling package. __ 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] SEM and count data
Hi all- New to R, and I've managed to learn a bit about Lavaan package for SEM, and pscl package for analyzing count data. I would like to find a way to combine these analyses as I am hoping to run a model with a multi-trait, multi-reporter factor (2 reporters by 4 traits apiece, with one overall factor to represent common variance) as a predictor, and predict (zero-inflated) count substance use outcomes. Do people have any suggestions for how to do this? It seems that Lavaan can't handle count data, and I don't know if there is a count data package that can handle SEM models. I'm thinking I may have to do a two-step process and run SEM package to get factor scores, and then put in as a predictor in count outcomes package. Thanks! Rick [[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 coordinates when trying to draw lines into a raster (image) file
Hi All, I am struggling with something, and could use some help I have a scenario where I need to draw lines onto a base image using R â briefly, the image has what amounts to an outline âmapâ of locations, and the lines will correspond to âroutesâ between two locations. The locations are known in terms of image pixel coordinates â letâs call them (px1, py1) and (px2, py2), but when I try and plot a line into the image using these coordinates, the visual positions are incorrect â the start and end points of the line are offset from the desired position, and the amount of offset changes as I resize the window. I've tried such things as normalising them into the [0,1] range used by the viewport but this does not correct the problem. So, I figured that I must have made some mistake with my scaling of coordinates from image to viewport, but I cannot find where or what. Iâve fiddled around a bit (well, a lot!) but cannot get the desired result. So, it is time to ask for help, hence this messageâ¦. Any suggestions gratefully received⦠Iâve done a fair amount of R programming, but have not used these extended graphics capabilities much at all, so I really am getting frustrated Regards and thanks in advance, Rick -- The code segment in question is: # load packages library(jpeg) library(grid) # read the image file baseimg <- readJPEG("loc_map.jpg", native=FALSE) xsize <- ncol(baseimg) # Get image size â this one is 1344 px wide ysize <- nrow(baseimg) # and 1008 px high # create a viewport xrange <- c(0, xsize)# set up the viewport range to match the image size yrange <- c(0, ysize) vp <- viewport(x=0.5, y=0.5, width=0.9, height=0.9, xscale=xrange, yscale=yrange) pushViewport(vp) grid.rect(gp=gpar(lty="dashed"))# draw a dashed line around it. # display the base image grid.raster(baseimg) # First location â image pixel coordinates (748, 177). Normalise these to [0,1] to # match the viewpoint coordinate scheme. Note that we need to invert the # y coordinate as R coords run from bottom up, but image ones are top down px1 <- (748/xsize)# 748/1344 ~= 0.556, so in range [0,1] py1 <- (1.0 - (177/ysize)) # 1-(177/1008) ~= 0.824, so also in range [0,1] # position of the St Johns Hill enterance (image coords # [769, 892]) normalised to the viewport x2 <- (769/xsize) y2 <- (1.0 - (892/ysize)) # draw a line from pixel (px1,py1) to pixel (px2,py2) in blue xx <- c(px1, px2) yy <- c(py1, py2) grid.lines(xx, yy, gp=gpar(col="blue")) __ 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] R - Time Series Regression with a p-value check for each additional added point.
Hi All, Here is my sample data set.. y x 7/4/2009 -0.2368 -1.2727 7/11/2009 -0.5039 -5.2805 7/18/2009 -0.6655 -6.9641 7/25/2009 -0.3936 -3.6937 8/1/2009 -0.3463 -5.6457 8/8/2009 -0.3000 -1.7368 8/15/2009 0.2378 6.4600 8/22/2009 -0.2962 -3.1113 8/29/2009 -0.4346 -4.2039 9/5/2009 -0.6971 -7.8216 9/12/2009 -0.1217 5.1446 9/19/2009 -0.3107 2.0862 9/26/2009 -0.1797 -3.6055 10/3/2009 0.2299 -0.7373 *10/10/2009 0.4098 -10.1939* When graphed on a scatter plot the bold faced data point significantly reduces the robustness of my regression model. Question, is there a way in R to run a p-value check on each added data point. So lets say given the range of 7/4/2009- 10/03/2009 my p-value was .01; but then after adding 10/10/2009 to the data set my p-value increased to 0.4. At this point a conditional statement could be made saying IF(p-value increase > z) then stop regression at prior date. Thanks for your help, Rick [[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] plotCI overlay
I'm using the plotCI function and I'd like to overlay additional means with CIs onto an existing plotCI-created plot in a different color. Is this possible? Thanks. Rick __ 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] Generate multivariate normal data with a random correlation matrix
Hi All. I'd like to generate a sample of n observations from a k dimensional multivariate normal distribution with a random correlation matrix. My solution: The lower (or upper) triangle of the correlation matrix has n.tri=(d/2)(d+1)-d entries. Take a uniform sample of n.tri possible correlations (runi(n.tr,-.99,.99) Populate a triangle of the matrix with the sampled correlations Mirror the triangle to populate the other triangle forming a symmetric matrix, cormat Sample n observations from a multivariate normal distribution with mean vector=0 and varcov=cormat Problem: This approach violates the triangle inequality property of correlation matrices. So, the matrix I've constructed is certainly a valid matrix but it is not a valid correlation matrix and it blows up when you submit it to a random number generator such as rmnorm. With a small matrix you sometimes get lucky and generate a valid correlation matrix but as you increase d the probability of obtaining a valid correlation matrix drops off quickly. So, any ideas on how to construct a correlation matrix with random entries that cover the range (or most of the range) or the correlation [-1,1]? Here's the code I've used that won't work. library(mnormt) n <- 1000 d <- 50 n.tri <- ((d*(d+1))/2)-d r <- runif(n.tri, min=-.5, max=.5) cormat <- diag(c) count1=1 for (i in 1:c){ for (j in 1:c){ if (ihttps://stat.ethz.ch/mailman/listinfo/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] Generate multivariate normal data with a random correlation matrix
Hi All. I'd like to generate a sample of n observations from a k dimensional multivariate normal distribution with a random correlation matrix. My solution: 1) The lower (or upper) triangle of the correlation matrix has n.tri=(d/2)(d+1)-d entries. 2) Take a uniform sample of n.tri possible correlations (runi(n.tr,-.99,.99) 3) Populate a triangle of the matrix with the sampled correlations 4) Mirror the triangle to populate the other triangle forming a symmetric matrix, cormat 5) Sample n observations from a multivariate normal distribution with mean vector=0 and varcov=cormat Problem: This approach violates the triangle inequality property of correlation matrices. So, the matrix I've constructed is certainly a valid matrix but it is not a valid correlation matrix and it blows up when you submit it to a random number generator such as rmnorm. With a small matrix you sometimes get lucky and generate a valid correlation matrix but as you increase d the probability of obtaining a valid correlation matrix drops off quickly. So, any ideas on how to construct a correlation matrix with random entries that cover the range (or most of the range) or the correlation [-1,1]? Here's the code I've used that won't work. library(mnormt) n <- 1000 d <- 50 n.tri <- ((d*(d+1))/2)-d r <- runif(n.tri, min=-.5, max=.5) cormat <- diag(c) count1=1 for (i in 1:c){ for (j in 1:c){ if (ihttps://stat.ethz.ch/mailman/listinfo/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] Generate multivariate normal data with a random correlation matrix
Thanks for the response, Rex. This is an interesting approach. The Choleski decomposition approach that John suggested seems to be an obvious and direct approach to this problem. Your approach is less obvious to me but may be equal or superior to the Choleski decomposition. Are all possible correlation matrices of size k equally likely using your approach? It would seem so based on your description. If so, it is a way cool solution. Rick On Thu, Feb 10, 2011 at 12:18 PM, wrote: > If you want a random correlation matrix, why not just generate random data > and accept the correlation matrix that you get? The standard normal > distribution in k dimensions is (hyper)spherically symmetric. If you > generate k standard normal N(0,1) variates, you have a point in k-space with > direction uniformly distributed on the (k-1)sphere and Gaussian magnitude. > If you generate k such, you have a random linear transformation with all > sorts of desirable symmetries. So, if you generate a kxk matrix of standard > normal variates, and another nxk standard normal variates, and multiply the > two matrices to get n points in k space, that seems to be a pretty good > definition of random correlation to me. I'm sure you can decompose the kxk > matrix to get the theoretical distribution, maybe by multiplying it by its > transpose and doing an SVD; I'd have to think about that part. > ... unless you have a particular distribution of correlation matrices in mind > to begin with, which doesn't seem to be the case. > > > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Szumiloski, John > Sent: Wednesday, February 09, 2011 11:30 AM > To: r-help@r-project.org > Cc: Rick DeShon > Subject: Re: [R] Generate multivariate normal data with a random correlation > matrix > > The knee jerk thought I had was to express the correlation matrix as a > generic Choleski decomposition, then randomly populate the triangular > decomposed matrix. When you remultiply, you can simply rescale to 1s on the > diagonals. Then rmnorm as usual. > > In R, see ?chol > > If you want to get fancy, you could look at the random distribution you would > use for the triangular matrix and play with that, including different > distributions for different elements, elements' distributions being > conditional on values of previously randomized elements, etc. > > John > > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Rick DeShon > Sent: Wednesday, 09 February, 2011 11:06 AM > To: r-h...@stat.math.ethz.ch > Subject: [R] Generate multivariate normal data with a random correlation > matrix > > Hi All. > > I'd like to generate a sample of n observations from a k dimensional > multivariate normal distribution with a random correlation matrix. > > My solution: > The lower (or upper) triangle of the correlation matrix has > n.tri=(d/2)(d+1)-d entries. > Take a uniform sample of n.tri possible correlations (runi(n.tr,-.99,.99) > Populate a triangle of the matrix with the sampled correlations Mirror the > triangle to populate the other triangle forming a symmetric matrix, cormat > Sample n observations from a multivariate normal distribution with mean > vector=0 and varcov=cormat > > > Problem: > This approach violates the triangle inequality property of correlation > matrices. So, the matrix I've constructed is certainly a valid matrix but it > is not a valid correlation matrix and it blows up when you submit it to a > random number generator such as rmnorm. With a small matrix you sometimes > get lucky and generate a valid correlation matrix but as you increase d the > probability of obtaining a valid correlation matrix drops off quickly. > > So, any ideas on how to construct a correlation matrix with random entries > that cover the range (or most of the range) or the correlation [-1,1]? > > Here's the code I've used that won't work. > > library(mnormt) > n <- 1000 > d <- 50 > > n.tri <- ((d*(d+1))/2)-d > r <- runif(n.tri, min=-.5, max=.5) > > cormat <- diag(c) > count1=1 > for (i in 1:c){ > for (j in 1:c){ > if (i cormat[i,j]=r[count1] > cormat[j,i]=cormat[i,j] > count1=count1+1 > } > } > } > eigen(cormat) # if negative eigenvalue, then the matrix violates the > triangle inequality > > x <- rmnorm(n, rep(0, c), cormat) # Sample the data >
[R] Missing times chron
Dear all, As a novice user of R I ran into a problem that's quite hard for me to resolve. I have a database containing data of a clinical trial in which patients are included that survived or died: x <- matrix(data=c(1:5,0, "1/1/2012 00:00:00",0,0,"1/7/2012 00:00:00"), nrow=5, ncol=2, dimnames= list(NULL,c("ID", "dateofdeath"))) My file is a .csv so I don't have a problem with the brackets, don't know how to show you the idea without the brackets... I want to be able to do calculations with the values in the column x$dateofdeath so use the chron-package for this: library(chron) x$dateofdeath<- as.character(x$dateofdeath) dateofdeath1 <- t(as.data.frame(strsplit(x$dateofdeath,' '))) row.names(dateofdeath1) <- NULL x$dateofdeath<- chron(dates=dateofdeath1[,1],times=dateofdeath1[,2],format=c('d-m-y','h:m:s')) When I run this script the database looks like this: > x ID dateofdeath 1 1 (NA NA) 2 2 (01-01-12 00:00:00) 3 3 (NA NA) 4 4 (NA NA) 5 5 (01-07-12 00:00:00) The times are how I want them to be, the zero's on the other hand should stay that way. In other words: how can I make the database look like this: > x ID dateofdeath 1 1 0 2 2 (01-01-12 00:00:00) 3 3 0 4 4 0 5 5 (01-07-12 00:00:00) I already tried replacing the NA's with 0 which gives me 1-1-1970 (the default date by chron) and making a subset and only replacing values that are not equal to zero doesn't work either: d <- x ## above coding for chron with x replaced with d ## mat <- match(x$ID, d$ID) x$dateofdeath <- d$dateofdeath[mat] Does anybody know how to resolve this issue? Thanks in advance! Cheers, Rick Admiraal [[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] FIML with missing data in sem package
On 12/01/2011 07:18 AM, John Fox wrote: > To:r-help@r-project.org > Subject: [R] FIML with missing data in sem package > You should check out the OpenMx R package. Just search for OpenMx and SEM. You can download from the web site. It does FIML and is an excellent SEM package. Rick B . __ 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] args() function does not list function prototype for locally-produced/installed R package
Greetings: I have check the 'Building R Extensions' manual and can find no advice on this issue, so I am asking -- I have created an R package consisting entirely of R source code, and created an installer using the R CMD build / R CMD check commands. The package installs correctly, using R CMD install, and the .Rd files for each function (one function per .R / .Rd file) are visible using the '?function' command. However, the 'args(function)' command does not list the function prototype; instead generating the error: Error in args(function) : object "function" not found. Question: If it is possible, what changes do I make to my package and install process to get args() to display the function prototype(s) for the functions in my local package? Thanks, Rick Reeves __ 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] args() function does not list function prototype for locally-produced/installed R package
Duncan: Indeed, adding the function names to the NAMESPACE file (in the form: export(functionName)) solved the problem, and the args() function displays the function argument lists. Thanks, Rick Reeves On 12/5/2011 2:49 PM, Duncan Murdoch wrote: On 11-12-05 3:04 PM, Rick Reeves wrote: > Greetings: > > I have check the 'Building R Extensions' manual and can find no advice > on this issue, > so I am asking -- > > I have created an R package consisting entirely of R source code, and > created an installer > using the R CMD build / R CMD check commands. The package installs > correctly, using > R CMD install, and the .Rd files for each function (one function per .R > / .Rd file) are visible > using the '?function' command. However, the 'args(function)' command > does not list the > function prototype; instead generating the error: > > Error in args(function) : object "function" not found. > > Question: If it is possible, what changes do I make to my package and > install process to get > args() to display the function prototype(s) for the functions in my > local package? Is the function visible (e.g., if you type the name of the function, does it print)? I would guess not: I think you have a NAMESPACE file, and you haven't listed this function in it. If you don't have a NAMESPACE file, or you do have one and you list this function, then I think you need to be more forthcoming with accurate information. When I type args(function), I don't get the error you get, since "function" is a reserved word: > args(function) Error: unexpected ')' in "args(function)" Duncan Murdoch 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. __ 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] PMML for Cox Regression
Hi, We have created a cox regression model (coxph) and exported from R as PMML using the Rattle package. The resulting PMML is a standard Regression model in the format y=b1*x1+b2*x2+…….bn*xn: risk= (0.027968680616809*dropped_Calls)+(0.00777220409115466*helpdesk_Calls) The PMML is included at the end of this post. Cox Regression is usually in this format: h(t)= h0(t)*e^(b1*x1+b2*x2+…….bn*xn) We couldn't find any documentation about how a scoring engine should generate scores from the R PMML and it seems that the standard regression model will not generate the proper results for this cox regression model. Can someone point us to the proper documentation for scoring this model? Thanks in advance, Rick Pechter http://www.dmg.org/PMML-3_2"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://www.dmg.org/PMML-3_2 http://www.dmg.org/v3-2/pmml-3-2.xsd";> 2011-10-11 15:13:04 -- View this message in context: http://r.789695.n4.nabble.com/PMML-for-Cox-Regression-tp3896791p3896791.html Sent from the R help mailing list archive at Nabble.com. __ 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 IML with R and SAS
The SAS/IML documentation on calling R is at http://support.sas.com/documentation/cdl/en/imlug/64248/HTML/default/viewer.htm#r_toc.htm Other ways to get help include calling SAS Technical Support (it's free) and posting your question to the SAS/IML Discussion forum at http://communities.sas.com/community/sas_iml_and_sas_iml_studio I'd like to see an example of what you're trying to do, but here are few general ways to do this: 1) Call R in a loop from SAS/IML. At each iteration, generate each matrix or data frame, export it to a SAS matrix or data set, and do the analysis. 2) While the previous option is conceptually easy, it might be more efficient to generate all the data with a single call to R, export it all to SAS, and then use SAS to analyze each subset of the data. I don't usually monitor this R forum, so if you want further details might want to use one of the options in the first paragraph. -- View this message in context: http://r.789695.n4.nabble.com/How-to-use-IML-with-R-and-SAS-tp3954943p3955888.html Sent from the R help mailing list archive at Nabble.com. __ 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] Getting R and x11 to work
I'm using Suse Linux Enterprise Desktop 10.2 (SP2) on an HP 2133 (x86) mini-notebook. (There apparently are a LOT of bugs in 10.1!) I downloaded R-base from the openSuse 10.2 repository and was (finally) able to install it (after installing blas and gcc-fortran). I can start an R session and do computations. When I try to do any graphics using x11, I get the message: unable to load shared library '/usr/lib/R/modules//R_X11.so': /usr/lib/R/modules//R_X11.so: undefined symbol: cairo_image_surface_get_data Does anyone have an idea on how to fix this? Rick B. __ 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] Installing R-2.6.2 on Windows multiuser
What is the proper way to install/configure R-2.6.2 for M$-Windows XPSP2 for multiple users when the other users don't have administrative rights. I don't remember this was a problem with previous versions of R. I installed R-2.6.2 as administrator on the computer. It installs, runs, and can manually update fine. The main user of this computer does not have administrator rights. Now, R won't even start. It gives an error of 0xC022 unable to initialize properly which is a permissions issue. The R icon shortcut is coded to look for configuration/startup files in my directory. So, I went into Control Panels > System > Advanced and created an environment variable R_USER as "C:\\Documents and Settings\\X\My Documents" where X is the user's login name. I tried this with and without quotes, and with single \ or \\ . I tried an uninstall/reinstall and had the same problem. Thanks for any suggestions. -- Rick Voland [EMAIL PROTECTED] __ 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] Installing R-2.6.2 on Windows multiuser
The issue is new to R-2.6.2. I solved my problem for now by replacing with R-2.6.1. The icon to R-2.6.2 for **all users** starts in c:\Documents and Settings\Y\My Documents where Y is the login name of the person who installed. I tried changing this startup directory to C:\Program Files\R\R-2.6.2 (used for previous versions of R) and still had the same permissions issue. I also tried setting R_USER environment variable as I previously indicated. -- Rick Voland [EMAIL PROTECTED] __ 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] NLS plinear question
Hi All. I've run into a problem with the plinear algorithm in nls that is confusing me. Assume the following reaction time data over 15 trials for a single unit. Trials are coded from 0-14 so that the intercept represents reaction time in the first trial. trl RT 01132.0 1 630.5 21371.5 3 704.0 4 488.5 5 575.5 6 613.0 7 824.5 8 509.0 9 791.0 10 492.5 11 515.5 12 467.0 13 556.5 14 456.0 Now fit a power function to this data using nls with the plinear algorithm >fit.pw <-nls(RT ~ cbind(1,trl, trl^p), start = c(p = -.2), algorithm = "plinear", data=df.one) Yields the following error message "Error in numericDeriv(form[[3]], names(ind), env) : Missing value or an infinity produced when evaluating the model" Now, recode trial from 1-15 and run the same model. >fit.pw <-nls(RT ~ cbind(1,trl, trl^p), start = c(p = -.2), algorithm = "plinear", data=df.one) Seems to work fine now... Nonlinear regression model model: RT ~ cbind(1, trl, trl^p) data: df.one p .lin1.lin.trl .lin3 -0.2845 200.3230-8.9467 904.7582 residual sum-of-squares: 555915 Number of iterations to convergence: 11 Any idea why having a zero for the first value of X causes this problem? Thanks in advance, Rick DeShon [[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] Efficient computation of average covariance matrix over a list
Hi All. I would like to compute a separate covariance matrix for a set of variables for each of the levels of a factor and then compute the average covariance matrix over the factor levels. I can loop through this computation but I need to perform the calculation for a large number of levels and am looking for something more elegant. To be concrete u<- 3 n<- 10 x<- rnorm((id*u)) y<- rnorm((id*u)) z<- rnorm((id*u)) id <- gl(u,n) df <- data.frame(id,x,y,z) df.s <- split(xxx,id) lcov <- lapply(df.s,cov) lcov What's an efficient way to compute the average covariance matrix over the list members in "lcov"? Thanks in advance, Rick [[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] Efficient computation of average covariance matrix over a list
Hi All. I would like to compute a separate covariance matrix for a set of variables for each of the levels of a factor and then compute the average covariance matrix over the factor levels. I can loop through this computation but I need to perform the calculation for a large number of levels and am looking for something more elegant. To be concrete u<- 3 n<- 10 x<- rnorm((id*u)) y<- rnorm((id*u)) z<- rnorm((id*u)) id <- gl(u,n) df <- data.frame(id,x,y,z) df.s <- split(xxx,id) lcov <- lapply(df.s,cov) lcov What's an efficient way to compute the average covariance matrix over the list members in "lcov"? Thanks in advance, Rick DeShon __ 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] Ordinal Package Errors
I'm trying to install the ordinal package (http://popgen.unimaas.nl/~plindsey/rlibs.html). I downloaded ordinal03.tgz and untarred it. rmutil was previously installed (and appears to work ok.) Then I installed ordinal: [r...@localhost ~]# R CMD INSTALL /home/chippy/Download/ordinal * Installing to library '/usr/lib/R/library' * Installing *source* package 'ordinal' ... ** libs ** arch - gcc -m32 -std=gnu99 -I/usr/include/R -I/usr/local/include-fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -c dist.c -o dist.o dist.c: In function ‘evalfn’: dist.c:119: warning: unused variable ‘nn’ dist.c: In function ‘romberg’: dist.c:146: warning: unused variable ‘j’ dist.c:147: warning: ‘sum[0]’ may be used uninitialized in this function dist.c:147: warning: ‘Rf_df’ may be used uninitialized in this function gcc -m32 -std=gnu99 -I/usr/include/R -I/usr/local/include-fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -c kord.c -o kord.o kord.c: In function ‘pkord’: kord.c:428: warning: suggest explicit braces to avoid ambiguous ‘else’ kord.c: In function ‘kord’: kord.c:73: warning: ‘omega’ may be used uninitialized in this function kord.c:73: warning: ‘b0b’ may be used uninitialized in this function kord.c:73: warning: ‘a0a’ may be used uninitialized in this function gcc -m32 -std=gnu99 -I/usr/include/R -I/usr/local/include-fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -c lcr.c -o lcr.o lcr.c: In function ‘lbr’: lcr.c:247: warning: ‘p’ may be used uninitialized in this function gcc -m32 -std=gnu99 -shared -L/usr/local/lib -o ordinal..so dist.o kord.o lcr.o -L/usr/lib/R/lib -lR ** R ** data ** preparing package for lazy loading Loading required package: rmutil Attaching package: 'rmutil' The following object(s) are masked from package:base : units ** help >>> Building/Updating help pages for package 'ordinal' Formats: text html latex example ** building package indices ... * DONE (ordinal) I start up R but when I try to load ordinal I get error messages: [r...@localhost ~]# R R version 2.8.0 (2008-10-20) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. [Previously saved workspace restored] > library(ordinal) Loading required package: rmutil Attaching package: 'rmutil' The following object(s) are masked from package:base : units Error in library.dynam("ordinal", pkg, lib) : shared library 'ordinal' not found Error in library(ordinal) : .First.lib failed for 'ordinal' Does anyone know how to fix this? Rick B. __ 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] Ordinal Package Errors
On Wed, 2009-01-14 at 16:38 +, Prof Brian Ripley wrote: > You need to ask the author (as the posting guide asked you to). > > I'm tempted to not help further given the (almost complete) lack of > cooperation of that author with R's recommendations, but note > 'ordinal..so' in your log and look for the obvious fix in > src/Makefile. > > I had no idea whether this was a problem with the particular package or my installation of R. Sometimes you have to ask a question before it's clear what to do. I went to /usr/lib/R/library/ordinal/libs and moved "ordinal..so" to "ordinal.so". This solved the problem. I didn't see anything obvious in the Makefile (at least, not obvious to me). There were other things that made installing the ordinal package difficult. The first is that the file is "ordinal03.tgz". Using > R CMD INSTALL ordinal03.tgz won't work because the package name is ordinal, not ordinal03. I tried renaming but that didn't work, so I untarred it and then did: > R CMD INSTALL ordinal This installed the package but then ordinal..so is incorrectly named so I corrected it as described above. It would have been a whole lot easier if the package was in the contributed package repository. Rick B. __ 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] Power analysis for MANOVA?
On Wed, 2009-01-28 at 21:21 +0100, Stephan Kolassa wrote: > Hi Adam, > > first: I really don't know much about MANOVA, so I sadly can't help you > without learning about it an Pillai's V... which I would be glad to do, > but I really don't have the time right now. Sorry! > > Second: you seem to be doing a kind of "post-hoc power analysis", "my > result isn't significant, perhaps that's due to low power? Let's look at > the power of my experiment!" My impression is that "post-hoc power > analysis" and its interpretation is, shall we say, not entirely accepted > within the statistical community, see: > > Hoenig, J. M., & Heisey, D. M. (2001, February). The abuse of power: The > pervasive fallacy of power calculations for data analysis. The American > Statistician, 55 (1), 1-6 > > And this: > http://staff.pubhealth.ku.dk/~bxc/SDC-courses/power.pdf > > However, I am sure that lots of people can discuss this more competently > than me... > > Best wishes > Stephan > The point of the article was that doing a so-called "retrospective" power analysis leads to logical contradictions with respect to the confidence intervals and p-values from the analysis of the data. In other words, DON'T DO IT! All the information is contained in the confidence intervals which are based on the observed data - an after the fact "power analysis" cannot provide any insight - it's not data analysis. Rick B. __ 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] replace zeros in a block diagonal matrix with small random values?
Hi All. Imagine you have a large block diagonal matrix. I'd like to replace the zeros in this matrix with small random (runif) numbers. Any ideas for a simple and efficient way to do this? Best regards, Rick DeShon __ 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] nlsList (nlme) error
Hi All. I'm trying to run nlsList an getting an error that makes no sense to me. I have accuracy and reaction time data over many trials for each person (id) When I use nlsList code that is virtually identical to the example in the doc file I get the following error. I've tried everything I could think of and can't get around it. Any ideas what I'm doing wrong? ** fm.nls<-nlsList(RT ~ SSasymp(trial, Asym, R0, lrc) , data = df.group, na.action="na.exclude", start = c(Asym = 550, R0 = 770, rc =-2.5)) "Error in nlsList.formula(RT ~ SSasymp(trial, Asym, R0, lrc), data = df.group, : Data must be a groupedData object if formula does not include groups" *** Here's the first 10 records of my data: > df.group[1:10,] Grouped Data: RT ~ trial | id id trial ACC RT block 1.1 1 1 1 1 2.1 2 1 0 NA 1 3.1 3 1 1 1309 1 4.1 4 1 1 544 1 5.1 5 1 1 654 1 6.1 6 1 0 NA 1 7.1 7 1 1 441 1 8.1 8 1 1 882 1 9.1 9 1 1 1097 1 10.1 10 1 1 898 1 The data are clearly grouped. Just to be sure str(df.group) Classes 'nfnGroupedData', 'nfGroupedData', 'groupedData' and 'data.frame': 15480 obs. of 5 variables: $ id : Ord.factor w/ 43 levels "31"<"8"<"30"<..: 41 11 33 22 4 27 5 2 37 19 ... $ trial: int 1 1 1 1 1 1 1 1 1 1 ... $ ACC : int 1 0 1 1 1 0 1 1 1 1 ... $ RT : int NA 1309 544 654 NA 441 882 1097 898 ... $ block: int 1 1 1 1 1 1 1 1 1 1 ... - attr(*, "formula")=Class 'formula' length 3 RT ~ trial | id .. ..- attr(*, ".Environment")= - attr(*, "FUN")=function (x) - attr(*, "order.groups")= logi TRUE Thanks! Rick DeShon > version _ platform i386-apple-darwin8.10.1 arch i386 os darwin8.10.1 system i386, darwin8.10.1 status major 2 minor 6.1 year 2007 month 11 day26 svn rev43537 language R version.string R version 2.6.1 (2007-11-26) __ 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] Errors running gam examples
I'm running R 2.8.0 under Fedora 8 (32-bit). I installed the gam package. I can fit gam models, but I get error messages when I try to use step.gam and plot.gam, even for examples: > library(gam) > ?plot.gam > data(gam.data) > gam.object <- gam(y ~ s(x,6) + z,data=gam.data) > plot(gam.object,se=TRUE) Error in dim(data) <- dim : attempt to set an attribute on NULL summary(gam.object) appears to work OK. The same thing happens if I use my own data and model. Package: gam Title: Generalized Additive Models Date: 2008-05-28 Version: 1.0 I was able to get step.gam to work on its example but it doesn't work on my model. Has anyone else run into this? Rick B. __ 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] Superimposing vector polygons over raster grid in a plot
Hello: I would like to superimpose vector polygons (state outlines) from a Shape file on top of a satellite image, imported into a SpatialGridDataFrame from GEOTIFF via gdal_translate and readGDAL. When I plot polygon and point shape files in R, into SpatialPointDataFrame and SpatialPolygonDataFrame, the two feature sets line up geographically, so it seems logical that a SpatialGridDataFrame should behave in the same way. From my initial research, the spplot function is the correct function for plotting grids/images with axes and annotation. The big question is, how do I incorporate a Spatial(Points or Polygons)DataFrame into the spplot display list? It seems as though many scientists would like to create such plots without resorting to GRASS or another GIS. Thanks for any advice, Rick Reeves Rick Reeves Scientific Programmer / Analyst National Center for Ecological Analysis and Synthesis UC Santa Barbara [EMAIL PROTECTED] www.nceas.ucsb.edu 805 892 2533 __ 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] This site provided an excellent answer to my raster / vector plot question
I can recommend it highly, esp for those of us in the geo spatial realm: http://casoilresource.lawr.ucdavis.edu/drupal/node/442 Thanks do Dylan for answering... RR -- Rick Reeves Scientific Programmer / Analyst National Center for Ecological Analysis and Synthesis UC Santa Barbara [EMAIL PROTECTED] www.nceas.ucsb.edu 805 892 2533 __ 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] Cannot Install rimage
I'm trying to install rimage in R version 2.5.1 running on Fedora 6 (kernel 2.6.22.7-57.fc6 with the headers and gcc installed, along with fftw2 and libjpeg and headers): > install.packages("rimage") Warning in install.packages("rimage") : argument 'lib' is missing: using '/usr/lib/R/library' trying URL 'http://lib.stat.cmu.edu/R/CRAN/src/contrib/rimage_0.5-7.tar.gz' Content type 'application/x-gzip' length 331029 bytes opened URL == downloaded 323Kb * Installing *source* package 'rimage' ... checking for g++... no checking for c++... no checking for gpp... no checking for aCC... no checking for CC... no checking for cxx... no checking for cc++... no checking for cl... no checking for FCC... no checking for KCC... no checking for RCC... no checking for xlC_r... no checking for xlC... no checking for C++ compiler default output... configure: error: C++ compiler cannot create executables See `config.log' for more details. ERROR: configuration failed for package 'rimage' ** Removing '/usr/lib/R/library/rimage' The downloaded packages are in /tmp/RtmpGDx12u/downloaded_packages Warning message: installation of package 'rimage' had non-zero exit status in: install.packages("rimage") I cannot find "config.log" that is mentioned. Can someone please tell me what is missing from my configuration? rimage installed on another system running Fedora 7 once I installed fftw2. Rick B. __ 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] Executing a Function in a Loop With a Changing Value for an Argument
I want to run a function in a loop and replace one of the arguments from a large list each time through the loop. If I was writing it out manually: myfunc(x=var1) myfunc(x=var2) etc. But I want to do this in a loop where x is replaced by a new name. Something like: for(i in vars) { myfunc(x=i) } where "vars" is a vector of names for items in a data.frame. If I use "as.symbol" to create names, the evaluation never works correctly. Is there a way to do this? Any suggestions would be appreciated. Rick B. __ 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] Executing a Function in a Loop With a Changing Value foran Argument
On Thu, 2007-10-25 at 15:34 +1000, [EMAIL PROTECTED] wrote: > There are many simple ways to do this, if I understand you correctly. > Here is an example > > > dat <- data.frame(matrix(rnorm(25), 5, 5)) > > names(dat) > [1] "X1" "X2" "X3" "X4" "X5" > > vars <- names(dat)[-1] > > vars > [1] "X2" "X3" "X4" "X5" > > myfunc <- function(x) print(mean(x)) > > for(i in dat[, vars]) myfunc(x = i) > [1] 0.3648022 > [1] -0.1593466 > [1] 0.5874517 > [1] -0.5049586 > > colMeans(dat) ## as a check > X1 X2 X3 X4 X5 > 0.1779146 0.3648022 -0.1593466 0.5874517 -0.5049586 > > > > > Bill Venables > Thanks. The problem with this approach is that the data.frame variable names are lost. (A minor point is that it won't work if only one variable is chosen.) The function I wrote generates labels for a plot and I want the variable name to show up (not "i"). I was hoping not to have to re-write my function. Is there a way to pass the variables that will allow my function to work normally (just as it would if I wrote out the function calls with the names manually inserted)? (I would assume that any function that generates a character variable from the variable name is not going to produce the desired result.) Rick B. __ 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] Executing a Function in a Loop With a ChangingValue foran Argument
On Thu, 2007-10-25 at 16:26 +1000, [EMAIL PROTECTED] wrote: > I wondered if the real problem was bigger than your abstract version. > OK. Here is one way to do it > > > myfunc <- function(x) { > nam <- deparse(substitute(x)) > val <- mean(x) > cat("mean(", nam, ") =", val, "\n") > invisible(val) > } > > ex <- quote(myfunc(x)) > > subst <- function(Command, ...) do.call("substitute", list(Command, > list(...))) > > dat <- data.frame(matrix(rnorm(25), 5, 5)) > > vars <- names(dat)[-1] > > vars > [1] "X2" "X3" "X4" "X5" > > for(i in vars) with(dat, eval(subst(ex, x = as.symbol(i > mean( X2 ) = -0.08661249 > mean( X3 ) = 0.009840606 > mean( X4 ) = -0.21054 > mean( X5 ) = 0.07321301 > > colMeans(dat[, -1]) > X2 X3 X4 X5 > -0.086612490 0.009840606 -0.210540008 0.073213012 > > > > Now why do I suspect there is something more as wellhmmm...? > > > Bill Venables Thanks. I'm sure I didn't explain it well but I did mention trying to use "as.symbol" and problems with evaluation. I didn't have the words to describe what exactly I was trying to do. Probably best to write a simple version like you did (although the function I'm using isn't complicated, it's just too long to serve as an example). I modified your example so that I can see how it should work with my actual function (I added one extra argument that doesn't need to change): myfunc <- function(y,x) { nam <- deparse(substitute(x)) val <- mean(x) cat("mean(", nam, ") =", val,"y=",y, "\n") invisible(val) } ex <- quote(myfunc(y,x)) subst <- function(Command, ...) do.call("substitute", list(Command,list(...))) dat <- data.frame(matrix(rnorm(25), 5, 5)) vars <- names(dat)[-1] vars for(i in vars) with(dat, eval(subst(ex, x = as.symbol(i),y=2))) > myfunc <- function(y,x) { + nam <- deparse(substitute(x)) + val <- mean(x) + cat("mean(", nam, ") =", val,"y=",y, "\n") + invisible(val) + } > ex <- quote(myfunc(y,x)) > subst <- function(Command, ...) do.call("substitute", list(Command,list(...))) > dat <- data.frame(matrix(rnorm(25), 5, 5)) > vars <- names(dat)[-1] > vars [1] "X2" "X3" "X4" "X5" > for(i in vars) with(dat, eval(subst(ex, x = as.symbol(i),y=2))) mean( X2 ) = -0.6343765 y= 2 mean( X3 ) = 0.4810482 y= 2 mean( X4 ) = 0.5850177 y= 2 mean( X5 ) = -0.006917436 y= 2 Thanks again. Rick B. __ 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] Confidence Intervals for Random Effect BLUP's
I want to compute confidence intervals for the random effect estimates for each subject. From checking on postings, this is what I cobbled together using Orthodont data.frame as an example. There was some discussion of how to properly access lmer slots and bVar, but I'm not sure I understood. Is the approach shown below correct? Rick B. # Orthodont is from nlme (can't have both nlme and lme4 loaded at same time!) # OrthoFem<-Orthodont[Orthodont$Sex=="Female",] # http://tolstoy.newcastle.edu.au/R/help/06/03/23758.html library(lme4) fm1OrthF. <- lmer(distance~age+(age|Subject), data=OrthoFem) lmer(distance~age+(age|Subject), data=OrthoFem)@bVar$Subject[2,2,]* (attr(VarCorr(lmer(distance~age+(age| Subject),data=OrthoFem)),"sc")^2)[1] (attr(VarCorr(fm1OrthF.),"sc")^2)[1] fm1.s <- coef(fm1OrthF.)$Subject fm1.s.var <- [EMAIL PROTECTED](attr(VarCorr(fm1OrthF.),"sc")^2)[1] fm1.s0.s <- sqrt(fm1.s.var[1,1,]) fm1.s0.a <- sqrt(fm1.s.var[2,2,]) fm1.s[,1]+outer(fm1.s0.s, c(-2,0,2)) fm1.s[,2]+outer(fm1.s0.a, c(-2,0,2)) > fm1.s (Intercept) age F1014.48493 0.3758608 F0917.26499 0.3529804 F0616.77328 0.3986699 F0116.95609 0.4041058 F0518.36188 0.3855955 F0717.28390 0.5193954 F0216.05461 0.6336191 F0819.40204 0.3562135 F0316.35720 0.6727714 F0419.02380 0.5258971 F1119.13726 0.6498911 > fm1.s[,1]+outer(fm1.s0.s, c(-2,0,2)) [,1] [,2] [,3] [1,] 12.21371 14.48493 16.75616 [2,] 14.99377 17.26499 19.53622 [3,] 14.50205 16.77328 19.04450 [4,] 14.68487 16.95609 19.22732 [5,] 16.09066 18.36188 20.63311 [6,] 15.01267 17.28390 19.55512 [7,] 13.78339 16.05461 18.32584 [8,] 17.13082 19.40204 21.67327 [9,] 14.08598 16.35720 18.62843 [10,] 16.75257 19.02380 21.29502 [11,] 16.86604 19.13726 21.40849 > fm1.s[,2]+outer(fm1.s0.a, c(-2,0,2)) [,1] [,2] [,3] [1,] 0.1738325 0.3758608 0.5778890 [2,] 0.1509522 0.3529804 0.5550087 [3,] 0.1966417 0.3986699 0.6006982 [4,] 0.2020775 0.4041058 0.6061340 [5,] 0.1835672 0.3855955 0.5876237 [6,] 0.3173671 0.5193954 0.7214236 [7,] 0.4315909 0.6336191 0.8356474 [8,] 0.1541852 0.3562135 0.5582417 [9,] 0.4707432 0.6727714 0.8747997 [10,] 0.3238688 0.5258971 0.7279253 [11,] 0.4478629 0.6498911 0.8519194 __ 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] Confidence Intervals for Random Effect BLUP's
On Fri, 2007-11-09 at 10:01 -0800, Bert Gunter wrote: > Ummm... > > Define: "Confidence interval for BLUP" . > > I know what a confidence interval for a parameter or function of parameters > (which is what a predicted value is) is; but a BLUP is neither, so I don't > get what a confidence interval for it should mean. > > Feel free to reply off list, as this is clearly not an R question. > > > Bert Gunter > Genentech Nonclinical Statistics Would you feel better with "prediction interval"? What I'm asking is how to access the information from lmer to compute intervals for the BLUPS that reflect the uncertainty in these estimates. The code I showed was taken from someone who had the same question and the various replies. Rick B. __ 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] Confidence Intervals for Random Effect BLUP's
On Fri, 2007-11-09 at 18:55 +, Prof Brian Ripley wrote: > I think Bert's point is important: I picked up a student on it in a case > study presentation on this week because I could think of three > interpretations, none strictly confidence intervals. I think 'tolerance > interval' is fairly standard for prediction of a random quantity: see > ?predict.lm. > I think prediction interval is what is usually used. Regardless, I'm not sure how "predict.lm" will be of much help because I asked specifically about BLUP's for random effects and the last time I checked lm did not handle mixed effects models. Neither predict.lme and predict.lmer provide intervals. Here is the code that I included in my original e-mail. My simple question is, will this code correctly compute a prediction interval for each subjects random effect? In particular, will the code handle the bVar slot correctly? Some postings warned about inappropriate access to slots. Here is the code that I asked about in my original e-mail: # OrthoFem has all the females from Orthodont from the nlme package library(lme4) fm1OrthF. <- lmer(distance~age+(age|Subject), data=OrthoFem) lmer(distance~age+(age|Subject), data=OrthoFem)@bVar$Subject[2,2,]* (attr(VarCorr(lmer(distance~age+(age| Subject),data=OrthoFem)),"sc")^2)[1] (attr(VarCorr(fm1OrthF.),"sc")^2)[1] fm1.s <- coef(fm1OrthF.)$Subject fm1.s.var <- [EMAIL PROTECTED](attr(VarCorr(fm1OrthF.),"sc")^2)[1] fm1.s0.s <- sqrt(fm1.s.var[1,1,]) fm1.s0.a <- sqrt(fm1.s.var[2,2,]) fm1.s[,1]+outer(fm1.s0.s, c(-2,0,2)) fm1.s[,2]+outer(fm1.s0.a, c(-2,0,2)) > fm1.s (Intercept) age F1014.48493 0.3758608 F0917.26499 0.3529804 F0616.77328 0.3986699 F0116.95609 0.4041058 F0518.36188 0.3855955 F0717.28390 0.5193954 F0216.05461 0.6336191 F0819.40204 0.3562135 F0316.35720 0.6727714 F0419.02380 0.5258971 F1119.13726 0.6498911 > fm1.s[,1]+outer(fm1.s0.s, c(-2,0,2)) [,1] [,2] [,3] [1,] 12.21371 14.48493 16.75616 [2,] 14.99377 17.26499 19.53622 [3,] 14.50205 16.77328 19.04450 [4,] 14.68487 16.95609 19.22732 [5,] 16.09066 18.36188 20.63311 [6,] 15.01267 17.28390 19.55512 [7,] 13.78339 16.05461 18.32584 [8,] 17.13082 19.40204 21.67327 [9,] 14.08598 16.35720 18.62843 [10,] 16.75257 19.02380 21.29502 [11,] 16.86604 19.13726 21.40849 > fm1.s[,2]+outer(fm1.s0.a, c(-2,0,2)) [,1] [,2] [,3] [1,] 0.1738325 0.3758608 0.5778890 [2,] 0.1509522 0.3529804 0.5550087 [3,] 0.1966417 0.3986699 0.6006982 [4,] 0.2020775 0.4041058 0.6061340 [5,] 0.1835672 0.3855955 0.5876237 [6,] 0.3173671 0.5193954 0.7214236 [7,] 0.4315909 0.6336191 0.8356474 [8,] 0.1541852 0.3562135 0.5582417 [9,] 0.4707432 0.6727714 0.8747997 [10,] 0.3238688 0.5258971 0.7279253 [11,] 0.4478629 0.6498911 0.8519194 This web page describes "bVar": http://hosho.ees.hokudai.ac.jp/~kubo/Rdoc/library/lme4/html/lmer-class.html bVar: A list of the diagonal inner blocks (upper triangles only) of the positive-definite matrices on the diagonal of the inverse of ZtZ+Omega. With the appropriate scale factor (and conversion to a symmetric matrix) these are the conditional variance-covariance matrices of the random effects. Rick B. __ 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 lme (nlme) to find the conditional variance of the random effects
Using lmer in the lme4 package, you can compute the conditional variance-covariance matrix of the random effects using the bVar slot: bVar: A list of the diagonal inner blocks (upper triangles only) of the positive-definite matrices on the diagonal of the inverse of ZtZ+Omega. With the appropriate scale factor (and conversion to a symmetric matrix) these are the conditional variance-covariance matrices of the random effects. Is there anything similar in the nlme package using the lme function? Rick B. __ 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 lme (nlme) to find the conditional variance of therandom effects
On Mon, 2007-11-12 at 16:45 -0500, Doran, Harold wrote: > No, don't reach into the bVar slot. Use the proper extractor function > ranef() with postVar=T. There is no similar function for lme() > > > -Original Message- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On Behalf Of Rick Bilonick > > Sent: Monday, November 12, 2007 4:40 PM > > To: R Help > > Subject: [R] Using lme (nlme) to find the conditional > > variance of therandom effects > > > > Using lmer in the lme4 package, you can compute the > > conditional variance-covariance matrix of the random effects > > using the bVar slot: > > > > bVar: A list of the diagonal inner blocks (upper triangles > > only) of the positive-definite matrices on the diagonal of > > the inverse of ZtZ+Omega. > > With the appropriate scale factor (and conversion to a > > symmetric matrix) these are the conditional > > variance-covariance matrices of the random effects. > > > > Is there anything similar in the nlme package using the lme function? > > > > Rick B. > > > > __ Is there some way to get ranef with postVar=TRUE to show what the variances are, or what the lower and upper bounds are? qqmath makes nice plots but I need to obtain the numerical values. Rick B. __ 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 lme (nlme) to find the conditional variance of therandom effects
On Tue, 2007-11-13 at 01:03 -0500, Rick Bilonick wrote: > > Is there some way to get ranef with postVar=TRUE to show what the > variances are, or what the lower and upper bounds are? qqmath makes nice > plots but I need to obtain the numerical values. > > Rick B. > I found a way: attr(ranef(lmer.13,postVar=TRUE)[[2]],"postVar") But I still don't understand why it's not OK to access the bVar slot directly. Also, the code I originally showed and the results from ranef are very similar with a correlation of 0.9983 (it varies very slightly from subject to subject): > round(data.frame(a=as.numeric([EMAIL PROTECTED](attr(VarCorr(lmer.13),"sc")^2)[1]), b=as.numeric(attr(ranef(lmer.13,postVar=TRUE)[[2]],"postVar"))),10) ab 1 5.41e-08 5.44e-08 2 4.77e-08 4.83e-08 3 6.24e-08 6.25e-08 4 4.44e-08 4.52e-08 5 6.50e-08 6.50e-08 6 2.67e-08 2.92e-08 7 5.07e-08 5.12e-08 8 6.43e-08 6.43e-08 9 3.64e-08 3.79e-08 10 4.86e-08 4.92e-08 11 6.33e-08 6.33e-08 12 3.44e-08 3.60e-08 13 4.16e-08 4.26e-08 14 3.69e-08 3.83e-08 15 5.96e-08 5.97e-08 16 6.46e-08 6.46e-08 17 3.28e-08 3.46e-08 18 4.71e-08 4.77e-08 19 5.18e-08 5.22e-08 20 2.81e-08 3.04e-08 21 3.97e-08 4.09e-08 22 5.70e-08 5.72e-08 23 6.06e-08 6.07e-08 24 3.23e-08 3.42e-08 25 4.94e-08 4.99e-08 26 5.35e-08 5.38e-08 27 3.86e-08 3.98e-08 28 6.73e-08 6.73e-08 29 4.68e-08 4.74e-08 30 6.15e-08 6.16e-08 31 4.67e-08 4.74e-08 32 2.04e-08 2.37e-08 33 3.45e-08 3.61e-08 34 6.28e-08 6.29e-08 35 5.53e-08 5.55e-08 Not sure why they are not exactly the same. Rick B. __ 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 remove index from list after split?
In the following example, how can I drop the group index from the list after I perform a split? n <- 3 nn <- 10 g <- factor(round(n * runif(n * nn))) x <- rnorm(n * nn) + sqrt(as.numeric(g)) df<- data.frame(g,x) df.s <- split(df,g) Thanks! Rick DeShon [[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] Rserve - Request assistance with installation, confirmation thereof and starting (R 3.5.1 on 64-bit Win7 Pro)
Hello, I am attempting to install two R packages with specific version numbers. These are Rserve_1.8-0.zip and MASS_7.3-45.zip. As the file extension suggests, I am installing packages from local zipfiles in the GUI Packages menu. R Console displays positive feedback when MASS is loaded in this manner: *> utils:::menuInstallLocal()* package ‘MASS’ successfully unpacked and MD5 sums checked The R Console does not display any message when I attempt to install Rserve in the same manner. What does this indicate about Rserve being installed successfully? I was only provided instructions to install these two packages. No mention is made af loading them and this is feasible as Rserve can run without R being open. Further, I recently located two discussion threads indicating Rserve requires a configuration file and this is created by the user. These threads refer the reader to three files: 1) Rserve.exe, 2) Rserve.dll, and 3) Rserve_d.exe and instructs these should be placed into the same directory where R.dll is located (This is the bin directory on my installation: R.home("bin")). Next, it instructs readers to create the file "Rserv.cfg" and provide the desired arguments such port number. Here is my result of sessionInfo() *> sessionInfo()* R version 3.5.1 (2018-07-02) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1 Matrix products: default locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_3.5.1 tools_3.5.1 Please let me know if you need anything else regarding my installation of R. Since I have been unable to accomplish this task, I have not saved a workspace. Thank you. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.