Re: [R] Auto-save possible in R?
John Morrow a écrit : Hello fellow R'ers, I have a simple calculation with a very large data set being generated (34.9 million values) on a somewhat unreliable XP box that will likely take ~ 74hrs. I wanted to know if there is a way to have my script automatically save.image() throughout the calculation in case of a crash. This could be on the basis of output generated or time elapsed. I checked the archive, and only got a hint of it from: https://stat.ethz.ch/pipermail/r-help/1997-May/001611.html Any quick suggestions would be greatly appreciated, John Morrow # make a save every hour minutes = substr(date(),...); if (minutes=='00') save_my_stuff; hih __ R-help@stat.math.ethz.ch 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] Colour-coding intervals on a line
Sara-Jane Dunn a écrit : I need to know if there is any way of using different colours for different intervals of a line on a graph. Eg. If I plot the line y=x for x=1:10, and split this line into 106 intervals (i.e. not a 'nice' number of intervals) how could I colour different intervals different colours without having to use segments and specify coordinates to join? Thanks in advance for any help! Sara-Jane I think you'll have to use segments (?lines()) but it shouldn't be too complicated. Put your line begin, line end, line color in a matrix(, ncol=106) and call lines(...) in a for loop. I would be happy to hear about another way to do it ? __ R-help@stat.math.ethz.ch 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] anova.mlm for single model (one-way repeated measured anova)
On Sat, 12 Aug 2006, takahashi kohske wrote: Dear list members: I'd like to one-way repeated measured anova by using mlm. I'm using R-2.3.1 and my code is: dat-matrix( c(9,7,8,8,12,11,8,13, 6,5,6,3,6,7,10,9, 10,13,8,13,12,14,14,16, 9,11,13,14,16,12,15,14), ncol=4, dimname=list(s=1:8, c=1:4)) mlmfit-lm(dat~1) anova(mlmfit, X=~1) Error: ceiling(length.out) : Non-numeric argument to mathematical function this error occurs in anova.mlm if (rk 0) { p1 - 1:rk comp - object$effects[p1, ] asgn - object$assign[object$qr$pivot][p1] nmeffects - c((Intercept), attr(object$terms, term.labels)) tlabels - nmeffects[1 + unique(asgn)] ix - split(seq(length = nrow(comp)), asgn) #HERE ss - lapply(ix, function(i) crossprod(comp[i, , drop = FALSE])) df - sapply(split(asgn, asgn), length) } because nrow(comp) returns NULL. in my memory, R-2.2.* ( or may be R-2.3.0) can correctly handle this code. so, I think this is a kind of side-effect of fixing PR#8679. currently, i can workaround as follows: anova(mlmfit, update(mlmfit, ~0), X=~1) this code returns correct answer. I don't know whether this behavior is correct or bug. Yes, it is a bug. The line comp - object$effects[p1, ] should be comp - object$effects[p1, , drop=FALSE] I am changing this in 2.3.1 patched and R-devel. -- 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@stat.math.ethz.ch 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] Colour-coding intervals on a line
Sara-Jane Dunn wrote: Hi, This is a simple version of something that I am trying to do. If I can sort the problem basically, I figure I should be able to sort it for the program I'm writing (which would take longer to explain). I need to know if there is any way of using different colours for different intervals of a line on a graph. Eg. If I plot the line y=x for x=1:10, and split this line into 106 intervals (i.e. not a 'nice' number of intervals) how could I colour different intervals different colours without having to use segments and specify coordinates to join? Hi Sara-Jane, This is a problem that I have been facing myself. I wanted to display color-coded curves that indicated something depending upon the values plotted. This might be useful to you, although you will need the functions color.scale and rescale from the plotrix package to make it work. color.scale.lines-function(x,y,redrange,greenrange,bluerange, scale.to=y,...) { lenx-length(x) leny-length(y) nseg-lenx-1 if(lenx != leny) { warning(x and y are different lengths - some values will be ignored) if(lenxleny) nseg-leny-1 } if(scale.to==y) lcol-color.scale(y[1:nseg],redrange,greenrange,bluerange) else lcol-color.scale(x[1:nseg],redrange,greenrange,bluerange) segments(x[1:nseg],y[1:nseg],x[2:(nseg+1)],y[2:(nseg+1)],col=lcol,...) } plot(0,xlim=c(0,pi),ylim=c(0,1),type=n) x-seq(0,pi,length=106) color.scale.lines(x,sin(x)*10,c(0,1),c(1,0),0,lwd=2) Jim __ R-help@stat.math.ethz.ch 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] tkinsert
claude.josse wrote: But in my text window I have : x=2a=mean(c(1,2,3)) I d'like to have something like: x=2 a=mean(c(1,2,3)) AFAIK you need to separate lines with a newline character ('\n'). Put a 'tkinsert(txt, end, \n)' between the insert commands. Or append each line with '\n'. 2)My second problem, In function run: print(eval(e)) Make the evaluation in the workspace environment: print(eval(e, envir=.GlobalEnv)) Then the results are available in R console. HTH -- Jarimatti Valkonen __ R-help@stat.math.ethz.ch 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] between-within anova: aov and lme
To understand why this works, you need to understand the math in a more general formulation. Ordinary least squares can be written in matrix / vector notation as follows: y = X %*% b + e, where y and e are N x 1 vectors, X is an N x k matrix, and b is a k x 1 vector. In this formulation, e follows a multivariate normal distribution with mean 0 and covariance = s.e^2 times the N x N identity matrix. For mixed effects, e is assumed to follow a multivariate normal distribution with a more general variance-covariance structure, specified in various ways as discussed in Pinheiro and Bates (2000) Mixed-Effects Models in S and S-Plus (Springer). If e ~ N(0, W), then the maximum likelihood estimates for b in the above model can be written as follows: b = inv(t(X) %*% solve(W, X)) %*% y. As explained by Pinheiro and Bates, we estimate the fixed effects, b, using maximum likelihood (ML) and parameters in W using restricted maximum likelihood (REML). The standard analysis of variance is then obtained from the likelihood ratio for nested models. In certain special cases, a monotonic transformation of a likelihood ratio follows an F distribution with degrees of freedom computed from the ranks of various matrices. The approach provides a unified way of analyzing data with mixed effects that does not care if the design is balance or not. Analyses following this method may not always give the same answers as textbooks that discuss standard balanced designs. However, I'm not prepared to discuss that. Hope this helps. Spencer Graves ## William Simpson wrote: Hi Spencer 'lme' is smart enough to figure out from the data whether a factor is 'between' or 'within' or partially one or the other. This allows you avoid worrying about that during data analysis -- except as a check on factor coding. Just to check Spencer, the following lme() statement: lme(y~a*b*c,random=~1|s, data=d) will work for any combination of a,b,c as between or within factors. At one extreme a,b,c could all be between subjects, at the other extreme a,b,c could all be within subjects, and any other combo of between/within. That is a bit mind-bending. So far as lme is concerned all that matters is that s is a random effect. It will probably be difficult to convince experimental psychologists who consider themselves to be experts in the statistical analysis of experiments. Cheers Bill # I can't answer your question about 'aov', but have you tried the following with 'lme': lme(response~A*B*C,random=~1|subject) This assumes that A, B, and C are fixed effects, either continuous variables or factors present at only a very few levels whose effects are not reasonably modeled as a random sample from some other distribution. It also assumes that the effect of each level of subject can be reasonable modeled as a random adjustment to the intercept following a common distribution with mean 0 and variance = 'var.subj'. The function 'aov' is old and mostly obsoleted by 'nlme'. There may be things that can be done in 'aov' that can not be done more or less as easily and usually better and more generally with 'lme', but I'm not familiar with such cases. Your question suggests you may not be familiar with Pinheiro and Bates (2000) Mixed-Effects Models in S and S-Plus (Springer). The standard R distribution comes with a directory ~library\nlme\scripts containing script files 'ch01.R', 'ch02.R', ..., 'ch06.R', and 'ch08.R'. These contain R script files with the R code for each chapter in the book. I've learned a lot from walking through the script files line by line while reviewing the corresponding text in the book. Doing so protects me from problems with silly typographical errors as well as subtle problems where the S-Plus syntax in the book gives a different answer in R because of the few differences in the syntax between S-Plus and R. Hope this helps. Spencer Graves William Simpson wrote: I have 2 questions on ANOVA with 1 between subjects factor and 2 within factors. 1. I am confused on how to do the analysis with aov because I have seen two examples on the web with different solutions. a) Jon Baron (http://www.psych.upenn.edu/~baron/rpsych/rpsych.html) does 6.8.5 Example 5: Stevens pp. 468 - 474 (one between, two within) between: gp within: drug, dose aov(effect ~ gp * drug * dose + Error(subj/(dose*drug)), data=Ela.uni) b) Bill Venables answered a question on R help as follows. - factor A between subjects - factors B*C within subjects. aov(response ~ A*B*C + Error(subject), Kirk) An alternative formula would be response ~ A/(B*C) + Error(subject), which would only change things by grouping together some
Re: [R] Geometrical Interpretation of Eigen value and Eigen vector
Arun, have a look at: http://149.170.199.144/multivar/eigen.htm HTH, Dirk Arun Kumar Saha [EMAIL PROTECTED] wrote: It is not a R related problem rather than statistical/mathematical. However I am posting this query hoping that anyone can help me on this matter. My problem is to get the Geometrical Interpretation of Eigen value and Eigen vector of any square matrix. Can anyone give me a light on it? __ R-help@stat.math.ethz.ch 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] tkinsert
Dear List, I'm looking for some informations about the function tkinsert(). I d'like to write lot of command in my text window and after to evaluate it with a button Submit for example, but i have some problems: here a exemple of my code: 1) My first problem tt=tktoplevel() txt=tktext(tt,height=40) tkpack(txt) var1=paste(x=2) tkinsert(txt,0.0,var1) var2=paste(a=mean(c(1,2,3))) tkinsert(txt,end,var2) But in my text window I have : x=2a=mean(c(1,2,3)) I d'like to have something like: x=2 a=mean(c(1,2,3)) 2)My second problem, I use the run function that i have found in R TCLTK example Evaluating R Code From A Text Window in R TclTk: run - function() { code - tclvalue(tkget(txt,0.0,end)) e - try(parse(text=code)) if (inherits(e, try-error)) { tkmessageBox(message=Syntax error, icon=error) return() } cat(Executing from script window:, -, code, result:, sep=\n) print(eval(e)) } topMenu - tkmenu(tt) tkconfigure(tt, menu=topMenu) fileMenu - tkmenu(topMenu, tearoff=FALSE) tkadd(topMenu, command, label=Run, command=run) But when I run a=mean(c(1,2,3)) I have the result on my R console but i can't access to the result. If i write a, R don't know a. Thanks a lot, and so sorry for my poor english, i hope you understand my problems... Julie. Cet été, pensez aux cartes postales de laposte.net ! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] adding columns to a table after a loop
Dear list, I am trying to find the way to add columns to a table (or a matrix) after a loop. The result of this loop is an array and I would like to get all the results in a single table once the loop is finish. I have reproduced a simplified example below: a- 1 b - matrix() while (a = 4) { + b-rnorm(10) + a- a +1 + } # I have tried several methods but without succes so far. result - as.data.frame(cbind(b)) result b 1 -0.03250661 2 -0.59823770 3 1.58120471 4 0.41086546 5 0.78959090 6 1.23587125 7 0.83427190 8 1.09035581 9 0.11331056 10 0.25267231 the result above is not what I am looking for because it shows only the results from the last operation in the loop, I would like to obtain something like the following. result b1 b2 b3 b4 1 -0.08420826 -0.0637943 -0.83246201 -1.0902384 2 0.40623009 -2.7940096 1.37664973 1.6023967 3 -1.13850505 1.1660669 -0.95962296 -0.7325098 4 -1.06183391 1.1063677 1.67948677 -1.9875475 5 -0.64431067 -0.4843952 -1.30742858 0.5064134 6 0.56729468 1.0860484 0.07651954 0.4380108 7 0.95036177 -0.5328609 1.28954934 -0.2775614 8 -0.17848223 0.5340379 -0.22613700 1.0179886 9 2.93145454 -1.8639607 -0.25478610 1.6619754 10 1.51942415 -0.2051423 0.09144450 -1.6329481 I hope someone can give me a hand best regards a p5.vert.ukl.yahoo.com uncompressed/chunked Sat Aug 12 13:14:00 GMT 2006 __ R-help@stat.math.ethz.ch 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] Changing R network connections
Dear all, I have some difficulties to get R to download the various packages. It seems that it's a problem of the network that I'm on. I would need to configure R so that I can put the proxy address and the port of the network that I'm on. Can anyone explain to me how to change these in R. I've looked at the preferences but couldn't find it there. Thanks a lot for you help. Regards, Fabrice Letimier -- __ R-help@stat.math.ethz.ch 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 : tcltk library on linux
On Friday 11 August 2006 10:31, Yohan CHOUKROUN wrote: Thank you for your answer but I already use the .deb package. Also I have compiled the source code, but it is the same result... I have already the same error.. I 'm going to be crazy ;-) Has anyone got the same problem (and found the solution!) ? Thanks in advance Yohan Only a week ago it was a similar thread, and it was solved by installing the .deb package from CRAN. Assuming you use the latest version Dapper (you didn't specified), add this line to your sources.list: deb http://cran.R-project.org/bin/linux/ubuntu/ dapper/ Then: $ sudo apt-get update $ sudo apt-get install r-cran-rcmdr (as Dirk Eddelbuettel advised). It _should_ work flawlessly. HTH, 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@stat.math.ethz.ch 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] adding columns to a table after a loop
Albert Picado wrote: Dear list, I am trying to find the way to add columns to a table (or a matrix) after a loop. The result of this loop is an array and I would like to get all the results in a single table once the loop is finish. I have reproduced a simplified example below: a- 1 b - matrix() while (a = 4) { + b-rnorm(10) + a- a +1 + } Staying in your example: a - 1 b - matrix(nrow=10, ncol=4) while(a = 4){ b[,i] - rnorm(10) a - a + 1 } Uwe Ligges # I have tried several methods but without succes so far. result - as.data.frame(cbind(b)) result b 1 -0.03250661 2 -0.59823770 3 1.58120471 4 0.41086546 5 0.78959090 6 1.23587125 7 0.83427190 8 1.09035581 9 0.11331056 10 0.25267231 the result above is not what I am looking for because it shows only the results from the last operation in the loop, I would like to obtain something like the following. result b1 b2 b3 b4 1 -0.08420826 -0.0637943 -0.83246201 -1.0902384 2 0.40623009 -2.7940096 1.37664973 1.6023967 3 -1.13850505 1.1660669 -0.95962296 -0.7325098 4 -1.06183391 1.1063677 1.67948677 -1.9875475 5 -0.64431067 -0.4843952 -1.30742858 0.5064134 6 0.56729468 1.0860484 0.07651954 0.4380108 7 0.95036177 -0.5328609 1.28954934 -0.2775614 8 -0.17848223 0.5340379 -0.22613700 1.0179886 9 2.93145454 -1.8639607 -0.25478610 1.6619754 10 1.51942415 -0.2051423 0.09144450 -1.6329481 I hope someone can give me a hand best regards a p5.vert.ukl.yahoo.com uncompressed/chunked Sat Aug 12 13:14:00 GMT 2006 __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] Changing R network connections
Since you mention 'preferences', it seems you might be using Windows: the information you require is in the rw-FAQ. Since the posting guide asked you to state your platform and read the relevant FAQ, that is the place to start: see the footer below. On Fri, 11 Aug 2006, Alexandre Fabrice Letimier wrote: Dear all, I have some difficulties to get R to download the various packages. It seems that it's a problem of the network that I'm on. I would need to configure R so that I can put the proxy address and the port of the network that I'm on. Can anyone explain to me how to change these in R. I've looked at the preferences but couldn't find it there. Thanks a lot for you help. Regards, Fabrice Letimier -- __ R-help@stat.math.ethz.ch 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. -- 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@stat.math.ethz.ch 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] Re : adding columns to a table after a loop
Dear Uwe, Thanks for your answer. I have been trying your suggestion but I haven't been able to solve my problem as I may have simplified in excess my example. The real situation is actually much similar to the following: a-1 b-1 i-1 pvalue-matrix() while(a=4) { while(b=10){ pvalue[i]-rnorm(1) i-i+1 b-b+1 } a-a+1 } To get the desired outcome I have tried two things based on your suggestion: 1) a-1 b-1 i-1 pvalue- matrix(ncol=4, nrow=10) result- matrix() while(a=4) { while(b=10){ pvalue[i]-rnorm(1) i-i+1 b-b+1 } result[,a]-pvalue a-a+1 } here I get an error message: Error in [-(`*tmp*`, , a, value = c(1.38661984066808, -0.641565430307799, : number of items to replace is not a multiple of replacement length 2) a-1 b-1 i-1 pvalue-matrix(ncol=4, nrow=10) while(a=4) { while(b=10){ pvalue[i,a]-rnorm(1) i-i+1 b-b+1 } a-a+1 } here what I get is: pvalue [,1] [,2] [,3] [,4] [1,] -2.18379100 NA NA NA [2,] -0.90112392 NA NA NA [3,] -0.91762163 NA NA NA [4,] 0.54922398 NA NA NA [5,] 0.95511590 NA NA NA [6,] 0.08509518 NA NA NA [7,] -0.92576835 NA NA NA [8,] 1.62361191 NA NA NA [9,] 0.02644486 NA NA NA [10,] 0.32406407 NA NA NA I do not know what else to try... best wishes a - Message d'origine De : Uwe Ligges [EMAIL PROTECTED] À : Albert Picado [EMAIL PROTECTED] Cc : r-help@stat.math.ethz.ch Envoyé le : Samedi, 12 Août 2006, 3h57mn 16s Objet : Re: [R] adding columns to a table after a loop Albert Picado wrote: Dear list, I am trying to find the way to add columns to a table (or a matrix) after a loop. The result of this loop is an array and I would like to get all the results in a single table once the loop is finish. I have reproduced a simplified example below: a- 1 b - matrix() while (a = 4) { + b-rnorm(10) + a- a +1 + } Staying in your example: a - 1 b - matrix(nrow=10, ncol=4) while(a = 4){ b[,i] - rnorm(10) a - a + 1 } Uwe Ligges # I have tried several methods but without succes so far. result - as.data.frame(cbind(b)) result b 1 -0.03250661 2 -0.59823770 3 1.58120471 4 0.41086546 5 0.78959090 6 1.23587125 7 0.83427190 8 1.09035581 9 0.11331056 10 0.25267231 the result above is not what I am looking for because it shows only the results from the last operation in the loop, I would like to obtain something like the following. result b1 b2 b3 b4 1 -0.08420826 -0.0637943 -0.83246201 -1.0902384 2 0.40623009 -2.7940096 1.37664973 1.6023967 3 -1.13850505 1.1660669 -0.95962296 -0.7325098 4 -1.06183391 1.1063677 1.67948677 -1.9875475 5 -0.64431067 -0.4843952 -1.30742858 0.5064134 6 0.56729468 1.0860484 0.07651954 0.4380108 7 0.95036177 -0.5328609 1.28954934 -0.2775614 8 -0.17848223 0.5340379 -0.22613700 1.0179886 9 2.93145454 -1.8639607 -0.25478610 1.6619754 10 1.51942415 -0.2051423 0.09144450 -1.6329481 I hope someone can give me a hand best regards a p5.vert.ukl.yahoo.com uncompressed/chunked Sat Aug 12 13:14:00 GMT 2006 __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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 : adding columns to a table after a loop
Albert Picado wrote: Dear Uwe, Thanks for your answer. I have been trying your suggestion but I haven't been able to solve my problem as I may have simplified in excess my example. The real situation is actually much similar to the following: a-1 b-1 i-1 pvalue-matrix() while(a=4) { while(b=10){ pvalue[i]-rnorm(1) i-i+1 b-b+1 } a-a+1 } I think you will have to read some basic documentation such as An Introduction to R about data structures, indexing, and loops in R before proceeding ... Anyway, you can do: a - 1 pvalue - matrix(nrow = 10, ncol = 4) while(a = 4) { b - 1 while(b = 10){ pvalue[b, a] - rnorm(1) b - b+1 } a - a+1 } or much shorter pvalue - matrix(nrow = 10, ncol = 4) for(a in 1:4) { for(b in 1:10){ pvalue[b, a] - rnorm(1) } } Uwe Ligges To get the desired outcome I have tried two things based on your suggestion: 1) a-1 b-1 i-1 pvalue- matrix(ncol=4, nrow=10) result- matrix() while(a=4) { while(b=10){ pvalue[i]-rnorm(1) i-i+1 b-b+1 } result[,a]-pvalue a-a+1 } here I get an error message: Error in [-(`*tmp*`, , a, value = c(1.38661984066808, -0.641565430307799, : number of items to replace is not a multiple of replacement length 2) a-1 b-1 i-1 pvalue-matrix(ncol=4, nrow=10) while(a=4) { while(b=10){ pvalue[i,a]-rnorm(1) i-i+1 b-b+1 } a-a+1 } here what I get is: pvalue [,1] [,2] [,3] [,4] [1,] -2.18379100 NA NA NA [2,] -0.90112392 NA NA NA [3,] -0.91762163 NA NA NA [4,] 0.54922398 NA NA NA [5,] 0.95511590 NA NA NA [6,] 0.08509518 NA NA NA [7,] -0.92576835 NA NA NA [8,] 1.62361191 NA NA NA [9,] 0.02644486 NA NA NA [10,] 0.32406407 NA NA NA I do not know what else to try... best wishes a - Message d'origine De : Uwe Ligges [EMAIL PROTECTED] À : Albert Picado [EMAIL PROTECTED] Cc : r-help@stat.math.ethz.ch Envoyé le : Samedi, 12 Août 2006, 3h57mn 16s Objet : Re: [R] adding columns to a table after a loop Albert Picado wrote: Dear list, I am trying to find the way to add columns to a table (or a matrix) after a loop. The result of this loop is an array and I would like to get all the results in a single table once the loop is finish. I have reproduced a simplified example below: a- 1 b - matrix() while (a = 4) { + b-rnorm(10) + a- a +1 + } Staying in your example: a - 1 b - matrix(nrow=10, ncol=4) while(a = 4){ b[,i] - rnorm(10) a - a + 1 } Uwe Ligges # I have tried several methods but without succes so far. result - as.data.frame(cbind(b)) result b 1 -0.03250661 2 -0.59823770 3 1.58120471 4 0.41086546 5 0.78959090 6 1.23587125 7 0.83427190 8 1.09035581 9 0.11331056 10 0.25267231 the result above is not what I am looking for because it shows only the results from the last operation in the loop, I would like to obtain something like the following. result b1 b2 b3 b4 1 -0.08420826 -0.0637943 -0.83246201 -1.0902384 2 0.40623009 -2.7940096 1.37664973 1.6023967 3 -1.13850505 1.1660669 -0.95962296 -0.7325098 4 -1.06183391 1.1063677 1.67948677 -1.9875475 5 -0.64431067 -0.4843952 -1.30742858 0.5064134 6 0.56729468 1.0860484 0.07651954 0.4380108 7 0.95036177 -0.5328609 1.28954934 -0.2775614 8 -0.17848223 0.5340379 -0.22613700 1.0179886 9 2.93145454 -1.8639607 -0.25478610 1.6619754 10 1.51942415 -0.2051423 0.09144450 -1.6329481 I hope someone can give me a hand best regards a p5.vert.ukl.yahoo.com uncompressed/chunked Sat Aug 12 13:14:00 GMT 2006 __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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 : adding columns to a table after a loop
--- Albert Picado [EMAIL PROTECTED] wrote: Albert Dear Uwe, Thanks for your answer. clip De : Uwe Ligges [EMAIL PROTECTED] � : Albert Picado [EMAIL PROTECTED] Cc : r-help@stat.math.ethz.ch Envoy� le : Samedi, 12 Ao�t 2006, 3h57mn 16s Objet : Re: [R] adding columns to a table after a loop Albert Picado wrote: Dear list, I am trying to find the way to add columns to a table (or a matrix) after a loop. The result of this loop is an array and I would like to get all the results in a single table once the loop is finish. I have reproduced a simplified example below: a- 1 b - matrix() while (a = 4) { + b-rnorm(10) + a- a +1 + } Staying in your example: a - 1 b - matrix(nrow=10, ncol=4) while(a = 4){ b[,i] - rnorm(10) a - a + 1 } Uwe Ligges There is a minor typo in the above example. b[,1] should read b[,a]. It works very nicely with that small correction. __ R-help@stat.math.ethz.ch 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] lasso for variable selection
Attended JSM last week and Friedman mentioned the use of LASSO for variable selection (he uses it for rules ensembles). I am an econometrician and not familiar with, i started running the examples in R this week and you get to the plots section of the LARS package. Plots of beta/max(beta) vs standardized coefficients. How does one interpret them? u see plots of each variable converging to zero at different times - its pretty cool - but can i use this for variable importance? for variable selection - i have a group of correlated variables that we need to determine importance in predicting change of a Y variable. -zubin __ R-help@stat.math.ethz.ch 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] lasso for variable selection
Zubin, my understanding about lasso is that it is a restricted version of regression, where minimization of sse subject to sum(abs(beta)) upper limit such that for unimportant feature, its beta will be restricted by ZERO. the whole game of lasso is to find the proper upper limit. I think in lasso package, this upper limit is found by CV. Speaking of lasso, I think it can be also implemented in SAS with proc glmselect. for more information, Prof. Tibshirani's lasso page is extremely helpful: http://www-stat.stanford.edu/~tibs/lasso.html HTH. wensui On 8/12/06, zubin [EMAIL PROTECTED] wrote: Attended JSM last week and Friedman mentioned the use of LASSO for variable selection (he uses it for rules ensembles). I am an econometrician and not familiar with, i started running the examples in R this week and you get to the plots section of the LARS package. Plots of beta/max(beta) vs standardized coefficients. How does one interpret them? u see plots of each variable converging to zero at different times - its pretty cool - but can i use this for variable importance? for variable selection - i have a group of correlated variables that we need to determine importance in predicting change of a Y variable. -zubin __ R-help@stat.math.ethz.ch 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. -- WenSui Liu (http://spaces.msn.com/statcompute/blog) Senior Decision Support Analyst Health Policy and Clinical Effectiveness Cincinnati Children Hospital Medical Center [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] proc standardize data frame x and y
Hello! i know these are basic but i cannot seem to find the answer thru my searches.. 1) Can someone recommend an equivalent to SAS PROC Standardize in R? I am in need to frequently standardize a data frame, with z-scores, or squash to 0-1 scale - is there a slick function or package someone can recommend? 2) Also, have data sets with a lot of predictor variables. in the diabetes data frame i see that fields have been grouped to X and Y variables, making it very easy to identify X and Y in the regression techniques. How is this done, how do you group lets say a group of columns into 1 matrix, within a data frame. example: the AsIs group is a matrix of X variables: str(diabetes) `data.frame': 442 obs. of 3 variables: $ x : AsIs [1:442, 1:10] 0.038075 -0.00188 0.085298 -0.08906 0.005383 ... ..- attr(*, dimnames)=List of 2 .. ..$ : NULL .. ..$ : chr age sex bmi map ... ..- attr(*, class)= chr AsIs $ y : num 151 75 141 206 135 97 138 63 110 310 ... $ x2: AsIs [1:442, 1:64] 0.038075 -0.00188 0.085298 -0.08906 0.005383 ... ..- attr(*, .Names)= chr age age age age ... ..- attr(*, dimnames)=List of 2 .. ..$ : chr 1 2 3 4 ... .. ..$ : chr age sex bmi map ... ..- attr(*, class)= chr AsIs __ R-help@stat.math.ethz.ch 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] proc standardize data frame x and y
for proc standardzize, check ?scale On 8/12/06, zubin [EMAIL PROTECTED] wrote: Hello! i know these are basic but i cannot seem to find the answer thru my searches.. 1) Can someone recommend an equivalent to SAS PROC Standardize in R? I am in need to frequently standardize a data frame, with z-scores, or squash to 0-1 scale - is there a slick function or package someone can recommend? 2) Also, have data sets with a lot of predictor variables. in the diabetes data frame i see that fields have been grouped to X and Y variables, making it very easy to identify X and Y in the regression techniques. How is this done, how do you group lets say a group of columns into 1 matrix, within a data frame. example: the AsIs group is a matrix of X variables: str(diabetes) `data.frame': 442 obs. of 3 variables: $ x : AsIs [1:442, 1:10] 0.038075 -0.00188 0.085298 -0.08906 0.005383 ... ..- attr(*, dimnames)=List of 2 .. ..$ : NULL .. ..$ : chr age sex bmi map ... ..- attr(*, class)= chr AsIs $ y : num 151 75 141 206 135 97 138 63 110 310 ... $ x2: AsIs [1:442, 1:64] 0.038075 -0.00188 0.085298 -0.08906 0.005383 ... ..- attr(*, .Names)= chr age age age age ... ..- attr(*, dimnames)=List of 2 .. ..$ : chr 1 2 3 4 ... .. ..$ : chr age sex bmi map ... ..- attr(*, class)= chr AsIs __ R-help@stat.math.ethz.ch 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. -- WenSui Liu (http://spaces.msn.com/statcompute/blog) Senior Decision Support Analyst Health Policy and Clinical Effectiveness Cincinnati Children Hospital Medical Center [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] GARCH(1,1) optimization with R
RSiteSearch(garch, functions) produced 21 hits, the first 10 of which identified 'garch'-type capabilities in packages 'tseries', 'fSeries' and 'fOptions'. Hope this helps. Spencer Graves p.s. You might get better and quicker help from this listserve if your post conforms more closely to the posting guide www.R-project.org/posting-guide.html, including providing commented, minimal, self-contained, reproducible code. Also, you may be interested in the R-sig-finance listserve for the Special Interest Group for 'R in Finance'. Patrick Zhang wrote: Hello all, Trying to implement GARCH(1,1) with ASP.NET http://asp.net/ and VB.NEThttp://vb.net/. It involves optimization of a three-variate function with some constraints. Learned from Wilmott.com http://wilmott.com/ that R might be able to do it but have no idea how. Could anyone help me out please. Thanks in advance. Additional info: 1. Tried calling Excel Solver from within my web application - it works fine except that Excel.exe won't go away from task manager although the Quit() method has been used; 2. Also tried running (Process.Start) a separate console application that calls Excel Solver from the code, getting error message: The application failed to initialize properly (0xc142). Any thought of an alternative? Best wishes, Pat [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] proc standardize data frame x and y
zubin, for your second question: supposed you have x1 and x2 and want to combine them in a matrix X in a data frame called data, try the following code: X-matrix(1:10, ncol = 2, dimnames = list(NULL, c(x1, x2))); class(X) class(X)-AsIs; class(X) data-data.frame(X); summary(data); On 8/12/06, zubin [EMAIL PROTECTED] wrote: Hello! i know these are basic but i cannot seem to find the answer thru my searches.. 1) Can someone recommend an equivalent to SAS PROC Standardize in R? I am in need to frequently standardize a data frame, with z-scores, or squash to 0-1 scale - is there a slick function or package someone can recommend? 2) Also, have data sets with a lot of predictor variables. in the diabetes data frame i see that fields have been grouped to X and Y variables, making it very easy to identify X and Y in the regression techniques. How is this done, how do you group lets say a group of columns into 1 matrix, within a data frame. example: the AsIs group is a matrix of X variables: str(diabetes) `data.frame': 442 obs. of 3 variables: $ x : AsIs [1:442, 1:10] 0.038075 -0.00188 0.085298 -0.08906 0.005383 ... ..- attr(*, dimnames)=List of 2 .. ..$ : NULL .. ..$ : chr age sex bmi map ... ..- attr(*, class)= chr AsIs $ y : num 151 75 141 206 135 97 138 63 110 310 ... $ x2: AsIs [1:442, 1:64] 0.038075 -0.00188 0.085298 -0.08906 0.005383 ... ..- attr(*, .Names)= chr age age age age ... ..- attr(*, dimnames)=List of 2 .. ..$ : chr 1 2 3 4 ... .. ..$ : chr age sex bmi map ... ..- attr(*, class)= chr AsIs __ R-help@stat.math.ethz.ch 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. -- WenSui Liu (http://spaces.msn.com/statcompute/blog) Senior Decision Support Analyst Health Policy and Clinical Effectiveness Cincinnati Children Hospital Medical Center __ R-help@stat.math.ethz.ch 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.