Re: [R] [DKIM] Batch Installer for R [SEC=UNCLASSIFIED]
Hi Tobias, Here is something I acquired from this mailing list some years ago. It works well for me: #---run in previous version (e.g. R 3.1.0) packages <- installed.packages()[,"Package"] save(packages, file="Rpackages_R3.1.0") #---run in new version load("Rpackages_R3.1.0") for (p in setdiff(packages, installed.packages()[,"Package"])) install.packages(p) Hope this helps. Jin -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Tobias Knuth Sent: Friday, 1 April 2016 12:05 AM To: r-help@r-project.org Subject: [DKIM] [R] Batch Installer for R Hi everyone, in Python, you can run pip install -r filename to install all packages listed in the file. Is there something similar to R? If not, isn't it quite easy to write? For me, it would be much easier to work on projects with other people if I could just install all dependencies with one line in a generalised manner. Did anybody try something like that before me? Best, Tobias [[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. Geoscience Australia Disclaimer: This e-mail (and files transmitted with it) is intended only for the person or entity to which it is addressed. If you are not the intended recipient, then you have received this e-mail by mistake and any use, dissemination, forwarding, printing or copying of this e-mail and its file attachments is prohibited. The security of emails transmitted cannot be guaranteed; by forwarding or replying to this email, you acknowledge and accept these risks. __ 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] Filtering based on the occurrence
Hi Jim, Thank you tons for your help. The code worked perfectly :) Best,Farnoosh On Wednesday, March 30, 2016 1:13 AM, Jim Lemonwrote: Hi Farnoosh, Despite my deep suspicion that this answer will solve a useless problem, try this: last_subject<-0 keep_deps<-c("B","D","F") keep_rows<-NULL for(rowindex in 1:dim(df)[1]) { if(df[rowindex,"Subject"] != last_subject) { last_subject<-df[rowindex,"Subject"] start_keeping<-0 } if(df[rowindex,"deps"] %in% keep_deps) start_keeping<-1 if(start_keeping) keep_rows<-c(keep_rows,rowindex) } final<-matrix(unlist(lapply(df[keep_rows,],as.character)),ncol=3) I find it terribly hard to ignore puzzles. Jim On Wed, Mar 30, 2016 at 10:52 AM, Farnoosh Sheikhi via R-help wrote: > Hello, > I have a data set similar to below and I wanted to keep the observations > after the first occurrence of these department: "B", "D", "F".For example for > ID=2, the observation with deps=B and anything after will be kept in the > data. For ID=3, observations with deps=D and anything after will be included. > Subject<- c("2", "2", "2", "3", "3", "3", "4", "4", "5", "5", "5", > "5")dates<-seq(as.Date('2011-01-01'),as.Date('2011-01-12'),by = 1) > deps<-c("A", "B", "C", "C", "D", "A", "F", "G", "A", "F", "A", "D")df <- > data.frame(Subject, dates, deps)df > The final data should look like this:final<-c("2 2011-01-02 B","2 > 2011-01-03 C","3 2011-01-05 D","3 2011-01-06 A","4 2011-01-07 > F","4 2011-01-08 G","5 2011-01-10 F","5 2011-01-11 A","5 2011-01-12 > D") Thank you tons for your help. > Farnoosh > > > [[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. [[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] Compute the Gini coefficient
Hello, Thank you very much for your help. How can I draw a Lorenz curve with several replications ? Here is an example with 4 replications: hosts=c(23,31,19,10,7,7,3, 39,40,8,3,6,2,2, 47,17,8,10,6,11,1, 30,30,10,0,15,15,0) parasites=rep(seq(from=0,to=6,by=1),4) replications=c(rep(1,7),rep(2,7),rep(3,7),rep(4,7)) test <- cbind(parasites,hosts,replications) Should I calculate the average frequency of hosts (replication mean values) and next calculate the cumulative percentage of hosts from the average frequency ? Thank you very much for your time. Have a nice day. Marine De : Achim ZeileisEnvoyé : mercredi 30 mars 2016 12:05 À : Erich Neuwirth Cc : Marine Regis; r-help@r-project.org Objet : Re: [R] Compute the Gini coefficient On Wed, 30 Mar 2016, Erich Neuwirth wrote: > >> On 30 Mar 2016, at 02:53, Marine Regis wrote: >> >> Hello, >> >> I would like to build a Lorenz curve and calculate a Gini coefficient in >> order to find how much parasites does the top 20% most infected hosts >> support. >> >> Here is my data set: >> >> Number of parasites per host: >> parasites = c(0,1,2,3,4,5,6,7,8,9,10) >> >> Number of hosts associated with each number of parasites given above: >> hosts = c(18,20,28,19,16,10,3,1,0,0,0) >> >> To represent the Lorenz curve: >> I manually calculated the cumulative percentage of parasites and hosts: >> >> cumul_parasites <- cumsum(parasites)/max(cumsum(parasites)) >> cumul_hosts <- cumsum(hosts)/max(cumsum(hosts)) >> plot(cumul_hosts, cumul_parasites, type= "l?) > > > Your values in hosts are frequencies. So you need to calculate > > cumul_hosts = cumsum(hosts)/sum(hosts) > cumul_parasites = cumsum(hosts*parasites)/sum(parasites) That's what I thought as well but Marine explicitly said that the 'host' are _not_ weights. Hence I was confused what this would actually mean. Using the "ineq" package you can also do plot(Lc(parasites, hosts)) > The Lorenz curves starts at (0,0), so to draw it, you need to extend these > vectors > > cumul_hosts = c(0,cumul_hosts) > cumul_parasites = c(0,cumul_parasites) > > plot(cumul_hosts,cum9l_parasites,type=?l?) > > > The Gini coefficient can be calculated as > library(reldist) > gini(parasites,hosts) > > > If you want to check, you can ?recreate? the original data (number of > parasited for each host) with > > num_parasites = rep(parasites,hosts) > > and > gini(num_parasites) > > will also give you the Gini coefficient you want. > > > >> > >>> From this Lorenz curve, how can I calculate the Gini coefficient with the >>> function "gini" in R (package reldist) given that the vector "hosts" is not >>> a vector of weights ? >> >> Thank you very much for your help. >> Have a nice day >> Marine >> >> >> [[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. > > __ 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] Ask if an object will respond to a function or method
> On Mar 31, 2016, at 1:00 PM, Paul Johnsonwrote: > > In the rockchalk package, I want to provide functions for regression > objects that are "well behaved." If an object responds to the methods > that lm or glm objects can handle, like coef(), nobs(), and summary(), > I want to be able to handle the same thing. > > It is more difficult than expected to ask a given fitted model object > "do you respond to these functions: coef(), nobs(), summary()." How > would you do it? > > I tried this with the methods() function but learned that all methods > that a class can perform are not listed. I'll demonstrate with a > regression "zz" that is created by the example in the plm package. > The coef() function succeeds on the zz object, but coef is not listed > in the list of methods that the function can carry out. > >> library(plm) >> example(plm) > >> class(zz) > [1] "plm""panelmodel" >> methods(class = "plm") > [1] ercomp fixef has.intercept model.matrix > [5] pFtest plmtest plotpmodel.response > [9] pooltestpredict residuals summary > [13] vcovBK vcovDC vcovG vcovHC > [17] vcovNW vcovSCC > see '?methods' for accessing help and source code >> methods(class = "panelmodel") > [1] deviance df.residual fittedhas.intercept index > [6] nobs pbgtest pbsytest pcdtest pdim > [11] pdwtest phtestprint pwartest pwfdtest > [16] pwtestresiduals terms updatevcov > see '?methods' for accessing help and source code >> coef(zz) > log(pcap) log(pc) log(emp)unemp > -0.026149654 0.292006925 0.768159473 -0.005297741 > > I don't understand why coef(zz) succeeds but coef is not listed as a method. There is a coef.default method. (Also an S$ coef,ANY-method ) > > Right now, I'm contemplating this: > > zz1 < - try(coef(zz)) > if (inherits(zz1, "try-error")) stop("Your model has no coef method") > > This seems like a bad workaround because I have to actually run the > function in order to find out if the function exists. That might be > time consuming for some summary() methods. > > pj > > -- > Paul E. Johnson > Professor, Political ScienceDirector > 1541 Lilac Lane, Room 504 Center for Research Methods > University of Kansas University of Kansas > http://pj.freefaculty.org http://crmda.ku.edu > > __ > 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. David Winsemius Alameda, CA, USA __ 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] reduced set of alternatives in package mlogit
code? example data? We can only guess based on your vague post. "PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code." Moreover, this sounds like a statistical question, not a question about R programming, and so might be more appropriate for a statistical list like stats.stackexchange.com . Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Thu, Mar 31, 2016 at 2:51 PM, Jose Marcos Ferrarowrote: > I'm trying to estimate a multinomial logit model but in some choices only > alternatives from a subset of all possible alternatives can be chosen. > At the moment I get around it by creating "dummy" variables to mean the > alternative is not available and let it estimate this coefficient as highly > negative. Is there a better way to do it? > > [[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. __ 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-es] R igraph
Estimados Copio un mensaje de error que da igraph, es más fácil verlo que explicarlo. > fastgreedy.community(udatos) Error in .Call("R_igraph_community_fastgreedy", graph, as.logical(merges), : At fast_community.c:553 : fast-greedy community finding works only on graphs without multiple edges, Invalid value > cluster_louvain(udatos) IGRAPH clustering multi level, groups: 7, mod: 0.26 + groups: $`1` [1] "Ficha 1127" "Ficha 1309" "Ficha 1530" "Ficha 603" "mes 2" Los datos están de esta forma: (udatos son los mismos pero - udatos <-as.undirected(datos.network)) > head(get.data.frame(dIgraph.network)) fromto Descripcion A Descripcion B Relacion 1 Ficha 1022mes 10 Ficha Mes Ficha Mes 2 Ficha 1024mes 8 Ficha Mes Ficha Mes 3 Ficha 1028mes 2 Ficha Mes Ficha Mes … Esperando que sea entendible mi correo, ¿Dónde tendré el problema? ¿En la preparación de los datos? Desde ya, gracias. Javier Rubén Marcuzzi [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
[R] reduced set of alternatives in package mlogit
I'm trying to estimate a multinomial logit model but in some choices only alternatives from a subset of all possible alternatives can be chosen. At the moment I get around it by creating "dummy" variables to mean the alternative is not available and let it estimate this coefficient as highly negative. Is there a better way to do it? [[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.
[R] Installing specific version of R
Hi, When I am trying to install specific version of R , using apt-get -y --force-yes install r-base=3.2.1-4precise0 r-recommended=3.2.1-4precise0 r-base-dev=3.2.1-4precise0, I do see correct version being set up in in the logs , but the installed version shows me 3.2.4. Is there anything else to be done to install specific version? $version.string [1] "R version 3.2.4 Revised (2016-03-16 r70336)" Setting up r-recommended (3.2.1-4precise0) ... Setting up r-base (3.2.1-4precise0) ... Setting up liblzma-dev (5.1.1alpha+20110809-3) ... Setting up r-doc-html (3.2.4-revised-1precise0) ... Setting up x11-xserver-utils (7.6+3) ... Setting up xbitmaps (1.1.1-1) ... Setting up xterm (271-1ubuntu2.1) ... update-alternatives: using /usr/bin/xterm to provide /usr/bin/x-terminal-emulator (x-terminal-emulator) in auto mode. update-alternatives: using /usr/bin/uxterm to provide /usr/bin/x-terminal-emulator (x-terminal-emulator) in auto mode. update-alternatives: using /usr/bin/lxterm to provide /usr/bin/x-terminal-emulator (x-terminal-emulator) in auto mode. Setting up r-base-html (3.2.4-revised-1precise0) ... Setting up libstdc++6-4.6-dev (4.6.3-1ubuntu5) ... Setting up g++-4.6 (4.6.3-1ubuntu5) ... Setting up g++ (4:4.6.3-1ubuntu5) ... update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode. Setting up build-essential (11.5ubuntu2.1) ... Setting up libwww-perl (6.03-1) ... Setting up libxml-parser-perl (2.41-1build1) ... Setting up intltool (0.50.2-2) ... Setting up dh-translations (116) ... Setting up cdbs (0.4.100ubuntu2) ... Setting up r-base-dev (3.2.1-4precise0) ... Setting up liblwp-protocol-https-perl (6.02-1) ... Thanks! Sandhya [[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] Ask if an object will respond to a function or method
On 03/31/2016 04:00 PM, Paul Johnson wrote: In the rockchalk package, I want to provide functions for regression objects that are "well behaved." If an object responds to the methods that lm or glm objects can handle, like coef(), nobs(), and summary(), I want to be able to handle the same thing. It is more difficult than expected to ask a given fitted model object "do you respond to these functions: coef(), nobs(), summary()." How would you do it? I tried this with the methods() function but learned that all methods that a class can perform are not listed. I'll demonstrate with a regression "zz" that is created by the example in the plm package. The coef() function succeeds on the zz object, but coef is not listed in the list of methods that the function can carry out. library(plm) example(plm) class(zz) [1] "plm""panelmodel" methods(class = "plm") [1] ercomp fixef has.intercept model.matrix [5] pFtest plmtest plotpmodel.response [9] pooltestpredict residuals summary [13] vcovBK vcovDC vcovG vcovHC [17] vcovNW vcovSCC see '?methods' for accessing help and source code methods(class = "panelmodel") [1] deviance df.residual fittedhas.intercept index [6] nobs pbgtest pbsytest pcdtest pdim [11] pdwtest phtestprint pwartest pwfdtest [16] pwtestresiduals terms updatevcov see '?methods' for accessing help and source code coef(zz) log(pcap) log(pc) log(emp)unemp -0.026149654 0.292006925 0.768159473 -0.005297741 I don't understand why coef(zz) succeeds but coef is not listed as a method. coef(zz) finds stats:::coef.default, which happens to do the right thing for zz but also 'works' (returns without an error) for things that don't have coefficients, e.g., coef(data.frame()). stats:::coef.default is > stats:::coef.default function (object, ...) object$coefficients Maybe fail on use, rather than trying to guess up-front that the object is fully appropriate? Martin Morgan Right now, I'm contemplating this: zz1 < - try(coef(zz)) if (inherits(zz1, "try-error")) stop("Your model has no coef method") This seems like a bad workaround because I have to actually run the function in order to find out if the function exists. That might be time consuming for some summary() methods. pj This email message may contain legally privileged and/or confidential information. If you are not the intended recipient(s), or the employee or agent responsible for the delivery of this message to the intended recipient(s), you are hereby notified that any disclosure, copying, distribution, or use of this email message is prohibited. If you have received this message in error, please notify the sender immediately by e-mail and delete this email message from your computer. Thank you. __ 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] converting a class dataframe (chars) to transaction class
A more specific reproducible example. set.seed(1023) library(arules) # starting from a dataframe whose fields are characters (see stringsAsFactors = FALSE), as asked products <- c("P1", "P2", "P3", "P4", "P5", "P6", "P7", "P8", "P9", "P10") mydf <- data.frame(user = sample(LETTERS[1:20], 100, replace=T), prod = sample(products, 100, replace=T), stringsAsFactors=FALSE) str(mydf) # convert to factors mydf$user <- factor(mydf$user) mydf$prod <- factor(mydf$prod) # splitting by user prodlist <- split(x=mydf[,"prod"], f=mydf$user) prodlist # remove duplicates prodlist <- lapply(prodlist, unique) prod.trans <- as(prodlist, "transactions") itemFrequency(prod.trans) # generating rules rules <- apriori(prod.trans,parameter=list(support=.1, confidence=.5)) inspect(rules) -- Best, GG [[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.
[R] Ask if an object will respond to a function or method
In the rockchalk package, I want to provide functions for regression objects that are "well behaved." If an object responds to the methods that lm or glm objects can handle, like coef(), nobs(), and summary(), I want to be able to handle the same thing. It is more difficult than expected to ask a given fitted model object "do you respond to these functions: coef(), nobs(), summary()." How would you do it? I tried this with the methods() function but learned that all methods that a class can perform are not listed. I'll demonstrate with a regression "zz" that is created by the example in the plm package. The coef() function succeeds on the zz object, but coef is not listed in the list of methods that the function can carry out. > library(plm) > example(plm) > class(zz) [1] "plm""panelmodel" > methods(class = "plm") [1] ercomp fixef has.intercept model.matrix [5] pFtest plmtest plotpmodel.response [9] pooltestpredict residuals summary [13] vcovBK vcovDC vcovG vcovHC [17] vcovNW vcovSCC see '?methods' for accessing help and source code > methods(class = "panelmodel") [1] deviance df.residual fittedhas.intercept index [6] nobs pbgtest pbsytest pcdtest pdim [11] pdwtest phtestprint pwartest pwfdtest [16] pwtestresiduals terms updatevcov see '?methods' for accessing help and source code > coef(zz) log(pcap) log(pc) log(emp)unemp -0.026149654 0.292006925 0.768159473 -0.005297741 I don't understand why coef(zz) succeeds but coef is not listed as a method. Right now, I'm contemplating this: zz1 < - try(coef(zz)) if (inherits(zz1, "try-error")) stop("Your model has no coef method") This seems like a bad workaround because I have to actually run the function in order to find out if the function exists. That might be time consuming for some summary() methods. pj -- Paul E. Johnson Professor, Political ScienceDirector 1541 Lilac Lane, Room 504 Center for Research Methods University of Kansas University of Kansas http://pj.freefaculty.org http://crmda.ku.edu __ 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] Batch Installer for R
Does the package packrat do what you want? -- Better name for the general practitioner might be multispecialist. ~Martin H. Fischer (1879-1962) -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Tobias Knuth Sent: Thursday, March 31, 2016 9:05 AM To: r-help@r-project.org Subject: [R] Batch Installer for R Hi everyone, in Python, you can run pip install -r filename to install all packages listed in the file. Is there something similar to R? If not, isn't it quite easy to write? For me, it would be much easier to work on projects with other people if I could just install all dependencies with one line in a generalised manner. Did anybody try something like that before me? Best, Tobias [[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. __ 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] Batch Installer for R
Hi everyone, in Python, you can run pip install -r filename to install all packages listed in the file. Is there something similar to R? If not, isn't it quite easy to write? For me, it would be much easier to work on projects with other people if I could just install all dependencies with one line in a generalised manner. Did anybody try something like that before me? Best, Tobias [[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-es] usar R a traves de la web
Genial que se pueda usar un enlace de dropbox, muchas gracias, saludos, eric. On 03/31/2016 06:32 AM, Jesús Para Fernández wrote: Si tus datos no son muy confidenciales, puedes subirlos a dropbox o similar y usar el enlace que dicha plataforma te proporciona. Un saludo Jesús From: j.para.fernan...@hotmail.com To: ericconchamu...@gmail.com; r-help-es@r-project.org Date: Thu, 31 Mar 2016 11:30:45 +0200 Subject: Re: [R-es] usar R a traves de la web Lo unicio que funciona es subir los datos a la web y luego usar el codigo: datos<-read.table("http://mate.dm.uba.ar/~meszre/datos_regresion/ejemploint.txt",header=T) Subject: Re: [R-es] usar R a traves de la web To: j.para.fernan...@hotmail.com; r-help-es@r-project.org From: ericconchamu...@gmail.com Date: Sun, 6 Mar 2016 12:28:51 -0300 Hola Jesus, muchas gracias, esta opcion se ve bastante bien, aunque no encuentro un modo de subir mis archivos de datos, pero debe poderse, no ? Muchas gracias, Eric. On 03/05/2016 09:03 AM, Jes�s Para Fern�ndez wrote: > Buscas algo asi? > >http://www.r-fiddle.org/#/ > > > > > From: ericconchamu...@gmail.com > > To: r-help-es@r-project.org > > Date: Sat, 5 Mar 2016 09:01:42 -0300 > > Subject: [R-es] usar R a traves de la web > > > > Estimada comunidad, para mi trabajo uso latex y R normalmente, ahora > > debo viajar sin mi portatil, pero tengo la opcion de llevar un peque�o > > tablet (con android) ... para suplir latex he estado usando > > www.overleaf.com y trabaja excelente, practicamente todos los paquetes > > que uso estan disponibles ahi ... pero no he encontrado algo similar > para R. > > > > Saben ustedes si existe algun proyecto que permita usar R en la web ? ya > > he mirado muchas opciones > > > (https://nsaunders.wordpress.com/2009/11/30/a-brief-survey-of-r-web-interfaces/) > > > como las de Rstudio (tengo android, no puedo instalar R en el tablet), > > tampoco tengo la opcion de instalar un RApache por ejemplo, pero ninguna > > me sirve ... necesito una pagina en que simplemente entre, pegue el > > codigo y me devuelva las salidas sin tener que instalar nada localmente. > > > > Muchas gracias, > > > > Eric. > > > > > > > > -- > > Forest Engineer > > Master in Environmental and Natural Resource Economics > > Ph.D. student in Sciences of Natural Resources at La Frontera University > > Member in AguaDeTemu2030, citizen movement for Temuco with green city > > standards for living > > > > Nota: Las tildes se han omitido para asegurar compatibilidad con algunos > > lectores de correo. > > > > ___ > > R-help-es mailing list > > R-help-es@r-project.org > >https://stat.ethz.ch/mailman/listinfo/r-help-es -- Forest Engineer Master in Environmental and Natural Resource Economics Ph.D. student in Sciences of Natural Resources at La Frontera University Member in AguaDeTemu2030, citizen movement for Temuco with green city standards for living Nota: Las tildes se han omitido para asegurar compatibilidad con algunos lectores de correo. [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es -- Forest Engineer Master in Environmental and Natural Resource Economics Ph.D. student in Sciences of Natural Resources at La Frontera University Member in AguaDeTemu2030, citizen movement for Temuco with green city standards for living Nota: Las tildes se han omitido para asegurar compatibilidad con algunos lectores de correo. ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
Re: [R] Convergence issues when using ns splines (pkg: spline) in Cox model (coxph) even when changing coxph.control
Thanks to David for pointing this out. The "time dependent covariates" vignette in the survival package has a section on time dependent coefficients that talks directly about this issue. In short, the following model is simply wrong: coxph(Surv(time, status) ~ trt + prior + karno + I(karno * log(time)), data=veteran) People try this often as a way to create the time dependent covariate Karnofsky * log(t), which is often put forwards as a way to deal with non-proportional hazards. To do this correctly you have to use the tt() functionality in coxph to move the computation out of the model statement: coxph(Surv(time, status) ~ trt + prior + karno + tt(karno), data=veteran, tt = function(x, time, ...) x*log(time)) BTW the following SAS code is also wrong: proc phreg data=veteran; model time * status(0) = trt + prior + karno* time; SAS does the right thing, however, if you move the computation off the model line. model time * status(0) = trt + karno + zzz; zzz = karno * time; The quote "SAS does it but R fails" comes at me moderately often in this context. The reason is that SAS won't LET you put a phrase like "log(time)" into the model statement, so people end up doing the right thing, but by accident. Terry T. On 03/30/2016 05:28 PM, Göran Broström wrote: On 2016-03-30 23:06, David Winsemius wrote: On Mar 29, 2016, at 1:47 PM, Jennifer Wu, Misswrote: Hi, I am currently using R v3.2.3 and on Windows 10 OS 64Bit. I am having convergence issues when I use coxph with a interaction term (glarg*bca_py) and interaction term with the restricted cubic spline (glarg*bca_time_ns). I use survival and spline package to create the Cox model and cubic splines respectively. Without the interaction term and/or spline, I have no convergence problem. I read some forums about changing the iterations and I have but it did not work. I was just wondering if I am using the inter.max and outer.max appropriately. I read the survival manual, other R-help and stackoverflow pages and it suggested changing the iterations but it doesn't specify what is the max I can go. I ran something similar in SAS and did not run into a convergence problem. This is my code: bca_time_ns <- ns(ins_ca$bca_py, knots=3, Boundary.knots=range(2,5,10)) test <- ins_ca$glarg*ins_ca$bca_py test1 <- ins_ca$glarg*bca_time_ns In your `coxph` call the variable 'bca_py' is the survival time and Right David: I didn't notice that the 'missing main effect' in fact was part of the survival object! And as you say: Time to rethink the whole model. Göran yet here you are constructing not just one but two interactions (one of which is a vector but the other one a matrix) between 'glarg' and your survival times. Is this some sort of effort to identify a violation of proportionality over the course of a study? Broström sagely points out that these interactions are not in the data-object and subsequent efforts to refer to them may be confounded by the multiple environments from which data would be coming into the model. Better to have everything come in from the data-object. The fact that SAS did not have a problem with this rather self-referential or circular model may be a poor reflection on SAS rather than on the survival package. Unlike Therneau or Broström who asked for data, I suggest the problem lies with the model construction and you should be reading what Therneau has written about identification of non-proportionality and identification of time dependence of effects. See Chapter 6 of his "Modeling Survival Data". __ 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] ts or xts with high-frequency data within a year
TYPO on TYPO! It should be X[,3] Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Thu, Mar 31, 2016 at 9:47 AM, Bert Gunterwrote: > Inline. > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along > and sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > On Wed, Mar 30, 2016 at 5:37 PM, Ryan Utz wrote: >> Bill, Josh, and Bert, >> >> Thanks for your responses. I still can't quite get this when I use actual >> dates. Here's an example of what is going wrong: >> >> X=as.data.frame(1:6000) >> X[2]=seq.POSIXt(ISOdate(2015,11,1),by='hour',length.out=6000) >> X[3]=sample(100,size=6000,replace=T) >> >> Y=xts(X[,3],order.by=X[,2]) >> decompose(Y) >> >> Z=ts(X[,2],frequency=24*365) >> plot(decompose(Z)) > > ## TYPO! It should be X[,2]. > > ***WARNING*** > I am not a time series expert. The remarks below are therefore subject > to confirmation or correction by those who are. Caveat emptor! > > Also, you seem to be somewhat confused about how the seasonal > decomposition in decompose() works. > > My understanding from what you said is that your unit of time is days > and that you have samples every 15 minutes, but that you wish to > estimate hourly effects. If this is correct, you first need to first > combine (e.g. via by() ) your 4 observations into a single summary > (e.g. average or median, maybe) so that you have an hourly time > series. Run this through ts() with frequency = 24: your period is > daily = 24 hours and you have 24 observations/period. > > (Note that you could use the original data to get 96 15 minute > estimates instead of hourly estimates). > > When you run this through decompose(), it will give you 24 "seasonal" > effects/period, the hourly effects. The "trend" component will try to > remove longer term effects and trends over time. > > Note, however, this is probably **not** what you want. I suspect you > want both hourly effects and daily or monthly effects to reflect > annual seasonalities as well as daily. decompose() cannot do this, > apparently, so you should look for an alternative solution. Better > yet, consult with a local time series expert to help you figure out > what you might want and how to get it in R. > > Cheers, > Bert > > >> >> When I specify an actual date/time (rather than just a number as Bill >> posited), it does not like anything short of a year. This seems like I'm >> overlooking something obvious, but I can't get this for the life of me... >> >> Thanks for your time, >> r >> >> >> On Wed, Mar 30, 2016 at 1:03 PM, William Dunlap wrote: >>> >>> You said you specified frequency=96 when you constructed the time >>> series, but when I do that the decomposition looks reasonable: >>> >>> > time <- seq(0,9,by=1/96) # 15-minute intervals, assuming time unit is >>> > day >>> > measurement <- sqrt(time) + 1/(1.2+sin(time*2*pi)) + >>> > rnorm(length(time),0,.3) >>> > plot(decompose(ts(measurement, frequency=96))) >>> >>> How is your code different from the above? >>> >>> >>> >>> Bill Dunlap >>> TIBCO Software >>> wdunlap tibco.com >>> >>> On Wed, Mar 30, 2016 at 8:03 AM, Ryan Utz wrote: Hello, I have a time series that represents data sampled every 15-minutes. The data currently run from November through February, 8623 total readings. There are definitely daily periodic trends and non-stationary long-term trends. I would love to decompose this using basic time series analysis. However, every time I attempt decomposition, I get the Error in decompose( ) : time series has no or less than 2 periods Is it only possible to do basic time-series analysis if you have a year or more worth of data? That seems absurd to me, since there is definite periodicity and the data are a time series. I have tried every manner of specifying frequency= with no luck (96 does not work). All manner of searching for help has turned up fruitless. Can I only do this after I wait another year or two? Thanks, Ryan -- Ryan Utz, Ph.D. Assistant professor of water resources *chatham**UNIVERSITY* Home/Cell: (724) 272-7769 [[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. >>> >>> >> >> >> >> -- >> >> Ryan Utz, Ph.D. >> Assistant professor of water resources >> chathamUNIVERSITY >> Home/Cell: (724) 272-7769 >>
Re: [R] ts or xts with high-frequency data within a year
Inline. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Wed, Mar 30, 2016 at 5:37 PM, Ryan Utzwrote: > Bill, Josh, and Bert, > > Thanks for your responses. I still can't quite get this when I use actual > dates. Here's an example of what is going wrong: > > X=as.data.frame(1:6000) > X[2]=seq.POSIXt(ISOdate(2015,11,1),by='hour',length.out=6000) > X[3]=sample(100,size=6000,replace=T) > > Y=xts(X[,3],order.by=X[,2]) > decompose(Y) > > Z=ts(X[,2],frequency=24*365) > plot(decompose(Z)) ## TYPO! It should be X[,2]. ***WARNING*** I am not a time series expert. The remarks below are therefore subject to confirmation or correction by those who are. Caveat emptor! Also, you seem to be somewhat confused about how the seasonal decomposition in decompose() works. My understanding from what you said is that your unit of time is days and that you have samples every 15 minutes, but that you wish to estimate hourly effects. If this is correct, you first need to first combine (e.g. via by() ) your 4 observations into a single summary (e.g. average or median, maybe) so that you have an hourly time series. Run this through ts() with frequency = 24: your period is daily = 24 hours and you have 24 observations/period. (Note that you could use the original data to get 96 15 minute estimates instead of hourly estimates). When you run this through decompose(), it will give you 24 "seasonal" effects/period, the hourly effects. The "trend" component will try to remove longer term effects and trends over time. Note, however, this is probably **not** what you want. I suspect you want both hourly effects and daily or monthly effects to reflect annual seasonalities as well as daily. decompose() cannot do this, apparently, so you should look for an alternative solution. Better yet, consult with a local time series expert to help you figure out what you might want and how to get it in R. Cheers, Bert > > When I specify an actual date/time (rather than just a number as Bill > posited), it does not like anything short of a year. This seems like I'm > overlooking something obvious, but I can't get this for the life of me... > > Thanks for your time, > r > > > On Wed, Mar 30, 2016 at 1:03 PM, William Dunlap wrote: >> >> You said you specified frequency=96 when you constructed the time >> series, but when I do that the decomposition looks reasonable: >> >> > time <- seq(0,9,by=1/96) # 15-minute intervals, assuming time unit is >> > day >> > measurement <- sqrt(time) + 1/(1.2+sin(time*2*pi)) + >> > rnorm(length(time),0,.3) >> > plot(decompose(ts(measurement, frequency=96))) >> >> How is your code different from the above? >> >> >> >> Bill Dunlap >> TIBCO Software >> wdunlap tibco.com >> >> On Wed, Mar 30, 2016 at 8:03 AM, Ryan Utz wrote: >>> >>> Hello, >>> >>> I have a time series that represents data sampled every 15-minutes. The >>> data currently run from November through February, 8623 total readings. >>> There are definitely daily periodic trends and non-stationary long-term >>> trends. I would love to decompose this using basic time series analysis. >>> >>> However, every time I attempt decomposition, I get the >>> >>> Error in decompose( ) : time series has no or less than 2 periods >>> >>> Is it only possible to do basic time-series analysis if you have a year >>> or >>> more worth of data? That seems absurd to me, since there is definite >>> periodicity and the data are a time series. I have tried every manner of >>> specifying frequency= with no luck (96 does not work). All manner of >>> searching for help has turned up fruitless. >>> >>> Can I only do this after I wait another year or two? >>> >>> Thanks, >>> Ryan >>> >>> -- >>> >>> Ryan Utz, Ph.D. >>> Assistant professor of water resources >>> *chatham**UNIVERSITY* >>> Home/Cell: (724) 272-7769 >>> >>> [[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. >> >> > > > > -- > > Ryan Utz, Ph.D. > Assistant professor of water resources > chathamUNIVERSITY > Home/Cell: (724) 272-7769 > __ 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-es] Bootstrap de días seguidos
Hola, Yo lo que he entendido es que quieres generar los 20 días siguientes a una fecha dada. Una forma de hacerlo es así: > as.Date("2000-01-01") + 0:10 [1] "2000-01-01" "2000-01-02" "2000-01-03" "2000-01-04" "2000-01-05" "2000-01-06" [7] "2000-01-07" "2000-01-08" "2000-01-09" "2000-01-10" "2000-01-11" Más detalles aquí: http://stackoverflow.com/questions/7536306/creating-a-unique-sequence-of-dates Saludos, Carlos Ortega www.qualityexcellence.es El 31 de marzo de 2016, 10:46, Jesús Para Fernández < j.para.fernan...@hotmail.com> escribió: > Buenas a todos, > > Lo primero agradecer todas las respuesta sque tuve en el tema de Bootstrap > dataframe, que por estar de baja no he podido agradecer. > > De aquel tema salió una sugerencia que me parece muy interesante y que a > dia de hoy no soy capaz de hacer de una manera optima. > > Lo que quiero hacer es coger un dia al azar de todo el periodo, y a > partuir de ese dia, coger por ejemplo los 20 dias siguientes. > > Recuerdo que para cogerlos al azar hacia lo siguiente: > > set.seed(121) > final<-0 > nuevo<-0 > for(i in 1:10){ > nuevo<-sample(datos$pedidos,replace=T) > final[i]<-sum(nuevo[1:20]) > } > > donde aqui estoy cogiendo los 20 dias al azar. > > ¿Como haria para coger estos 20 dias seguidos?? > > Gracias > Jesús > > > > > [[alternative HTML version deleted]] > > > ___ > R-help-es mailing list > R-help-es@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-help-es > -- Saludos, Carlos Ortega www.qualityexcellence.es [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
Re: [R-es] Bootstrap de días seguidos
Buenas, para concatenar (rbind) los resultados de ‘muestras’ a un data.frame podrías hacer lo siguiente: df.muestras <- data.frame(do.call(rbind, muestras)) Un saludo, Luisfo > El 31 mar 2016, a las 18:00, Jesús Para Fernández >escribió: > > Es justo lo que buscaba. Muchas gracias. > > Una unica cosa, como puedo pasar a un data.frame el resultado muestras, del > lapply??? > > > > > >> To: r-help-es@r-project.org >> From: canadasre...@gmail.com >> Date: Thu, 31 Mar 2016 15:18:55 +0200 >> Subject: Re: [R-es] Bootstrap de días seguidos >> >> Hola. >> >> No sé si buscas algo parecido a esto >> >> datos <- data.frame(v1 = rnorm(1000, 2, 5), v2 = rnorm(1000) ) >> >> # numero de puntos aleatorios >> n.puntos <- 20 >> puntos <- replicate(n.puntos, sample(nrow(datos), 1, replace = T) ) >> >> puntos >> [1] 348 52 520 675 574 303 264 678 749 29 310 691 460 114 892 903 >> 335 984 207 964 >> >> # muestras de 21 filas >> k <- 20 >> muestras <- lapply(puntos, function(x) datos[x:(x+k),]) >> >> # muestras es una lista con k data.frames, el primero serán los datos de >> la fila 348 hasta la368 >> muestras[[1]] >> v1 v2 >> 348 -1.8855298 1.67022010 >> 349 8.3539108 -0.75856401 >> 350 3.1723330 -0.15722935 >> 351 2.5871373 1.30962887 >> 352 4.0801806 -0.22205638 >> 353 8.7792425 1.92769400 >> 354 1.8023941 0.60780632 >> 355 -4.4542464 -0.30940621 >> 356 1.4032584 -1.22315174 >> 357 -1.1669957 -0.36789523 >> 358 0.8834993 -0.51625882 >> 359 -4.4173234 0.35013974 >> 360 -6.2964411 0.64394556 >> 361 0.4808418 1.41868648 >> 362 0.6912628 -0.29357748 >> 363 -4.1933794 0.90492395 >> 364 -9.3685116 0.08371681 >> 365 1.3305264 -0.18474498 >> 366 2.9247997 1.24475278 >> 367 8.8120307 0.48149808 >> 368 8.0995250 1.30719019 >> >> El 31/03/16 a las 10:46, Jesús Para Fernández escribió: >>> Buenas a todos, >>> >>> Lo primero agradecer todas las respuesta sque tuve en el tema de Bootstrap >>> dataframe, que por estar de baja no he podido agradecer. >>> >>> De aquel tema sali� una sugerencia que me parece muy interesante y que a >>> dia de hoy no soy capaz de hacer de una manera optima. >>> >>> Lo que quiero hacer es coger un dia al azar de todo el periodo, y a partuir >>> de ese dia, coger por ejemplo los 20 dias siguientes. >>> >>> Recuerdo que para cogerlos al azar hacia lo siguiente: >>> >>> set.seed(121) >>> final<-0 >>> nuevo<-0 >>> for(i in 1:10){ >>> nuevo<-sample(datos$pedidos,replace=T) >>> final[i]<-sum(nuevo[1:20]) >>> } >>> >>> donde aqui estoy cogiendo los 20 dias al azar. >>> >>> �Como haria para coger estos 20 dias seguidos?? >>> >>> Gracias >>> Jes�s >>> >>> >>> >>> >>> [[alternative HTML version deleted]] >>> >>> >>> >>> ___ >>> R-help-es mailing list >>> R-help-es@r-project.org >>> https://stat.ethz.ch/mailman/listinfo/r-help-es >> >> >> [[alternative HTML version deleted]] >> >> ___ >> R-help-es mailing list >> R-help-es@r-project.org >> https://stat.ethz.ch/mailman/listinfo/r-help-es > > [[alternative HTML version deleted]] > > ___ > R-help-es mailing list > R-help-es@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-help-es ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
Re: [R-es] Bootstrap de días seguidos
Hola. No sé si buscas algo parecido a esto datos <- data.frame(v1 = rnorm(1000, 2, 5), v2 = rnorm(1000) ) # numero de puntos aleatorios n.puntos <- 20 puntos <- replicate(n.puntos, sample(nrow(datos), 1, replace = T) ) puntos [1] 348 52 520 675 574 303 264 678 749 29 310 691 460 114 892 903 335 984 207 964 # muestras de 21 filas k <- 20 muestras <- lapply(puntos, function(x) datos[x:(x+k),]) # muestras es una lista con k data.frames, el primero serán los datos de la fila 348 hasta la368 muestras[[1]] v1 v2 348 -1.8855298 1.67022010 349 8.3539108 -0.75856401 350 3.1723330 -0.15722935 351 2.5871373 1.30962887 352 4.0801806 -0.22205638 353 8.7792425 1.92769400 354 1.8023941 0.60780632 355 -4.4542464 -0.30940621 356 1.4032584 -1.22315174 357 -1.1669957 -0.36789523 358 0.8834993 -0.51625882 359 -4.4173234 0.35013974 360 -6.2964411 0.64394556 361 0.4808418 1.41868648 362 0.6912628 -0.29357748 363 -4.1933794 0.90492395 364 -9.3685116 0.08371681 365 1.3305264 -0.18474498 366 2.9247997 1.24475278 367 8.8120307 0.48149808 368 8.0995250 1.30719019 El 31/03/16 a las 10:46, Jesús Para Fernández escribió: > Buenas a todos, > > Lo primero agradecer todas las respuesta sque tuve en el tema de Bootstrap > dataframe, que por estar de baja no he podido agradecer. > > De aquel tema sali� una sugerencia que me parece muy interesante y que a dia > de hoy no soy capaz de hacer de una manera optima. > > Lo que quiero hacer es coger un dia al azar de todo el periodo, y a partuir > de ese dia, coger por ejemplo los 20 dias siguientes. > > Recuerdo que para cogerlos al azar hacia lo siguiente: > > set.seed(121) > final<-0 > nuevo<-0 > for(i in 1:10){ > nuevo<-sample(datos$pedidos,replace=T) > final[i]<-sum(nuevo[1:20]) > } > > donde aqui estoy cogiendo los 20 dias al azar. > > �Como haria para coger estos 20 dias seguidos?? > > Gracias > Jes�s > > > > > [[alternative HTML version deleted]] > > > > ___ > R-help-es mailing list > R-help-es@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-help-es [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
Re: [R] ts or xts with high-frequency data within a year
Ryan, >From "decompose()" source code, two conditions can trigger the error message: "time series has no or less than 2 periods" based on the frequency value, specifically: 1. f <= 1 2. length(na.omit(x)) < 2 * f It appears to me that your reproducible code has got a typo error, it should be: Z=ts(X[,3],frequency=24*365) I mean X[,3] in place of X[,2]. Further, frequency=24*365, 2*frequency > 6000 = length(X[,3]), and that triggers the second condition. >From R console: > decompose function (x, type = c("additive", "multiplicative"), filter = NULL) { type <- match.arg(type) l <- length(x) f <- frequency(x) if (f <= 1 || length(na.omit(x)) < 2 * f) stop("time series has no or less than 2 periods") -- Best, GG [[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.
[R] function to carry out Bootstrap LRT with poLCA results
Dear List, I would like to determine the optimal number of latent classes (polytomous data) using Bootstrap LRT. poLCA does not provide such a possibility and I am not enough into programming to modify the code. Is there any other way to do this, e.g. use a poLCA object with some other package? Thank you for help. Best wishes Alain __ 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-es] Bootstrap de días seguidos
Buenas a todos, Lo primero agradecer todas las respuesta sque tuve en el tema de Bootstrap dataframe, que por estar de baja no he podido agradecer. De aquel tema sali� una sugerencia que me parece muy interesante y que a dia de hoy no soy capaz de hacer de una manera optima. Lo que quiero hacer es coger un dia al azar de todo el periodo, y a partuir de ese dia, coger por ejemplo los 20 dias siguientes. Recuerdo que para cogerlos al azar hacia lo siguiente: set.seed(121) final<-0 nuevo<-0 for(i in 1:10){ nuevo<-sample(datos$pedidos,replace=T) final[i]<-sum(nuevo[1:20]) } donde aqui estoy cogiendo los 20 dias al azar. �Como haria para coger estos 20 dias seguidos?? Gracias Jes�s [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es