Re: [R] BLAS with glmnet
On Apr 12, 2013, at 22:49 , Brian Pasley wrote: I'm using a multithreaded BLAS library with R and I see the expected speed improvements with matrix multiplication, svd, etc. However, glmnet continues to use only a single CPU. Since this package is compiled from Fortran, is this the expected behavior or is there a way to compile the glmnet package so that it uses the multithreaded BLAS library? You'd need to check with the author for full details, or study the code yourself. Or the JSS paper. As a general matter, a package won't benefit from a fast BLAS if it doesn't use it. Presumably, glmnet does not, or does not do so in timing-critical areas. I wouldn't expect Fortran per se to have anything to do with it, although I can't rule out that the code might be rewritten to take advantage of the BLAS. -pd -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.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] script works in Rgui, but failes in Rscript (coords, package 'pROC')
Dearh all, I have following question: a script (using pROC functions) that works when run in Rgui, failes when run through rscript. This is the script: library(pROC) hits - c(T, D, T, D, T, D, T, D, T, D, T, D, T, D, T, D, T, D) score - c(1.804984e-05, 1.908517e-02, 2.934481e-02, 8.188098e-02, 1.528048e-03, 4.617807e-01, 1.420925e-03, 2.360183e-01, 1.874567e-02, 5.127498e-01, 9.438651e-03, 2.162788e-01, 9.142649e-04, 1.173577e-01, 7.270350e-03, 4.699286e-01, 4.553215e-03, 3.942892e-01) roc_test - data.frame (hits, score) roc1 - roc(roc_test$hit, roc_test$score, plot = FALSE, smooth = FALSE, sensitivities = TRUE ) roc.result - coords(roc1, best, ret=c(t, se, sp), as.list = TRUE, best.method=c(closest.topleft)) print(roc.result$best$threshold) # script ends here. However, executing in the command line (C:\Progra~1\R\R-2.15.3\bin\Rscript.exe ROC_test.R) gives following errors: Error in ifelse(is(roc, smooth.roc), length(attr(roc, roc)$cases), : could not find function is Calls: coords ... coords.roc - lapply - FUN - coords.roc - ifelse Execution halted Any ideas? Thanks in advance, Christoph -- View this message in context: http://r.789695.n4.nabble.com/script-works-in-Rgui-but-failes-in-Rscript-coords-package-pROC-tp4664173.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] Aggregate function Bagging
Good morning all. I am doing bagging with package caret. I need bagging for a classification problem. I am working with bag. bag(x, y, B = 10, vars = NULL, bagControl = bagControl(), ...) bagControl(fit = NULL, predict = NULL, aggregate = NULL, downSample = FALSE) My fit function is: svmFit - function(x, y, ...) { library(e1071) svm(Score~., data = mydataset) } My predict function is : svmPred - function(object, x) { predict(object, x)[,1] } However, I don't know how to build the aggregate function. Does anyone know how to develop it? [[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] Aggregate function Bagging
Hello, If you run the example in ?bag you can type data(BloodBrain) ctreeBag$aggregate at an R prompt to see an example aggregate function. Note that it dos _not_ have the parenthesis. Hope this helps, Rui Barradas Em 14-04-2013 11:31, Nicolás Sánchez escreveu: Good morning all. I am doing bagging with package caret. I need bagging for a classification problem. I am working with bag. bag(x, y, B = 10, vars = NULL, bagControl = bagControl(), ...) bagControl(fit = NULL, predict = NULL, aggregate = NULL, downSample = FALSE) My fit function is: svmFit - function(x, y, ...) { library(e1071) svm(Score~., data = mydataset) } My predict function is : svmPred - function(object, x) { predict(object, x)[,1] } However, I don't know how to build the aggregate function. Does anyone know how to develop it? [[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@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] script works in Rgui, but failes in Rscript (coords, package 'pROC')
On Apr 14, 2013, at 11:37 , christoph_s wrote: ... However, executing in the command line (C:\Progra~1\R\R-2.15.3\bin\Rscript.exe ROC_test.R) gives following errors: Error in ifelse(is(roc, smooth.roc), length(attr(roc, roc)$cases), : could not find function is Calls: coords ... coords.roc - lapply - FUN - coords.roc - ifelse Execution halted Any ideas? Thanks in advance, is() is in methods, so try require(methods). -pd -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.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] script works in Rgui, but failes in Rscript (coords, package 'pROC')
Yes, that was what was missing. Great! Thanks a lot! Best regards, Christoph -- View this message in context: http://r.789695.n4.nabble.com/script-works-in-Rgui-but-failes-in-Rscript-coords-package-pROC-tp4664173p4664182.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] Reshaping Data for bi-partite Network Analysis [SOLVED]
HI Sylvain, To get the same order as in Output Input$place- factor(Input$place,levels=c(school,home,sport,beach)) Input$people- factor(Input$people,levels=c(Marc,Joe,Mary)) xtabs(time~.,Input) # place #people school home sport beach # Marc 2 4 0 0 #Joe 0 3 1 5 #Mary 4 0 0 0 A.K. From: sylvain willart sylvain.will...@gmail.com To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Saturday, April 13, 2013 5:41 PM Subject: Re: [R] Reshaping Data for bi-partite Network Analysis [SOLVED] Wow ! so many thanks Arun and Rui works like a charm problem solved 2013/4/13 arun smartpink...@yahoo.com Hi, Try this; library(reshape2) res-dcast(Input,people~place,value.var=time) res[is.na(res)]-0 res # people beach home school sport #1 Joe 5 3 0 1 #2 Marc 0 4 2 0 #3 Mary 0 0 4 0 #or xtabs(time~.,Input) # place #people beach home school sport # Joe 5 3 0 1 # Marc 0 4 2 0 # Mary 0 0 4 0 A.K. From: sylvain willart sylvain.will...@gmail.com To: r-help r-help@r-project.org; sylvain willart sylvain.will...@gmail.com Sent: Saturday, April 13, 2013 5:03 PM Subject: [R] Reshaping Data for bi-partite Network Analysis Hello I have a dataset of people spending time in places. But most people don't hang out in all the places. it looks like: Input-data.frame(people=c(Marc,Marc,Joe,Joe,Joe,Mary), + place=c(school,home,home,sport,beach,school), + time=c(2,4,3,1,5,4)) Input people place time 1 Marc school 2 2 Marc home 4 3 Joe home 3 4 Joe sport 1 5 Joe beach 5 6 Mary school 4 In order to import it within R's igraph, I must use graph.incidence(), but the data needs to be formatted that way: Output-data.frame(school=c(2,0,4),home=c(4,3,0),sport=c(0,1,0),beach=c(0,5,0), + row.names=c(Marc,Joe,Mary)) Output school home sport beach Marc 2 4 0 0 Joe 0 3 1 5 Mary 4 0 0 0 The Dataset is fairly large (couple hundreds of people and places), and I would very much appreciate if someone could point me to a routine or function that could transform my Input dataset to the required Output, Thank you very much in advance Regards Sylvain PS: sorry for cross-posting this on statnet and then on R help list, but I received a message from statnet pointing out the question was more related to general data management than actual network analysis. Which is true indeed... [[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@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] ZA unit root test lag order selection
I was wondering if anyone could help with choosing optimal lag length for ZA test. There have been two lag order selection methods commonly used in the literature: 1) The ZA paper recommends to run the test with maximum number of lags. Then the lag order is reduced sequentially until the longest lag is statistically significant; 2) One could also use AIC or SBC or other criteria to choose lag order. I am using annual series with 22 observations. Which of the above lag order selection procedures would be correct to apply? -- View this message in context: http://r.789695.n4.nabble.com/ZA-unit-root-test-lag-order-selection-tp4664183.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] Problem plotting continuous and discrete series in ggplot with facet
I have data that plots over time with four different variables. I would like to combine them in one plot using facet_grid, where each variable gets its own sub-plot. The following code resembles my data require(ggplot2) require(reshape2) subm - melt(economics, id='date', c('psavert','uempmed','unemploy')) mcsm - melt(data.frame(date=economics$date, q=quarters(economics$date)), id='date') mcsm$value - factor(mcsm$value) ggplot(subm, aes(date, value, col=variable, group=1)) + geom_line() + facet_grid(variable~., scale='free_y') + geom_step(data=mcsm, aes(date, value)) + scale_y_discrete(breaks=levels(mcsm$value)) If I leave out scale_y_discrete, R complains that I'm trying to combine discrete value with continuous scale. If I include scale_y_discreate my continuous series miss their scale. Is there any neat way of solving this issue ? I also see that the legend is alphabetically sorted, can I change that so the legend is ordered like the sub-plots ? --- Regards, Sigurgeir [[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] Postscript files graphic quality and other problems
Hi all, I try to save graphic as eps file, but I have probles with quality. My graphics as pdf file is ok. The quality is very good. But when I save as eps the quality is very poor. I try convert pdf to eps file using others programs like adobe acrobat and the quality of eps is like pdf (file is larger than). I try lot of recommendation found in google and others lists. I used: postscript(test.eps,onefile=FALSE,horizontal=FALSE,width=14,height=7) plot(1:10, 1:10) dev.off() How can I improve the quality of graphic? I have other problem too. When I save my graphic with code above, I can import to other programs like Word without problem. But, when I change symbols with pch parameter, the importation have problems. postscript(test.eps,onefile=FALSE,horizontal=FALSE,width=14,height=7) plot(1:10, 1:10, pch=3) dev.off() The graphic imported is not showed. Best regards, Mario __ 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] Create New Column Inside Data Frame for Many Data Frames
Dear R Helpers, I have a large number of data frames and I need to create a new column inside each data frame. Because there is a large number, I need to loop through this, but I don't know the syntax of assigning a new column name dynamically. Below is a simple example of what I need to do. Assume that I have to do this for all 26 letters and you should see the form of the problem. Any help would be much appreciated. If more information is needed, please let me know. Many thanks. --John Sparks library(quantmod) A - data.frame(population=c(100, 300, 5000, 2000, 900, 2500)) A$Rate-ROC(A[population]) B - data.frame(population=c(200, 300, 4000, 3000, 2000, 500)) B$Rate-ROC(B[population]) letters-c(A,B) length(letters) #for (i in letters){ # HELP! #} __ 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] Create New Column Inside Data Frame for Many Data Frames
Hello, I'm not completely sure I've understood. Your variable 'letters' iholds the names of the data.frames? If so it's better if you put yoyr data.frames in a list and then use that list. Something like lst - list(A, B) for (i in seq_along(lst)){ lst[[i]][[Rate]] - ROC(lst[[i]][[population]]) } Hope this helps, Rui Barradas Em 14-04-2013 18:19, Sparks, John James escreveu: Dear R Helpers, I have a large number of data frames and I need to create a new column inside each data frame. Because there is a large number, I need to loop through this, but I don't know the syntax of assigning a new column name dynamically. Below is a simple example of what I need to do. Assume that I have to do this for all 26 letters and you should see the form of the problem. Any help would be much appreciated. If more information is needed, please let me know. Many thanks. --John Sparks library(quantmod) A - data.frame(population=c(100, 300, 5000, 2000, 900, 2500)) A$Rate-ROC(A[population]) B - data.frame(population=c(200, 300, 4000, 3000, 2000, 500)) B$Rate-ROC(B[population]) letters-c(A,B) length(letters) #for (i in letters){ # HELP! #} __ 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.
Re: [R] Create New Column Inside Data Frame for Many Data Frames
I suggest you read the section on indexing in the Introduction to R document that comes with R. In particular, look at the [[i]] notation. This comes in handy in a couple of ways. First, you shouldn't be working with many data frames at once that are stored as separately-named objects. If you plan to do similar things to them, then you should store them in a list: myframes - list() myframes[[A]] - data.frame(population=c(100, 300, 5000, 2000, 900, 2500)) Secondly, you can programmatically access the columns in a data frame if needed: i - A dest - Rate myframes[[i]][[dest]]-ROC(myframes[[i]][[population]]) Study up on indexing in R... much of the power of this language lies there. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Sparks, John James jspa...@uic.edu wrote: Dear R Helpers, I have a large number of data frames and I need to create a new column inside each data frame. Because there is a large number, I need to loop through this, but I don't know the syntax of assigning a new column name dynamically. Below is a simple example of what I need to do. Assume that I have to do this for all 26 letters and you should see the form of the problem. Any help would be much appreciated. If more information is needed, please let me know. Many thanks. --John Sparks library(quantmod) A - data.frame(population=c(100, 300, 5000, 2000, 900, 2500)) A$Rate-ROC(A[population]) B - data.frame(population=c(200, 300, 4000, 3000, 2000, 500)) B$Rate-ROC(B[population]) letters-c(A,B) length(letters) #for (i in letters){ # HELP! #} __ 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.
Re: [R] Postscript files graphic quality and other problems
On 13-04-14 1:11 PM, Mario José wrote: Hi all, I try to save graphic as eps file, but I have probles with quality. My graphics as pdf file is ok. The quality is very good. But when I save as eps the quality is very poor. How are you determining this? The quality looks similar to me. I try convert pdf to eps file using others programs like adobe acrobat and the quality of eps is like pdf (file is larger than). I try lot of recommendation found in google and others lists. I used: postscript(test.eps,onefile=FALSE,horizontal=FALSE,width=14,height=7) plot(1:10, 1:10) dev.off() How can I improve the quality of graphic? I have other problem too. When I save my graphic with code above, I can import to other programs like Word without problem. But, when I change symbols with pch parameter, the importation have problems. This sounds like a problem with Word. Are you judging the quality by how it shows up in Word? That would also be a problem with Word's importing, I think. Duncan Murdoch postscript(test.eps,onefile=FALSE,horizontal=FALSE,width=14,height=7) plot(1:10, 1:10, pch=3) dev.off() The graphic imported is not showed. Best regards, Mario __ 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] Logistic regression
I have a data set to be analyzed using to binary logistic regression. The data set is iin grouped form. My question is: how I can compute Hosmer-Lemeshow test and measures like sensitivity and specificity? Any suggestion will be greatly appreciated. Thank you Endy [[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 handling of attributes in xmlToList in XML package
Hello all, I have a problem with the way attributes are dealt with in the function xmlToList(), and I haven't been able to figure it out for days now. Say I have a document (produced by nmap) like this: mydoc - 'host starttime=1365204834 endtime=1365205860status state=up reason=echo-reply reason_ttl=127/ address addr=XXX.XXX.XXX.XXX addrtype=ipv4/ portsport protocol=tcp portid=135state state=open reason=syn-ack reason_ttl=127/service name=msrpc product=Microsoft Windows RPC ostype=Windows method=probed conf=10cpecpe:/o:microsoft:windows/cpe/service/port port protocol=tcp portid=139state state=open reason=syn-ack reason_ttl=127/service name=netbios-ssn method=probed conf=10//port /ports times srtt=647 rttvar=71 to=10/ /host' I want to store this as a list of lists, so I do: mytree-xmlTreeParse(mydoc) myroot-xmlRoot(mytree) mylist-xmlToList(myroot) Now my problem is that when I want to fetch the attributes of the services running of each port, the behavior is not consistent: mylist[[ports]][[1]][[service]]$.attrs[name] name msrpc mylist[[ports]][[2]][[service]]$.attrs[name] Error in trash_list[[ports]][[2]][[service]]$.attrs : $ operator is invalid for atomic vectors I understand that the way they are dfined in the documnt is not the same, but I think there still should be a consistent behavior. I've tried many combination of parameters for xmlTreeParse() but nothing has helped me. I can't find a way to call up the name of the service consistently regardless of whether the node has children or not. Any tips? All the best, S.G. -- --- http://barabasilab.neu.edu/people/gil/ __ 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] Postscript files graphic quality and other problems
On Apr 14, 2013, at 11:00 AM, Duncan Murdoch wrote: On 13-04-14 1:11 PM, Mario José wrote: Hi all, I try to save graphic as eps file, but I have probles with quality. My graphics as pdf file is ok. The quality is very good. But when I save as eps the quality is very poor. How are you determining this? The quality looks similar to me. I am wondering if this is being viewed with a Mac mail client (or possibly some other device) that extracts a low-resolution bitmap from a pdf file? When I insert this test file it registers as being only 4.2Kb. In the file system browser it is a 106Kb file (I know that it will not appear to most of the audience but it should remain attached for the OP and Duncan.) -- David. I try convert pdf to eps file using others programs like adobe acrobat and the quality of eps is like pdf (file is larger than). I try lot of recommendation found in google and others lists. I used: postscript(test.eps,onefile=FALSE,horizontal=FALSE,width=14,height=7) plot(1:10, 1:10) dev.off() How can I improve the quality of graphic? I have other problem too. When I save my graphic with code above, I can import to other programs like Word without problem. But, when I change symbols with pch parameter, the importation have problems. This sounds like a problem with Word. Are you judging the quality by how it shows up in Word? That would also be a problem with Word's importing, I think. Duncan Murdoch postscript(test.eps,onefile=FALSE,horizontal=FALSE,width=14,height=7) plot(1:10, 1:10, pch=3) dev.off() The graphic imported is not showed. Best regards, Mario __ 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. David Winsemius Alameda, CA, USA __ 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] Create New Column Inside Data Frame for Many Data Frames
Hi, lapply(LETTERS[1:2],function(x) {x1-get(x); x1$Rate- ROC(x1$population);x1}) #[[1]] # population Rate #1 100 NA #2 300 1.0986123 #3 5000 2.8134107 #4 2000 -0.9162907 #5 900 -0.7985077 #6 2500 1.0216512 #[[2]] # population Rate #1 200 NA #2 300 0.4054651 #3 4000 2.5902672 #4 3000 -0.2876821 #5 2000 -0.4054651 #6 500 -1.3862944 #If it is for 26 letters lapply(LETTERS,function(x) {x1-get(x); x1$Rate- ROC(x1$population);x1}) A.K. - Original Message - From: Sparks, John James jspa...@uic.edu To: r-help@r-project.org Cc: Sent: Sunday, April 14, 2013 1:19 PM Subject: [R] Create New Column Inside Data Frame for Many Data Frames Dear R Helpers, I have a large number of data frames and I need to create a new column inside each data frame. Because there is a large number, I need to loop through this, but I don't know the syntax of assigning a new column name dynamically. Below is a simple example of what I need to do. Assume that I have to do this for all 26 letters and you should see the form of the problem. Any help would be much appreciated. If more information is needed, please let me know. Many thanks. --John Sparks library(quantmod) A - data.frame(population=c(100, 300, 5000, 2000, 900, 2500)) A$Rate-ROC(A[population]) B - data.frame(population=c(200, 300, 4000, 3000, 2000, 500)) B$Rate-ROC(B[population]) letters-c(A,B) length(letters) #for (i in letters){ # HELP! #} __ 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.
Re: [R] Logistic regression
Endy, See the package ResourceSelection for the HL test and the package caret for the sensitivity and specificity measures. Regards, Jose Iparraguirre Chief Economist Age UK, London From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of Endy BlackEndy [pert...@gmail.com] Sent: 14 April 2013 19:05 To: R-Help Subject: [R] Logistic regression I have a data set to be analyzed using to binary logistic regression. The data set is iin grouped form. My question is: how I can compute Hosmer-Lemeshow test and measures like sensitivity and specificity? Any suggestion will be greatly appreciated. Thank you Endy [[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. Please donate to the Syria Crisis Appeal by text or online: To donate £5 by mobile, text SYRIA to 70800. To donate online, please visit http://www.ageinternational.org.uk/syria Over one million refugees are desperately in need of water, food, healthcare, warm clothing, blankets and shelter; Age International urgently needs your support to help affected older refugees. Age International is a subsidiary charity of Age UK and a member of the Disasters Emergency Committee (DEC). The DEC launches and co-ordinates national fundraising appeals for public donations on behalf of its member agencies. Texts cost £5 plus one standard rate message. Age International will receive a minimum of £4.96. More info at ageinternational.org.uk/SyriaTerms --- Age UK is a registered charity and company limited by guarantee, (registered charity number 1128267, registered company number 6825798). Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA. For the purposes of promoting Age UK Insurance, Age UK is an Appointed Representative of Age UK Enterprises Limited, Age UK is an Introducer Appointed Representative of JLT Benefit Solutions Limited and Simplyhealth Access for the purposes of introducing potential annuity and health cash plans customers respectively. Age UK Enterprises Limited, JLT Benefit Solutions Limited and Simplyhealth Access are all authorised and regulated by the Financial Services Authority. -- This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you receive a message in error, please advise the sender and delete immediately. Except where this email is sent in the usual course of our business, any opinions expressed in this email are those of the author and do not necessarily reflect the opinions of Age UK or its subsidiaries and associated companies. Age UK monitors all e-mail transmissions passing through its network and may block or modify mails which are deemed to be unsuitable. Age Concern England (charity number 261794) and Help the Aged (charity number 272786) and their trading and other associated companies merged on 1st April 2009. Together they have formed the Age UK Group, dedicated to improving the lives of people in later life. The three national Age Concerns in Scotland, Northern Ireland and Wales have also merged with Help the Aged in these nations to form three registered charities: Age Scotland, Age NI, Age Cymru. __ 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] Postscript files graphic quality and other problems
Hi all, excuse me my question. I read that eps have bmp incorporated and this bmp maybe have different resolution. But eps file not have resolution. I try import in Word and OpenOffice but this editors don't import my file. I create a pdf file with eps file on pdfcreator and this is ok. I try on LyX too and is ok. The problem is in Word/OpenOffice. Thank you and excuse me again. Best regards, Mario On 14/04/2013 15:00, Duncan Murdoch wrote: On 13-04-14 1:11 PM, Mario José wrote: Hi all, I try to save graphic as eps file, but I have probles with quality. My graphics as pdf file is ok. The quality is very good. But when I save as eps the quality is very poor. How are you determining this? The quality looks similar to me. I try convert pdf to eps file using others programs like adobe acrobat and the quality of eps is like pdf (file is larger than). I try lot of recommendation found in google and others lists. I used: postscript(test.eps,onefile=FALSE,horizontal=FALSE,width=14,height=7) plot(1:10, 1:10) dev.off() How can I improve the quality of graphic? I have other problem too. When I save my graphic with code above, I can import to other programs like Word without problem. But, when I change symbols with pch parameter, the importation have problems. This sounds like a problem with Word. Are you judging the quality by how it shows up in Word? That would also be a problem with Word's importing, I think. Duncan Murdoch postscript(test.eps,onefile=FALSE,horizontal=FALSE,width=14,height=7) plot(1:10, 1:10, pch=3) dev.off() The graphic imported is not showed. Best regards, Mario __ 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.
Re: [R] possible loop problem
Hi, It would be better if you provided the output of dput(dataset). I am not sure about the structure of your dataset. Just from reading the data as is shown. dat1- read.table(text= separator,tissID ,,2 ,2,1 ,6,5 ,11,13 ,,4 ,4,9 ,6,2 ,7,3 ,21,1 ,23,58 ,25,9 ,26,4 ,,11 ,1,12 ,,21 ,4,1 ,11,3 ,sep=,,header=TRUE,stringsAsFactors=FALSE,row.names=NULL) indx-which(grepl(,dat1[,1])) indx1-diff(c(indx,nrow(dat1)+1)) res1-do.call(rbind,lapply(seq_along(indx),function(i) {x1-dat1[indx[i]:(indx[i]+(indx1[i]-1)),];x1[-1,1]- x1[1,3];x1})) res2- as.matrix(res1[,-1]) row.names(res2)- res1[,1] res2 # separator tissID # 2 #2 2 1 #2 6 5 #2 11 13 # 4 #4 4 9 #4 6 2 #4 7 3 #4 21 1 #4 23 58 #4 25 9 #4 26 4 # 11 #11 1 12 # 21 #21 4 1 #21 11 3 A.K. Hello, I hope this is not too stupid a question, as I'm still new to R (had a couple of days of tutorials this week, so still very wet behind the ears). A sample of my problem is here: separator tissID 2 2 1 6 5 11 13 4 4 9 6 2 7 3 21 1 23 58 25 9 26 4 11 1 12 21 4 1 11 3 I have a table of data I can load into R no problem. What I'm trying to do is for all those empty cells in the first column, replace them with the value that is next to the second chevron for the corresponding range (everything up until the next chevron). So it would look like: sep tissID 2 2 2 1 2 6 5 2 11 13 4 4 4 9 4 6 2 4 7 3 4 21 1 4 23 58 4 25 9 4 26 4 11 11 1 12 21 21 4 1 21 11 3 (actually, I have to do something else with that value by appending a piece of text in front, but you get the idea). So far, my idea was to try: for (i in 1:(length(targrow)-1)) { label - test2[targrow[i],3] start - targrow[i]+1 end - targrow[i+1]-1 test2[start:end,1] - label } where test2 is the read, delimited matrix (verified the columns and such are properly formatted), and targrow was a vector I generated, searching the main table to identify the rows that have those chevrons. This returns an error though and it seems whatever I type to try to change that label (text, number, whatever) returns the error message: 1: In `[-.factor`(`*tmp*`, iseq, value = c(137L, 137L, 137L, 137L, : invalid factor level, NA generated repeated multiple times for however many entries I'm using in my test case. If I try manually outside of a loop (ie just test2[start:end,1] - 'test' for example) it works. I presume I have overlooked something in terms of variable properties or something, that it doesn't work in the loop. This has to be done for a table with about half a million entries, hence my interest in finding a way to automate the process. Any suggestions (specific to this code, or if there's another way - I know, I have the feeling that what I've come up with already isn't exactly elegant, but I was trying to debug) would be most welcome. __ 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 plotting continuous and discrete series in ggplot with facet
I'm avare that I'm trying to plot factors and numeric in the same try. What I needed confirmed, before waisting more time seeking the answer, was if this was possible. Now I have confirmed that this is in deed not possible. I have received a really good answer on stackexchange, which I like to share with the list: http://stackoverflow.com/questions/15999304/plotting-continuous-and-discrete-series-in-ggplot-with-facet Regard, Sigurgeir 2013/4/14 Dennis Murphy djmu...@gmail.com Look at head(mcsm): head(mcsm) date variable value 1 1967-06-30qQ2 2 1967-07-31qQ3 3 1967-08-31qQ3 4 1967-09-30qQ3 5 1967-10-31qQ4 6 1967-11-30qQ4 I suspect what you're trying to do and it won't work the way you're doing it. I'd suggest plotting the quarterly data separately and use the gridExtra package and its grid.arrange() function to put the two plots on the same graphics page. It will affect the legend, but that's life. Dennis On Sun, Apr 14, 2013 at 4:36 AM, Sigurgeir Gunnarsson sgunn...@gmail.com wrote: I have data that plots over time with four different variables. I would like to combine them in one plot using facet_grid, where each variable gets its own sub-plot. The following code resembles my data require(ggplot2) require(reshape2) subm - melt(economics, id='date', c('psavert','uempmed','unemploy')) mcsm - melt(data.frame(date=economics$date, q=quarters(economics$date)), id='date') mcsm$value - factor(mcsm$value) ggplot(subm, aes(date, value, col=variable, group=1)) + geom_line() + facet_grid(variable~., scale='free_y') + geom_step(data=mcsm, aes(date, value)) + scale_y_discrete(breaks=levels(mcsm$value)) If I leave out scale_y_discrete, R complains that I'm trying to combine discrete value with continuous scale. If I include scale_y_discreate my continuous series miss their scale. Is there any neat way of solving this issue ? I also see that the legend is alphabetically sorted, can I change that so the legend is ordered like the sub-plots ? --- Regards, Sigurgeir [[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. -- Kv. Sigurgeir [[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] Alternative to Generalized Path Seeking Regression Friedman
Dear All, I would greatly appreciate if someone could suggest an alternative similar package to GPS of Professor Friedman Thank you! Christos Giannoulis, PhD [[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] Cross validation for Naive Bayes and Bayes Networks
Hi, I need to classify, using Naive Bayes and Bayes Networks, and estimate their performance using cross validation. How can I do this? I tried the bnlearn package for Bayes Networks, althought I need to get more indexes, not only the error rate (precision, sensitivity, ...). I also tried the *e1071* package, but I could not find a way to do cross-validation. Thanks for everyone. Guilherme. [[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] Fwd: Cross validation for Naive Bayes and Bayes Networks
Hi, I need to classify, using Naive Bayes and Bayes Networks, and estimate their performance using cross validation. How can I do this? I tried the bnlearn package for Bayes Networks, althought I need to get more indexes, not only the error rate (precision, sensitivity, ...). I also tried the *e1071* package, but I could not find a way to do cross-validation. Thanks for everyone. Guilherme. [[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] Kruskal-Wallis
Hi, I have got two groups of samples; and for every row, I wish to calculate Kruskal-Wallis' p-value. In the example below, and the stars () show where I am struggling to design and put things together. Any help would be appreciated. myFile - data.frame(Sample_1a = 1:10, Sample_1b = 2:11, Sample_1c = 3:12, Sample_2a=4:13, Sample_2b=7:16, row.names=LETTERS[1:10]) groups - rep (0:1, c(3,2)) kruskal - apply(myFile [1:nrow(myFile),], 1, kruskal.test, **) p_kruskal - sapply(kruskal, function(x) x$p.value) Thanks, Chintanu [[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.