Re: [R] R-2.6.0 and RWinEdt
Dear Listers, I have the same problem on vista home premium. library(RWinEdt) Does not launch R-Winedt startWinEdt(.gW$InstallRoot, .gW$ApplData) Does nor either launch sessionInfo() R version 2.6.0 Patched (2007-10-03 r43075) i386-pc-mingw32 locale: LC_COLLATE=French_France.1252;LC_CTYPE=French_France.1252;LC_MONETARY=French_France.1252;LC_NUMERIC=C;LC_TIME=French_France.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] RWinEdt_1.7-6 Perhaps Patrick can et me know what he does to start manually R-WinEdt as I don't see where I need to double-click as mentioned in his post. Thanks and best whishes, Jean-Louis Patrick Giraudoux wrote: Dear Listers, I have just installed R-2.6.0 and the RWinEdt package 1.7-6 under Windows XP. The R-WinEdt menu well appears at launching (the command library(RWinEdt) is in .Rprofile), but WinEdt is NOT started automatically (this was not the case in the earlier versions of R). When WinEdt is started by hand (eg double-click on a RWinEdt alias after R launching), syntax highlighting and connexion to R works well. Any idea about how to fix this and get WinEdt automatically started when library(RWinEdt) is called? Patrick __ 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. -- View this message in context: http://www.nabble.com/R-2.6.0-and-RWinEdt-tf4579046.html#a13080322 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] list matching
On Sunday 07 October 2007, Gabor Grothendieck wrote: zoo's merge can do a multiway intersection. We turn each component of aa into the times of a dataless zoo object (assuming the elements of each component are unique) and merge them together using all = FALSE which will only leave those points at times in all components. Extracting the time and stripping off the names gives the result. library(zoo) as.vector(time(do.call(merge, c(lapply(aa, function(x) zoo(,x)), all = FALSE Hi Gabor, it's always good to see clever solutions. Never thought about using time series to perform intersections :) I can't reproduce your solution though: Error in rval[[1]] : subscript out of bounds The elements of each component are indeed unique; the argument all = FALSE intrigues me: which function should use it, zoo() or c() ? The result of lapply() is a list; when performing c() over that list, the argument all = FALSE does nothing but to add another branch... hmm, I should really use more time series... Adrian -- Adrian Dusa Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ 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] Controlling the Output from table()
Dear All, I would like to have some controll over the output from the function table(). I want to controll the order of the cells and I want to include empty cells (if any). Example: I have ordinal data wich takes the values 1,2,3N but I want the output from table to put the frequencies in a different order, say, 3,7,1,4 and I want to include categories with zero frequency. How is that done? Cheers, Patrik __ 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] Controlling the Output from table()
On Sun, 7 Oct 2007, Öhagen Patrik wrote: Dear All, I would like to have some controll over the output from the function table(). I want to controll the order of the cells and I want to include empty cells (if any). Example: I have ordinal data wich takes the values 1,2,3N but I want the output from table to put the frequencies in a different order, say, 3,7,1,4 and I want to include categories with zero frequency. How is that done? See ?tabulate. You can reorder the result via indexing: I don't follow what you want and you did not give us an example. (For example, is 'ordinal data' represented by an ordered factor or by an integer vector?) -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ R-help@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] Controlling the Output from table()
Sorry for the vaugness. I have text data (exam grades, say) for different courses and I want to table them. In my table I want the frequency for the lowest grade first and the other frequencies in increaseing (grade) order. Some frequencies might be zero but I want to include those empty cells in my table. I hope that made sense? Thank you in advance! Cheer, Patrik -Ursprungligt meddelande- Från: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Skickat: den 7 oktober 2007 09:11 Till: Öhagen Patrik Kopia: [EMAIL PROTECTED] Ämne: Re: [R] Controlling the Output from table() On Sun, 7 Oct 2007, Öhagen Patrik wrote: Dear All, I would like to have some controll over the output from the function table(). I want to controll the order of the cells and I want to include empty cells (if any). Example: I have ordinal data wich takes the values 1,2,3N but I want the output from table to put the frequencies in a different order, say, 3,7,1,4 and I want to include categories with zero frequency. How is that done? See ?tabulate. You can reorder the result via indexing: I don't follow what you want and you did not give us an example. (For example, is 'ordinal data' represented by an ordered factor or by an integer vector?) -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@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] Simulate data based on correlation coefficient
Try this: rnormcor - function(x,rho) rnorm(1,rho*x,sqrt(1-rho^2)) a - rnorm(1000,0,1) b - sapply(a, rnormcor, rho = 0.7) cor(a,b) Joris Gustavo [EMAIL PROTECTED] .com.br To Sent by: r-help@r-project.org [EMAIL PROTECTED] cc project.org Subject [R] Simulate data based on 06/10/2007 04:48 correlation coefficient Hello all, I have a vector with 1000 values and I would like to generate other correlated vector, but with different correlation coefficient (for example, r = 0.7). Any ideas how can I do this? Regards, Gustavo. ___ Experimente já e veja as novidades. __ 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] how to use \Sexpr{} with sweave
Hi, this works for me (R 2.5.1, Linux): echo=false= data(airquality) library(ctest) kruskal.test(Ozone ~ Month, data = airquality) @ Wir haben hier also \Sexpr{nrow(airquality)} Datenzeilen in airquality. This works \Sexpr{2+6} I think the error is in your latex setup, not in R or Sweave. ryancw wrote: I'm trying to learn Sweave. So far things are going well with the chunks of code identified by = But I'm having trouble with the in-line text use of \Sexpr. Here is a short example .Rnw file: \documentclass[12pt]{article} \usepackage[margin=1.25in]{geometry} \usepackage{graphicx} \usepackage{Sweave} \begin{document} test= pnorm(1) @ \Sexpr{2+6} \end{document} The .tex file that it yields contains \Sexpr{2+6} as its next-to-last line. \usepackage{Sweave} is in its preamble. When I pdflatex that file, the resulting pdf file shows the proper value of pnorm(1), but it does not contain 8 near its end. Instead it contains 2+6. I had expected the computed value. Also, pdflatex gives me a message that there was an error opening the document. The file cannot be found. I have to go find it and open it, instead of it opening automatically like a non-problematic case would. Running R 2.5.1 on WinXP, with MikTex. Any advice? Thanks. --Chris Ryan __ 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. -- View this message in context: http://www.nabble.com/how-to-use-%5CSexpr%7B%7D-with-sweave-tf4581860.html#a13080823 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] Re-ordering factors
Thanks to James and Phil and Peter for their helpful suggestions. I think that I should also point out one way *not* to do the job: xtabs(Count ~ Education + Age_Group, data=educ) Age_Group Education64 25-34 35-44 45-54 55-64 CompletedHS 7558 16431 1855 9435 8795 IncompleteHS 13746 5416 5030 5777 7606 Uni1-32503 8555 5576 3124 2524 Uni4+ 2483 9771 7596 3904 3109 levels(educ$Education) - c(IncompleteHS,CompletedHS, + Uni1-3,Uni4+) levels(educ$Age_Group) - c(25-34,35-44,45-54,55-64,64) xtabs(Count ~ Education + Age_Group, data=educ) Age_Group Education 25-34 35-44 45-54 55-64 64 IncompleteHS 7558 16431 1855 9435 8795 CompletedHS 13746 5416 5030 5777 7606 Uni1-32503 8555 5576 3124 2524 Uni4+ 2483 9771 7596 3904 3109 Cheers, Murray James Reilly wrote: Using reorder.factor from the stats package seems to work: educ$ed - reorder(educ$Education, sort(rep(1:4,5))) levels(educ$Education) [1] CompletedHS IncompleteHS Uni1-3 Uni4+ levels(educ$ed) [1] IncompleteHS CompletedHS Uni1-3 Uni4+ xtabs(Count ~ ed + Age_Group, data=educ) Age_Group ed 25-34 35-44 45-54 55-64 64 IncompleteHS 5416 5030 5777 7606 13746 CompletedHS 16431 1855 9435 8795 7558 Uni1-38555 5576 3124 2524 2503 Uni4+ 9771 7596 3904 3109 2483 Notice that factor() itself will do it quite happily: ed - factor(Education, levels = c(IncompleteHS, CompletedHS, Uni1-3, Uni4+)) or even, utilizing the fact that the levels were in the right order to begin with educ$Education - factor(educ$Education, levels=unique(educ$Education)) educ$Age_Group - factor(educ$Age_Group, levels=unique(educ$Age_Group)) xtabs(Count ~ Education + Age_Group, data=educ) Age_Group Education 25-34 35-44 45-54 55-64 64 IncompleteHS 5416 5030 5777 7606 13746 CompletedHS 16431 1855 9435 8795 7558 Uni1-38555 5576 3124 2524 2503 Uni4+ 9771 7596 3904 3109 2483 -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ 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] Tricky vectorization problem
a small improvement is to avoid computing the spectral decomposition of `Sigma' (look at code of mvrnorm()) in each iteration, e.g., #set up a collector for subject means in A a - numeric(Ns) #set up a collector for subject means in B b - numeric(Ns) eS - eigen(Sigma, symmetric = TRUE, EISPACK = TRUE) ev - eS$values fact - eS$vectors %*% diag(sqrt(pmax(ev, 0)), 2) #start a monte carlo experiment for (i in 1:mce) { #generate correlated ideal means for each subject in each condition X - rnorm(2 * Ns) dim(X) - c(2, Ns) sub.means - t(fact %*% X) #for each subject for (s in 1:Ns) { #generate some data for A and grab the mean a[s] - mean(rnorm(a.No[s], sub.means[s, 1], s.a.w[s])) #generate some data for B and grab the mean b[s] - mean(rnorm(b.No[s], sub.means[s, 2], s.b.w[s])) } #store the observed correlation between A and B sim.r[i] - cor(a, b) } I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm Quoting Mike Lawrence [EMAIL PROTECTED]: Seems there were some line break issues when pasting the code, trying again with a different commenting style: #start a timer start = proc.time()[1] #set the true correllation rho = .5 #set the number of Subjects Ns = 100 #for each subject, set a number of observations in A a.No = 1:100 #for each subject, set a number of observations in B b.No = 1:100 #set the between Ss variance in condition A v.a = 1 #set the between Ss variance in condition B v.b = 2 #for each subject, set a standard deviation in A s.a.w = 1:100 #for each subject, set a standard deviation in B s.b.w = 1:100 #set the number of monte carlo experiments mce = 1e3 #set up a collector for the simulated correlations sim.r = vector(length=mce) #define a covariance matrix for use in generating the correlated data Sigma=matrix(c(v.a,sqrt(v.a*v.b)*rho,sqrt(v.a*v.b)*rho,v.b),2,2) #set up a collector for subject means in A a = vector(length=Ns) #set up a collector for subject means in B b = vector(length=Ns) #start a monte carlo experiment for(i in 1:mce){ #generate correlated ideal means for for each subject in each condition sub.means=mvrnorm(Ns,rep(0,2),Sigma) #for each subject for(s in 1:Ns){ #generate some data for A and grab the mean a[s] = mean(rnorm(a.No[s],sub.means[s,1],s.a.w[s])) #generate some data for B and grab the mean b[s] = mean(rnorm(b.No[s],sub.means[s,2],s.b.w[s])) } #store the observed correlation between A and B sim.r[i] = cor(a,b) } #show the total time this took print(proc.time()[1]-start) __ 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. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ 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 \Sexpr{} with sweave
[EMAIL PROTECTED] wrote: I'm trying to learn Sweave. So far things are going well with the chunks of code identified by = But I'm having trouble with the in-line text use of \Sexpr. Here is a short example .Rnw file: \documentclass[12pt]{article} \usepackage[margin=1.25in]{geometry} \usepackage{graphicx} \usepackage{Sweave} \begin{document} test= pnorm(1) @ \Sexpr{2+6} \end{document} The .tex file that it yields contains \Sexpr{2+6} as its next-to-last line. \usepackage{Sweave} is in its preamble. When I pdflatex that file, the resulting pdf file shows the proper value of pnorm(1), but it does not contain 8 near its end. Instead it contains 2+6. I had expected the computed value. Also, pdflatex gives me a message that there was an error opening the document. The file cannot be found. I have to go find it and open it, instead of it opening automatically like a non-problematic case would. Running R 2.5.1 on WinXP, with MikTex. Any advice? Thanks. How did you produce the .tex file? I just cut and pasted your file into test.Rnw, and Sweave( test.Rnw ) produced the .tex file shown below, with no 2+6 in it. \documentclass[12pt]{article} \usepackage[margin=1.25in]{geometry} \usepackage{graphicx} \usepackage{Sweave} \begin{document} \begin{Schunk} \begin{Sinput} pnorm(1) \end{Sinput} \begin{Soutput} [1] 0.8413447 \end{Soutput} \end{Schunk} 8 \end{document} __ 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] R-2.6.0 and RWinEdt
Again, a binary includeing a bugfix for R-2.6.0 of RWinEdt is on its way to CRAN master. Uwe Ligges Jean-Louis Abitbol wrote: Dear Listers, I have the same problem on vista home premium. library(RWinEdt) Does not launch R-Winedt startWinEdt(.gW$InstallRoot, .gW$ApplData) Does nor either launch sessionInfo() R version 2.6.0 Patched (2007-10-03 r43075) i386-pc-mingw32 locale: LC_COLLATE=French_France.1252;LC_CTYPE=French_France.1252;LC_MONETARY=French_France.1252;LC_NUMERIC=C;LC_TIME=French_France.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] RWinEdt_1.7-6 Perhaps Patrick can et me know what he does to start manually R-WinEdt as I don't see where I need to double-click as mentioned in his post. Thanks and best whishes, Jean-Louis Patrick Giraudoux wrote: Dear Listers, I have just installed R-2.6.0 and the RWinEdt package 1.7-6 under Windows XP. The R-WinEdt menu well appears at launching (the command library(RWinEdt) is in .Rprofile), but WinEdt is NOT started automatically (this was not the case in the earlier versions of R). When WinEdt is started by hand (eg double-click on a RWinEdt alias after R launching), syntax highlighting and connexion to R works well. Any idea about how to fix this and get WinEdt automatically started when library(RWinEdt) is called? Patrick __ 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] Variable characterization by the modalities of other variables
sorry to all: I'm looking for a way to display the statistical links between categories of observations and active variables (or characteristic modalities). SAPD call this Description of Modalities - procedure DEMOD which statistically characterises each category of the dependent variable with the categories of other variables. Finally the characteristic modalities are arranged in descending order of statistical significance. Are there a package for this kind of analysis? Thanks Dear Sirs, Is there a way to make in R a variable modalities characterisation by the modalities of other categorical variables? Usually I do this task in SPAD. The output are: column 3 -- modality % in the class column 4 -- modality % in the population column 5 -- class % in the modality suppose: Variable A (two modalities: A1 and A2) dependent variable Variable B (two modalities: B1 and B2) independent variable variable A - modality A1 Variable-Modality column 3 column 4 column 5 chi-squared p-value A A1 100 67.45 40.872 0,00 B B2 56 2345 1.8 0,00 variable A -- modality A2 Variable-Modality column 3 column 4 column 5 chi-squared p-value A A2 100 57.45 30.283 0,00 B B1 38 3225 2.3 0,00 Have a nice night Thanks a lot Jorge __ 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. Abraços, Jorge Manuel de Almeida Magalhães [[alternative text/enriched 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] list matching
Perhaps its a version problem? Here is what I get: aa - list(one=c(o, n, e), + tea=c(t, e, a), + thre=c(t, h, r, e)) library(zoo) as.vector(time(do.call(merge, c(lapply(aa, function(x) zoo(,x)), all = FALSE [1] e R.version.string # Vista [1] R version 2.6.0 beta (2007-09-23 r42958) packageDescription(zoo)$Version [1] 1.3-2 On 10/7/07, Adrian Dusa [EMAIL PROTECTED] wrote: On Sunday 07 October 2007, Gabor Grothendieck wrote: zoo's merge can do a multiway intersection. We turn each component of aa into the times of a dataless zoo object (assuming the elements of each component are unique) and merge them together using all = FALSE which will only leave those points at times in all components. Extracting the time and stripping off the names gives the result. library(zoo) as.vector(time(do.call(merge, c(lapply(aa, function(x) zoo(,x)), all = FALSE Hi Gabor, it's always good to see clever solutions. Never thought about using time series to perform intersections :) I can't reproduce your solution though: Error in rval[[1]] : subscript out of bounds The elements of each component are indeed unique; the argument all = FALSE intrigues me: which function should use it, zoo() or c() ? The result of lapply() is a list; when performing c() over that list, the argument all = FALSE does nothing but to add another branch... hmm, I should really use more time series... Adrian -- Adrian Dusa Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ 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] factanal: error message
At 17:51 06/10/2007, Steve Friedman wrote: Hi everyone, I'm running a factor analysis on a correlation matrix with 32 rows and columns. I get the following error when I issue the command sequence mich.fac1 - factanal(michcor, factor=1) Error in solve.default(cv) : system is computationally singular: reciprocal condition number = 3.24729e-18 I'd really appreciate an explanation for this error and a solution to the problem ?factanal reveals that factanal(x, factors, data = NULL, covmat = NULL, n.obs = NA, subset, na.action, start = NULL, scores = c(none, regression, Bartlett), rotation = varimax, control = NULL, ...) and x A formula or a numeric matrix or an object that can be coerced to a numeric matrix. I think you meant covmat = michcor Thanks Steve [[alternative HTML version deleted]] Michael Dewey http://www.aghmed.fsnet.co.uk __ 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] plot the chi-square distribution for n=1 through 10, on one plot
At 23:48 06/10/2007, fb wrote: Dear help list. I would like to plot the chi-square distribution for n=1 through 10, on one plot. How do I go about doing that? I know how to plot one chi-square (using curve() for example), but plotting 10 on one plot, that is too difficult for me. I greatly appreciate your help. have you tried add = TRUE? -- fb [EMAIL PROTECTED] -- Michael Dewey http://www.aghmed.fsnet.co.uk __ 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] list matching
On Sunday 07 October 2007, you wrote: Perhaps its a version problem? [...] R.version.string # Vista [1] R version 2.6.0 beta (2007-09-23 r42958) packageDescription(zoo)$Version [1] 1.3-2 I don't know, everything is up to date here, too. I'm using Kubuntu Linux and the latest versions of R and zoo: R.version.string [1] R version 2.6.0 (2007-10-03) packageDescription(zoo)$Version [1] 1.3-2 Adrian -- Adrian Dusa Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ 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] Tricky vectorization problem
Had a realization this morning that I think achieves ceiling performance and thought I'd share with the list. I was previously generating sample data per participant and then calculating a mean, but of course this could be simplified by simply getting a single value from the sampling distribution of the mean for that participant. This speeds things up immensely (from 10.5 seconds to .5 seconds) and should be sufficient for my needs, but I'd still welcome further improvement suggestions. #start a timer start = proc.time()[1] #set the number of monte carlo experiments mce = 1e3 #set the true correllation rho = .5 #set the number of Subjects Ns = 100 #for each subject, set a number of observations in A a.No = 1:100 #for each subject, set a number of observations in B b.No = 1:100 #set the between Ss variance in condition A v.a = 1 #set the between Ss variance in condition B v.b = 2 #for each subject, set a standard deviation in A s.a.w = 1:100 #for each subject, set a standard deviation in B s.b.w = 1:100 #set up a collector for the simulated correlations sim.r = vector(length=mce) #define a covariance matrix for use in generating the correlated data Sigma=matrix(c(v.a,sqrt(v.a*v.b)*rho,sqrt(v.a*v.b)*rho,v.b),2,2) eS - eigen(Sigma, symmetric = TRUE, EISPACK = TRUE) ev - eS$values fact - eS$vectors %*% diag(sqrt(pmax(ev, 0)), 2) #set up a collector for subject means in A a = vector(length=Ns) #set up a collector for subject means in B b = vector(length=Ns) #generate correlated ideal means for for each subject in each condition X - rnorm(2 * Ns * mce) dim(X) - c(2, Ns * mce) sub.means - t(fact %*% X) #generate observed means for each Subject in A a=sub.means[,1]+rnorm(Ns*mce,0,s.a.w/sqrt(a.No)) #generate observed means for each Subject in B b=sub.means[,2]+rnorm(Ns*mce,0,s.b.w/sqrt(b.No)) #Get the observed correlation for each monte carlo experiment for(i in 1:mce){ sim.r[i] = cor( a[(i*Ns-Ns+1):(i*Ns)] ,b[(i*Ns-Ns+1):(i*Ns)] ) } #show the total time this took print(proc.time()[1]-start) __ 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] ex-post prediction
Dear help-list, I would like to predict ex-post from a model fitted by arima, but the time series prediction methods in package stats have only the argument n.ahead specifying how many time steps ahead to predict . Is there any other possibility to do that? I really appreciate your help! Thanks! Erinys -- View this message in context: http://www.nabble.com/ex-post-prediction-tf4583732.html#a13084414 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] list matching
I thought the latest zoo fixes were on CRAN but perhaps they are not. Try this: library(zoo) # next line loads latest version of merge.zoo (fixed in August) source(http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/*checkout*/pkg/R/merge.zoo.R?rev=361root=zoo;) as.vector(time(do.call(merge, c(lapply(aa, function(x) zoo(,x)), all = FALSE On 10/7/07, Adrian Dusa [EMAIL PROTECTED] wrote: On Sunday 07 October 2007, you wrote: Perhaps its a version problem? [...] R.version.string # Vista [1] R version 2.6.0 beta (2007-09-23 r42958) packageDescription(zoo)$Version [1] 1.3-2 I don't know, everything is up to date here, too. I'm using Kubuntu Linux and the latest versions of R and zoo: R.version.string [1] R version 2.6.0 (2007-10-03) packageDescription(zoo)$Version [1] 1.3-2 Adrian -- Adrian Dusa Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ 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] list matching
On Sunday 07 October 2007, Gabor Grothendieck wrote: I thought the latest zoo fixes were on CRAN but perhaps they are not. Try this: library(zoo) # next line loads latest version of merge.zoo (fixed in August) source(http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/*checkout*/ pkg/R/merge.zoo.R?rev=361root=zoo) as.vector(time(do.call(merge, c(lapply(aa, function(x) zoo(,x)), all = FALSE Yeap, that fixes it. Ah-haa, so all = FALSE is merge()s argument... Neat :) Adrian -- Adrian Dusa Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ 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] list matching
On 10/7/07, Adrian Dusa [EMAIL PROTECTED] wrote: On Sunday 07 October 2007, Gabor Grothendieck wrote: I thought the latest zoo fixes were on CRAN but perhaps they are not. Try this: library(zoo) # next line loads latest version of merge.zoo (fixed in August) source(http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/*checkout*/ pkg/R/merge.zoo.R?rev=361root=zoo) as.vector(time(do.call(merge, c(lapply(aa, function(x) zoo(,x)), all = FALSE Yeap, that fixes it. Ah-haa, so all = FALSE is merge()s argument... Neat :) Adrian It also makes use of the fact that zoo is sufficiently general that the times in the time series can be character strings. For example, the following time series has the value 1 at time a, 2 at time b, etc. zoo(1:26, letters) __ 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: cluster analysis
-- Forwarded message -- From: amna khan [EMAIL PROTECTED] Date: Oct 6, 2007 11:02 AM Subject: cluster analysis To: Alberto Viglione [EMAIL PROTECTED] Dear Sir I am facing problem in using traceWminim() function for cluster analysis. A sample of data frame that I am using is of the following form sitename latlong elev map 1 Dir 35.12 71.51 4675 1472.10 2S.Sharif 34.4472.21 3155 1051.70 3Peshawar 34.01 71.35 1185 435.90 4 Kakul 34.11 73.15 4301 1330.17 5 Balakot 34.3372.21 3214 1652.20 Sir when I used the above function for 2 clusters as traceWminim(atsite,2) then the following error message appears Error in if (min.traceW.2 traceW.1) { : missing value where TRUE/FALSE needed Please provide your guidance Thank You -- AMINA SHAHZADI Department of Statistics GC University Lahore, Pakistan. -- AMINA SHAHZADI Department of Statistics GC University Lahore, Pakistan. [[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] R-2.6.0 and RWinEdt
Patrick Giraudoux wrote: Dear Listers, I have just installed R-2.6.0 and the RWinEdt package 1.7-6 under Windows XP. wait for 1.7-7 which should appear on CRAN real soon now. Uwe The R-WinEdt menu well appears at launching (the command library(RWinEdt) is in .Rprofile), but WinEdt is NOT started automatically (this was not the case in the earlier versions of R). When WinEdt is started by hand (eg double-click on a RWinEdt alias after R launching), syntax highlighting and connexion to R works well. Any idea about how to fix this and get WinEdt automatically started when library(RWinEdt) is called? Patrick __ 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] Trust p-values or not ?
Hi, First of all kudos to the creaters/contributors to R ! This is a great package and I am finding it very useful in my research, will love to contribute any modules and dataset which I develop to the project. While doing multiple regression I arrived at the following peculiar situation. Out of 8 variables only 4 have 0.04 p-values (of t-statistic), rest all have p-values between 0.1 and 1.0 and the coeff of Regression is coming around ~0.8 (adjusted ~0.78). The F-statistic is around 30 and its own p-value is ~0. Also I am constrained with a dataset of 130 datapoints. Being new to statistics I would really appreciate if someone can help me understand these values. 1) Does the above test values indicate a statistically sound and significant model ? 2) Is a dataset of 130 enough to run linear regression with ~7-10 variables ? If not what is approximately a good size. Thanks in advance. -Ankit [[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] Question about aov
Hello R gurus, I am a beginner with R. I am doing an ANCOVA analysis using 'aov,' and need some help understanding how 'aov' works. I have a dataset (taken from http://faculty.vassar.edu/lowry/ch17pt2.html) looking at hypnotic induction. The variable 'X' is a measure of how susceptible the subject is to being hypnotized, the variable 'Y' is how well the subject was hypnotized in the experiment, and the variable 'Method' is the method of hypnosis used in the experiment. If I use the following code, I get the correct analysis (F = 16): ANCOVA=aov(lm(Y~X+Method,data=hypnotic.induction)) summary(ANCOVA); But if I switch the order of independent variables to: ANCOVA=aov(lm(Y~Method+X,data=hypnotic.induction)) summary(ANCOVA) I get a very different result (F = 0.8). I assume it has something to do with the order in which the variables are entered into the regression? In 'aov' is there something 'special' about the first independent variable entered into the formula? It would be greatly appreciated if anyone could shed some light on these results? Thanks! Alex Keedy - [[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] how to use \Sexpr{} with sweave
Duncan-- The .tex file that you describe as output of Sweave(test.Rnw) is what I had expected. But I get this .tex file when I run Sweave: \documentclass[12pt]{article} \usepackage[margin=1.25in]{geometry} \usepackage{graphicx} \usepackage{Sweave} \begin{document} \begin{Schunk} \begin{Sinput} pnorm(1) \end{Sinput} \begin{Soutput} [1] 0.8413447 \end{Soutput} \end{Schunk} \Sexpr{2+6} \end{document}\documentclass[12pt]{article} \usepackage[margin=1.25in]{geometry} \usepackage{graphicx} \usepackage{Sweave} \begin{document} \begin{Schunk} \begin{Sinput} pnorm(1) \end{Sinput} \begin{Soutput} [1] 0.8413447 \end{Soutput} \end{Schunk} \Sexpr{2+6} \end{document} __ 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 in R-2-6-0?
I was happy today to install the new version of R 2-6-0 But I ran into problems I did not have before: setwd(C:/R/DATA/BRugs) library(BRugs) modelCheck(rcapturemodel.txt) Error in file(con, r) : unable to open connection In addition: Warning message: In file(con, r) : cannot open file 'C:\DOCUME~1\Franco\LOCALS~1\Temp\RtmpU0eG2C/buffer.txt', reason 'No such file or directory' I am 100 percent sure my file is in C:/R/DATA/BRugs and I don't know why it is trying to open the C:\DOCUME~1... I never asked the program to go search for any file there! -- View this message in context: http://www.nabble.com/Errors-in-R-2-6-0--tf4584279.html#a13085996 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] Linux editor for R+LaTeX, but not Emacs
On Sat, 06-Oct-2007 at 11:01AM +0200, Scionforbai wrote: | Hi, | | What features are you missing in emacs that you wish were there? Are | these ESS features or LaTeX related features? | | is it only me or has anyone else the problem that running an R process | within emacs is way much slower than in a regular terminal/console? | (linux here) I think it's only you. R certainly takes longer to start within ESS than from the command line, but once it's running, there's no difference that's had an effect on me. -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_Middle minds discuss events (:_~*~_:)Small minds discuss people (_)-(_) . Anon ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. __ 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 \Sexpr{} with sweave
I think some inadvertent cutting and pasting may have made my last e-mail difficult to interpret. Here is the .tex file I get as output of Sweaving my .Rnw file. Note that \Sexpr{2+6} appears where you get (and I want) simply 8. \documentclass[12pt]{article} \usepackage[margin=1.25in]{geometry} \usepackage{graphicx} \usepackage{Sweave} \begin{document} \begin{Schunk} \begin{Sinput} pnorm(1) \end{Sinput} \begin{Soutput} [1] 0.8413447 \end{Soutput} \end{Schunk} \Sexpr{2+6} \end{document} __ 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] Errors in R-2-6-0?
I re-installed version 2-5-0 and it works well. I believe this problem is due to an incompatibility of BRugs with R-2-6-0 francogrex wrote: I was happy today to install the new version of R 2-6-0 But I ran into problems I did not have before: setwd(C:/R/DATA/BRugs) library(BRugs) modelCheck(rcapturemodel.txt) Error in file(con, r) : unable to open connection In addition: Warning message: In file(con, r) : cannot open file 'C:\DOCUME~1\Franco\LOCALS~1\Temp\RtmpU0eG2C/buffer.txt', reason 'No such file or directory' I am 100 percent sure my file is in C:/R/DATA/BRugs and I don't know why it is trying to open the C:\DOCUME~1... I never asked the program to go search for any file there! -- View this message in context: http://www.nabble.com/Errors-in-R-2-6-0--tf4584279.html#a13086255 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] Trust p-values or not ?
Ankit, (1) Not necessarily. Linear regression has a number of assumptions. I suggest you get a basics statistics textbook and do some reading. A brief summary of the assumptions include: (a) The relation between outcome and predictor variables lie along a line (or plane for a regression with multiple predictor variables) or some surface that can be modeled using a linear function (b) The predictor variables are independent of one another (c) The residuals from the regression are normally distributed (d) The variance of the residuals is constant through out the range of the independent variables. (e) The predictor variables are measured without error. Even if the above assumptions are violated, you can still get a significant f statistic, significance for some, or all of your predictor variables, etc. If the assumptions are violated, the meaning of the results you obtain from your regression analysis can be questionable, if not outrightly incorrect. There a number of tests that you can perform to make sure you model conforms to (or at least does not wildly violate) the basic assumptions. Some commonly performed tests like examining the pattern of residuals, can be done in R by simply plotting the fit you obtain, i.e. fit1-lm(y~x+z) plot(fit1) #This produces a number of helpful graphs that will help you evaluate your model. Fortunately, linear regression is fairly robust to minor violations of several of the assumptions noted above, however in order to fully evaluate the appropriateness of you model, you will need to read a textbook, speak to people with more experience than you, and play, play, play with data. (2) The more predictor variables you have the more observations you need. Although there is no absolute rule, many people like to have a minimum of five to ten observations per independent variable. I like to have at least ten. Given that you have eight independent variables, you would, by my criteria need at least 80 observations. You have 130 so you should be OK, assuming that your observations are independent of one-another. Sorry I can't be of more help; statistics can not be learned in a single E-mail message. The fact that you are asking important questions about what you are doing reflects well on you. I suspect that in a year or so you will be answering, rather than asking questions posted on the R Listserv mailing list! John John Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics Baltimore VA Medical Center GRECC, University of Maryland School of Medicine Claude D. Pepper OAIC, University of Maryland Clinical Nutrition Research Unit, and Baltimore VA Center Stroke of Excellence University of Maryland School of Medicine Division of Gerontology 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) [EMAIL PROTECTED] rocker turtle [EMAIL PROTECTED] 10/07/07 2:32 PM Hi, First of all kudos to the creaters/contributors to R ! This is a great package and I am finding it very useful in my research, will love to contribute any modules and dataset which I develop to the project. While doing multiple regression I arrived at the following peculiar situation. Out of 8 variables only 4 have 0.04 p-values (of t-statistic), rest all have p-values between 0.1 and 1.0 and the coeff of Regression is coming around ~0.8 (adjusted ~0.78). The F-statistic is around 30 and its own p-value is ~0. Also I am constrained with a dataset of 130 datapoints. Being new to statistics I would really appreciate if someone can help me understand these values. 1) Does the above test values indicate a statistically sound and significant model ? 2) Is a dataset of 130 enough to run linear regression with ~7-10 variables ? If not what is approximately a good size. Thanks in advance. -Ankit [[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. Confidentiality Statement: This email message, including any attachments, is for th...{{dropped:6}} __ 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] Arguments to personalised plot()
Hi Folks, I'm curious for an explanation of the following -- it's a matter of trying to understand how R parses it. I've written sundry little helper variants of functions, in particular plot(), to save repetitively typing the same options over and over again. For example: plotb - function(x,...){plot(x,pch=+,col=blue,...)} This does exactly what you'd expect it to do when fed with a vector of values to plot, e.g. plotb(cos(0.01*2*pi*(0:100))) namely a plot of the values of cos(..) with x-coordinates marked 0, 20, 40, 60, 80, 100, as blue +. As expected, one can add other plot options if needed, e.g. plotb(cos(0.01*2*pi*(0:100)), xlim=c(0,4*pi)) if one wants. In this case, I'm supposing that the xlim=c(0,4*pi) goes in under the umbrella of ..., which is what I guessed would happen. Interestingly, though, if I do x-0.01*2*pi*(0:100); plotb(x,cos(x)) I now get it with the x-axis labelled 0,1,2,3,4,5,6 just as if I had used the built-in x-0.01*2*pi*(0:100); plot(x,cos(x),pch=+,col=blue) and I can *also* add xlim=c(0,4*pi): x-0.01*2*pi*(0:100); plotb(x,cos(x),xlim=c(0,4*pi)) and it still works! Now the latter is the same ... mechanism as before, I suppose; but this doesn't explain how plotb() sees x, along with cos(x), and picks it up to do the right thing. So my question -- which is why I'm posting -- is: How does x get in along with cos(x) when I do plotb(x,cos(x)), when the definition of the function is plotb - function(x,...){plot(x,pch=+,col=blue,...)} Thanks, and best wishes to all, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 07-Oct-07 Time: 20:49:26 -- XFMail -- __ 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] Linux editor for R+LaTeX, but not Emacs
Have you ever considered using C-u C-c C-r instead of C-c C-r? Best regards Frede Fra: [EMAIL PROTECTED] på vegne af [EMAIL PROTECTED] Sendt: lø 06-10-2007 23:10 Til: Dirk Eddelbuettel Cc: r-help@r-project.org Emne: Re: [R] Linux editor for R+LaTeX, but not Emacs On 10/6/07, Dirk Eddelbuettel [EMAIL PROTECTED] wrote: On 6 October 2007 at 11:01, Scionforbai wrote: | What features are you missing in emacs that you wish were there? Are | these ESS features or LaTeX related features? | | is it only me or has anyone else the problem that running an R process | within emacs is way much slower than in a regular terminal/console? | (linux here) It's just you, and if you think some more about it, you'll see why we are all grinning. [ Hint: it can't be slower, outside of ridiculous corner sitations where there isn't enough ram for Emacs and R at the same time. Or foobared setups. In all normal situations, it'll be the same. ] Actually, copying multi-line R code (e.g. C-c C-r) is way slower with ESS if you use Emacs22 (and its derivatives such as AquaMacs). Things are perfect with Emacs21 though (and I'm sticking with it). Maybe that explains the discrepancy. -Deepayan __ 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] Trust p-values or not ?
rocker turtle wrote: Hi, First of all kudos to the creaters/contributors to R ! This is a great package and I am finding it very useful in my research, will love to contribute any modules and dataset which I develop to the project. While doing multiple regression I arrived at the following peculiar situation. Out of 8 variables only 4 have 0.04 p-values (of t-statistic), rest all have p-values between 0.1 and 1.0 and the coeff of Regression is coming around ~0.8 (adjusted ~0.78). The F-statistic is around 30 and its own p-value is ~0. Also I am constrained with a dataset of 130 datapoints. Nothing particularly peculiar about this... Being new to statistics I would really appreciate if someone can help me understand these values. 1) Does the above test values indicate a statistically sound and significant model ? Significant, yes, in a sense (see below). Soundness is something you cannot really see from the output of a regression analysis, because it contains results which are valid _provided_ the model assumption holds. To check the assumptions there is a battery of techniques, e.g. residual plots and interaction tests -- there are books about this, which won't really fit into a short email Re. significance, it is important to realise that you generally need to compare multiple model fits to assess which variables are important. With one fit, you can say what happens if you drop single variables from the model, so in your case, you have four seven-variable models that do not fit any worse than the full model. You can't really say anything about what happens if you remove two or more variables. You can also see what happens if you drop all variables; this is the overall F test, which in your case is highly significant, so at least one variable must be required. You can be fairly confident that variables with very small p-values cannot be removed, whereas borderline cases may end up with their p-values becoming insignificant when other variables are removed. 2) Is a dataset of 130 enough to run linear regression with ~7-10 variables ? If not what is approximately a good size. Wrong question, I think. Some people suggest heuristics like 10-20 observations per variable, but this contains an implicit understanding that you are dealing with typical problems in e.g. clinical epidemiology. Designed experiments can contain many more parameters, data with strong correlations require more observations to untangle which variables are important, and even otherwise, you might be looking for effects that are small compared to the residual variation and consequentially require more observations. When you do have the data, I think it is more sound to look at the standard errors of the regression coefficients and discuss whether they are sufficiently small for the kinds of conclusions you want to make. Thanks in advance. -Ankit [[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. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ 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] Linux editor for R+LaTeX, but not Emacs
On 10/7/07, Frede Aakmann Tøgersen [EMAIL PROTECTED] wrote: Have you ever considered using C-u C-c C-r instead of C-c C-r? Yes (or equivalently (setq ess-eval-visibly-p nil)), and found that I didn't like it much. In any case, I'm not looking for ugly workarounds, I just wanted to point out that this could explain the reported slowness. -Deepayan Best regards Frede Fra: [EMAIL PROTECTED] på vegne af [EMAIL PROTECTED] Sendt: lø 06-10-2007 23:10 Til: Dirk Eddelbuettel Cc: r-help@r-project.org Emne: Re: [R] Linux editor for R+LaTeX, but not Emacs On 10/6/07, Dirk Eddelbuettel [EMAIL PROTECTED] wrote: On 6 October 2007 at 11:01, Scionforbai wrote: | What features are you missing in emacs that you wish were there? Are | these ESS features or LaTeX related features? | | is it only me or has anyone else the problem that running an R process | within emacs is way much slower than in a regular terminal/console? | (linux here) It's just you, and if you think some more about it, you'll see why we are all grinning. [ Hint: it can't be slower, outside of ridiculous corner sitations where there isn't enough ram for Emacs and R at the same time. Or foobared setups. In all normal situations, it'll be the same. ] Actually, copying multi-line R code (e.g. C-c C-r) is way slower with ESS if you use Emacs22 (and its derivatives such as AquaMacs). Things are perfect with Emacs21 though (and I'm sticking with it). Maybe that explains the discrepancy. -Deepayan __ 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] Old packages to updated R
I am 100% positive there is a better fix for this problem and it has been discussed. Thank you in advance for bringing it to my attention. When upgrading to newer versions of R the old packages are not brought along in the process. I solved that problem by creating a list of the packages in the old version of R, importing them to the new version via a CSV, and re-installing into the newer R directory. The script is below. Is there a more efficient way to do this? Should I simply attempt to drag the package folders from the old directory to the new one? Thanks ## in old version of R2.6 package-c(library()) write.csv(package$results, file=file path/oldpackages.csv) ##** Update R or open updated R version (R=2.60) package.list-read.csv(file=file path/oldpackages.csv, header=TRUE) package.list$Package-as.character(package.list$Package) install.packages(c(package.list$Package)) #wait awhile and ignore errors for base packages. system: Mac powerbook intel duo. Latest OS R 2.60 [now, thanks to everyone involved] Jon Loehrke Fisheries Graduate Research Assistant School for Marine Science and Technology UMASS-Dartmouth 838 S. Rodney French Blvd. New Bedford, MA 02744 Phone: 508-910-6393 Fax: 508-910-6396 Opportunity is missed by most people because it is dressed in overalls and looks like work. --Thomas A. Edison __ 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] Arguments to personalised plot()
On 07-Oct-07 21:01:08, Deepayan Sarkar wrote: On 10/7/07, Ted Harding [EMAIL PROTECTED] wrote: Hi Folks, I'm curious for an explanation of the following -- it's a matter of trying to understand how R parses it. I've written sundry little helper variants of functions, in particular plot(), to save repetitively typing the same options over and over again. For example: plotb - function(x,...){plot(x,pch=+,col=blue,...)} This does exactly what you'd expect it to do when fed with a vector of values to plot, e.g. plotb(cos(0.01*2*pi*(0:100))) namely a plot of the values of cos(..) with x-coordinates marked 0, 20, 40, 60, 80, 100, as blue +. As expected, one can add other plot options if needed, e.g. plotb(cos(0.01*2*pi*(0:100)), xlim=c(0,4*pi)) if one wants. In this case, I'm supposing that the xlim=c(0,4*pi) goes in under the umbrella of ..., which is what I guessed would happen. Interestingly, though, if I do x-0.01*2*pi*(0:100); plotb(x,cos(x)) I now get it with the x-axis labelled 0,1,2,3,4,5,6 just as if I had used the built-in x-0.01*2*pi*(0:100); plot(x,cos(x),pch=+,col=blue) and I can *also* add xlim=c(0,4*pi): x-0.01*2*pi*(0:100); plotb(x,cos(x),xlim=c(0,4*pi)) and it still works! Now the latter is the same ... mechanism as before, I suppose; but this doesn't explain how plotb() sees x, along with cos(x), and picks it up to do the right thing. So my question -- which is why I'm posting -- is: How does x get in along with cos(x) when I do plotb(x,cos(x)), when the definition of the function is plotb - function(x,...){plot(x,pch=+,col=blue,...)} I'm not sure exactly which part you didn't expect. Given this definition of plotb, I would expect plotb(x,cos(x)) to expand to plot(x, pch=+, col=blue, cos(x)) [A] and as far as I can tell, these give identical results. Is that what surprises you? Why? See below. The other possibility is that you are surprised by the behavior of plot(x, pch=+, col=blue, cos(x)) [B] Remember that named arguments trump positional matching, Ahh, thank you!! I think this is the clue I was looking for. I had guessed that [A](above) and therefore [B] was what was really happening, and that therefore some sort of precedence was working to ensure that things came in in the right order. Now I know what it is. and consequently, this is equivalent to plot(x, cos(x), pch=+, col=blue) In the sense, I suppose, that in either case the effect is a) First sort out (*,pch=+,col=blue,*) (since these are named), leaving (x, cos(x)) (as it were). -Deepayan Thanks, Deepayan. Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 07-Oct-07 Time: 22:48:05 -- XFMail -- __ 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] Arguments to personalised plot()
On 8/10/2007, at 10:01 AM, Deepayan Sarkar wrote: On 10/7/07, Ted Harding [EMAIL PROTECTED] wrote: Hi Folks, I'm curious for an explanation of the following -- it's a matter of trying to understand how R parses it. I've written sundry little helper variants of functions, in particular plot(), to save repetitively typing the same options over and over again. For example: plotb - function(x,...){plot(x,pch=+,col=blue,...)} This does exactly what you'd expect it to do when fed with a vector of values to plot, e.g. plotb(cos(0.01*2*pi*(0:100))) namely a plot of the values of cos(..) with x-coordinates marked 0, 20, 40, 60, 80, 100, as blue +. As expected, one can add other plot options if needed, e.g. plotb(cos(0.01*2*pi*(0:100)), xlim=c(0,4*pi)) if one wants. In this case, I'm supposing that the xlim=c(0,4*pi) goes in under the umbrella of ..., which is what I guessed would happen. Interestingly, though, if I do x-0.01*2*pi*(0:100); plotb(x,cos(x)) I now get it with the x-axis labelled 0,1,2,3,4,5,6 just as if I had used the built-in x-0.01*2*pi*(0:100); plot(x,cos(x),pch=+,col=blue) and I can *also* add xlim=c(0,4*pi): x-0.01*2*pi*(0:100); plotb(x,cos(x),xlim=c(0,4*pi)) and it still works! Now the latter is the same ... mechanism as before, I suppose; but this doesn't explain how plotb() sees x, along with cos(x), and picks it up to do the right thing. So my question -- which is why I'm posting -- is: How does x get in along with cos(x) when I do plotb(x,cos(x)), when the definition of the function is plotb - function(x,...){plot(x,pch=+,col=blue,...)} I'm not sure exactly which part you didn't expect. Given this definition of plotb, I would expect plotb(x,cos(x)) to expand to plot(x, pch=+, col=blue, cos(x)) and as far as I can tell, these give identical results. Is that what surprises you? Why? The other possibility is that you are surprised by the behavior of plot(x, pch=+, col=blue, cos(x)) Remember that named arguments trump positional matching, and consequently, this is equivalent to plot(x, cos(x), pch=+, col=blue) I think that this is the crucial issue. I'm guessing that what puzzled Ted (it is what certainly puzzled me) was ``how did plot() know that cos(x) was the y-value?'' Your (very well expressed) explanation makes this clear. cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ 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] Question about aov
Dear Alex, First, the call to lm() is superfluous; you'd get the same output from summary(aov(Y~X+Method,data=hypnotic.induction)). Second, it's not common to use aov() in this manner, since the function is really intended for balanced ANOVAs. More common would be something like model - lm(Y~X+Method,data=hypnotic.induction) summary(model) anova(model) This would give you both the regression coefficients for the model and the ANOVA table. Finally, aov() and anova() produce sequential sums of squares, which is why the order of the terms matters. Thus the first ordering gives you the sum of squares for X ignoring Method and for Method after X; the second gives you the sum of squares for Method ignoring X and for X after Method. What one typically wants is the sum of squares for each term after the other(s). A convenient way to get this is via the Anova() function in the car package. I hope this helps, John John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alexander Keedy Sent: Sunday, October 07, 2007 2:37 PM To: r-help@r-project.org Subject: [R] Question about aov Hello R gurus, I am a beginner with R. I am doing an ANCOVA analysis using 'aov,' and need some help understanding how 'aov' works. I have a dataset (taken from http://faculty.vassar.edu/lowry/ch17pt2.html) looking at hypnotic induction. The variable 'X' is a measure of how susceptible the subject is to being hypnotized, the variable 'Y' is how well the subject was hypnotized in the experiment, and the variable 'Method' is the method of hypnosis used in the experiment. If I use the following code, I get the correct analysis (F = 16): ANCOVA=aov(lm(Y~X+Method,data=hypnotic.induction)) summary(ANCOVA); But if I switch the order of independent variables to: ANCOVA=aov(lm(Y~Method+X,data=hypnotic.induction)) summary(ANCOVA) I get a very different result (F = 0.8). I assume it has something to do with the order in which the variables are entered into the regression? In 'aov' is there something 'special' about the first independent variable entered into the formula? It would be greatly appreciated if anyone could shed some light on these results? Thanks! Alex Keedy - [[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] Tricky vectorization problem
Posting this for posterity and to demonstrate that a speed-up of 2 orders of magnitude is indeed possible! I can now run 1e5 monte carlo experiments in the time the old code could only run 1e3. The final change was to replace my use of cor() with .Internal(cor()), which avoids some checks that are unnecessary in this case: #start a timer start = proc.time()[1] #set the number of monte carlo experiments mce = 1e5 #set the true correllation rho = 1 #set the number of Subjects Ns = 100 #for each subject, set a number of observations in A a.No = 1:100 #for each subject, set a number of observations in B b.No = 1:100 #set the between Ss variance in condition A v.a = 1 #set the between Ss variance in condition B v.b = 2 #for each subject, set a standard deviation in A s.a.w = 1:100 #for each subject, set a standard deviation in B s.b.w = 1:100 #set up a collector for the simulated correlations sim.r = vector(length=mce) #define a covariance matrix for use in generating the correlated data Sigma=matrix(c(v.a,sqrt(v.a*v.b)*rho,sqrt(v.a*v.b)*rho,v.b),2,2) eS - eigen(Sigma, symmetric = TRUE, EISPACK = TRUE) ev - eS$values fact - eS$vectors %*% diag(sqrt(pmax(ev, 0)), 2) #set up a collector for subject means in A a = vector(length=Ns) #set up a collector for subject means in B b = vector(length=Ns) #generate correlated ideal means for for each subject in each condition X - rnorm(2 * Ns * mce) dim(X) - c(2, Ns * mce) sub.means - t(fact %*% X) a=sub.means[,1]+rnorm(Ns*mce,0,s.a.w/sqrt(a.No)) b=sub.means[,2]+rnorm(Ns*mce,0,s.b.w/sqrt(b.No)) for(i in 1:mce){ end=i*Ns sim.r[i] = .Internal( cor( a[(end-Ns+1):end] ,b[(end-Ns+1):end] ,TRUE ,FALSE ) ) } #show the total time this took print(proc.time()[1]-start) __ 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] Arguments to personalised plot()
On 07-Oct-07 21:51:29, Rolf Turner wrote: On 8/10/2007, at 10:01 AM, Deepayan Sarkar wrote: [...] I'm not sure exactly which part you didn't expect. Given this definition of plotb, I would expect plotb(x,cos(x)) to expand to plot(x, pch=+, col=blue, cos(x)) and as far as I can tell, these give identical results. Is that what surprises you? Why? The other possibility is that you are surprised by the behavior of plot(x, pch=+, col=blue, cos(x)) Remember that named arguments trump positional matching, and consequently, this is equivalent to plot(x, cos(x), pch=+, col=blue) I think that this is the crucial issue. I'm guessing that what puzzled Ted (it is what certainly puzzled me) was ``how did plot() know that cos(x) was the y-value?'' Exactly! Your (very well expressed) explanation makes this clear. Agreed! cheers, Rolf Turner And Cheers! Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 08-Oct-07 Time: 00:10:45 -- XFMail -- __ 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] Break [SEC=UNCLASSIFIED]
Hi, You can exit out of the 'identify()' routine by either: right-click 'stop' Or click on 'stop stop locator' in the top-left of the plot window. The script should continue with line1, line2 etc. Cheers Joe Joe Crombie Information and Risk Sciences Bureau of Rural Science Canberra Australia p: +61 2 6272 5906 e: [EMAIL PROTECTED] -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Monday, 8 October 2007 6:38 AM To: r-help@r-project.org Subject: [R] Break Hi I'm running R-2.5.1 for Windows and I have a rsy.txt script with a structure like . . . pl - plot(mod,dis = sp,type=p) identify(pl,sp,labels=shnam,pos=TRUE) line1 line2 . . . I enter the command source(*.txt) and when R read the identify instruction they stop and wait user actions. After all I give a escape e R end! They d'ont read line1 line2 and so on. How to force the continuation of the script execution. Thanks __ 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. --IMPORTANT - This message has been issued by The Department of Agriculture, Fisheries and Forestry (DAFF). The information transmitted is for the use of the intended recipient only and may contain confidential and/or legally privileged material. It is your responsibility to check any attachments for viruses and defects before opening or sending them on. Any reproduction, publication, communication, re-transmission, disclosure, dissemination or other use of the information contained in this e-mail by persons or entities other than the intended recipient is prohibited. The taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you have received this e-mail in error please notify the sender and delete all copies of this transmission together with any attachments. If you have received this e-mail as part of a valid mailing list and no longer want to receive a message such as this one advise the sender by return e-mail accordingly. Only e-mail correspondence which includes this footer, has been authorised by DAFF -- __ 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] multcomp and lme4
Dear list members, Can anyone please point to an example of how to use glht(multcomp) with lmer objects? I am trying: summary(glht(lmerObject, linfct = mcp(x = Tukey))) as I would for a glm object, but with no luck. Thank you, Andy. [[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] R and FDA trials
Yesterday I just noticed the new document on R and regulatory aspects for biomedical research posted at http://www.r-project.org/doc/R-FDA.pdf Coming from an institution that performs a large number of clinical trials for FDA and being an advocate of R myself, I have found that the following issues usually come up when discussing the use of R for FDA trials: 1. Most FDA submissions come down to a series of r x k tables, and it is hard to claim that one system is better than another for that. 2. Data is to be submitted to the FDA in SAS (considered by many as the industry standard) or CDISC XML formats (http://www.cdisc.org/); there are pretty good SAS tools for that; does R have comparable? 3. Some packages in R provide acknowledgedly better functionality than their SAS-equivalent, but an entire FDA validation would have to occur each time an enhancement is made to the R package because often an enhancement breaks something else or the syntax would change from one release to another. would be interested in opinions on how to respond to these comments Ricardo __ 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] R and FDA trials
Ricardo Pietrobon wrote: Yesterday I just noticed the new document on R and regulatory aspects for biomedical research posted at http://www.r-project.org/doc/R-FDA.pdf Coming from an institution that performs a large number of clinical trials for FDA and being an advocate of R myself, I have found that the following issues usually come up when discussing the use of R for FDA trials: 1. Most FDA submissions come down to a series of r x k tables, and it is hard to claim that one system is better than another for that. 2. Data is to be submitted to the FDA in SAS (considered by many as the industry standard) or CDISC XML formats (http://www.cdisc.org/); there are pretty good SAS tools for that; does R have comparable? 3. Some packages in R provide acknowledgedly better functionality than their SAS-equivalent, but an entire FDA validation would have to occur each time an enhancement is made to the R package because often an enhancement breaks something else or the syntax would change from one release to another. Your item 3. is up to the company's policy. FDA does not require it and the word validation is not well defined in this context. No package does a complete validation any time any piece of the package is enhanced. Frank would be interested in opinions on how to respond to these comments Ricardo -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ 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 can i perform Fisher Exact Test for such data in R?
Dear all, I am sorry, but this not exact a R question.It's a statistic one. Suppose I have two vectors PA and PB, which are both consist of no-redundant nature numbers. PA and PB have overlaps.GA and GB are drawn from PA and PB, respectively.So GA and GB may have overlaps. The question is whether GA and GB have significant overlap.Someone told me Fisher Exact Test in R can do this. Thanks in advance. Jiantao Shi [[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] special characters in linux using dev.print
Hi List, I want to print ± in a lattice graph label. This works in windows, but the linux version has problems - it cannot translate the character. Error is invalid input in mbcsToLatin1. I use the standard encoding and also dev.print(file=filename,dev=pdf, encoding=PDFDoc.enc) I am afraid I don't know enough about the linux font encodings to figure out what to use. So I am hoping others using ± have already come across the trap. Any help appreciated. Thanks Herry Using x86_64 opensuse 10.2, R2.5.0 (2007-04-23) __ 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.